From 47785e7fdd0e2613c068b7c2abc279818340b7b9 Mon Sep 17 00:00:00 2001 From: Adriano Carlos Verona Date: Sat, 11 Jan 2025 12:46:07 -0500 Subject: [PATCH] update to .NET 9.0 --- .github/workflows/cecilifier-ci.yml | 4 +- Cecilifier.Common.props | 2 +- Cecilifier.CommonPackages.props | 4 +- .../Cecilifier.Core.Tests.csproj | 6 ++- .../Generics/GenericTypesAsMembers.cs.txt | 4 +- .../Members/Methods/RefProperties.cs.txt | 4 +- .../MemberDependencyTestBase.cs | 39 +++++++++++++++++++ .../Cecilifier.TypeMapGenerator.csproj | 8 ++-- Cecilifier.Web/Startup.cs | 4 +- 9 files changed, 58 insertions(+), 17 deletions(-) create mode 100644 Cecilifier.Core.Tests/Tests/Unit/MemberDependencies/MemberDependencyTestBase.cs diff --git a/.github/workflows/cecilifier-ci.yml b/.github/workflows/cecilifier-ci.yml index 4199421d..007897db 100644 --- a/.github/workflows/cecilifier-ci.yml +++ b/.github/workflows/cecilifier-ci.yml @@ -8,8 +8,8 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-dotnet@v4 with: - dotnet-version: '8.0.x' - - run: dotnet tool install --global dotnet-ilverify --version 8.0.0 + dotnet-version: '9.0.x' + - run: dotnet tool install --global dotnet-ilverify --version 9.0.0 - run: dotnet restore - run: dotnet test --filter 'TestCategory !~ Issues' --collect:"XPlat Code Coverage" - run: dotnet format style --verify-no-changes diff --git a/Cecilifier.Common.props b/Cecilifier.Common.props index 91d60219..ffb3e58d 100644 --- a/Cecilifier.Common.props +++ b/Cecilifier.Common.props @@ -1,6 +1,6 @@ - net8.0 + net9.0 12 2.16.0 true diff --git a/Cecilifier.CommonPackages.props b/Cecilifier.CommonPackages.props index 721bb067..156554c5 100644 --- a/Cecilifier.CommonPackages.props +++ b/Cecilifier.CommonPackages.props @@ -1,7 +1,7 @@ - - + + 0.11.6 diff --git a/Cecilifier.Core.Tests/Cecilifier.Core.Tests.csproj b/Cecilifier.Core.Tests/Cecilifier.Core.Tests.csproj index 9eb166c7..8dc2b12c 100644 --- a/Cecilifier.Core.Tests/Cecilifier.Core.Tests.csproj +++ b/Cecilifier.Core.Tests/Cecilifier.Core.Tests.csproj @@ -2,13 +2,15 @@ + - runtime; build; native; contentfiles; analyzers; buildtransitive all + runtime; build; native; contentfiles; analyzers; buildtransitive + - + diff --git a/Cecilifier.Core.Tests/TestResources/Integration/Generics/GenericTypesAsMembers.cs.txt b/Cecilifier.Core.Tests/TestResources/Integration/Generics/GenericTypesAsMembers.cs.txt index e3ca3533..4131a1fb 100644 --- a/Cecilifier.Core.Tests/TestResources/Integration/Generics/GenericTypesAsMembers.cs.txt +++ b/Cecilifier.Core.Tests/TestResources/Integration/Generics/GenericTypesAsMembers.cs.txt @@ -2,8 +2,8 @@ using System.Collections.Generic; class GenericTypesAsMembers { - public IList field; - public IList Property { get { return field; } set { field = value; } } + public IList asField; + public IList Property { get { return asField; } set { asField = value; } } public IList Method(IList l) { diff --git a/Cecilifier.Core.Tests/TestResources/Integration/Members/Methods/RefProperties.cs.txt b/Cecilifier.Core.Tests/TestResources/Integration/Members/Methods/RefProperties.cs.txt index 66d60dee..bc70d740 100644 --- a/Cecilifier.Core.Tests/TestResources/Integration/Members/Methods/RefProperties.cs.txt +++ b/Cecilifier.Core.Tests/TestResources/Integration/Members/Methods/RefProperties.cs.txt @@ -1,9 +1,9 @@ class RefProperties { - private int field; + private int prop; ref int Property { - get => ref field; + get => ref prop; } public ref int UseRefProperty() => ref Property; diff --git a/Cecilifier.Core.Tests/Tests/Unit/MemberDependencies/MemberDependencyTestBase.cs b/Cecilifier.Core.Tests/Tests/Unit/MemberDependencies/MemberDependencyTestBase.cs new file mode 100644 index 00000000..21ca1be0 --- /dev/null +++ b/Cecilifier.Core.Tests/Tests/Unit/MemberDependencies/MemberDependencyTestBase.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Cecilifier.Core.AST.MemberDependencies; +using Cecilifier.Core.Tests.Tests.Unit.Framework; + +namespace Cecilifier.Core.Tests.Tests.Unit; + +public class MemberDependencyTestBase +{ + private protected IReadOnlyCollection CollectDependenciesFromSingleType(CSharpCompilation compilation) + { + var collector = new MemberDependencyCollector(); + + var typeUnderTest = compilation.SyntaxTrees[0].GetRoot().ChildNodes().OfType().Single(); + var computedDependencies = collector.Process(typeUnderTest, compilation.GetSemanticModel(compilation.SyntaxTrees[0])); + return computedDependencies; + } + + protected static CSharpCompilation CompilationFor(params string[] code) + { + var syntaxTrees = code.Select(source => CSharpSyntaxTree.ParseText(source)); + var comp = CSharpCompilation.Create("Test", syntaxTrees, Basic.Reference.Assemblies.Net90.References.All, new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)); + + var errors = comp.GetDiagnostics() + .Where(d => d.Severity == DiagnosticSeverity.Error) + .Select(d => d.GetMessage()) + .ToArray(); + + if (errors.Any()) + throw new ArgumentException($"Code has compilation errors:\n\t{string.Join("\n\t", errors)}"); + return comp; + } + + internal static string MemberNameFrom(MemberDependency dependency) => dependency.Declaration.MemberName(); +} diff --git a/Cecilifier.TypeMapGenerator/Cecilifier.TypeMapGenerator.csproj b/Cecilifier.TypeMapGenerator/Cecilifier.TypeMapGenerator.csproj index 70f20736..ff7289d5 100644 --- a/Cecilifier.TypeMapGenerator/Cecilifier.TypeMapGenerator.csproj +++ b/Cecilifier.TypeMapGenerator/Cecilifier.TypeMapGenerator.csproj @@ -15,10 +15,10 @@ - - - - + + + + diff --git a/Cecilifier.Web/Startup.cs b/Cecilifier.Web/Startup.cs index 7fbfad63..ea245ce8 100644 --- a/Cecilifier.Web/Startup.cs +++ b/Cecilifier.Web/Startup.cs @@ -34,10 +34,10 @@ public class Startup Exe - net8.0 + net9.0 - +