Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
bd265fc
Add GeneratedCustomPropertyProviderAttribute class
Sergio0694 Dec 8, 2025
191327b
Add SyntaxExtensions with helper methods for Roslyn
Sergio0694 Dec 8, 2025
4294e45
Add extension for attribute analysis with config options
Sergio0694 Dec 8, 2025
e5c4cb9
Add MemberDeclarationSyntaxExtensions for partial checks
Sergio0694 Dec 8, 2025
23de378
WIP
Sergio0694 Dec 8, 2025
5e08a47
Add generic object pool implementation
Sergio0694 Dec 8, 2025
1e419ac
Add PooledArrayBuilder<T> helper for pooled arrays
Sergio0694 Dec 8, 2025
2180a35
Add IndentedTextWriter helper and update PooledArrayBuilder
Sergio0694 Dec 8, 2025
7c7f274
Comment out bindable custom property generation logic
Sergio0694 Dec 8, 2025
169491c
Add IsDefaultOrEmpty and Length properties to EquatableArray
Sergio0694 Dec 8, 2025
8a4944e
Add ITypeSymbol extension methods for metadata names
Sergio0694 Dec 8, 2025
a99dbb9
Add IndentedTextWriter extension methods
Sergio0694 Dec 8, 2025
290d516
Add HierarchyInfo and TypeInfo models
Sergio0694 Dec 8, 2025
69fbe29
Disallow ICustomPropertyProvider on ref types
Sergio0694 Dec 8, 2025
869d57f
Add SkipNullValues extension for IncrementalValuesProvider
Sergio0694 Dec 9, 2025
0a40e16
Add EnumerateAllMembers extension for ITypeSymbol
Sergio0694 Dec 9, 2025
a0567e6
Add 'this' modifier to SkipNullValues extension method
Sergio0694 Dec 9, 2025
a744c1b
Add methods for fully qualified symbol names
Sergio0694 Dec 9, 2025
480db17
WIP
Sergio0694 Dec 9, 2025
3d29240
Refactor ToImmutable to use ToImmutableArray
Sergio0694 Dec 9, 2025
f6d69dd
Refactor GetCustomPropertyInfo for clarity and filtering
Sergio0694 Dec 9, 2025
610ac38
Refactor CustomPropertyProvider models and implementation
Sergio0694 Dec 9, 2025
30dfca7
Refactor CustomPropertyProviderGenerator emit logic
Sergio0694 Dec 9, 2025
6e07ad4
Add CanBeBoxed property to ITypeSymbolExtensions
Sergio0694 Dec 10, 2025
6f2ac22
Add IsIndexer property to CustomPropertyInfo record
Sergio0694 Dec 10, 2025
1b2106b
Skip static indexer properties in generator
Sergio0694 Dec 10, 2025
c877960
Add code generation for ICustomProperty implementation types
Sergio0694 Dec 10, 2025
c6174aa
Add ICustomPropertyProvider test and XAML references
Sergio0694 Dec 10, 2025
9beffa7
Add diagnostic descriptors for custom property provider
Sergio0694 Dec 11, 2025
a26bc07
Add analyzer release tracking and test implementation
Sergio0694 Dec 11, 2025
b1aedf0
Add analyzer for GeneratedCustomPropertyProvider targets
Sergio0694 Dec 11, 2025
0d9939f
Add analyzer for missing ICustomPropertyProvider interface
Sergio0694 Dec 11, 2025
22d4abe
Add SourceGenerator2Test project to solution
Sergio0694 Dec 17, 2025
43606c4
Suppress CS8620 warning in generator file
Sergio0694 Dec 17, 2025
6311e46
Set VersionOverride for CSharp.Workspaces package
Sergio0694 Dec 17, 2025
af7825b
Add MSTest package to dependencies
Sergio0694 Dec 17, 2025
6a2b071
Add AssemblyInfo with Parallelize attribute to tests
Sergio0694 Dec 17, 2025
0d10299
Add CSharpGeneratorTest helper for source generator tests
Sergio0694 Dec 17, 2025
15bfb65
Add test for CustomPropertyProviderGenerator
Sergio0694 Dec 17, 2025
7aa7800
Add custom CSharpAnalyzerTest helper for analyzer tests
Sergio0694 Dec 17, 2025
d70dfba
Refactor RunGenerator parameter order and default
Sergio0694 Dec 17, 2025
58dc0d3
Add tests for GeneratedCustomPropertyProvider analyzer
Sergio0694 Dec 17, 2025
a54eb71
Add .NET 10 reference assemblies support for tests
Sergio0694 Dec 17, 2025
c08c650
Fix comment typo and rename test method
Sergio0694 Feb 9, 2026
f8a6ee2
Fix ICustomProperty emit for indexed/non-indexed
Sergio0694 Feb 9, 2026
82aaa0d
Use ComHelpers.EnsureQueryInterface in test
Sergio0694 Feb 9, 2026
404b6ce
Fix typos in XML/doc comments
Sergio0694 Feb 9, 2026
4d20026
Bump Roslyn packages to 5.0.0
Sergio0694 Feb 9, 2026
e5973d4
Use IndentedTextWriter overload and clear buffer
Sergio0694 Feb 15, 2026
885cbb6
Use WinRT.Runtime.csproj in test project
Sergio0694 Feb 24, 2026
225ec3c
Add Directory.Build.props to SourceGenerator2Test
Sergio0694 Mar 11, 2026
a08cb86
Remove VersionOverride from CSharp.Workspaces ref
Sergio0694 Mar 11, 2026
1c757cc
Refactor MSTest references and add projections
Sergio0694 Mar 11, 2026
627eb2b
Centralize MSTest using and set OutputType
Sergio0694 Mar 11, 2026
530d1c4
Add x86/x64 platform targets to SourceGenerator2Test
Sergio0694 Mar 11, 2026
7b2ab03
Update GeneratedCustomPropertyProvider analyzer tests
Sergio0694 Mar 11, 2026
9d48a32
Add CoreApplication and Button refs to tests
Sergio0694 Mar 11, 2026
f738e61
Use IndentedTextWriter and preallocate buffer
Sergio0694 Mar 11, 2026
9aa2881
Make IndentedTextWriter ref/scoped and update usages
Sergio0694 Mar 11, 2026
94e62fc
Add .editorconfig to SourceGenerator2 projects
Sergio0694 Mar 11, 2026
37d1be5
Use pointers in handlers and Dispose
Sergio0694 Mar 11, 2026
75be5e7
Improve WriteLine skip logic for trailing chars
Sergio0694 Mar 12, 2026
2c6b192
Refactor CustomPropertyProvider code generation
Sergio0694 Mar 12, 2026
0d878bf
Update test expected output for property provider
Sergio0694 Mar 12, 2026
c4e1a30
Nits
Sergio0694 Mar 12, 2026
1ba4218
Initialize IndentedTextWriter with estimated size
Sergio0694 Mar 12, 2026
d5b7ec5
Add tests for no properties, normal-only, and indexer-only scenarios
Sergio0694 Mar 12, 2026
a1f26f2
Add tests for read-only, write-only, static, and read-only indexer pr…
Sergio0694 Mar 12, 2026
032b948
Remove DataRow for static partial struct
Sergio0694 Mar 12, 2026
ed7f764
Expose CsWinRT XAML projection option to tests
Sergio0694 Mar 12, 2026
805c147
Remove trailing whitespace in generator file
Sergio0694 Mar 12, 2026
0165800
Add HasAnyImplementedMembersForInterface helper
Sergio0694 Mar 12, 2026
c059fff
Resolve ICustomPropertyProvider by projection
Sergio0694 Mar 12, 2026
dc3a001
Add analyzer for GeneratedCustomPropertyProvider
Sergio0694 Mar 12, 2026
c4bf08e
Add tests for GeneratedCustomPropertyProvider
Sergio0694 Mar 12, 2026
8991bad
Support expectedDiagnostics in analyzer test helper
Sergio0694 Mar 12, 2026
3788322
Add .editorconfig and normalize line endings
Sergio0694 Mar 12, 2026
13465b0
Normalize line endings for generator projects
Sergio0694 Mar 12, 2026
666ae83
Fix missing semicolons in CustomPropertyProviderGenerator output
Sergio0694 Mar 13, 2026
ad53ee0
Fix GetValue/SetValue emit for read-only and write-only properties
Sergio0694 Mar 13, 2026
697e751
Add [GeneratedCode] attribute to generated ICustomPropertyProvider me…
Sergio0694 Mar 13, 2026
c71c913
Fix CSWINRT2003 analyzer to exclude generated implementations
Sergio0694 Mar 13, 2026
80e75bb
Refactor HasAnyImplementedMembersForInterface into three methods
Sergio0694 Mar 13, 2026
130602a
Refactor generated-code checks and helper
Sergio0694 Mar 13, 2026
5659ecf
Add diagnostic descriptors for attribute argument validation
Sergio0694 Mar 13, 2026
659dd5b
Add analyzer for [GeneratedCustomPropertyProvider] attribute arguments
Sergio0694 Mar 13, 2026
4753601
Add tests for attribute argument analyzer
Sergio0694 Mar 13, 2026
69bc2de
Detect generated code on implemented members
Sergio0694 Mar 13, 2026
86a3376
Default CsWinRTUseWindowsUIXamlProjections to false
Sergio0694 Mar 13, 2026
d87d7ba
Add SourceGenerator2Test to CI build script
Sergio0694 Mar 14, 2026
571f864
Fix nuget feed issue in test
manodasanW Mar 14, 2026
e29f1a5
Set LF in SourceGenerator2 .editorconfig
Sergio0694 Mar 14, 2026
2d8ae33
Add analyzer option for Windows UI Xaml projections
Sergio0694 Mar 14, 2026
b9a7a64
Use Microsoft.WindowsAppSDK.WinUI in diagnostic
Sergio0694 Mar 14, 2026
8e83b93
Normalize expected text line endings in tests
Sergio0694 Mar 14, 2026
45cea4e
Normalize generated LF newlines
Sergio0694 Mar 15, 2026
56fc294
SetValue now throws NotSupportedException
Sergio0694 Mar 15, 2026
11e0dd5
Remove ContentPropertyAttribute include
Sergio0694 Mar 16, 2026
b961866
Remove other overlapping includes
manodasanW Mar 16, 2026
dc24e66
Make reference projection match impl projection
manodasanW Mar 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions build/AzurePipelineTemplates/CsWinRT-Test-Steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ steps:
--no-build
testRunTitle: Unit Tests

