Skip to content
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
20 changes: 20 additions & 0 deletions Code/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>false</CentralPackageTransitivePinningEnabled>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="BenchmarkDotNet" Version="0.15.6" />
<PackageVersion Include="FluentAssertions" Version="[7.2.0]" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.13.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Binder" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.CommandLine" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="10.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="Nullable" Version="1.3.1" />
<PackageVersion Include="System.Collections.Immutable" Version="10.0.0" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
</ItemGroup>
</Project>
16 changes: 11 additions & 5 deletions Code/Light.GuardClauses.AllProjects.sln
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,24 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Light.GuardClauses.SourceCo
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Light.GuardClauses.Source", "Light.GuardClauses.Source\Light.GuardClauses.Source.csproj", "{A7B9AC78-FA4F-4BDE-9DAF-B854408AB843}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Versioning", "Versioning", "{176BEDC4-CFE3-4084-8213-B4EC155A7E38}"
ProjectSection(SolutionItems) = preProject
Version.props = Version.props
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Light.GuardClauses.SourceCodeTransformation.Tests", "Light.GuardClauses.SourceCodeTransformation.Tests\Light.GuardClauses.SourceCodeTransformation.Tests.csproj", "{A2067796-F167-47BE-B367-191152DCE230}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plans", "Plans", "{664661A0-3861-486B-87B5-A35A5CC5F7B7}"
ProjectSection(SolutionItems) = preProject
Plans\issue-114-must-not-be-default-or-empty-for-immutable-array.md = Plans\issue-114-must-not-be-default-or-empty-for-immutable-array.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionItems", "{8A42A536-E597-454B-BE18-4F62311FA158}"
ProjectSection(SolutionItems) = preProject
..\CONTRIBUTING.md = ..\CONTRIBUTING.md
..\README.md = ..\README.md
..\LICENSE = ..\LICENSE
Directory.Packages.props = Directory.Packages.props
Version.props = Version.props
Light.GuardClauses.AllProjects.sln.DotSettings = Light.GuardClauses.AllProjects.sln.DotSettings
Light.GuardClauses.sln.DotSettings = Light.GuardClauses.sln.DotSettings
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

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

<ItemGroup>
<ProjectReference Include="..\Light.GuardClauses.InternalRoslynAnalyzers\Light.GuardClauses.InternalRoslynAnalyzers.csproj" />
<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" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio" />
<PackageReference Include="FluentAssertions" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

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

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

</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using BenchmarkDotNet.Attributes;

namespace Light.GuardClauses.Performance.StringAssertions
namespace Light.GuardClauses.FrameworkExtensions.Performance.StringAssertions
{
public class ContainsOrdinalBenchmark
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
Expand All @@ -8,7 +8,7 @@

<ItemGroup>
<ProjectReference Include="..\Light.GuardClauses\Light.GuardClauses.csproj" />
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
<PackageReference Include="BenchmarkDotNet" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
Expand All @@ -10,8 +10,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Memory" Version="4.6.0" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.1.0" />
<PackageReference Include="System.Collections.Immutable" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

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

<ItemGroup>
<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" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" />
<PackageReference Include="FluentAssertions" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,54 +5,56 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Xunit;

namespace Light.GuardClauses.SourceCodeTransformation.Tests
namespace Light.GuardClauses.SourceCodeTransformation.Tests;

public static class ParseCSharpWithRoslynTests
{
public static class ParseCSharpWithRoslynTests
{
private static readonly DirectoryInfo CodeDirectory;
private static readonly DirectoryInfo CodeDirectory;

static ParseCSharpWithRoslynTests()
{
CodeDirectory = FindCodeDirectory();
}
static ParseCSharpWithRoslynTests() => CodeDirectory = FindCodeDirectory();

[Fact]
public static void ParseExpressionExtensionsFile()
{
var fileInfo = GetLightGuardClausesFile(@"FrameworkExtensions\ExpressionExtensions.cs");
var syntaxTree = CSharpSyntaxTree.ParseText(File.ReadAllText(fileInfo.FullName));
var root = (CompilationUnitSyntax) syntaxTree.GetRoot();

root.Members.Should().NotBeEmpty();
}
[Fact]
public static void ParseExpressionExtensionsFile()
{
var fileInfo = GetLightGuardClausesFile("FrameworkExtensions/ExpressionExtensions.cs");
var syntaxTree = CSharpSyntaxTree.ParseText(File.ReadAllText(fileInfo.FullName));
var root = (CompilationUnitSyntax) syntaxTree.GetRoot();

[Fact]
public static void ParseSpanDelegatesFile()
{
var fileInfo = GetLightGuardClausesFile("SpanDelegates.cs");
var syntaxTree = CSharpSyntaxTree.ParseText(File.ReadAllText(fileInfo.FullName), new CSharpParseOptions(LanguageVersion.CSharp7_3, preprocessorSymbols: new[] { "NETSTANDARD2_0" }));
var root = (CompilationUnitSyntax) syntaxTree.GetRoot();
root.Members.Should().NotBeEmpty();
}

root.Members.Should().NotBeEmpty();
}
[Fact]
public static void ParseSpanDelegatesFile()
{
var fileInfo = GetLightGuardClausesFile("ExceptionFactory/SpanDelegates.cs");
var syntaxTree = CSharpSyntaxTree.ParseText(
File.ReadAllText(fileInfo.FullName),
new (LanguageVersion.CSharp7_3, preprocessorSymbols: ["NETSTANDARD2_0"])
);
var root = (CompilationUnitSyntax) syntaxTree.GetRoot();

root.Members.Should().NotBeEmpty();
}

private static DirectoryInfo FindCodeDirectory()
private static DirectoryInfo FindCodeDirectory()
{
var currentDirectory = new DirectoryInfo(".");
do
{
var currentDirectory = new DirectoryInfo(".");
do
if (currentDirectory.Name == "Code")
{
if (currentDirectory.Name == "Code")
return currentDirectory;
return currentDirectory;
}

currentDirectory = currentDirectory.Parent;
} while (currentDirectory != null);
currentDirectory = currentDirectory.Parent;
} while (currentDirectory != null);

throw new InvalidOperationException("This test project does not reside in a folder called \"Code\" (directly or indirectly).");
}

private static FileInfo GetLightGuardClausesFile(string relativeFilePath)
{
return new FileInfo(Path.Combine(CodeDirectory.FullName, "Light.GuardClauses", relativeFilePath));
}
throw new InvalidOperationException(
"This test project does not reside in a folder called \"Code\" (directly or indirectly)."
);
}
}

