Skip to content

Commit 8ae059f

Browse files
jkurdeksimonrozsival
authored andcommitted
added filepath sanitizing
1 parent 5b86c55 commit 8ae059f

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/Controls/src/BindingSourceGen/BindingSourceGenerator.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
3737

3838
context.RegisterSourceOutput(bindings, (spc, binding) =>
3939
{
40-
41-
var fileName = $"{binding.Location.FilePath}/GeneratedBindableObjectExtensions-{binding.Location.Line}-{binding.Location.Column}.g.cs";
42-
spc.AddSource(fileName, BindingCodeWriter.GenerateBinding(binding, (uint)Math.Abs(binding.Location.GetHashCode())));
40+
var fileName = $"{binding.Location.FilePath}-GeneratedBindableObjectExtensions-{binding.Location.Line}-{binding.Location.Column}.g.cs";
41+
var sanitizedFileName = fileName.Replace('/', '-').Replace('\\', '-').Replace(':', '-');
42+
spc.AddSource(sanitizedFileName, BindingCodeWriter.GenerateBinding(binding, (uint)Math.Abs(binding.Location.GetHashCode())));
4343
});
4444
}
4545

src/Controls/tests/BindingSourceGen.UnitTests/IntegrationTests.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ internal static partial class GeneratedBindableObjectExtensions
8080
}
8181
}
8282
""",
83-
result.GeneratedFiles["Path/To/Program.cs/GeneratedBindableObjectExtensions-3-7.g.cs"]);
83+
result.GeneratedFiles["Path-To-Program.cs-GeneratedBindableObjectExtensions-3-7.g.cs"]);
8484
}
8585

8686
[Fact]
@@ -182,7 +182,7 @@ internal static partial class GeneratedBindableObjectExtensions
182182
}
183183
}
184184
""",
185-
result.GeneratedFiles["Path/To/Program.cs/GeneratedBindableObjectExtensions-6-7.g.cs"]);
185+
result.GeneratedFiles["Path-To-Program.cs-GeneratedBindableObjectExtensions-6-7.g.cs"]);
186186
}
187187

188188
[Fact]
@@ -287,7 +287,7 @@ internal static partial class GeneratedBindableObjectExtensions
287287
}
288288
}
289289
""",
290-
result.GeneratedFiles["Path/To/Program.cs/GeneratedBindableObjectExtensions-7-7.g.cs"]);
290+
result.GeneratedFiles["Path-To-Program.cs-GeneratedBindableObjectExtensions-7-7.g.cs"]);
291291
}
292292

293293
public static IEnumerable<object[]> GenerateSimpleBindingWhenNullableDisabledAndPropertyNullableData =>
@@ -493,7 +493,7 @@ internal static partial class GeneratedBindableObjectExtensions
493493
}
494494
}
495495
""",
496-
result.GeneratedFiles["Path/To/Program.cs/GeneratedBindableObjectExtensions-7-7.g.cs"]);
496+
result.GeneratedFiles["Path-To-Program.cs-GeneratedBindableObjectExtensions-7-7.g.cs"]);
497497
}
498498

499499
[Fact]
@@ -611,7 +611,7 @@ internal static partial class GeneratedBindableObjectExtensions
611611
}
612612
}
613613
""",
614-
result.GeneratedFiles["Path/To/Program.cs/GeneratedBindableObjectExtensions-7-7.g.cs"]);
614+
result.GeneratedFiles["Path-To-Program.cs-GeneratedBindableObjectExtensions-7-7.g.cs"]);
615615
}
616616

617617
[Theory]
@@ -736,7 +736,7 @@ internal static partial class GeneratedBindableObjectExtensions
736736
}
737737
}
738738
""",
739-
result.GeneratedFiles["Path/To/Program.cs/GeneratedBindableObjectExtensions-4-7.g.cs"]);
739+
result.GeneratedFiles["Path-To-Program.cs-GeneratedBindableObjectExtensions-4-7.g.cs"]);
740740
}
741741

742742
[Fact]
@@ -855,7 +855,7 @@ internal static partial class GeneratedBindableObjectExtensions
855855
}
856856
}
857857
""",
858-
result.GeneratedFiles["Path/To/Program.cs/GeneratedBindableObjectExtensions-4-7.g.cs"]);
858+
result.GeneratedFiles["Path-To-Program.cs-GeneratedBindableObjectExtensions-4-7.g.cs"]);
859859
}
860860

861861
[Fact]
@@ -957,7 +957,7 @@ internal static partial class GeneratedBindableObjectExtensions
957957
}
958958
}
959959
""",
960-
result.GeneratedFiles["Path/To/Program.cs/GeneratedBindableObjectExtensions-3-7.g.cs"]);
960+
result.GeneratedFiles["Path-To-Program.cs-GeneratedBindableObjectExtensions-3-7.g.cs"]);
961961
}
962962

963963
[Fact]
@@ -1073,6 +1073,6 @@ internal static partial class GeneratedBindableObjectExtensions
10731073
}
10741074
}
10751075
""",
1076-
result.GeneratedFiles["Path/To/Program.cs/GeneratedBindableObjectExtensions-6-7.g.cs"]);
1076+
result.GeneratedFiles["Path-To-Program.cs-GeneratedBindableObjectExtensions-6-7.g.cs"]);
10771077
}
10781078
}

0 commit comments

Comments
 (0)