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 2 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
Expand Up @@ -40,7 +40,7 @@ public void Validator_TryValidateObject_Returns_The_Expected_Error_Message_When_
Assert.Equal(expectedErrorMessage, result.ErrorMessage);
}

private class ValidData : IEnumerable<object?[]>
private sealed class ValidData : IEnumerable<object?[]>
{
public IEnumerator<object?[]> GetEnumerator()
{
Expand All @@ -58,7 +58,7 @@ private class ValidData : IEnumerable<object?[]>
IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator();
}

private class InvalidData : IEnumerable<object?[]>
private sealed class InvalidData : IEnumerable<object?[]>
{
public IEnumerator<object?[]> GetEnumerator()
{
Expand All @@ -74,7 +74,7 @@ private class InvalidData : IEnumerable<object?[]>
IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator();
}

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
Expand Up @@ -41,7 +41,7 @@ public void Validator_TryValidateObject_Returns_The_Expected_Error_Message_When_
Assert.Equal(expectedErrorMessage, result.ErrorMessage);
}

private class ValidData : IEnumerable<object?[]>
private sealed class ValidData : IEnumerable<object?[]>
{
public IEnumerator<object?[]> GetEnumerator()
{
Expand All @@ -56,7 +56,7 @@ private class ValidData : IEnumerable<object?[]>
IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator();
}

private class InvalidData : IEnumerable<object?[]>
private sealed class InvalidData : IEnumerable<object?[]>
{
public IEnumerator<object?[]> GetEnumerator()
{
Expand All @@ -69,7 +69,7 @@ private class InvalidData : IEnumerable<object?[]>
IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator();
}

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
Expand Up @@ -40,23 +40,23 @@ public void Validator_TryValidateObject_Returns_The_Expected_Error_Message_When_
Assert.Equal(expectedErrorMessage, result.ErrorMessage);
}

private class ValidData : IEnumerable<object?[]>
private sealed class ValidData : IEnumerable<object?[]>
Gcaya marked this conversation as resolved.
Show resolved Hide resolved
{
public IEnumerator<object?[]> GetEnumerator()
{
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[] { Array.Empty<Guid>() };
yield return new object[] { Array.Empty<Guid?>() };
yield return new object[] { Array.Empty<string>() };
yield return new object[] { Array.Empty<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();
}

private class InvalidData : IEnumerable<object?[]>
private sealed class InvalidData : IEnumerable<object?[]>
{
public IEnumerator<object?[]> GetEnumerator()
{
Expand All @@ -78,7 +78,7 @@ private class InvalidData : IEnumerable<object?[]>
IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator();
}

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,3 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
Expand Down Expand Up @@ -40,21 +41,21 @@ public void Validator_TryValidateObject_Returns_The_Expected_Error_Message_When_
Assert.Equal(expectedErrorMessage, result.ErrorMessage);
}

private class ValidData : IEnumerable<object?[]>
private sealed class ValidData : IEnumerable<object?[]>
{
public IEnumerator<object?[]> GetEnumerator()
{
yield return new object?[] { null };
yield return new object[] { new string?[] { } };
yield return new object[] { new string[] { } };
yield return new object[] { Array.Empty<string?>() };
yield return new object[] { Array.Empty<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();
}

private class InvalidData : IEnumerable<object?[]>
private sealed class InvalidData : IEnumerable<object?[]>
{
public IEnumerator<object?[]> GetEnumerator()
{
Expand All @@ -70,7 +71,7 @@ private class InvalidData : IEnumerable<object?[]>
IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator();
}

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
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Workleap.ComponentModel.DataAnnotations.Tests;

public class GuidAttributeTests
public sealed class GuidAttributeTests
{
private const string ACustomErrorMessage = "A custom error message.";

Expand All @@ -29,7 +29,6 @@ public void IsValid_Returns_True_When_Value_Is_Null()
[InlineData("{0xf4aebf09,0x7ac8,0x4521,{0x9b,0x0b,0x91,0x8d,0x81,0x39,0xbd,0xe0}}")]
public void IsValid_Returns_True_When_Valid_Guid_String_Without_Format(string value)
{
var format = default(string);
var attr = new GuidAttribute();
Assert.Null(attr.Format);
Assert.True(attr.IsValid(value));
Expand Down Expand Up @@ -115,7 +114,7 @@ public void Validator_TryValidateObject_Returns_The_Expected_Error_Messages_When
Assert.Single(errorMessages, expectedValue5ErrorMessage);
}

private class Something
private sealed class Something
{
[Guid]
public string Value1 => "not_a_valid_guid_string";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Workleap.ComponentModel.DataAnnotations.Tests;

public class MaxValueAttributeTests
public sealed class MaxValueAttributeTests
{
[Theory]
[InlineData(50, 49)]
Expand All @@ -10,21 +10,21 @@ public class MaxValueAttributeTests
public void GivenIntValue_ShouldPassValidation_WhenValueIsLessThanOrEqualToMax(int maxValue, int valueBeingValidated)
{
var maxValueAttribute = new MaxValueAttribute(maxValue);

Assert.True(maxValueAttribute.IsValid(valueBeingValidated));
}

[Theory]
[InlineData(49, 50)]
[InlineData(49, int.MaxValue)]
[InlineData(-51, -50)]
public void GivenIntValue_ShouldFailValidation_WhenValueIsMoreThanMax(int maxValue, int valueBeingValidated)
{
var maxValueAttribute = new MaxValueAttribute(maxValue);

Assert.False(maxValueAttribute.IsValid(valueBeingValidated));
}

[Theory]
[InlineData(50.0, 49.0)]
[InlineData(double.MaxValue, 49.0)]
Expand All @@ -33,21 +33,21 @@ public void GivenIntValue_ShouldFailValidation_WhenValueIsMoreThanMax(int maxVal
public void GivenDoubleValue_ShouldPassValidation_WhenValueIsLessThanOrEqualToMax(double maxValue, double valueBeingValidated)
{
var maxValueAttribute = new MaxValueAttribute(maxValue);

Assert.True(maxValueAttribute.IsValid(valueBeingValidated));
}

[Theory]
[InlineData(49.0, 50.0)]
[InlineData(49.0, double.MaxValue)]
[InlineData(-51.0, -50.0)]
public void GivenDoubleValue_ShouldFailValidation_WhenValueIsMoreThanToMax(double maxValue, double valueBeingValidated)
{
var maxValueAttribute = new MaxValueAttribute(maxValue);

Assert.False(maxValueAttribute.IsValid(valueBeingValidated));
}

[Theory]
[InlineData(50.0, 49.0)]
[InlineData(long.MaxValue, 49.0)]
Expand All @@ -56,21 +56,21 @@ public void GivenDoubleValue_ShouldFailValidation_WhenValueIsMoreThanToMax(doubl
public void GivenLongValue_ShouldPassValidation_WhenValueIsLessThanOrEqualToMax(long maxValue, long valueBeingValidated)
{
var maxValueAttribute = new MaxValueAttribute(maxValue);

Assert.True(maxValueAttribute.IsValid(valueBeingValidated));
}

[Theory]
[InlineData(49, 50)]
[InlineData(49.0, long.MaxValue)]
[InlineData(-51, -50)]
public void GivenLongValue_ShouldFailValidation_WhenValueIsMoreThanMax(long maxValue, long valueBeingValidated)
{
var maxValueAttribute = new MaxValueAttribute(maxValue);

Assert.False(maxValueAttribute.IsValid(valueBeingValidated));
}

[Theory]
[InlineData(50.0f, 49.0f)]
[InlineData(float.MaxValue, 49.0f)]
Expand All @@ -79,18 +79,18 @@ public void GivenLongValue_ShouldFailValidation_WhenValueIsMoreThanMax(long maxV
public void GivenFloatValue_ShouldPassValidation_WhenValueIsLessThanOrEqualToMax(float maxValue, float valueBeingValidated)
{
var maxValueAttribute = new MaxValueAttribute(maxValue);

Assert.True(maxValueAttribute.IsValid(valueBeingValidated));
}

[Theory]
[InlineData(49.0f, 50.0f)]
[InlineData(49.0f, float.MaxValue)]
[InlineData(-51.0f, -50.0f)]
public void GivenFloatValue_ShouldFailValidation_WhenValueIsMoreThanToMax(float maxValue, float valueBeingValidated)
{
var maxValueAttribute = new MaxValueAttribute(maxValue);

Assert.False(maxValueAttribute.IsValid(valueBeingValidated));
}
}
Loading