Skip to content
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

🧪 [Experiment] DependencyPropertyGenerator #617

Open
wants to merge 112 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
054506c
Generated DependencyPropertyGenerator component from template
Arlodotexe Dec 2, 2024
4ed6172
Port files from private repo
Sergio0694 Dec 2, 2024
794d0c3
Cleanup and merge ported csproj, rename files
Arlodotexe Dec 2, 2024
bd3f0c5
Fix default namespace and package name for DependencyPropertyGenerato…
Arlodotexe Dec 2, 2024
28b5c83
Disable globalusings in DependencyPropertyGenerator
Arlodotexe Dec 2, 2024
8e7694f
Move files, fix folder name
Arlodotexe Dec 3, 2024
54f0445
Bring back embedded resources
Sergio0694 Dec 3, 2024
9aec601
Fix folder name typo
Arlodotexe Dec 3, 2024
f472ab0
Fix project references and update embedded resource paths in Dependen…
Arlodotexe Dec 3, 2024
a559c58
Fix wrong paths in test project
Sergio0694 Dec 3, 2024
bf62d4d
Fix more wrong paths
Sergio0694 Dec 3, 2024
eb854c9
Fix some warnings in the test project
Sergio0694 Dec 3, 2024
df93079
Create .gitattributes
Sergio0694 Dec 3, 2024
03f041e
Fix newlines to LF
Sergio0694 Dec 3, 2024
d503756
Use 'WellKnownTypeNames' in all analyzers
Sergio0694 Dec 3, 2024
8846a70
Remove global usings
Sergio0694 Dec 3, 2024
51d44bd
Finish 'InvalidPropertyDefaultValueTypeAnalyzer'
Sergio0694 Dec 3, 2024
6b2d0cb
Add unit tests
Sergio0694 Dec 3, 2024
6c1ceb7
Consolidate GlobalUsings imports around tooling
Arlodotexe Dec 3, 2024
d9bec94
Fixed namespace errors when running under Uno
Arlodotexe Dec 3, 2024
291f7fa
Update tooling submodule
Arlodotexe Dec 3, 2024
9637c3a
Remove LangVersion setting from DependencyPropertyGenerator project
Arlodotexe Dec 3, 2024
9f0809d
Ran XAML styler
Arlodotexe Dec 3, 2024
8436bde
Remove empty samples
Arlodotexe Dec 3, 2024
1babcec
Remove empty component doc to fix CI error
Arlodotexe Dec 3, 2024
c2351ac
Remove unused test files from DependencyPropertyGenerator project
Arlodotexe Dec 3, 2024
471c161
Update .NET version to 9.0 in Dockerfile, devcontainer.json, build.ym…
Arlodotexe Dec 5, 2024
9657827
Fixed compilation conditionals
Arlodotexe Dec 5, 2024
10499ac
Temporarily limit WinUI and multitarget options in build matrix for U…
Arlodotexe Dec 5, 2024
da2b2c3
Temporarily disable wasm-linux check, only build DependencyPropertyGe…
Arlodotexe Dec 5, 2024
cf30a64
Adjust CI to only build DependencyPropertyGenerator
Arlodotexe Dec 5, 2024
ec018ef
Enable WinUI 3, fix GenerateSingleSampleHeads script invocation
Arlodotexe Dec 5, 2024
c937c4c
Switch generator to WinAppSDK for now
Sergio0694 Dec 5, 2024
9acc0ce
Temp: Refactor build workflow to use Build-Toolkit-Components script …
Arlodotexe Dec 5, 2024
05edd93
Fix condition for local caching in generator
Sergio0694 Dec 5, 2024
c7ab831
Define 'DependencyPropertyGeneratorUseWindowsUIXaml'
Sergio0694 Dec 5, 2024
aff5de9
Generalize .dll reference check
Sergio0694 Dec 5, 2024
9ee417e
Add 'ForAttributeWithMetadataNameAndOptions'
Sergio0694 Dec 5, 2024
061f74e
Add 'AnalyzerConfigOptionsExtensions'
Sergio0694 Dec 5, 2024
6af9be8
Enable XAML option for generators/analyzers
Sergio0694 Dec 5, 2024
c100c0e
Enable Windows.UI.Xaml for legacy UWP
Sergio0694 Dec 5, 2024
9439f37
Add 'SyntaxKind' extensions
Sergio0694 Dec 6, 2024
eb41e28
Add support for more modifiers, bug fixes
Sergio0694 Dec 6, 2024
1b40caf
Add unit tests for more modifiers
Sergio0694 Dec 6, 2024
e152803
Add diagnostic and test for pointer types
Sergio0694 Dec 6, 2024
95590f0
Add 'DefaultValueCallback' property
Sergio0694 Dec 6, 2024
22ab868
Add initial support for default value callbacks
Sergio0694 Dec 6, 2024
c053699
Fix value callbacks, add unit tests
Sergio0694 Dec 7, 2024
b0e178e
Add '[DisallowNull]' to 'DefaultValueCallback'
Sergio0694 Dec 7, 2024
b4bf0a3
Add 'InvalidPropertyDefaultValueCallbackTypeAnalyzer'
Sergio0694 Dec 7, 2024
ba00de9
Add unit tests for new analyzer
Sergio0694 Dec 7, 2024
8f971c9
Fix codegen for all default value callback cases
Sergio0694 Dec 7, 2024
aa12670
Add 'PropertyDeclarationWithPropertyNameSuffixAnalyzer'
Sergio0694 Dec 7, 2024
e988aab
Fix two nullability warnings
Sergio0694 Dec 7, 2024
4a42758
Improve formatting for property initialization
Sergio0694 Dec 7, 2024
d40bee5
Bug fixes to embedded mode
Sergio0694 Dec 9, 2024
b48e37f
Update components/DependencyPropertyGenerator/CommunityToolkit.Depend…
Arlodotexe Dec 9, 2024
a943c7b
Update components/DependencyPropertyGenerator/CommunityToolkit.Depend…
Arlodotexe Dec 9, 2024
42d3211
Fix typos
Sergio0694 Dec 9, 2024
e481f48
Add draft 'UseGeneratedDependencyPropertyOnManualPropertyAnalyzer'
Sergio0694 Dec 12, 2024
ef70aab
Pass the location of the target field
Sergio0694 Dec 12, 2024
08707e6
Add empty 'CodeFixers' project
Sergio0694 Dec 12, 2024
2389d33
Bump 'Microsoft.CodeAnalysis.CSharp' to latest
Sergio0694 Dec 12, 2024
0281e36
Pack code fixers into NuGet package
Sergio0694 Dec 12, 2024
a032d85
Add 'InternalsVisibleTo' for code fixers
Sergio0694 Dec 12, 2024
8524021
Add draft 'UseGeneratedDependencyPropertyOnManualPropertyCodeFixer'
Sergio0694 Dec 12, 2024
df50c2f
Add 'CSharpCodeFixTest<,>' type
Sergio0694 Dec 12, 2024
7f57e6c
Add basic code fixer test
Sergio0694 Dec 12, 2024
866492b
Optimize registration for default values
Sergio0694 Dec 12, 2024
26fdeed
Handle more default properties in analyzer
Sergio0694 Dec 12, 2024
bebdcac
Handle even more default properties in analyzer
Sergio0694 Dec 12, 2024
be37f5f
Add more generator unit tests
Sergio0694 Dec 13, 2024
26d8f03
Handle supported default value types
Sergio0694 Dec 13, 2024
a3e4c02
Remove unnecessary using directive
Sergio0694 Dec 13, 2024
d8aee78
Fix handling of numerics, add more projected types
Sergio0694 Dec 13, 2024
a7c5130
Handle projected enums in analyzer, add tests
Sergio0694 Dec 13, 2024
3c250da
Fix some analyzer bugs, add unit tests
Sergio0694 Dec 13, 2024
49786ff
Merge branch 'main' into component/DependencyPropertyGenerator
Arlodotexe Dec 13, 2024
3241ea5
Adjust priority for enum typed constants
Sergio0694 Dec 13, 2024
7d65ea1
Fix handling of defaulted custom structs in analyzer
Sergio0694 Dec 13, 2024
e48226c
Improve formatting for known enum members
Sergio0694 Dec 13, 2024
4d085d3
Improve codegen for property changed callbacks
Sergio0694 Dec 16, 2024
bea72f9
Add incrementality tests
Sergio0694 Dec 18, 2024
0262e78
Remove unnecessary test code
Sergio0694 Dec 18, 2024
c315a6c
Fix some leftovers
Sergio0694 Dec 20, 2024
4873405
Remove unnecessary parentheses
Sergio0694 Dec 20, 2024
fc423c5
Improve code fixer for known enum members
Sergio0694 Dec 20, 2024
b65e899
Add .targets to .NET 9 folders too
Sergio0694 Dec 21, 2024
7524a0c
Simplify code fixer tests
Sergio0694 Dec 25, 2024
b85e1bc
Merge branch 'main' into component/DependencyPropertyGenerator
Sergio0694 Dec 25, 2024
45029c6
Undo temporary hacks and workarounds
Sergio0694 Dec 25, 2024
f888673
Fix tooling submodule pointer
Sergio0694 Dec 25, 2024
079da46
Only build for UWP and WindowsAppSDK
Sergio0694 Dec 25, 2024
cce95d3
Fix TFMs for UWP projects
Sergio0694 Dec 25, 2024
a4ced34
Simplify packed .targets files
Sergio0694 Dec 25, 2024
65fdb63
Disable 'UseUwpTools' property
Sergio0694 Dec 25, 2024
5a89531
Fix filenames for packaged .targets files
Sergio0694 Dec 25, 2024
ea71909
Fix typos in .targets file
Sergio0694 Dec 26, 2024
a2f339c
Fix .targets again, add basic test
Sergio0694 Dec 26, 2024
4e5bc48
Bump tooling pointer
Sergio0694 Dec 26, 2024
191e386
Bump UWP .NET 9 target SDK to 18362
Sergio0694 Dec 26, 2024
9924f77
Add more code fixer tests
Sergio0694 Dec 26, 2024
0c45212
Improve handling of known constants
Sergio0694 Dec 26, 2024
500ed36
Improve number formatting, add fixer tests
Sergio0694 Dec 26, 2024
f4ec6f5
Bump SDK of UWP on .NET 9 to 19041
Sergio0694 Dec 26, 2024
53f3195
Remove Uno workaround, fix TFMs
Sergio0694 Dec 26, 2024
f3613a3
Trivia handling
Youssef1313 Dec 26, 2024
c031808
Use the lambda overload
Youssef1313 Dec 26, 2024
9ae5fba
Tweak WinRT types matching logic
Sergio0694 Dec 27, 2024
74919d5
Fix AppServices build
Sergio0694 Dec 27, 2024
7d5c559
Add more test coverage for XML docs
Sergio0694 Dec 27, 2024
17bc997
Fix handling of EOLs in removed members
Sergio0694 Dec 27, 2024
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
1 change: 0 additions & 1 deletion Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
<SlnGenSolutionItem Include="$(MSBuildThisFileDirectory).editorconfig" />
<SlnGenSolutionItem Include="$(MSBuildThisFileDirectory)settings.xamlstyler" />
<SlnGenSolutionItem Include="$(MSBuildThisFileDirectory)*.md" />
<SlnGenSolutionItem Include="$(MSBuildThisFileDirectory)tooling\GlobalUsings*.cs" />
</ItemGroup>

