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 88 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 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
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
7 changes: 2 additions & 5 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.208.0/containers/dotnet/.devcontainer/base.Dockerfile

# [Choice] .NET version: 6.0, 5.0, 3.1, 6.0-bullseye, 5.0-bullseye, 3.1-bullseye, 6.0-focal, 5.0-focal, 3.1-focal, etc
ARG VARIANT="8.0-bullseye-slim"
FROM mcr.microsoft.com/vscode/devcontainers/dotnet:0-${VARIANT}
# See https://github.com/devcontainers/images/tree/main/src/dotnet for image choices
FROM mcr.microsoft.com/vscode/devcontainers/dotnet:9.0

# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
ARG NODE_VERSION="none"
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"args": {
// Update 'VARIANT' to pick a .NET Core version: 3.1, 5.0, 6.0
// Append -bullseye or -focal to pin to an OS version.
"VARIANT": "6.0",
"VARIANT": "9.0",
// Options
"NODE_VERSION": "lts/*"
}
Expand Down
99 changes: 7 additions & 92 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ on:
merge_group:

env:
DOTNET_VERSION: ${{ '8.0.201' }}
DOTNET_INSTALL_DIR: dotnet-install
DOTNET_ROOT: dotnet-install
DOTNET_VERSION: ${{ '9.0.x' }}
ENABLE_DIAGNOSTICS: false
#COREHOST_TRACE: 1
MSBUILD_VERBOSITY: normal
Expand Down Expand Up @@ -62,8 +60,8 @@ jobs:
strategy:
fail-fast: false # prevent one matrix pipeline from being cancelled if one fails, we want them all to run to completion.
matrix:
winui: [2, 3]
multitarget: ['uwp', 'wasdk', 'wasm', 'wpf', 'linuxgtk', 'macos', 'ios', 'android']
winui: [2, 3] # Temporary until we can get Uno/Wasm working
multitarget: ['uwp', 'wasdk'] # Temporary until we can get Uno/Wasm working
exclude:
# WinUI 2 not supported on wasdk
- winui: 2
Expand Down Expand Up @@ -136,42 +134,7 @@ jobs:

# Generate full solution with all projects (sample gallery heads, components, tests)
- name: Generate solution with ${{ matrix.multitarget }} gallery, components and tests
working-directory: ./
run: powershell -version 5.1 -command "./tooling/GenerateAllSolution.ps1 -MultiTargets ${{ matrix.multitarget }} ${{ env.ENABLE_DIAGNOSTICS == 'true' && ' -UseDiagnostics' || '' }} -WinUIMajorVersion ${{ matrix.winui }}" -ErrorAction Stop

# Build solution
- name: MSBuild (With diagnostics)
if: ${{ env.ENABLE_DIAGNOSTICS == 'true' }}
run: >
msbuild.exe /restore /nowarn:MSB4011
/p:Configuration=Release
/m
${{ env.ENABLE_DIAGNOSTICS == 'true' && '/bl' || '' }}
/v:${{ env.MSBUILD_VERBOSITY }}
CommunityToolkit.AllComponents.sln

- name: MSBuild
if: ${{ env.ENABLE_DIAGNOSTICS == 'false' }}
run: msbuild.exe CommunityToolkit.AllComponents.sln /restore /nowarn:MSB4011 -p:Configuration=Release

# Run tests
- name: Setup VSTest Path
uses: darenm/setup-vstest@3a16d909a1f3bbc65b52f8270d475d905e7d3e44

- name: Install Testspace Module
uses: testspace-com/setup-testspace@v1
with:
domain: ${{ github.repository_owner }}

- name: Run component tests against ${{ matrix.multitarget }}
if: ${{ matrix.multitarget == 'uwp' || matrix.multitarget == 'wasdk' }}
id: test-platform
run: vstest.console.exe ./tooling/**/CommunityToolkit.Tests.${{ matrix.multitarget }}.build.appxrecipe /Framework:FrameworkUap10 /logger:"trx;LogFileName=${{ matrix.multitarget }}.trx" /Blame

- name: Create test reports
run: |
testspace '[${{ matrix.multitarget }}]./TestResults/*.trx'
if: ${{ (matrix.multitarget == 'uwp' || matrix.multitarget == 'wasdk') && (steps.test-generator.conclusion == 'success' || steps.test-platform.conclusion == 'success') }}
run: powershell -version 5.1 -command "./tooling/Build-Toolkit-Components.ps1 -Components DependencyPropertyGenerator -Release -MultiTargets ${{ matrix.multitarget }} ${{ env.ENABLE_DIAGNOSTICS == 'true' && ' -UseDiagnostics' || '' }} -WinUIMajorVersion ${{ matrix.winui }}" -ErrorAction Stop