# Run Source Generator 2 Tests
- task: DotNetCoreCLI@2
displayName: Run Source Generator 2 Tests
condition: and(succeeded(), or(eq(variables['BuildPlatform'], 'x86'), eq(variables['BuildPlatform'], 'x64')))
inputs:
command: test
projects: 'src/Tests/SourceGenerator2Test/SourceGenerator2Test.csproj'
arguments: >
/p:platform=$(BuildPlatform);configuration=$(BuildConfiguration)
--no-build
testRunTitle: Source Generator 2 Tests

# Run Host Tests
- task: CmdLine@2
displayName: Run Host Tests
Expand Down
17 changes: 17 additions & 0 deletions src/Authoring/WinRT.SourceGenerator2/AnalyzerReleases.Shipped.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
; Shipped analyzer releases
; https://github.com/dotnet/roslyn-analyzers/blob/master/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md

## Release 3.0.0

### New Rules
Rule ID | Category | Severity | Notes
--------|----------|----------|-------
CSWINRT2000 | WindowsRuntime.SourceGenerator | Error | Invalid '[GeneratedCustomPropertyProvider]' target type
CSWINRT2001 | WindowsRuntime.SourceGenerator | Error | Missing 'partial' for '[GeneratedCustomPropertyProvider]' target type
CSWINRT2002 | WindowsRuntime.SourceGenerator | Error | 'ICustomPropertyProvider' interface type not available
CSWINRT2003 | WindowsRuntime.SourceGenerator | Error | Existing 'ICustomPropertyProvider' member implementation
CSWINRT2004 | WindowsRuntime.SourceGenerator | Error | Null property name in '[GeneratedCustomPropertyProvider]'
CSWINRT2005 | WindowsRuntime.SourceGenerator | Error | Null indexer type in '[GeneratedCustomPropertyProvider]'
CSWINRT2006 | WindowsRuntime.SourceGenerator | Error | Property name not found for '[GeneratedCustomPropertyProvider]'
CSWINRT2007 | WindowsRuntime.SourceGenerator | Error | Indexer type not found for '[GeneratedCustomPropertyProvider]'
CSWINRT2008 | WindowsRuntime.SourceGenerator | Error | Static indexer for '[GeneratedCustomPropertyProvider]'
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
; Unshipped analyzer release
; https://github.com/dotnet/roslyn-analyzers/blob/master/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md

