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

WUX/MUX prototype #1421

Merged
merged 55 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
4a84c72
Start prototype with TODOs on supporting build-time/runtime-startup s…
jkoritzinsky Aug 18, 2023
0d84261
Implement the base TODO-WuxMux items that must be completed to suppor…
jkoritzinsky Dec 15, 2023
0195eaf
Add WUX test projection and fix bug with ICommand special-casing.
jkoritzinsky Dec 18, 2023
4de7abc
Inline MUX guids.
jkoritzinsky Dec 18, 2023
a2e8df2
Add CsWinRT SDK support
jkoritzinsky Dec 18, 2023
0d88207
Add tests for authoring components with WUX APIs (also validates some…
jkoritzinsky Dec 19, 2023
ee4dce0
Remove Debug.Breaks
jkoritzinsky Dec 19, 2023
5e38d0a
Change approach so WUX/MUX works for delegates
jkoritzinsky Dec 19, 2023
e63e3d1
Use Xaml Islands and a custom main to enable writing GTest tests with…
jkoritzinsky Dec 19, 2023
21b99e5
Start prototype with TODOs on supporting build-time/runtime-startup s…
jkoritzinsky Aug 18, 2023
1c5d082
PR feedback
jkoritzinsky Jan 18, 2024
a9f1066
Merge branch 'staging/AOT' into users/jkoritzinsky/wux-mux
jkoritzinsky Jan 18, 2024
f09f81d
Use boolean feature flag for the WinRT.Runtime side of the support
jkoritzinsky Jan 19, 2024
1a7d5a3
Rename MSBuild property and expected values.
jkoritzinsky Jan 19, 2024
b1344aa
Consolidate item groups
jkoritzinsky Jan 19, 2024
afe0e22
Rename UiXamlMode to UIXamlProjectionsMode to better match the MSBuil…
jkoritzinsky Jan 19, 2024
9bb00c9
PR feedback
jkoritzinsky Jan 23, 2024
c82e5a9
Merge branch 'staging/AOT' of github.com:microsoft/CsWinRT into wux-mux
jkoritzinsky Jan 25, 2024
ca2abfa
Revert binding changes (the types have the same identity in Wux and M…
jkoritzinsky Jan 29, 2024
00c96a3
Merge branch 'staging/AOT' of github.com:microsoft/CsWinRT into wux-mux
jkoritzinsky Feb 2, 2024
24ed428
Merge branch 'staging/AOT' of github.com:microsoft/CsWinRT into wux-mux
jkoritzinsky Mar 13, 2024
56c16ce
Merge branch 'staging/AOT' of github.com:microsoft/CsWinRT into wux-mux
jkoritzinsky Apr 10, 2024
84bfe24
Make it easier to debug the source generator
jkoritzinsky Apr 12, 2024
4ddecdb
Merge branch 'users/jkoritzinsky/wux-mux' of github.com:microsoft/CsW…
jkoritzinsky Apr 12, 2024
50191c2
Fix the build
jkoritzinsky Apr 13, 2024
1595106
Merge branch 'staging/AOT' of github.com:microsoft/CsWinRT into wux-mux
jkoritzinsky May 21, 2024
d8f57f8
Finally fix the NRE
jkoritzinsky May 21, 2024
8663e0a
Provide a mechanism to exclude additions (for use when different sect…
jkoritzinsky May 21, 2024
14d285b
Fix property name in 'ILLink.Substitutions.xml'
Sergio0694 May 23, 2024
8bc71ac
Rename 'FeatureSwitches' switch for WUX
Sergio0694 May 23, 2024
c3ba195
Remove unnecessary mapping collection
Sergio0694 May 24, 2024
4fdcd11
Remove leftover 'Debugger.Launch' call
Sergio0694 May 24, 2024
4fe2d47
Remove 'IPropertyChangedEventArgsVftbl' type
Sergio0694 May 24, 2024
61091cd
Optimize 'PropertyChangedEventArgsRuntimeClassFactory'
Sergio0694 May 24, 2024
633b026
Merge branch 'staging/AOT' into users/jkoritzinsky/wux-mux
Sergio0694 Jun 5, 2024
3ade8ab
Fix merge conflicts
Sergio0694 Jun 5, 2024
b6f74c2
Fix capitalization of an IID
Sergio0694 Jun 5, 2024
7cdd72c
Centralize last WUX/MUX IIDs
Sergio0694 Jun 5, 2024
630123a
Remove runtime parsing of two IIDs
Sergio0694 Jun 5, 2024
3234a23
Fix WUX IID for 'INotifyCollectionChanged'
Sergio0694 Jun 5, 2024
72d47a1
Remove unnecessary [WuxMux] from vtable types
Sergio0694 Jun 5, 2024
a94f90c
Tweak 'NotifyCollectionChangedEventArgs'
Sergio0694 Jun 5, 2024
0addb86
Tweak 'NotifyCollectionChangedEventArgs'
Sergio0694 Jun 5, 2024
28797e3
Merge branch 'staging/AOT' into users/jkoritzinsky/wux-mux
Sergio0694 Jun 6, 2024
a508614
Simplify 'WuxMuxProjectedTypeAttribute'
Sergio0694 Jun 6, 2024
336649f
Fix 'MatchingRefApiCompatBaseline'
Sergio0694 Jun 6, 2024
f9a76d0
Fix 'PropertyChangedEventHandler.IID' accessibility
Sergio0694 Jun 6, 2024
b88e402
Throw 'NotSupportedException' for WUX downlevel
Sergio0694 Jun 7, 2024
3e4f2bc
Remove unnecessary ifdef
Sergio0694 Jun 7, 2024
c523855
Simplify 'Projections.CustomTypeMappings.tt'
Sergio0694 Jun 7, 2024
e0adf7e
Throw when trying to register invalid custom mappings
Sergio0694 Jun 7, 2024
fac074d
Support WUX for custom type mapping APIs
Sergio0694 Jun 7, 2024
c3c4aea
Fix IIDs
jkoritzinsky Jun 24, 2024
000ca9b
Remove unnecessary 'As<T>' calls for activation
Sergio0694 Jun 24, 2024
579b5e1
Reorder props, fix indendation
Sergio0694 Jun 24, 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
12 changes: 12 additions & 0 deletions build/AzurePipelineTemplates/CsWinRT-BuildAndTest-Stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,18 @@ stages:
script: |
dir _build\$(BuildPlatform)\$(BuildConfiguration)\AuthoringConsumptionTest\bin
_build\$(BuildPlatform)\$(BuildConfiguration)\AuthoringConsumptionTest\bin\AuthoringConsumptionTest.exe --gtest_output=xml:AUTHORINGTEST-$(Build.BuildNumber).xml
exit /b 0

# Run WUX Tests
- task: CmdLine@2
displayName: Run WUX Tests
condition: and(succeeded(), or(eq(variables['BuildPlatform'], 'x86'), eq(variables['BuildPlatform'], 'x64')))
continueOnError: True
inputs:
workingDirectory: $(Build.SourcesDirectory)\src
script: |
dir _build\$(BuildPlatform)\$(BuildConfiguration)\AuthoringWuxConsumptionTest\bin
_build\$(BuildPlatform)\$(BuildConfiguration)\AuthoringWuxConsumptionTest\bin\AuthoringWuxConsumptionTest.exe --gtest_output=xml:AUTHORINGWUXTEST-$(Build.BuildNumber).xml
exit /b 0

# Run Functional Tests
Expand Down
1 change: 1 addition & 0 deletions nuget/Microsoft.Windows.CsWinRT.Authoring.targets
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<CompilerVisibleProperty Include="CsWinRTWindowsMetadata" />
<CompilerVisibleProperty Include="CsWinRTGenerateProjection" />
<CompilerVisibleProperty Include="CsWinRTAuthoringInputs" />
<CompilerVisibleProperty Include="CsWinRTUiXamlMode" />
</ItemGroup>

<!-- Note this runs before the msbuild editor config file is generated because that is what is used to pass properties to the source generator. -->
Expand Down
7 changes: 7 additions & 0 deletions nuget/Microsoft.Windows.CsWinRT.targets
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,13 @@ $(CsWinRTInternalProjection)
</ItemGroup>
</Target>

<ItemGroup>
<RuntimeHostConfigurationOption Include="CsWinRT.UiXamlMode" Condition="'$(CsWinRTUiXamlMode)' != ''">
<Value>$(CsWinRTUiXamlMode)</Value>
<Trim>true</Trim>
</RuntimeHostConfigurationOption>
</ItemGroup>

<Import Project="$(MSBuildThisFileDirectory)Microsoft.Windows.CsWinRT.Prerelease.targets" Condition="Exists('$(MSBuildThisFileDirectory)Microsoft.Windows.CsWinRT.Prerelease.targets')"/>
<Import Project="$(MSBuildThisFileDirectory)Microsoft.Windows.CsWinRT.Authoring.targets" Condition="'$(CsWinRTComponent)' == 'true'"/>
<Import Project="$(MSBuildThisFileDirectory)Microsoft.Windows.CsWinRT.IIDOptimizer.targets" Condition="'$(CsWinRTIIDOptimizerOptOut)' != 'true'"/>
Expand Down
103 changes: 57 additions & 46 deletions src/Authoring/WinRT.SourceGenerator/AotOptimizer.cs

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions src/Authoring/WinRT.SourceGenerator/DiagnosticUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ public WinRTComponentScanner(GeneratorExecutionContext context, string assemblyN
_assemblyName = assemblyName;
_context = context;
_flag = false;
_typeMapper = new TypeMapper(context.AnalyzerConfigOptions.GlobalOptions.GetUiXamlMode());
}

private readonly string _assemblyName;
private readonly GeneratorExecutionContext _context;
private bool _flag;
private readonly TypeMapper _typeMapper;

public bool Found() { return _flag; }

Expand Down Expand Up @@ -105,7 +107,7 @@ private void CheckDeclarations()
var props = @class.DescendantNodes().OfType<PropertyDeclarationSyntax>().Where(IsPublic);

// filter out methods and properties that will be replaced with our custom type mappings
IgnoreCustomTypeMappings(classSymbol, ref publicMethods, ref props);
IgnoreCustomTypeMappings(classSymbol, _typeMapper, ref publicMethods, ref props);

if (!classSymbol.IsSealed && !classSymbol.IsStatic)
{
Expand Down Expand Up @@ -137,7 +139,7 @@ private void CheckDeclarations()
var props = @interface.DescendantNodes().OfType<PropertyDeclarationSyntax>().Where(IsPublic);

// filter out methods and properties that will be replaced with our custom type mappings
IgnoreCustomTypeMappings(interfaceSym, ref methods, ref props);
IgnoreCustomTypeMappings(interfaceSym, _typeMapper, ref methods, ref props);

if (interfaceSym.IsGenericType)
{
Expand Down Expand Up @@ -206,6 +208,7 @@ private bool IsMethodImpl(IMethodSymbol m, IMethodSymbol interfaceMethod)
}

private void IgnoreCustomTypeMappings(INamedTypeSymbol typeSymbol,
TypeMapper typeMapper,
ref IEnumerable<MethodDeclarationSyntax> methods,
ref IEnumerable<PropertyDeclarationSyntax> properties)
{
Expand All @@ -217,7 +220,7 @@ string QualifiedName(INamedTypeSymbol sym)
HashSet<ISymbol> classMethods = new();

foreach (var @interface in typeSymbol.AllInterfaces.
Where(symbol => GeneratorHelper.MappedCSharpTypes.ContainsKey(QualifiedName(symbol)) ||
Where(symbol => typeMapper.HasMappingForType(QualifiedName(symbol)) ||
WinRTTypeWriter.ImplementedInterfacesWithoutMapping.Contains(QualifiedName(symbol))))
{
foreach (var interfaceMember in @interface.GetMembers())
Expand Down
8 changes: 6 additions & 2 deletions src/Authoring/WinRT.SourceGenerator/Generator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
Expand All @@ -20,11 +20,14 @@ public class ComponentGenerator
private Logger Logger { get; }
private readonly GeneratorExecutionContext context;
private string tempFolder;
private readonly TypeMapper mapper;

public ComponentGenerator(GeneratorExecutionContext context)
{
this.context = context;
Logger = new Logger(context);
mapper = new(context.AnalyzerConfigOptions.GlobalOptions.GetUiXamlMode());
// TODO-WuxMux: output a module initializer that validates the MUX/WUX projection mode to ensure that things don't get out of sync.
}

private string GetTempFolder(bool clearSourceFilesFromFolder = false)
Expand Down Expand Up @@ -152,7 +155,8 @@ public void Generate()
assembly,
version,
metadataBuilder,
Logger);
Logger,
mapper);

WinRTSyntaxReceiver syntaxReceiver = (WinRTSyntaxReceiver)context.SyntaxReceiver;
Logger.Log("Found " + syntaxReceiver.Declarations.Count + " types");
Expand Down
Loading
Loading