From 40b134a3a795fd1636242b543ba830a69add2b49 Mon Sep 17 00:00:00 2001 From: jss2a98aj Date: Fri, 11 Oct 2024 19:30:54 -0400 Subject: [PATCH] Fix mono glue generation with .NET 6 EnablePreviewFeatures is utilized in two source generator tests so more invasive changes are not required. EnablePreviewFeatures should not impact anything outside of the tests. Raw string literals are not a feature covered by EnablePreviewFeatures, which is why some .cs files required edits. --- .../Godot.SourceGenerators.Sample.csproj | 1 + .../Godot.SourceGenerators.Tests/CSharpAnalyzerVerifier.cs | 5 +---- .../Godot.SourceGenerators.Tests/CSharpCodeFixVerifier.cs | 5 +---- .../CSharpSourceGeneratorVerifier.cs | 5 +---- .../Godot.SourceGenerators.Tests.csproj | 2 +- .../ScriptPathAttributeGeneratorTests.cs | 5 +---- modules/mono/global.json | 2 +- 7 files changed, 7 insertions(+), 18 deletions(-) diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Godot.SourceGenerators.Sample.csproj b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Godot.SourceGenerators.Sample.csproj index fc887313d5e8..d9e6e0f99ce8 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Godot.SourceGenerators.Sample.csproj +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Godot.SourceGenerators.Sample.csproj @@ -2,6 +2,7 @@ net6.0 + true 11 diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/CSharpAnalyzerVerifier.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/CSharpAnalyzerVerifier.cs index 253889296b17..bbdbf1e12b55 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/CSharpAnalyzerVerifier.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/CSharpAnalyzerVerifier.cs @@ -43,10 +43,7 @@ public static Test MakeVerifier(ICollection sources, params DiagnosticRe { var verifier = new Test(); - verifier.TestState.AnalyzerConfigFiles.Add(("/.globalconfig", $""" - is_global = true - build_property.GodotProjectDir = {Constants.ExecutingAssemblyPath} - """)); + verifier.TestState.AnalyzerConfigFiles.Add(("/.globalconfig", $"is_global = true\nbuild_property.GodotProjectDir = {Constants.ExecutingAssemblyPath}")); verifier.TestState.Sources.AddRange(sources.Select(source => { diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/CSharpCodeFixVerifier.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/CSharpCodeFixVerifier.cs index 51e215a17b22..7a9d3042469f 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/CSharpCodeFixVerifier.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/CSharpCodeFixVerifier.cs @@ -39,10 +39,7 @@ public static Test MakeVerifier(string source, string results) verifier.TestCode = File.ReadAllText(Path.Combine(Constants.SourceFolderPath, source)); verifier.FixedCode = File.ReadAllText(Path.Combine(Constants.GeneratedSourceFolderPath, results)); - verifier.TestState.AnalyzerConfigFiles.Add(("/.globalconfig", $""" - is_global = true - build_property.GodotProjectDir = {Constants.ExecutingAssemblyPath} - """)); + verifier.TestState.AnalyzerConfigFiles.Add(("/.globalconfig", $"is_global = true\nbuild_property.GodotProjectDir = {Constants.ExecutingAssemblyPath}")); return verifier; } diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/CSharpSourceGeneratorVerifier.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/CSharpSourceGeneratorVerifier.cs index 84e319352d9e..f78d35f35304 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/CSharpSourceGeneratorVerifier.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/CSharpSourceGeneratorVerifier.cs @@ -56,10 +56,7 @@ public static Test MakeVerifier(ICollection sources, ICollection { var verifier = new Test(); - verifier.TestState.AnalyzerConfigFiles.Add(("/.globalconfig", $""" - is_global = true - build_property.GodotProjectDir = {Constants.ExecutingAssemblyPath} - """)); + verifier.TestState.AnalyzerConfigFiles.Add(("/.globalconfig", $"is_global = true\nbuild_property.GodotProjectDir = {Constants.ExecutingAssemblyPath}")); verifier.TestState.Sources.AddRange(sources.Select(source => ( source, diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/Godot.SourceGenerators.Tests.csproj b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/Godot.SourceGenerators.Tests.csproj index 31a255dcdfcd..2e17a40f9932 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/Godot.SourceGenerators.Tests.csproj +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/Godot.SourceGenerators.Tests.csproj @@ -2,7 +2,7 @@ net6.0 - + true 11 enable diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/ScriptPathAttributeGeneratorTests.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/ScriptPathAttributeGeneratorTests.cs index 4f6b50cf0285..c96ba230fbe1 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/ScriptPathAttributeGeneratorTests.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/ScriptPathAttributeGeneratorTests.cs @@ -14,10 +14,7 @@ private static (string, SourceText) MakeAssemblyScriptTypesGeneratedSource(IColl { return ( Path.Combine("Godot.SourceGenerators", "Godot.SourceGenerators.ScriptPathAttributeGenerator", "AssemblyScriptTypes.generated.cs"), - SourceText.From($$""" - [assembly:Godot.AssemblyHasScriptsAttribute(new System.Type[] {{{string.Join(", ", types.Select(type => $"typeof({type})"))}}})] - - """, Encoding.UTF8) + SourceText.From($"[assembly:Godot.AssemblyHasScriptsAttribute(new System.Type[] {{{string.Join(", ", types.Select(type => $"typeof({type})"))}}})]\n", Encoding.UTF8) ); } diff --git a/modules/mono/global.json b/modules/mono/global.json index 8eb62bed1ef5..5087a866201f 100644 --- a/modules/mono/global.json +++ b/modules/mono/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.0", + "version": "6.0.0", "rollForward": "latestMajor" } }