C#: Encode GodotProjectDir as Base64 to prevent issues with special characters
This commit is contained in:
parent
61d2c85511
commit
f949e94991
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
<GodotProjectDir Condition=" '$(GodotProjectDir)' == '' ">$(MSBuildProjectDirectory)</GodotProjectDir>
|
<GodotProjectDir Condition=" '$(GodotProjectDir)' == '' ">$(MSBuildProjectDirectory)</GodotProjectDir>
|
||||||
<GodotProjectDir>$([MSBuild]::EnsureTrailingSlash('$(GodotProjectDir)'))</GodotProjectDir>
|
<GodotProjectDir>$([MSBuild]::EnsureTrailingSlash('$(GodotProjectDir)'))</GodotProjectDir>
|
||||||
|
<GodotProjectDirBase64>$([MSBuild]::ConvertToBase64('$(GodotProjectDir)'))</GodotProjectDirBase64>
|
||||||
|
|
||||||
<!-- Custom output paths for Godot projects. In brief, 'bin\' and 'obj\' are moved to '$(GodotProjectDir)\.godot\mono\temp\'. -->
|
<!-- Custom output paths for Godot projects. In brief, 'bin\' and 'obj\' are moved to '$(GodotProjectDir)\.godot\mono\temp\'. -->
|
||||||
<BaseOutputPath>$(GodotProjectDir).godot\mono\temp\bin\</BaseOutputPath>
|
<BaseOutputPath>$(GodotProjectDir).godot\mono\temp\bin\</BaseOutputPath>
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<!-- $(GodotProjectDir) would normally be defined by the Godot.NET.Sdk -->
|
<!-- $(GodotProjectDir) would normally be defined by the Godot.NET.Sdk -->
|
||||||
<GodotProjectDir>$(MSBuildProjectDirectory)</GodotProjectDir>
|
<GodotProjectDir>$(MSBuildProjectDirectory)</GodotProjectDir>
|
||||||
|
<GodotProjectDirBase64>$([MSBuild]::ConvertToBase64('$(GodotProjectDir)'))</GodotProjectDirBase64>
|
||||||
<!-- For compiling GetGodotPropertyDefaultValues. -->
|
<!-- For compiling GetGodotPropertyDefaultValues. -->
|
||||||
<DefineConstants>$(DefineConstants);TOOLS</DefineConstants>
|
<DefineConstants>$(DefineConstants);TOOLS</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!-- $(GodotProjectDir) is defined by Godot.NET.Sdk -->
|
<!-- $(GodotProjectDir) is defined by Godot.NET.Sdk -->
|
||||||
<CompilerVisibleProperty Include="GodotProjectDir" />
|
<CompilerVisibleProperty Include="GodotProjectDir" />
|
||||||
|
<CompilerVisibleProperty Include="GodotProjectDirBase64" />
|
||||||
<CompilerVisibleProperty Include="GodotSourceGenerators" />
|
<CompilerVisibleProperty Include="GodotSourceGenerators" />
|
||||||
<CompilerVisibleProperty Include="IsGodotToolsProject" />
|
<CompilerVisibleProperty Include="IsGodotToolsProject" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -22,10 +22,17 @@ namespace Godot.SourceGenerators
|
|||||||
|
|
||||||
// NOTE: NotNullWhen diagnostics don't work on projects targeting .NET Standard 2.0
|
// NOTE: NotNullWhen diagnostics don't work on projects targeting .NET Standard 2.0
|
||||||
// ReSharper disable once ReplaceWithStringIsNullOrEmpty
|
// ReSharper disable once ReplaceWithStringIsNullOrEmpty
|
||||||
if (!context.TryGetGlobalAnalyzerProperty("GodotProjectDir", out string? godotProjectDir)
|
if (!context.TryGetGlobalAnalyzerProperty("GodotProjectDirBase64", out string? godotProjectDir) || godotProjectDir!.Length == 0)
|
||||||
|| godotProjectDir!.Length == 0)
|
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("Property 'GodotProjectDir' is null or empty.");
|
if (!context.TryGetGlobalAnalyzerProperty("GodotProjectDir", out godotProjectDir) || godotProjectDir!.Length == 0)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Property 'GodotProjectDir' is null or empty.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Workaround for https://github.com/dotnet/roslyn/issues/51692
|
||||||
|
godotProjectDir = Encoding.UTF8.GetString(Convert.FromBase64String(godotProjectDir));
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary<INamedTypeSymbol, IEnumerable<ClassDeclarationSyntax>> godotClasses = context
|
Dictionary<INamedTypeSymbol, IEnumerable<ClassDeclarationSyntax>> godotClasses = context
|
||||||
|
Loading…
Reference in New Issue
Block a user