### New Rules
Rule ID | Category | Severity | Notes
--------|----------|----------|-------
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public static void EmitManagedExports(SourceProductionContext context, Authoring
return;
}

IndentedTextWriter writer = new(literalLength: 0, formattedCount: 0);
IndentedTextWriter writer = new(literalLength: 0, formattedCount: 0); // TODO: adjust the literal length

// Emit the '[WindowsRuntimeComponentAssemblyExportsType]' attribute so other tooling (including this same generator)
// can reliably find the generated export types from other assemblies, which is needed when merging activation factories.
Expand All @@ -134,14 +134,14 @@ namespace ABI.{{info.AssemblyName.EscapeIdentifierName()}};
/// <summary>
/// Contains the managed exports for activating types from the current project in an authoring scenario.
/// </summary>
""");
""", isMultiline: true);

// Emit the standard generated attributes, and also mark the type as hidden, since it's generated as a public type
writer.WriteGeneratedAttributes(nameof(AuthoringExportTypesGenerator), useFullyQualifiedTypeNames: false);
writer.WriteLine($$"""
[EditorBrowsable(EditorBrowsableState.Never)]
public static unsafe class ManagedExports
""");
""", isMultiline: true);

// Indent via a block, as we'll also need to emit custom logic for the activation factory
using (writer.WriteBlock())
Expand All @@ -155,7 +155,7 @@ public static unsafe class ManagedExports
/// <param name="activatableClassId">The class identifier that is associated with an activatable runtime class.</param>
/// <returns>The resulting pointer to the activation factory that corresponds with the class specified by <paramref name="activatableClassId"/>.</returns>
public static void* GetActivationFactory(ReadOnlySpan<char> activatableClassId)
""");
""", isMultiline: true);

using (writer.WriteBlock())
{
Expand All @@ -167,7 +167,7 @@ public static unsafe class ManagedExports
static extern void* AuthoringGetActivationFactory(
[UnsafeAccessorType("ABI.{info.AssemblyName.EscapeIdentifierName()}.ManagedExports, WinRT.Authoring")] object? _,
ReadOnlySpan<char> activatableClassId);
""");
""", isMultiline: true);
}

// Emit the specialized code to redirect the activation
Expand All @@ -181,7 +181,7 @@ public static unsafe class ManagedExports
void* activationFactory = AuthoringGetActivationFactory(null, activatableClassId);

return activationFactory ?? ReferencedManagedExports.GetActivationFactory(activatableClassId);
""");
""", isMultiline: true);
}
else if (info.Options.MergeReferencedActivationFactories)
{
Expand All @@ -198,7 +198,7 @@ public static nint GetActivationFactory(string activatableClassId)
{
return (nint)GetActivationFactory(activatableClassId.AsSpan());
}
""");
""", isMultiline: true);
}

// Emit a helper type with the logic for merging activaton factories, if needed
Expand All @@ -209,7 +209,7 @@ public static nint GetActivationFactory(string activatableClassId)
/// <summary>
/// Contains the logic for activating types from transitively referenced Windows Runtime components.
/// </summary>
""");
""", isMultiline: true);
writer.WriteGeneratedAttributes(nameof(AuthoringExportTypesGenerator), useFullyQualifiedTypeNames: false);
writer.WriteLine("file static unsafe class ReferencedManagedExports");

Expand All @@ -222,7 +222,7 @@ public static nint GetActivationFactory(string activatableClassId)
/// <param name="activatableClassId">The class identifier that is associated with an activatable runtime class.</param>
/// <returns>The resulting pointer to the activation factory that corresponds with the class specified by <paramref name="activatableClassId"/>.</returns>
public static void* GetActivationFactory(ReadOnlySpan<char> activatableClassId)
""");
""", isMultiline: true);

using (writer.WriteBlock())
{
Expand All @@ -239,7 +239,7 @@ public static nint GetActivationFactory(string activatableClassId)
{
return activationFactory;
}
""");
""", isMultiline: true);
}

// No match across the referenced factories, we can't do anything else
Expand Down Expand Up @@ -290,7 +290,7 @@ namespace ABI.{info.AssemblyName.EscapeIdentifierName()};
/// <summary>
/// Contains the native exports for activating types from the current project in an authoring scenario.
/// </summary>
""");
""", isMultiline: true);

// Emit the attributes to mark the code as generated, and to exclude it from code coverage as well. We also use a
// file-scoped P/Invoke, so we don't take a dependency on private implementation detail types from 'WinRT.Runtime.dll'.
Expand Down Expand Up @@ -383,7 +383,7 @@ file static class WindowsRuntimeImports
[SupportedOSPlatform("windows6.2")]
public static extern char* WindowsGetStringRawBuffer(HSTRING @string, uint* length);
}
""");
""", isMultiline: true);

context.AddSource("NativeExports.g.cs", writer.ToStringAndClear());
}
Expand Down
Loading