-
Notifications
You must be signed in to change notification settings - Fork 77
[DRAFT] DependencyPropertyGenerator #617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 26 commits
Commits
Show all changes
128 commits
Select commit
Hold shift + click to select a range
054506c
Generated DependencyPropertyGenerator component from template
Arlodotexe 4ed6172
Port files from private repo
Sergio0694 794d0c3
Cleanup and merge ported csproj, rename files
Arlodotexe bd3f0c5
Fix default namespace and package name for DependencyPropertyGenerato…
Arlodotexe 28b5c83
Disable globalusings in DependencyPropertyGenerator
Arlodotexe 8e7694f
Move files, fix folder name
Arlodotexe 54f0445
Bring back embedded resources
Sergio0694 9aec601
Fix folder name typo
Arlodotexe f472ab0
Fix project references and update embedded resource paths in Dependen…
Arlodotexe a559c58
Fix wrong paths in test project
Sergio0694 bf62d4d
Fix more wrong paths
Sergio0694 eb854c9
Fix some warnings in the test project
Sergio0694 df93079
Create .gitattributes
Sergio0694 03f041e
Fix newlines to LF
Sergio0694 d503756
Use 'WellKnownTypeNames' in all analyzers
Sergio0694 8846a70
Remove global usings
Sergio0694 51d44bd
Finish 'InvalidPropertyDefaultValueTypeAnalyzer'
Sergio0694 6b2d0cb
Add unit tests
Sergio0694 6c1ceb7
Consolidate GlobalUsings imports around tooling
Arlodotexe d9bec94
Fixed namespace errors when running under Uno
Arlodotexe 291f7fa
Update tooling submodule
Arlodotexe 9637c3a
Remove LangVersion setting from DependencyPropertyGenerator project
Arlodotexe 9f0809d
Ran XAML styler
Arlodotexe 8436bde
Remove empty samples
Arlodotexe 1babcec
Remove empty component doc to fix CI error
Arlodotexe c2351ac
Remove unused test files from DependencyPropertyGenerator project
Arlodotexe 471c161
Update .NET version to 9.0 in Dockerfile, devcontainer.json, build.ym…
Arlodotexe 9657827
Fixed compilation conditionals
Arlodotexe 10499ac
Temporarily limit WinUI and multitarget options in build matrix for U…
Arlodotexe da2b2c3
Temporarily disable wasm-linux check, only build DependencyPropertyGe…
Arlodotexe cf30a64
Adjust CI to only build DependencyPropertyGenerator
Arlodotexe ec018ef
Enable WinUI 3, fix GenerateSingleSampleHeads script invocation
Arlodotexe c937c4c
Switch generator to WinAppSDK for now
Sergio0694 9acc0ce
Temp: Refactor build workflow to use Build-Toolkit-Components script …
Arlodotexe 05edd93
Fix condition for local caching in generator
Sergio0694 c7ab831
Define 'DependencyPropertyGeneratorUseWindowsUIXaml'
Sergio0694 aff5de9
Generalize .dll reference check
Sergio0694 9ee417e
Add 'ForAttributeWithMetadataNameAndOptions'
Sergio0694 061f74e
Add 'AnalyzerConfigOptionsExtensions'
Sergio0694 6af9be8
Enable XAML option for generators/analyzers
Sergio0694 c100c0e
Enable Windows.UI.Xaml for legacy UWP
Sergio0694 9439f37
Add 'SyntaxKind' extensions
Sergio0694 eb41e28
Add support for more modifiers, bug fixes
Sergio0694 1b40caf
Add unit tests for more modifiers
Sergio0694 e152803
Add diagnostic and test for pointer types
Sergio0694 95590f0
Add 'DefaultValueCallback' property
Sergio0694 22ab868
Add initial support for default value callbacks
Sergio0694 c053699
Fix value callbacks, add unit tests
Sergio0694 b0e178e
Add '[DisallowNull]' to 'DefaultValueCallback'
Sergio0694 b4bf0a3
Add 'InvalidPropertyDefaultValueCallbackTypeAnalyzer'
Sergio0694 ba00de9
Add unit tests for new analyzer
Sergio0694 8f971c9
Fix codegen for all default value callback cases
Sergio0694 aa12670
Add 'PropertyDeclarationWithPropertyNameSuffixAnalyzer'
Sergio0694 e988aab
Fix two nullability warnings
Sergio0694 4a42758
Improve formatting for property initialization
Sergio0694 d40bee5
Bug fixes to embedded mode
Sergio0694 b48e37f
Update components/DependencyPropertyGenerator/CommunityToolkit.Depend…
Arlodotexe a943c7b
Update components/DependencyPropertyGenerator/CommunityToolkit.Depend…
Arlodotexe 42d3211
Fix typos
Sergio0694 e481f48
Add draft 'UseGeneratedDependencyPropertyOnManualPropertyAnalyzer'
Sergio0694 ef70aab
Pass the location of the target field
Sergio0694 08707e6
Add empty 'CodeFixers' project
Sergio0694 2389d33
Bump 'Microsoft.CodeAnalysis.CSharp' to latest
Sergio0694 0281e36
Pack code fixers into NuGet package
Sergio0694 a032d85
Add 'InternalsVisibleTo' for code fixers
Sergio0694 8524021
Add draft 'UseGeneratedDependencyPropertyOnManualPropertyCodeFixer'
Sergio0694 df50c2f
Add 'CSharpCodeFixTest<,>' type
Sergio0694 7f57e6c
Add basic code fixer test
Sergio0694 866492b
Optimize registration for default values
Sergio0694 26fdeed
Handle more default properties in analyzer
Sergio0694 bebdcac
Handle even more default properties in analyzer
Sergio0694 be37f5f
Add more generator unit tests
Sergio0694 26d8f03
Handle supported default value types
Sergio0694 a3e4c02
Remove unnecessary using directive
Sergio0694 d8aee78
Fix handling of numerics, add more projected types
Sergio0694 a7c5130
Handle projected enums in analyzer, add tests
Sergio0694 3c250da
Fix some analyzer bugs, add unit tests
Sergio0694 49786ff
Merge branch 'main' into component/DependencyPropertyGenerator
Arlodotexe 3241ea5
Adjust priority for enum typed constants
Sergio0694 7d65ea1
Fix handling of defaulted custom structs in analyzer
Sergio0694 e48226c
Improve formatting for known enum members
Sergio0694 4d085d3
Improve codegen for property changed callbacks
Sergio0694 bea72f9
Add incrementality tests
Sergio0694 0262e78
Remove unnecessary test code
Sergio0694 c315a6c
Fix some leftovers
Sergio0694 4873405
Remove unnecessary parentheses
Sergio0694 fc423c5
Improve code fixer for known enum members
Sergio0694 b65e899
Add .targets to .NET 9 folders too
Sergio0694 7524a0c
Simplify code fixer tests
Sergio0694 b85e1bc
Merge branch 'main' into component/DependencyPropertyGenerator
Sergio0694 45029c6
Undo temporary hacks and workarounds
Sergio0694 f888673
Fix tooling submodule pointer
Sergio0694 079da46
Only build for UWP and WindowsAppSDK
Sergio0694 cce95d3
Fix TFMs for UWP projects
Sergio0694 a4ced34
Simplify packed .targets files
Sergio0694 65fdb63
Disable 'UseUwpTools' property
Sergio0694 5a89531
Fix filenames for packaged .targets files
Sergio0694 ea71909
Fix typos in .targets file
Sergio0694 a2f339c
Fix .targets again, add basic test
Sergio0694 4e5bc48
Bump tooling pointer
Sergio0694 191e386
Bump UWP .NET 9 target SDK to 18362
Sergio0694 9924f77
Add more code fixer tests
Sergio0694 0c45212
Improve handling of known constants
Sergio0694 500ed36
Improve number formatting, add fixer tests
Sergio0694 f4ec6f5
Bump SDK of UWP on .NET 9 to 19041
Sergio0694 53f3195
Remove Uno workaround, fix TFMs
Sergio0694 f3613a3
Trivia handling
Youssef1313 c031808
Use the lambda overload
Youssef1313 9ae5fba
Tweak WinRT types matching logic
Sergio0694 74919d5
Fix AppServices build
Sergio0694 7d5c559
Add more test coverage for XML docs
Sergio0694 17bc997
Fix handling of EOLs in removed members
Sergio0694 1dadd4d
Fix EOL handling in more scenarios
Sergio0694 f456963
Respect accessibility of generated accessors
Sergio0694 70d5857
Add 'SyntaxTriviaExtensions', code tweaks
Sergio0694 072c750
Add 'AttributeInfo' type and associated logic
Sergio0694 9af0344
Gather forwarded attributes for generated fields
Sergio0694 e56f8ae
Fix attributes generation, add unit tests
Sergio0694 f75dcd5
Update analyzer for attributes, add unit tests
Sergio0694 e662f76
Update code fixer, add unit tests
Sergio0694 e617cf0
Add 'StaticAttributeListTargetOnGeneratedDependencyPropertyDeclaratio…
Sergio0694 2a5f0fe
Add analyzer for forwarded attributes, and tests
Sergio0694 81e2ad3
Fix outdated comments
Sergio0694 8a048a8
Strip trivia from forwarded attributes
Sergio0694 c36129f
Add 'CSharpSuppressorTest<TSuppressor>'
Sergio0694 c372d84
Fix diagnostic suppressor, add tests
Sergio0694 e37d7dc
Add interleaved non-fixable properties, add tests
Sergio0694 21f3684
Add 'partial' for nested types too, add tests
Sergio0694 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# All file types: | ||
# - Treat as text | ||
# - Normalize to LF line endings | ||
* text=auto eol=lf | ||
|
||
# Explicit settings for well known types | ||
*.cs text eol=lf | ||
*.csproj text eol=lf | ||
*.projitems text eol=lf | ||
*.shprroj text eol=lf |
20 changes: 20 additions & 0 deletions
20
...oolkit.DependencyPropertyGenerator.SourceGenerators/AnalyzerReleases.Shipped.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
; Shipped analyzer releases | ||
; https://github.com/dotnet/roslyn-analyzers/blob/master/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md | ||
|
||
## Release 1.0 | ||
|
||
### New Rules | ||
|
||
Rule ID | Category | Severity | Notes | ||
--------|----------|----------|------- | ||
WCTDP0001 | CommunityToolkit.GeneratedDependencyPropertyDependencyPropertyGenerator | Error | | ||
WCTDP0002 | CommunityToolkit.GeneratedDependencyPropertyDependencyPropertyGenerator | Error | | ||
WCTDP0003 | CommunityToolkit.GeneratedDependencyPropertyDependencyPropertyGenerator | Error | | ||
WCTDP0004 | CommunityToolkit.GeneratedDependencyPropertyDependencyPropertyGenerator | Error | | ||
WCTDP0005 | CommunityToolkit.GeneratedDependencyPropertyDependencyPropertyGenerator | Error | | ||
WCTDP0006 | CommunityToolkit.GeneratedDependencyPropertyDependencyPropertyGenerator | Error | | ||
WCTDP0007 | CommunityToolkit.GeneratedDependencyPropertyDependencyPropertyGenerator | Error | | ||
WCTDP0008 | CommunityToolkit.GeneratedDependencyPropertyDependencyPropertyGenerator | Error | | ||
WCTDP0009 | CommunityToolkit.GeneratedDependencyPropertyDependencyPropertyGenerator | Warning | | ||
WCTDP0010 | CommunityToolkit.GeneratedDependencyPropertyDependencyPropertyGenerator | Warning | | ||
WCTDP0011 | CommunityToolkit.GeneratedDependencyPropertyDependencyPropertyGenerator | Warning | |
2 changes: 2 additions & 0 deletions
2
...lkit.DependencyPropertyGenerator.SourceGenerators/AnalyzerReleases.Unshipped.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
; Unshipped analyzer release | ||
; https://github.com/dotnet/roslyn-analyzers/blob/master/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md |
29 changes: 29 additions & 0 deletions
29
...tor.SourceGenerators/CommunityToolkit.DependencyPropertyGenerator.SourceGenerators.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<DefineConstants>$(DefineConstants);WINDOWS_UWP</DefineConstants> | ||
|
||
<!-- We're intentionally not always matching the namespace with folder path, to better organize the code --> | ||
<NoWarn>$(NoWarn);IDE0130</NoWarn> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0-3.final" PrivateAssets="all" /> | ||
<PackageReference Include="PolySharp" Version="1.15.0" PrivateAssets="all" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<AdditionalFiles Include="AnalyzerReleases.Shipped.md" /> | ||
<AdditionalFiles Include="AnalyzerReleases.Unshipped.md" /> | ||
</ItemGroup> | ||
|
||
<!-- Include the embedded resources for the post initialization source outputs --> | ||
<ItemGroup> | ||
<Compile Remove="EmbeddedResources\*.cs" /> | ||
<EmbeddedResource Include="EmbeddedResources\GeneratedDependencyProperty.cs" LogicalName="GeneratedDependencyProperty.g.cs" /> | ||
<EmbeddedResource Include="EmbeddedResources\GeneratedDependencyPropertyAttribute.cs" LogicalName="GeneratedDependencyPropertyAttribute.g.cs" /> | ||
</ItemGroup> | ||
</Project> |
26 changes: 26 additions & 0 deletions
26
...yToolkit.DependencyPropertyGenerator.SourceGenerators/Constants/WellKnownTrackingNames.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace CommunityToolkit.GeneratedDependencyProperty.Constants; | ||
|
||
/// <summary> | ||
/// The well known names for tracking steps, to test the incremental generators. | ||
/// </summary> | ||
internal static class WellKnownTrackingNames | ||
{ | ||
/// <summary> | ||
/// The initial <see cref="Microsoft.CodeAnalysis.SyntaxValueProvider.ForAttributeWithMetadataName"/> transform node. | ||
/// </summary> | ||
public const string Execute = nameof(Execute); | ||
|
||
/// <summary> | ||
/// The filtered transform with just output diagnostics. | ||
/// </summary> | ||
public const string Diagnostics = nameof(Diagnostics); | ||
|
||
/// <summary> | ||
/// The filtered transform with just output sources. | ||
/// </summary> | ||
public const string Output = nameof(Output); | ||
} |
52 changes: 52 additions & 0 deletions
52
...unityToolkit.DependencyPropertyGenerator.SourceGenerators/Constants/WellKnownTypeNames.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace CommunityToolkit.GeneratedDependencyProperty.Constants; | ||
|
||
/// <summary> | ||
/// The well known names for types used by source generators and analyzers. | ||
/// </summary> | ||
internal static class WellKnownTypeNames | ||
{ | ||
/// <summary> | ||
/// The fully qualified type name for the <c>[GeneratedDependencyProperty]</c> type. | ||
/// </summary> | ||
public const string GeneratedDependencyPropertyAttribute = "CommunityToolkit.WinUI.GeneratedDependencyPropertyAttribute"; | ||
|
||
/// <summary> | ||
/// The fully qualified type name for the <c>GeneratedDependencyProperty</c> type. | ||
/// </summary> | ||
public const string GeneratedDependencyProperty = "CommunityToolkit.WinUI.GeneratedDependencyProperty"; | ||
|
||
/// <summary> | ||
/// The fully qualified type name for the <c>XAML</c> namespace. | ||
/// </summary> | ||
public const string XamlNamespace = | ||
#if WINDOWS_UWP | ||
"Windows.UI.Xaml"; | ||
|
||
#else | ||
"Microsoft.UI.Xaml"; | ||
#endif | ||
|
||
/// <summary> | ||
/// The fully qualified type name for the <c>DependencyObject</c> type. | ||
/// </summary> | ||
public const string DependencyObject = $"{XamlNamespace}.{nameof(DependencyObject)}"; | ||
|
||
/// <summary> | ||
/// The fully qualified type name for the <c>DependencyProperty</c> type. | ||
/// </summary> | ||
public const string DependencyProperty = $"{XamlNamespace}.{nameof(DependencyProperty)}"; | ||
|
||
/// <summary> | ||
/// The fully qualified type name for the <c>DependencyPropertyChangedEventArgs</c> type. | ||
/// </summary> | ||
public const string DependencyPropertyChangedEventArgs = $"{XamlNamespace}.{nameof(DependencyPropertyChangedEventArgs)}"; | ||
|
||
/// <summary> | ||
/// The fully qualified type name for the <c>PropertyMetadata</c> type. | ||
/// </summary> | ||
public const string PropertyMetadata = $"{XamlNamespace}.{nameof(PropertyMetadata)}"; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.