private static FileInfo GetLightGuardClausesFile(string relativeFilePath) => new (
Path.Combine(CodeDirectory.FullName, "Light.GuardClauses", relativeFilePath)
);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="..\Version.props" />

Expand All @@ -10,10 +10,10 @@

<ItemGroup>
<ProjectReference Include="..\Light.GuardClauses\Light.GuardClauses.csproj" />
<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.13.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Collections.ObjectModel;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static void FloatWithDefaultTolerance(float first, float second, bool exp
public static void FloatWithCustomTolerance(float first, float second, float tolerance, bool expected) =>
first.IsApproximately(second, tolerance).Should().Be(expected);

#if NET8_0
#if NET8_0_OR_GREATER
[Theory]
[InlineData(1.1, 1.3, 0.5, true)]
[InlineData(100.55, 100.555, 0.00001, false)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static void FloatWithDefaultTolerance(float first, float second, bool exp
public static void FloatWIthCustomTolerance(float first, float second, float tolerance, bool expected) =>
first.IsGreaterThanOrApproximately(second, tolerance).Should().Be(expected);

#if NET8_0
#if NET8_0_OR_GREATER
[Theory]
[InlineData(15.91, 15.9, 0.1, true)]
[InlineData(24.449, 24.45, 0.0001, false)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static void FloatWithDefaultTolerance(float first, float second, bool exp
public static void FloatWithCustomTolerance(float first, float second, float tolerance, bool expected) =>
first.IsLessThanOrApproximately(second, tolerance).Should().Be(expected);

#if NET8_0
#if NET8_0_OR_GREATER
[Theory]
[InlineData(13.25, 13.5, 0.1, true)] // Less than case
[InlineData(13.5, 13.5, 0.1, true)] // Equal case
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using FluentAssertions;
using Xunit;

Expand Down Expand Up @@ -178,7 +178,7 @@ public static void CallerArgumentExpressionWithTolerance_Float()
.WithParameterName(nameof(pi));
}

#if NET8_0
#if NET8_0_OR_GREATER
[Theory]
[InlineData(5.1, 5.0, 0.2)]
[InlineData(10.3, 10.3, 0.01)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using FluentAssertions;
using Xunit;

Expand Down Expand Up @@ -202,7 +202,7 @@ public static void CallerArgumentExpressionWithTolerance_Float()
.WithParameterName(nameof(pi));
}

#if NET8_0
#if NET8_0_OR_GREATER
[Theory]
[InlineData(15.91, 15.9, 0.1)]
[InlineData(24.4999, 24.45, 0.0001)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using FluentAssertions;
using Xunit;

Expand Down Expand Up @@ -202,7 +202,7 @@ public static void CallerArgumentExpressionWithTolerance_Float()
.WithParameterName(nameof(threePointFive));
}

#if NET8_0
#if NET8_0_OR_GREATER
[Theory]
[InlineData(15.9, 15.91, 0.1)]
[InlineData(24.45, 24.4999, 0.0001)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using FluentAssertions;
using Xunit;

Expand Down Expand Up @@ -180,7 +180,7 @@ public static void CallerArgumentExpressionWithTolerance_Float()
.WithParameterName(nameof(pi));
}

#if NET8_0
#if NET8_0_OR_GREATER
[Theory]
[InlineData(5.3, 5.0, 0.2)]
[InlineData(10.4, 10.3, 0.01)]
Expand Down
Loading
Loading