File tree Expand file tree Collapse file tree
SourceGenerators/Utilities/Extensions Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,8 +9,8 @@ public static string TryGetGodotProjectDir(this AnalyzerConfigOptions options)
99 const string GodotProjectDir = "build_property.GodotProjectDir" ;
1010 const string GodotProjectDirBase64 = "build_property.GodotProjectDirBase64" ;
1111
12- return options . TryGetValue ( GodotProjectDir , out var value ) ? value . Trim ( '\\ ' )
13- : options . TryGetValue ( GodotProjectDirBase64 , out value ) ? value . Trim ( '\\ ' ) : null ;
12+ return options . TryGetValue ( GodotProjectDir , out var value ) ? value . TrimEnd ( '\\ ' )
13+ : options . TryGetValue ( GodotProjectDirBase64 , out value ) ? value . TrimEnd ( '\\ ' ) : null ;
1414 }
1515 }
1616}
Original file line number Diff line number Diff line change 1- namespace GodotSharp . SourceGenerators
1+ using System . Diagnostics ;
2+
3+ namespace GodotSharp . SourceGenerators
24{
35 internal static class GD
46 {
@@ -27,9 +29,21 @@ static string GetProjectRoot(string path)
2729 }
2830
2931 public static string GetProjectFile ( string path , string projectDir = null )
30- => $ " { projectDir ?? GetProjectRoot ( path ) } / { GodotProjectFile } " ;
32+ => Path . Combine ( projectDir ?? GetProjectRoot ( path ) , GodotProjectFile ) ;
3133
3234 public static string GetResourcePath ( string path , string projectDir = null )
33- => $ "res:/{ path [ ( projectDir ?? GetProjectRoot ( path ) ) . Length ..] . Replace ( @"\" , "/" ) } ";
35+ {
36+ projectDir ??= GetProjectRoot ( path ) ;
37+ Debug . Assert ( path . StartsWith ( projectDir ) ) ;
38+
39+ var resPath = path [ projectDir . Length ..] ;
40+ Debug . Assert ( resPath . StartsWith ( @"\" ) ) ;
41+
42+ resPath = $ "res:/{ resPath . Replace ( @"\" , "/" ) } ";
43+ Debug . Assert ( resPath . StartsWith ( "res://" ) ) ;
44+ Debug . Assert ( ! resPath . StartsWith ( "res:///" ) ) ;
45+
46+ return resPath ;
47+ }
3448 }
3549}
You can’t perform that action at this time.
0 commit comments