From 54f96f60ce0a93c78ceb32b8a9af49f61e35d82c Mon Sep 17 00:00:00 2001 From: Martin Othamar Date: Sun, 24 Mar 2024 19:29:58 +0100 Subject: [PATCH] Update more packages (#143) --- Directory.Packages.props | 9 +- Justfile | 3 +- NuGet.config | 6 +- .../Mediator.SourceGenerator.Tests.csproj | 11 ++- .../SourceGenVerifier.cs | 84 ------------------- 5 files changed, 13 insertions(+), 100 deletions(-) delete mode 100644 test/Mediator.SourceGenerator.Tests/SourceGenVerifier.cs diff --git a/Directory.Packages.props b/Directory.Packages.props index 82fed93..18e3d3c 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -21,7 +21,7 @@ - + @@ -52,11 +52,10 @@ - - - + + + - diff --git a/Justfile b/Justfile index a725a3c..fca88ec 100644 --- a/Justfile +++ b/Justfile @@ -3,8 +3,7 @@ alias b := build alias t := test clean: - find . -iname "bin" -print0 | xargs -0 rm -rf - find . -iname "obj" -print0 | xargs -0 rm -rf + git clean -fxd dotnet build-server shutdown build: diff --git a/NuGet.config b/NuGet.config index 6dacb4e..07d85d3 100644 --- a/NuGet.config +++ b/NuGet.config @@ -4,16 +4,16 @@ - + - + diff --git a/test/Mediator.SourceGenerator.Tests/Mediator.SourceGenerator.Tests.csproj b/test/Mediator.SourceGenerator.Tests/Mediator.SourceGenerator.Tests.csproj index 7945cc0..38dade7 100644 --- a/test/Mediator.SourceGenerator.Tests/Mediator.SourceGenerator.Tests.csproj +++ b/test/Mediator.SourceGenerator.Tests/Mediator.SourceGenerator.Tests.csproj @@ -28,12 +28,11 @@ all - - - - - - + + + + + diff --git a/test/Mediator.SourceGenerator.Tests/SourceGenVerifier.cs b/test/Mediator.SourceGenerator.Tests/SourceGenVerifier.cs deleted file mode 100644 index d5c4b54..0000000 --- a/test/Mediator.SourceGenerator.Tests/SourceGenVerifier.cs +++ /dev/null @@ -1,84 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Linq; -using System.Threading.Tasks; -using Mediator.SourceGenerator.Tests; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Testing; -using Microsoft.CodeAnalysis.Testing; - -public static class CSharpSourceGeneratorVerifier - where TSourceGenerator : IIncrementalGenerator, new() -{ - public static Task VerifySolution(string source, OutputKind outputKind = OutputKind.DynamicallyLinkedLibrary) - { - var test = new Test - { - TestBehaviors = TestBehaviors.SkipGeneratedSourcesCheck, - TestState = { Sources = { source }, }, - }; - return test.RunAsync(); - } - - private class Test : CSharpSourceGeneratorTest - { - public Test() - { - var refs = Fixture.AssemblyReferencesForCodegen.Select(a => a.Location).ToImmutableArray(); - this.ReferenceAssemblies = ReferenceAssemblies.Net.Net80.WithAssemblies(refs); - - this.SolutionTransforms.Add( - (solution, projectId) => - { - var compilationOptions = solution.GetProject(projectId)!.CompilationOptions; - compilationOptions = compilationOptions!.WithSpecificDiagnosticOptions( - compilationOptions.SpecificDiagnosticOptions.SetItems(GetNullableWarningsFromCompiler()) - ); - compilationOptions = ((CSharpCompilationOptions)compilationOptions!).WithUsings( - "System", - "System.Collections.Generic", - "System.IO", - "System.Linq", - "System.Net.Http", - "System.Threading", - "System.Threading.Tasks" - ); - - compilationOptions = compilationOptions!.WithScriptClassName("Program"); - - solution = solution.AddMetadataReferences( - projectId, - refs.Select(l => MetadataReference.CreateFromFile(l)).ToImmutableArray() - ); - solution = solution.WithProjectCompilationOptions(projectId, compilationOptions); - return solution; - } - ); - } - - protected override IEnumerable GetSourceGenerators() - { - yield return new TSourceGenerator().AsSourceGenerator().GetGeneratorType(); - } - - public LanguageVersion LanguageVersion { get; set; } = LanguageVersion.Latest; - - protected override ParseOptions CreateParseOptions() - { - return ((CSharpParseOptions)base.CreateParseOptions()).WithLanguageVersion(LanguageVersion); - } - - static ImmutableDictionary GetNullableWarningsFromCompiler() - { - string[] args = { "/warnaserror:nullable" }; - var commandLineArguments = CSharpCommandLineParser.Default.Parse( - args, - baseDirectory: Environment.CurrentDirectory, - sdkDirectory: Environment.CurrentDirectory - ); - return commandLineArguments.CompilationOptions.SpecificDiagnosticOptions; - } - } -}