Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IDP-1261 - Lib maintenance #72

Merged
merged 4 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

- uses: actions/setup-dotnet@v4
with:
dotnet-version: "6.0.x"
global-json-file: "global.json"
Gcaya marked this conversation as resolved.
Show resolved Hide resolved

- run: ./Build.ps1
shell: pwsh
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0.423",
"version": "8.0.301",
"rollForward": "latestMinor",
"allowPrerelease": false
}
Expand Down
529 changes: 1 addition & 528 deletions src/.editorconfig

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
<PackageReference Include="Workleap.DotNet.CodingStandards" Version="0.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Workleap.ComponentModel.DataAnnotations.Tests;

public class ContainsAttributeTests
public sealed class ContainsAttributeTests
{
[Fact]
public void IsValid_Returns_True_When_Value_Is_Null()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
Expand All @@ -9,15 +8,15 @@ namespace Workleap.ComponentModel.DataAnnotations.Tests;
public sealed class ContainsNonEmptyGuidAttributeTests
{
[Theory]
[ClassData(typeof(ValidData))]
[MemberData(nameof(ValidData))]
public void Given_ValidGuids_When_Validate_Then_Valid(object? inputs)
{
var attr = new ContainsNonEmptyGuidAttribute();
Assert.True(attr.IsValid(inputs));
}

[Theory]
[ClassData(typeof(InvalidData))]
[MemberData(nameof(InvalidData))]
public void Given_InvalidGuids_When_Validate_Then_Invalid(object? inputs)
{
var attr = new ContainsNonEmptyGuidAttribute();
Expand All @@ -40,41 +39,37 @@ public void Validator_TryValidateObject_Returns_The_Expected_Error_Message_When_
Assert.Equal(expectedErrorMessage, result.ErrorMessage);
}

private class ValidData : IEnumerable<object?[]>
public static TheoryData<object?> ValidData()
{
public IEnumerator<object?[]> GetEnumerator()
return new TheoryData<object?>
{
yield return new object?[] { null };
yield return new object[] { new Guid[] { new("f8daff85-4393-42ae-9ab5-8620ab20c8da") } };
yield return new object[] { new string[] { "d78b48f9-37b8-47dd-8e47-0325dd3e7899" } };
yield return new object[] { new Guid[] { default, new("846398d2-416d-4f05-86b0-431e11117abc") } };
yield return new object[] { new Guid[] { Guid.Empty, new("08bfec4a-da43-40de-a15a-0d10f227e6b7") } };
yield return new object[] { new Guid?[] { default, new Guid("2dd81281-7498-411c-aea1-5cec96f2dd8d") } };
yield return new object[] { new string[] { "00000000-0000-0000-0000-000000000000", "7d8c61f7-a334-4599-b801-45f0934099a4" } };
yield return new object[] { new string[] { string.Empty, "7c3cdfba-4466-44ab-bb95-da02eac67380" } };
yield return new object[] { new string?[] { default, "f8daff85-4393-42ae-9ab5-8620ab20c8da" } };
}

IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator();
null,
new Guid[] { new("f8daff85-4393-42ae-9ab5-8620ab20c8da") },
new string[] { "d78b48f9-37b8-47dd-8e47-0325dd3e7899" },
new Guid[] { default, new("846398d2-416d-4f05-86b0-431e11117abc") },
new Guid[] { Guid.Empty, new("08bfec4a-da43-40de-a15a-0d10f227e6b7") },
new Guid?[] { default, new Guid("2dd81281-7498-411c-aea1-5cec96f2dd8d") },
new string[] { "00000000-0000-0000-0000-000000000000", "7d8c61f7-a334-4599-b801-45f0934099a4" },
new string[] { string.Empty, "7c3cdfba-4466-44ab-bb95-da02eac67380" },
new string?[] { default, "f8daff85-4393-42ae-9ab5-8620ab20c8da" },
};
}

private class InvalidData : IEnumerable<object?[]>
public static TheoryData<object?> InvalidData()
{
public IEnumerator<object?[]> GetEnumerator()
return new TheoryData<object?>
{
yield return new object[] { new Guid[] { default } };
yield return new object[] { new Guid?[] { default } };
yield return new object[] { new string[] { string.Empty } };
yield return new object[] { new string?[] { default } };
yield return new object[] { new Guid[] { Guid.Empty } };
yield return new object[] { new string[] { "00000000-0000-0000-0000-000000000000" } };
yield return new object[] { new int[] { 0 } };
}

IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator();
new Guid[] { default },
new Guid?[] { default },
new string[] { string.Empty },
new string?[] { default },
new Guid[] { Guid.Empty },
new string[] { "00000000-0000-0000-0000-000000000000" },
new int[] { 0 },
};
}

