Skip to content

Commit

Permalink
Merge pull request #102 from feO2x/dev
Browse files Browse the repository at this point in the history
v12.0.0
  • Loading branch information
feO2x authored Oct 27, 2024
2 parents 9d994da + cb87ede commit 85b04d9
Show file tree
Hide file tree
Showing 38 changed files with 2,753 additions and 369 deletions.
1 change: 1 addition & 0 deletions Code/Light.GuardClauses.AllProjects.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpRenamePlacementToArrangementMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002EMemberReordering_002EMigrations_002ECSharpFileLayoutPatternRemoveIsAttributeUpgrade/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAlwaysTreatStructAsNotReorderableMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Light.GuardClauses.InternalRoslynAnalyzers\Light.GuardClauses.InternalRoslynAnalyzers.csproj" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
<PackageReference Include="FluentAssertions" Version="6.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageReference Include="FluentAssertions" Version="6.12.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.0.1" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.11.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private static void AnalyzeXmlCommentsForParameterNameAndMessage(SymbolAnalysisC
if (methodSymbol.DeclaringSyntaxReferences.Length != 1 ||
!(methodSymbol.DeclaringSyntaxReferences[0].GetSyntax() is MethodDeclarationSyntax methodDeclarationSyntax) ||
!(methodDeclarationSyntax.DescendantTrivia()
.SingleOrDefault(trivia => trivia.Kind() == SyntaxKind.SingleLineDocumentationCommentTrivia)
.SingleOrDefault(trivia => trivia.IsKind(SyntaxKind.SingleLineDocumentationCommentTrivia))
.GetStructure() is DocumentationCommentTriviaSyntax documentationSyntax))
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ public string ImperativeVersion()

[Benchmark]
public string LightGuardClausesCustomException() =>
X.MustBe(Y, StringComparisonType.OrdinalIgnoreWhiteSpace, (x, y) => new Exception("The strings are not equal."));
X.MustBe(Y, StringComparisonType.OrdinalIgnoreWhiteSpace, (_, _, _) => new Exception("The strings are not equal."));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ public string ImperativeVersion()

[Benchmark]
public string LightGuardClausesCustomException() =>
X.MustNotBe(Y, StringComparisonType.OrdinalIgnoreCaseIgnoreWhiteSpace, (x, y) => new Exception("The strings are equal."));
X.MustNotBe(Y, StringComparisonType.OrdinalIgnoreCaseIgnoreWhiteSpace, (_, _, _) => new Exception("The strings are equal."));
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<LangVersion>10.0</LangVersion>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>12.0</LangVersion>
<Authors>Kenny Pflug</Authors>
<Company>Kenny Pflug</Company>
<Copyright>Copyright © Kenny Pflug 2016 - 2023</Copyright>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.6.0" />
<PackageReference Include="FluentAssertions" Version="6.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.11.0" />
<PackageReference Include="FluentAssertions" Version="6.12.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Light.GuardClauses\Light.GuardClauses.csproj" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.6.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.11.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static void CreateSingleSourceFile(SourceFileMergeOptions options)
.AppendLine($@"License information for Light.GuardClauses
The MIT License (MIT)
Copyright (c) 2016, 2023 Kenny Pflug mailto:[email protected]
Copyright (c) 2016, 2024 Kenny Pflug mailto:[email protected]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the ""Software""), to deal
Expand Down Expand Up @@ -69,6 +69,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
using System.Text.RegularExpressions;
{(options.IncludeJetBrainsAnnotationsUsing ? "using JetBrains.Annotations;" + Environment.NewLine : string.Empty)}using {options.BaseNamespace}.Exceptions;
using {options.BaseNamespace}.FrameworkExtensions;
{(options.IncludeJetBrainsAnnotationsUsing ? "using NotNullAttribute = System.Diagnostics.CodeAnalysis.NotNullAttribute;" : "")}
#nullable enable annotations
Expand Down
74 changes: 73 additions & 1 deletion Code/Light.GuardClauses.Tests/ComparableAssertions/RangeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,78 @@ public static void ConstructorException(int from, int to)
.Message.Should().Contain($"{nameof(to)} must not be less than {from}, but it actually is {to}.");
}

[Theory]
[InlineData(0, 10, 0)] // Lower boundary
[InlineData(0, 10, 5)] // Middle value
[InlineData(0, 10, 10)] // Upper boundary
public static void InclusiveBetween_ValuesInRange(int from, int to, int value)
{
var range = Range.InclusiveBetween(from, to);

var result = range.IsValueWithinRange(value);

result.Should().BeTrue();
}

[Theory]
[InlineData(0, 10, -1)] // Below range
[InlineData(0, 10, 11)] // Above range
public static void InclusiveBetween_ValuesOutOfRange(int from, int to, int value)
{
var range = Range.InclusiveBetween(from, to);

var result = range.IsValueWithinRange(value);

result.Should().BeFalse();
}

[Theory]
[InlineData(0, 10, 1)] // Just above lower boundary
[InlineData(0, 10, 5)] // Middle value
[InlineData(0, 10, 9)] // Just below upper boundary
public static void ExclusiveBetween_ValuesInRange(int from, int to, int value)
{
var range = Range.ExclusiveBetween(from, to);

var result = range.IsValueWithinRange(value);

result.Should().BeTrue();
}

[Theory]
[InlineData(0, 10, 0)] // Lower boundary
[InlineData(0, 10, 10)] // Upper boundary
[InlineData(0, 10, -1)] // Below range
[InlineData(0, 10, 11)] // Above range
public static void ExclusiveBetween_ValuesOutOfRange(int from, int to, int value)
{
var range = Range.ExclusiveBetween(from, to);

var result = range.IsValueWithinRange(value);

result.Should().BeFalse();
}

[Theory]
[InlineData(10, 5)] // To less than From
[InlineData(-5, -10)] // Negative To less than From
public static void InclusiveBetween_InvalidRange_ThrowsException(int from, int to)
{
Action inclusiveAct = () => Range.InclusiveBetween(from, to);
inclusiveAct.Should().Throw<ArgumentOutOfRangeException>()
.And.Message.Should().Contain($"{nameof(to)} must not be less than {from}");
}

[Theory]
[InlineData(10, 5)] // To less than From
[InlineData(-5, -10)] // Negative To less than From
public static void ExclusiveBetween_InvalidRange_ThrowsException(int from, int to)
{
Action exclusiveAct = () => Range.ExclusiveBetween(from, to);
exclusiveAct.Should().Throw<ArgumentOutOfRangeException>()
.And.Message.Should().Contain($"{nameof(to)} must not be less than {from}");
}

[Theory]
[MemberData(nameof(Collections))]
public static void RangeForCollections(IEnumerable enumerable)
Expand Down Expand Up @@ -164,4 +236,4 @@ public static void RangeForReadOnlySpan(Memory<int> memory)
Enumerable.Range(1, 500).ToArray(),
Array.Empty<int>()
};
}
}
Loading

0 comments on commit 85b04d9

Please sign in to comment.