Skip to content

Commit

Permalink
Fix mono glue generation with .NET 6
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jss2a98aj authored and Starkium committed Oct 16, 2024
1 parent d3061f8 commit 40b134a
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<EnablePreviewFeatures>true</EnablePreviewFeatures>
<LangVersion>11</LangVersion>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ public static Test MakeVerifier(ICollection<string> 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 =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ public static Test MakeVerifier(ICollection<string> sources, ICollection<string>
{
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

<EnablePreviewFeatures>true</EnablePreviewFeatures>
<LangVersion>11</LangVersion>

<Nullable>enable</Nullable>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
}

Expand Down
2 changes: 1 addition & 1 deletion modules/mono/global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.0",
"version": "6.0.0",
"rollForward": "latestMajor"
}
}

0 comments on commit 40b134a

Please sign in to comment.