private class SomeClass
private sealed class SomeClass
{
[ContainsNonEmptyGuid]
public Guid?[] Values { get; set; } = Array.Empty<Guid?>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
Expand All @@ -9,15 +8,15 @@ namespace Workleap.ComponentModel.DataAnnotations.Tests;
public sealed class ContainsNonEmptyStringAttributeTests
{
[Theory]
[ClassData(typeof(ValidData))]
[MemberData(nameof(ValidData))]
public void Given_ValidStrings_When_Validate_Then_Valid(object? inputs)
{
var attr = new ContainsNonEmptyStringAttribute();
Assert.True(attr.IsValid(inputs));
}

[Theory]
[ClassData(typeof(InvalidData))]
[MemberData(nameof(InvalidData))]
public void Given_InvalidGuids_When_Validate_Then_Invalid(object? inputs)
{
var attr = new ContainsNonEmptyStringAttribute();
Expand All @@ -41,35 +40,31 @@ public void Validator_TryValidateObject_Returns_The_Expected_Error_Message_When_
Assert.Equal(expectedErrorMessage, result.ErrorMessage);
}

private class ValidData : IEnumerable<object?[]>
public static TheoryData<string?[]?> ValidData()
{
public IEnumerator<object?[]> GetEnumerator()
return new TheoryData<string?[]?>
{
yield return new object?[] { null };
yield return new object[] { new string[] { "Lorem ipsum dolor sit amet" } };
yield return new object[] { new string[] { "Lorem ipsum dolor sit amet", "Etiam porta velit non nisi feugiat pulvinar" } };
yield return new object[] { new string[] { string.Empty, "Lorem ipsum dolor sit amet" } };
yield return new object[] { new string?[] { default, "Lorem ipsum dolor sit amet" } };
yield return new object[] { new string[] { "Lorem ipsum dolor sit amet", " " } };
}

IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator();
null,
new string[] { "Lorem ipsum dolor sit amet" },
new string[] { "Lorem ipsum dolor sit amet", "Etiam porta velit non nisi feugiat pulvinar" },
new string[] { string.Empty, "Lorem ipsum dolor sit amet" },
new string?[] { default, "Lorem ipsum dolor sit amet" },
new string[] { "Lorem ipsum dolor sit amet", " " },
};
}

private class InvalidData : IEnumerable<object?[]>
public static TheoryData<string?[]?> InvalidData()
{
public IEnumerator<object?[]> GetEnumerator()
return new TheoryData<string?[]?>
{
yield return new object[] { new string?[] { string.Empty, default } };
yield return new object[] { new string?[] { string.Empty } };
yield return new object[] { new string?[] { default } };
yield return new object[] { new string[] { " " } };
}

IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator();
new string?[] { string.Empty, default },
new string?[] { string.Empty },
new string?[] { default },
new string[] { " " },
};
}

private class SomeClass
private sealed class SomeClass
{
[ContainsNonEmptyString]
public string?[] Values { get; set; } = Array.Empty<string?>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
Expand All @@ -9,15 +8,15 @@ namespace Workleap.ComponentModel.DataAnnotations.Tests;
public sealed class ContainsOnlyNonEmptyGuidsAttributeTests
{
[Theory]
[ClassData(typeof(ValidData))]
[MemberData(nameof(ValidData))]
public void Given_ValidGuids_When_Validate_Then_Valid(object? inputs)
{
var attr = new ContainsOnlyNonEmptyGuidsAttribute();
Assert.True(attr.IsValid(inputs));
}

[Theory]
[ClassData(typeof(InvalidData))]
[MemberData(nameof(InvalidData))]
public void Given_InvalidGuids_When_Validate_Then_Invalid(object? inputs)
{
var attr = new ContainsOnlyNonEmptyGuidsAttribute();
Expand All @@ -40,45 +39,41 @@ public void Validator_TryValidateObject_Returns_The_Expected_Error_Message_When_
Assert.Equal(expectedErrorMessage, result.ErrorMessage);
}

private class ValidData : IEnumerable<object?[]>
public static TheoryData<object?> ValidData()
{
public IEnumerator<object?[]> GetEnumerator()
return new TheoryData<object?>
{
yield return new object?[] { null };
yield return new object[] { new Guid[] { } };
yield return new object[] { new Guid?[] { } };
yield return new object[] { new string[] { } };
yield return new object[] { new string?[] { } };
yield return new object[] { new Guid[] { new("f8daff85-4393-42ae-9ab5-8620ab20c8da") } };
yield return new object[] { new string[] { "d78b48f9-37b8-47dd-8e47-0325dd3e7899" } };
}

IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator();
null,
Array.Empty<Guid>(),
Array.Empty<Guid?>(),
Array.Empty<string>(),
Array.Empty<string?>(),
new Guid[] { new("f8daff85-4393-42ae-9ab5-8620ab20c8da") },
new string[] { "d78b48f9-37b8-47dd-8e47-0325dd3e7899" }
};
}

private class InvalidData : IEnumerable<object?[]>
public static TheoryData<object?> InvalidData()
{
public IEnumerator<object?[]> GetEnumerator()
return new TheoryData<object?>
{
yield return new object[] { new Guid[] { default } };
yield return new object[] { new Guid?[] { default } };
yield return new object[] { new string[] { string.Empty } };
yield return new object[] { new string?[] { default } };
yield return new object[] { new Guid[] { Guid.Empty } };
yield return new object[] { new string[] { "00000000-0000-0000-0000-000000000000" } };
yield return new object[] { new int[] { 0 } };
yield return new object[] { new Guid[] { default, new("846398d2-416d-4f05-86b0-431e11117abc") } };
yield return new object[] { new Guid[] { Guid.Empty, new("08bfec4a-da43-40de-a15a-0d10f227e6b7") } };
yield return new object[] { new Guid?[] { default, new Guid("2dd81281-7498-411c-aea1-5cec96f2dd8d") } };
yield return new object[] { new string[] { "00000000-0000-0000-0000-000000000000", "7d8c61f7-a334-4599-b801-45f0934099a4" } };
yield return new object[] { new string[] { string.Empty, "7c3cdfba-4466-44ab-bb95-da02eac67380" } };
yield return new object[] { new string?[] { default, "f8daff85-4393-42ae-9ab5-8620ab20c8da" } };
}

IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator();
new Guid[] { default },
new Guid?[] { default },
new string[] { string.Empty },
new string?[] { default },
new Guid[] { Guid.Empty },
new string[] { "00000000-0000-0000-0000-000000000000" },
new int[] { 0 },
new Guid[] { default, new("846398d2-416d-4f05-86b0-431e11117abc") },
new Guid[] { Guid.Empty, new("08bfec4a-da43-40de-a15a-0d10f227e6b7") },
new Guid?[] { default, new Guid("2dd81281-7498-411c-aea1-5cec96f2dd8d") },
new string[] { "00000000-0000-0000-0000-000000000000", "7d8c61f7-a334-4599-b801-45f0934099a4" },
new string[] { string.Empty, "7c3cdfba-4466-44ab-bb95-da02eac67380" },
new string?[] { default, "f8daff85-4393-42ae-9ab5-8620ab20c8da" }
};
}

