Skip to content

Commit 005aec8

Browse files
committed
Revert "Fixed issue where using the same property name in multiple samples within the same assembly broken the generator"
This reverts commit 5e10461.
1 parent 328c5cf commit 005aec8

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

common/CommunityToolkit.Labs.Core.SourceGenerators/ToolkitSampleOptionGenerator.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace CommunityToolkit.Labs.Core.SourceGenerators;
1717
public class ToolkitSampleOptionGenerator : IIncrementalGenerator
1818
{
1919
private readonly HashSet<string> _handledPropertyNames = new();
20+
private readonly HashSet<ToolkitSampleOptionBaseAttribute> _handledAttributes = new();
2021
private readonly HashSet<ISymbol> _handledContainingClasses = new(SymbolEqualityComparer.Default);
2122

2223
public void Initialize(IncrementalGeneratorInitializationContext context)
@@ -59,13 +60,13 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
5960
ctx.AddSource($"{data.ContainingClassSymbol}.GeneratedPropertyContainer.g", propertyContainerSource);
6061
}
6162

62-
var name = $"{data.ContainingClassSymbol}.Property.{data.Attribute.Name}.g";
63+
if (!_handledAttributes.Add(data.Attribute))
64+
return;
6365

64-
if (_handledPropertyNames.Add(name))
65-
{
66-
var dependencyPropertySource = BuildProperty(data.ContainingClassSymbol, data.Attribute.Name, data.Attribute.TypeName, data.Type);
67-
ctx.AddSource(name, dependencyPropertySource);
68-
}
66+
var dependencyPropertySource = BuildProperty(data.ContainingClassSymbol, data.Attribute.Name, data.Attribute.TypeName, data.Type);
67+
68+
if (_handledPropertyNames.Add(data.Attribute.Name))
69+
ctx.AddSource($"{data.ContainingClassSymbol}.Property.{data.Attribute.Name}.g", dependencyPropertySource);
6970
});
7071

7172
}
@@ -108,6 +109,7 @@ public partial class {containingClassSymbol.Name} : {typeof(IToolkitSampleGenera
108109
item.PropertyChanged -= OnPropertyChanged;
109110
}}
110111
112+
111113
if (!(value is null))
112114
{{
113115
foreach (var item in value)

0 commit comments

Comments
 (0)