</Project>
4 changes: 0 additions & 4 deletions Windows.Toolkit.Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,4 @@
<IsPublishable>true</IsPublishable>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

<ItemGroup>
<Compile Include="$(RepositoryDirectory)tooling\GlobalUsings.cs" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,4 @@
<ProjectReference Include="..\CommunityToolkit.AppServices.SourceGenerators\CommunityToolkit.AppServices.SourceGenerators.csproj" />
<ProjectReference Include="..\src\CommunityToolkit.AppServices.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Remove="C:\Users\sergiopedri\git\Labs-Windows\tooling\GlobalUsings.cs" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,4 @@
<AdditionalFiles Include="AnalyzerReleases.Shipped.md" />
<AdditionalFiles Include="AnalyzerReleases.Unshipped.md" />
</ItemGroup>

<!-- Remove imported global usings -->
<ItemGroup>
<Compile Remove="$(ToolingDirectory)\GlobalUsings.cs" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<RootNamespace>CommunityToolkit.AppServices</RootNamespace>
<PackageId>$(PackageIdPrefix).$(ToolkitComponentName)</PackageId>
<HasWinUI>false</HasWinUI>
<EnableGlobalUsings>false</EnableGlobalUsings>
</PropertyGroup>

<!-- Sets this up as a toolkit component's source project -->
Expand Down Expand Up @@ -57,9 +58,4 @@
<!-- Pack the source generator to the right package folder -->
<None Include="..\CommunityToolkit.AppServices.SourceGenerators\bin\$(Configuration)\netstandard2.0\CommunityToolkit.AppServices.SourceGenerators.dll" PackagePath="analyzers\dotnet\cs" Pack="true" Visible="false" />
</ItemGroup>

<!-- Remove imported global usings -->
<ItemGroup>
<Compile Remove="$(ToolingDirectory)\GlobalUsings.cs" />
</ItemGroup>
</Project>
10 changes: 10 additions & 0 deletions components/DependencyPropertyGenerator/.gitattributes
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
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 |
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
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>
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);
}
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
Sergio0694 marked this conversation as resolved.
Show resolved Hide resolved

/// <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)}";
}
Loading
Loading