private class SomeClass
private sealed class SomeClass
{
[ContainsOnlyNonEmptyGuids]
public Guid[] Values { get; set; } = new[] { Guid.Empty };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
Expand All @@ -8,15 +8,15 @@ namespace Workleap.ComponentModel.DataAnnotations.Tests;
public sealed class ContainsOnlyNonEmptyStringsAttributeTests
{
[Theory]
[ClassData(typeof(ValidData))]
[MemberData(nameof(ValidData))]
public void Given_ValidStrings_When_Validate_Then_Valid(object? inputs)
{
var attr = new ContainsOnlyNonEmptyStringsAttribute();
Assert.True(attr.IsValid(inputs));
}

[Theory]
[ClassData(typeof(InvalidData))]
[MemberData(nameof(InvalidData))]
public void Given_InvalidGuids_When_Validate_Then_Invalid(object? inputs)
{
var attr = new ContainsOnlyNonEmptyStringsAttribute();
Expand All @@ -40,37 +40,33 @@ public void Validator_TryValidateObject_Returns_The_Expected_Error_Message_When_
Assert.Equal(expectedErrorMessage, result.ErrorMessage);
}

private class ValidData : IEnumerable<object?[]>
public static TheoryData<string?[]?> ValidData()
{
public IEnumerator<object?[]> GetEnumerator()
return new TheoryData<string?[]?>
{
yield return new object?[] { null };
yield return new object[] { new string?[] { } };
yield return new object[] { new string[] { } };
yield return new object[] { new string[] { "Lorem ipsum dolor sit amet" } };
yield return new object[] { new string[] { "Lorem ipsum dolor sit amet", "Etiam porta velit non nisi feugiat pulvinar" } };
}

IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator();
null,
Array.Empty<string?>(),
Array.Empty<string>(),
new string[] { "Lorem ipsum dolor sit amet" },
new string[] { "Lorem ipsum dolor sit amet", "Etiam porta velit non nisi feugiat pulvinar" },
};
}

private class InvalidData : IEnumerable<object?[]>
public static TheoryData<string?[]?> InvalidData()
{
public IEnumerator<object?[]> GetEnumerator()
return new TheoryData<string?[]?>
{
yield return new object[] { new string?[] { string.Empty, default } };
yield return new object[] { new string?[] { string.Empty } };
yield return new object[] { new string?[] { default } };
yield return new object[] { new string[] { " " } };
yield return new object[] { new string[] { string.Empty, "Lorem ipsum dolor sit amet" } };
yield return new object[] { new string?[] { default, "Lorem ipsum dolor sit amet" } };
yield return new object[] { new string[] { "Lorem ipsum dolor sit amet", " " } };
}

IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator();
new string?[] { string.Empty, default },
new string?[] { string.Empty },
new string?[] { default },
new string[] { " " },
new string[] { string.Empty, "Lorem ipsum dolor sit amet" },
new string?[] { default, "Lorem ipsum dolor sit amet" },
new string[] { "Lorem ipsum dolor sit amet", " " },
};
}

private class SomeClass
private sealed class SomeClass
{
[ContainsOnlyNonEmptyStrings]
public string?[] Values { get; set; } = new[] { string.Empty };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Workleap.ComponentModel.DataAnnotations.Tests;

public class EndsWithAttributeTests
public sealed class EndsWithAttributeTests
{
[Fact]
public void IsValid_Returns_True_When_Value_Is_Null()
Expand Down
Loading