- name: Artifact - Diagnostic Logs
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -215,7 +178,7 @@ jobs:
strategy:
fail-fast: false # prevent one matrix pipeline from being cancelled if one fails, we want them all to run to completion.
matrix:
winui: [2, 3]
winui: [2, 3] # Temporary until we can get Uno/Wasm working

env:
VERSION_PROPERTY: ${{ github.ref == 'refs/heads/main' && format('build.{0}', github.run_number) || format('pull-{0}.{1}', github.event.number, github.run_number) }}
Expand Down Expand Up @@ -271,7 +234,7 @@ jobs:

# Build and pack component nupkg
- name: Build and pack component packages
run: ./tooling/Build-Toolkit-Components.ps1 -MultiTargets all -ExcludeMultiTargets ${{ env.EXCLUDED_MULTITARGETS }} -WinUIMajorVersion ${{ matrix.winui }} -DateForVersion ${{ env.VERSION_DATE }} ${{ env.VERSION_PROPERTY != '' && format('-PreviewVersion "{0}"', env.VERSION_PROPERTY) || '' }} ${{ env.ENABLE_DIAGNOSTICS == 'true' && '-EnableBinlogs' || '' }} ${{ env.ENABLE_DIAGNOSTICS == 'true' && '-Verbose' || '' }} -BinlogOutput ./ -NupkgOutput ./ -Release
run: ./tooling/Build-Toolkit-Components.ps1 -Components DependencyPropertyGenerator -MultiTargets uwp,wasdk -ExcludeMultiTargets ${{ env.EXCLUDED_MULTITARGETS }} -WinUIMajorVersion ${{ matrix.winui }} -DateForVersion ${{ env.VERSION_DATE }} ${{ env.VERSION_PROPERTY != '' && format('-PreviewVersion "{0}"', env.VERSION_PROPERTY) || '' }} ${{ env.ENABLE_DIAGNOSTICS == 'true' && '-EnableBinlogs' || '' }} ${{ env.ENABLE_DIAGNOSTICS == 'true' && '-Verbose' || '' }} -BinlogOutput ./ -NupkgOutput ./ -Release

- name: Validate package names
if: ${{ env.VERSION_PROPERTY != '' }}
Expand Down Expand Up @@ -308,52 +271,4 @@ jobs:
if: ${{ (env.ENABLE_DIAGNOSTICS == 'true' || env.COREHOST_TRACE != '') && always() }}
with:
name: build-logs-winui${{ matrix.winui }}
path: ./*.*log

wasm-linux:
runs-on: ubuntu-latest
env:
HEADS_DIRECTORY: tooling/ProjectHeads

steps:
- name: Install .NET SDK v${{ env.DOTNET_VERSION }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: .NET Info (if diagnostics)
if: ${{ env.ENABLE_DIAGNOSTICS == 'true' }}
run: dotnet --info

# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive

# Restore Tools from Manifest list in the Repository
- name: Restore dotnet tools
run: dotnet tool restore

- name: Generate solution
shell: pwsh
working-directory: ./
run: ./tooling/GenerateAllSolution.ps1${{ env.ENABLE_DIAGNOSTICS == 'true' && ' -UseDiagnostics' || '' }}

- name: Install ninja for WASM native dependencies
run: sudo apt-get install ninja-build

# Issue with Comment Links currently, see: https://github.com/mrlacey/CommentLinks/issues/38
# See launch.json configuration file for analogous command we're emulating here to build LINK: ../../.vscode/launch.json:CommunityToolkit.App.Wasm.csproj
- name: dotnet build
working-directory: ./${{ env.HEADS_DIRECTORY }}/AllComponents/Wasm/
run: dotnet build /r /bl /p:UnoSourceGeneratorUseGenerationHost=true /p:UnoSourceGeneratorUseGenerationController=false

# TODO: Do we want to run tests here? Can we do that on linux easily?

- name: Artifact - Diagnostic Logs
uses: actions/upload-artifact@v4
if: ${{ (env.ENABLE_DIAGNOSTICS == 'true' || env.COREHOST_TRACE != '') && always() }}
with:
name: linux-logs
path: ./**/*.*log
path: ./*.*log
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 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Nullable>enable</Nullable>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

<!-- 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.Workspaces" Version="4.12.0" PrivateAssets="all" />
<PackageReference Include="PolySharp" Version="1.15.0" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\CommunityToolkit.DependencyPropertyGenerator.SourceGenerators\CommunityToolkit.DependencyPropertyGenerator.SourceGenerators.csproj" />
</ItemGroup>
</Project>
Loading