From 7fd8724ea7803c0e1381fb5b61fe839889f312a9 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 14 Aug 2024 20:55:23 -0700 Subject: [PATCH] Enhance the bound generator concept to remove duplicate parameters and make it more pervasive throughout the system (#105597) --- ...tem.Runtime.InteropServices.JavaScript.sln | 387 +++++++++--------- .../JSExportCodeGenerator.cs | 25 +- .../JSImportGenerator/JSExportGenerator.cs | 8 +- .../JSImportGenerator/JSGeneratorFactory.cs | 202 ++++----- .../JSImportCodeGenerator.cs | 25 +- .../JSImportGenerator/JSSignatureContext.cs | 5 +- .../JSImportGenerator/JSStubCodeContext.cs | 46 --- .../Marshaling/ArrayJSGenerator.cs | 8 +- .../Marshaling/ArraySegmentJSGenerator.cs | 8 +- .../Marshaling/BaseJSGenerator.cs | 36 +- .../Marshaling/EmptyJSGenerator.cs | 3 +- .../Marshaling/FuncJSGenerator.cs | 32 +- .../Marshaling/IJSMarshallingGenerator.cs | 4 +- .../Marshaling/NullableJSGenerator.cs | 8 +- .../Marshaling/PrimitiveJSGenerator.cs | 31 +- .../Marshaling/SpanJSGenerator.cs | 8 +- .../Marshaling/TaskJSGenerator.cs | 34 +- .../Marshaling/VoidGenerator.cs | 8 +- .../CodeSnippets.cs | 29 ++ .../JSImportGenerator.UnitTest/Compiles.cs | 219 ++++++++++ ...omImportToGeneratedComInterfaceAnalyzer.cs | 6 +- .../ComInterfaceGenerator/ComMethodContext.cs | 2 +- .../ManagedToNativeVTableMethodGenerator.cs | 2 +- ...ComInterfaceDispatchMarshallingResolver.cs | 4 +- ...anagedHResultExceptionGeneratorResolver.cs | 8 +- .../Marshallers/ObjectUnwrapperResolver.cs | 4 +- .../StructAsHResultMarshallerFactory.cs | 4 +- .../UnmanagedToManagedStubGenerator.cs | 2 +- .../ConvertToLibraryImportAnalyzer.cs | 4 +- .../ForwarderResolver.cs | 2 +- .../PInvokeStubCodeGenerator.cs | 9 +- .../BoundGenerators.cs | 54 ++- .../GeneratedStatements.cs | 22 +- ...eneratorInitializationContextExtensions.cs | 6 +- ...ibutedMarshallingModelGeneratorResolver.cs | 42 +- .../Marshalling/BlittableMarshaller.cs | 2 +- .../Marshalling/BoolMarshaller.cs | 2 +- .../ByValueContentsMarshalKindValidator.cs | 10 +- .../ByValueMarshalKindSupportDescriptor.cs | 2 +- .../Marshalling/CharMarshaller.cs | 2 +- .../CharMarshallingGeneratorResolver.cs | 16 +- .../CustomTypeMarshallingGenerator.cs | 72 ++-- .../Marshalling/DelegateMarshaller.cs | 2 +- .../Marshalling/ElementsMarshalling.cs | 73 ++-- .../Marshalling/Forwarder.cs | 2 +- .../IMarshallingGeneratorResolver.cs | 2 +- .../MarshalAsMarshallingGeneratorResolver.cs | 28 +- .../Marshalling/MarshallingGenerator.cs | 119 +++++- .../MarshallingGeneratorExtensions.cs | 54 +-- .../NoMarshallingInfoErrorResolver.cs | 2 +- .../Marshalling/NotSupportedResolver.cs | 2 +- .../Marshalling/ResolvedGenerator.cs | 10 +- .../StaticPinnableManagedValueMarshaller.cs | 62 ++- ...nagedToManagedOwnershipTrackingStrategy.cs | 28 +- .../StubCodeContext.cs | 2 +- .../VariableDeclarations.cs | 24 +- 56 files changed, 1059 insertions(+), 754 deletions(-) delete mode 100644 src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSStubCodeContext.cs diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/System.Runtime.InteropServices.JavaScript.sln b/src/libraries/System.Runtime.InteropServices.JavaScript/System.Runtime.InteropServices.JavaScript.sln index 4c19df1d78c4c..4dd63b4bf9e9b 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/System.Runtime.InteropServices.JavaScript.sln +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/System.Runtime.InteropServices.JavaScript.sln @@ -1,4 +1,8 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.11.34930.192 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.CoreLib", "..\..\coreclr\System.Private.CoreLib\System.Private.CoreLib.csproj", "{0F7BA062-C34C-41A8-840F-F0B074B18686}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestUtilities", "..\Common\tests\TestUtilities\TestUtilities.csproj", "{ED86AB26-1CFB-457D-BF87-B7A0D8FAF272}" @@ -71,16 +75,21 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{32CDDDCD-531 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "gen", "{39B30F44-B141-44E9-B7A7-B1A9EDB1A61C}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "tools\gen", "{1A04C5D7-1DE9-47C3-BCC1-147678B9085F}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "gen", "{1A04C5D7-1DE9-47C3-BCC1-147678B9085F}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "tools\src", "{32733782-56D6-4EAF-B94E-5D10C759DD57}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{32733782-56D6-4EAF-B94E-5D10C759DD57}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "tools\ref", "{19EA33B4-0E87-451F-95E3-8F3959117654}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{19EA33B4-0E87-451F-95E3-8F3959117654}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{7392B838-42AF-4F54-AD02-366397DAF640}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Checked|Any CPU = Checked|Any CPU + Checked|arm = Checked|arm + Checked|arm64 = Checked|arm64 + Checked|x64 = Checked|x64 + Checked|x86 = Checked|x86 Debug|Any CPU = Debug|Any CPU Debug|arm = Debug|arm Debug|arm64 = Debug|arm64 @@ -91,13 +100,18 @@ Global Release|arm64 = Release|arm64 Release|x64 = Release|x64 Release|x86 = Release|x86 - Checked|Any CPU = Checked|Any CPU - Checked|arm = Checked|arm - Checked|arm64 = Checked|arm64 - Checked|x64 = Checked|x64 - Checked|x86 = Checked|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0F7BA062-C34C-41A8-840F-F0B074B18686}.Checked|Any CPU.ActiveCfg = Checked|x64 + {0F7BA062-C34C-41A8-840F-F0B074B18686}.Checked|Any CPU.Build.0 = Checked|x64 + {0F7BA062-C34C-41A8-840F-F0B074B18686}.Checked|arm.ActiveCfg = Checked|arm + {0F7BA062-C34C-41A8-840F-F0B074B18686}.Checked|arm.Build.0 = Checked|arm + {0F7BA062-C34C-41A8-840F-F0B074B18686}.Checked|arm64.ActiveCfg = Checked|arm64 + {0F7BA062-C34C-41A8-840F-F0B074B18686}.Checked|arm64.Build.0 = Checked|arm64 + {0F7BA062-C34C-41A8-840F-F0B074B18686}.Checked|x64.ActiveCfg = Checked|x64 + {0F7BA062-C34C-41A8-840F-F0B074B18686}.Checked|x64.Build.0 = Checked|x64 + {0F7BA062-C34C-41A8-840F-F0B074B18686}.Checked|x86.ActiveCfg = Checked|x86 + {0F7BA062-C34C-41A8-840F-F0B074B18686}.Checked|x86.Build.0 = Checked|x86 {0F7BA062-C34C-41A8-840F-F0B074B18686}.Debug|Any CPU.ActiveCfg = Debug|x64 {0F7BA062-C34C-41A8-840F-F0B074B18686}.Debug|Any CPU.Build.0 = Debug|x64 {0F7BA062-C34C-41A8-840F-F0B074B18686}.Debug|arm.ActiveCfg = Debug|arm @@ -118,16 +132,11 @@ Global {0F7BA062-C34C-41A8-840F-F0B074B18686}.Release|x64.Build.0 = Release|x64 {0F7BA062-C34C-41A8-840F-F0B074B18686}.Release|x86.ActiveCfg = Release|x86 {0F7BA062-C34C-41A8-840F-F0B074B18686}.Release|x86.Build.0 = Release|x86 - {0F7BA062-C34C-41A8-840F-F0B074B18686}.Checked|Any CPU.ActiveCfg = Checked|x64 - {0F7BA062-C34C-41A8-840F-F0B074B18686}.Checked|Any CPU.Build.0 = Checked|x64 - {0F7BA062-C34C-41A8-840F-F0B074B18686}.Checked|arm.ActiveCfg = Checked|arm - {0F7BA062-C34C-41A8-840F-F0B074B18686}.Checked|arm.Build.0 = Checked|arm - {0F7BA062-C34C-41A8-840F-F0B074B18686}.Checked|arm64.ActiveCfg = Checked|arm64 - {0F7BA062-C34C-41A8-840F-F0B074B18686}.Checked|arm64.Build.0 = Checked|arm64 - {0F7BA062-C34C-41A8-840F-F0B074B18686}.Checked|x64.ActiveCfg = Checked|x64 - {0F7BA062-C34C-41A8-840F-F0B074B18686}.Checked|x64.Build.0 = Checked|x64 - {0F7BA062-C34C-41A8-840F-F0B074B18686}.Checked|x86.ActiveCfg = Checked|x86 - {0F7BA062-C34C-41A8-840F-F0B074B18686}.Checked|x86.Build.0 = Checked|x86 + {ED86AB26-1CFB-457D-BF87-B7A0D8FAF272}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {ED86AB26-1CFB-457D-BF87-B7A0D8FAF272}.Checked|arm.ActiveCfg = Debug|Any CPU + {ED86AB26-1CFB-457D-BF87-B7A0D8FAF272}.Checked|arm64.ActiveCfg = Debug|Any CPU + {ED86AB26-1CFB-457D-BF87-B7A0D8FAF272}.Checked|x64.ActiveCfg = Debug|Any CPU + {ED86AB26-1CFB-457D-BF87-B7A0D8FAF272}.Checked|x86.ActiveCfg = Debug|Any CPU {ED86AB26-1CFB-457D-BF87-B7A0D8FAF272}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {ED86AB26-1CFB-457D-BF87-B7A0D8FAF272}.Debug|Any CPU.Build.0 = Debug|Any CPU {ED86AB26-1CFB-457D-BF87-B7A0D8FAF272}.Debug|arm.ActiveCfg = Debug|Any CPU @@ -144,11 +153,11 @@ Global {ED86AB26-1CFB-457D-BF87-B7A0D8FAF272}.Release|x64.Build.0 = Release|Any CPU {ED86AB26-1CFB-457D-BF87-B7A0D8FAF272}.Release|x86.ActiveCfg = Release|Any CPU {ED86AB26-1CFB-457D-BF87-B7A0D8FAF272}.Release|x86.Build.0 = Release|Any CPU - {ED86AB26-1CFB-457D-BF87-B7A0D8FAF272}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {ED86AB26-1CFB-457D-BF87-B7A0D8FAF272}.Checked|arm.ActiveCfg = Debug|Any CPU - {ED86AB26-1CFB-457D-BF87-B7A0D8FAF272}.Checked|arm64.ActiveCfg = Debug|Any CPU - {ED86AB26-1CFB-457D-BF87-B7A0D8FAF272}.Checked|x64.ActiveCfg = Debug|Any CPU - {ED86AB26-1CFB-457D-BF87-B7A0D8FAF272}.Checked|x86.ActiveCfg = Debug|Any CPU + {FC1007CC-9E52-49B7-A47B-A8AE76E75986}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {FC1007CC-9E52-49B7-A47B-A8AE76E75986}.Checked|arm.ActiveCfg = Debug|Any CPU + {FC1007CC-9E52-49B7-A47B-A8AE76E75986}.Checked|arm64.ActiveCfg = Debug|Any CPU + {FC1007CC-9E52-49B7-A47B-A8AE76E75986}.Checked|x64.ActiveCfg = Debug|Any CPU + {FC1007CC-9E52-49B7-A47B-A8AE76E75986}.Checked|x86.ActiveCfg = Debug|Any CPU {FC1007CC-9E52-49B7-A47B-A8AE76E75986}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FC1007CC-9E52-49B7-A47B-A8AE76E75986}.Debug|Any CPU.Build.0 = Debug|Any CPU {FC1007CC-9E52-49B7-A47B-A8AE76E75986}.Debug|arm.ActiveCfg = Debug|Any CPU @@ -165,11 +174,11 @@ Global {FC1007CC-9E52-49B7-A47B-A8AE76E75986}.Release|x64.Build.0 = Release|Any CPU {FC1007CC-9E52-49B7-A47B-A8AE76E75986}.Release|x86.ActiveCfg = Release|Any CPU {FC1007CC-9E52-49B7-A47B-A8AE76E75986}.Release|x86.Build.0 = Release|Any CPU - {FC1007CC-9E52-49B7-A47B-A8AE76E75986}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {FC1007CC-9E52-49B7-A47B-A8AE76E75986}.Checked|arm.ActiveCfg = Debug|Any CPU - {FC1007CC-9E52-49B7-A47B-A8AE76E75986}.Checked|arm64.ActiveCfg = Debug|Any CPU - {FC1007CC-9E52-49B7-A47B-A8AE76E75986}.Checked|x64.ActiveCfg = Debug|Any CPU - {FC1007CC-9E52-49B7-A47B-A8AE76E75986}.Checked|x86.ActiveCfg = Debug|Any CPU + {8B1D80E9-AE0D-4E3C-9F91-E6862B49AEF3}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {8B1D80E9-AE0D-4E3C-9F91-E6862B49AEF3}.Checked|arm.ActiveCfg = Debug|Any CPU + {8B1D80E9-AE0D-4E3C-9F91-E6862B49AEF3}.Checked|arm64.ActiveCfg = Debug|Any CPU + {8B1D80E9-AE0D-4E3C-9F91-E6862B49AEF3}.Checked|x64.ActiveCfg = Debug|Any CPU + {8B1D80E9-AE0D-4E3C-9F91-E6862B49AEF3}.Checked|x86.ActiveCfg = Debug|Any CPU {8B1D80E9-AE0D-4E3C-9F91-E6862B49AEF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8B1D80E9-AE0D-4E3C-9F91-E6862B49AEF3}.Debug|Any CPU.Build.0 = Debug|Any CPU {8B1D80E9-AE0D-4E3C-9F91-E6862B49AEF3}.Debug|arm.ActiveCfg = Debug|Any CPU @@ -186,11 +195,11 @@ Global {8B1D80E9-AE0D-4E3C-9F91-E6862B49AEF3}.Release|x64.Build.0 = Release|Any CPU {8B1D80E9-AE0D-4E3C-9F91-E6862B49AEF3}.Release|x86.ActiveCfg = Release|Any CPU {8B1D80E9-AE0D-4E3C-9F91-E6862B49AEF3}.Release|x86.Build.0 = Release|Any CPU - {8B1D80E9-AE0D-4E3C-9F91-E6862B49AEF3}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {8B1D80E9-AE0D-4E3C-9F91-E6862B49AEF3}.Checked|arm.ActiveCfg = Debug|Any CPU - {8B1D80E9-AE0D-4E3C-9F91-E6862B49AEF3}.Checked|arm64.ActiveCfg = Debug|Any CPU - {8B1D80E9-AE0D-4E3C-9F91-E6862B49AEF3}.Checked|x64.ActiveCfg = Debug|Any CPU - {8B1D80E9-AE0D-4E3C-9F91-E6862B49AEF3}.Checked|x86.ActiveCfg = Debug|Any CPU + {B79E5BB4-2595-48BC-A44C-0A7949AFBDEB}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {B79E5BB4-2595-48BC-A44C-0A7949AFBDEB}.Checked|arm.ActiveCfg = Debug|Any CPU + {B79E5BB4-2595-48BC-A44C-0A7949AFBDEB}.Checked|arm64.ActiveCfg = Debug|Any CPU + {B79E5BB4-2595-48BC-A44C-0A7949AFBDEB}.Checked|x64.ActiveCfg = Debug|Any CPU + {B79E5BB4-2595-48BC-A44C-0A7949AFBDEB}.Checked|x86.ActiveCfg = Debug|Any CPU {B79E5BB4-2595-48BC-A44C-0A7949AFBDEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B79E5BB4-2595-48BC-A44C-0A7949AFBDEB}.Debug|Any CPU.Build.0 = Debug|Any CPU {B79E5BB4-2595-48BC-A44C-0A7949AFBDEB}.Debug|arm.ActiveCfg = Debug|Any CPU @@ -207,11 +216,11 @@ Global {B79E5BB4-2595-48BC-A44C-0A7949AFBDEB}.Release|x64.Build.0 = Release|Any CPU {B79E5BB4-2595-48BC-A44C-0A7949AFBDEB}.Release|x86.ActiveCfg = Release|Any CPU {B79E5BB4-2595-48BC-A44C-0A7949AFBDEB}.Release|x86.Build.0 = Release|Any CPU - {B79E5BB4-2595-48BC-A44C-0A7949AFBDEB}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {B79E5BB4-2595-48BC-A44C-0A7949AFBDEB}.Checked|arm.ActiveCfg = Debug|Any CPU - {B79E5BB4-2595-48BC-A44C-0A7949AFBDEB}.Checked|arm64.ActiveCfg = Debug|Any CPU - {B79E5BB4-2595-48BC-A44C-0A7949AFBDEB}.Checked|x64.ActiveCfg = Debug|Any CPU - {B79E5BB4-2595-48BC-A44C-0A7949AFBDEB}.Checked|x86.ActiveCfg = Debug|Any CPU + {E00AE8BB-7C7F-4D07-949D-EDCC815AC8C8}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {E00AE8BB-7C7F-4D07-949D-EDCC815AC8C8}.Checked|arm.ActiveCfg = Debug|Any CPU + {E00AE8BB-7C7F-4D07-949D-EDCC815AC8C8}.Checked|arm64.ActiveCfg = Debug|Any CPU + {E00AE8BB-7C7F-4D07-949D-EDCC815AC8C8}.Checked|x64.ActiveCfg = Debug|Any CPU + {E00AE8BB-7C7F-4D07-949D-EDCC815AC8C8}.Checked|x86.ActiveCfg = Debug|Any CPU {E00AE8BB-7C7F-4D07-949D-EDCC815AC8C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E00AE8BB-7C7F-4D07-949D-EDCC815AC8C8}.Debug|Any CPU.Build.0 = Debug|Any CPU {E00AE8BB-7C7F-4D07-949D-EDCC815AC8C8}.Debug|arm.ActiveCfg = Debug|Any CPU @@ -228,11 +237,11 @@ Global {E00AE8BB-7C7F-4D07-949D-EDCC815AC8C8}.Release|x64.Build.0 = Release|Any CPU {E00AE8BB-7C7F-4D07-949D-EDCC815AC8C8}.Release|x86.ActiveCfg = Release|Any CPU {E00AE8BB-7C7F-4D07-949D-EDCC815AC8C8}.Release|x86.Build.0 = Release|Any CPU - {E00AE8BB-7C7F-4D07-949D-EDCC815AC8C8}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {E00AE8BB-7C7F-4D07-949D-EDCC815AC8C8}.Checked|arm.ActiveCfg = Debug|Any CPU - {E00AE8BB-7C7F-4D07-949D-EDCC815AC8C8}.Checked|arm64.ActiveCfg = Debug|Any CPU - {E00AE8BB-7C7F-4D07-949D-EDCC815AC8C8}.Checked|x64.ActiveCfg = Debug|Any CPU - {E00AE8BB-7C7F-4D07-949D-EDCC815AC8C8}.Checked|x86.ActiveCfg = Debug|Any CPU + {C1C606F3-A246-4EA0-A467-3AC4F31C2AFE}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {C1C606F3-A246-4EA0-A467-3AC4F31C2AFE}.Checked|arm.ActiveCfg = Debug|Any CPU + {C1C606F3-A246-4EA0-A467-3AC4F31C2AFE}.Checked|arm64.ActiveCfg = Debug|Any CPU + {C1C606F3-A246-4EA0-A467-3AC4F31C2AFE}.Checked|x64.ActiveCfg = Debug|Any CPU + {C1C606F3-A246-4EA0-A467-3AC4F31C2AFE}.Checked|x86.ActiveCfg = Debug|Any CPU {C1C606F3-A246-4EA0-A467-3AC4F31C2AFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C1C606F3-A246-4EA0-A467-3AC4F31C2AFE}.Debug|Any CPU.Build.0 = Debug|Any CPU {C1C606F3-A246-4EA0-A467-3AC4F31C2AFE}.Debug|arm.ActiveCfg = Debug|Any CPU @@ -249,11 +258,11 @@ Global {C1C606F3-A246-4EA0-A467-3AC4F31C2AFE}.Release|x64.Build.0 = Release|Any CPU {C1C606F3-A246-4EA0-A467-3AC4F31C2AFE}.Release|x86.ActiveCfg = Release|Any CPU {C1C606F3-A246-4EA0-A467-3AC4F31C2AFE}.Release|x86.Build.0 = Release|Any CPU - {C1C606F3-A246-4EA0-A467-3AC4F31C2AFE}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {C1C606F3-A246-4EA0-A467-3AC4F31C2AFE}.Checked|arm.ActiveCfg = Debug|Any CPU - {C1C606F3-A246-4EA0-A467-3AC4F31C2AFE}.Checked|arm64.ActiveCfg = Debug|Any CPU - {C1C606F3-A246-4EA0-A467-3AC4F31C2AFE}.Checked|x64.ActiveCfg = Debug|Any CPU - {C1C606F3-A246-4EA0-A467-3AC4F31C2AFE}.Checked|x86.ActiveCfg = Debug|Any CPU + {8CFB1155-26A2-43E3-B192-1F87D9E543AC}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {8CFB1155-26A2-43E3-B192-1F87D9E543AC}.Checked|arm.ActiveCfg = Debug|Any CPU + {8CFB1155-26A2-43E3-B192-1F87D9E543AC}.Checked|arm64.ActiveCfg = Debug|Any CPU + {8CFB1155-26A2-43E3-B192-1F87D9E543AC}.Checked|x64.ActiveCfg = Debug|Any CPU + {8CFB1155-26A2-43E3-B192-1F87D9E543AC}.Checked|x86.ActiveCfg = Debug|Any CPU {8CFB1155-26A2-43E3-B192-1F87D9E543AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8CFB1155-26A2-43E3-B192-1F87D9E543AC}.Debug|Any CPU.Build.0 = Debug|Any CPU {8CFB1155-26A2-43E3-B192-1F87D9E543AC}.Debug|arm.ActiveCfg = Debug|Any CPU @@ -270,11 +279,11 @@ Global {8CFB1155-26A2-43E3-B192-1F87D9E543AC}.Release|x64.Build.0 = Release|Any CPU {8CFB1155-26A2-43E3-B192-1F87D9E543AC}.Release|x86.ActiveCfg = Release|Any CPU {8CFB1155-26A2-43E3-B192-1F87D9E543AC}.Release|x86.Build.0 = Release|Any CPU - {8CFB1155-26A2-43E3-B192-1F87D9E543AC}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {8CFB1155-26A2-43E3-B192-1F87D9E543AC}.Checked|arm.ActiveCfg = Debug|Any CPU - {8CFB1155-26A2-43E3-B192-1F87D9E543AC}.Checked|arm64.ActiveCfg = Debug|Any CPU - {8CFB1155-26A2-43E3-B192-1F87D9E543AC}.Checked|x64.ActiveCfg = Debug|Any CPU - {8CFB1155-26A2-43E3-B192-1F87D9E543AC}.Checked|x86.ActiveCfg = Debug|Any CPU + {D549C13B-FC0D-4B5A-B50D-8F74CB5A3D08}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {D549C13B-FC0D-4B5A-B50D-8F74CB5A3D08}.Checked|arm.ActiveCfg = Debug|Any CPU + {D549C13B-FC0D-4B5A-B50D-8F74CB5A3D08}.Checked|arm64.ActiveCfg = Debug|Any CPU + {D549C13B-FC0D-4B5A-B50D-8F74CB5A3D08}.Checked|x64.ActiveCfg = Debug|Any CPU + {D549C13B-FC0D-4B5A-B50D-8F74CB5A3D08}.Checked|x86.ActiveCfg = Debug|Any CPU {D549C13B-FC0D-4B5A-B50D-8F74CB5A3D08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D549C13B-FC0D-4B5A-B50D-8F74CB5A3D08}.Debug|Any CPU.Build.0 = Debug|Any CPU {D549C13B-FC0D-4B5A-B50D-8F74CB5A3D08}.Debug|arm.ActiveCfg = Debug|Any CPU @@ -291,11 +300,11 @@ Global {D549C13B-FC0D-4B5A-B50D-8F74CB5A3D08}.Release|x64.Build.0 = Release|Any CPU {D549C13B-FC0D-4B5A-B50D-8F74CB5A3D08}.Release|x86.ActiveCfg = Release|Any CPU {D549C13B-FC0D-4B5A-B50D-8F74CB5A3D08}.Release|x86.Build.0 = Release|Any CPU - {D549C13B-FC0D-4B5A-B50D-8F74CB5A3D08}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {D549C13B-FC0D-4B5A-B50D-8F74CB5A3D08}.Checked|arm.ActiveCfg = Debug|Any CPU - {D549C13B-FC0D-4B5A-B50D-8F74CB5A3D08}.Checked|arm64.ActiveCfg = Debug|Any CPU - {D549C13B-FC0D-4B5A-B50D-8F74CB5A3D08}.Checked|x64.ActiveCfg = Debug|Any CPU - {D549C13B-FC0D-4B5A-B50D-8F74CB5A3D08}.Checked|x86.ActiveCfg = Debug|Any CPU + {74143A5F-6987-4AB5-B786-DE358F01241B}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {74143A5F-6987-4AB5-B786-DE358F01241B}.Checked|arm.ActiveCfg = Debug|Any CPU + {74143A5F-6987-4AB5-B786-DE358F01241B}.Checked|arm64.ActiveCfg = Debug|Any CPU + {74143A5F-6987-4AB5-B786-DE358F01241B}.Checked|x64.ActiveCfg = Debug|Any CPU + {74143A5F-6987-4AB5-B786-DE358F01241B}.Checked|x86.ActiveCfg = Debug|Any CPU {74143A5F-6987-4AB5-B786-DE358F01241B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {74143A5F-6987-4AB5-B786-DE358F01241B}.Debug|Any CPU.Build.0 = Debug|Any CPU {74143A5F-6987-4AB5-B786-DE358F01241B}.Debug|arm.ActiveCfg = Debug|Any CPU @@ -312,11 +321,11 @@ Global {74143A5F-6987-4AB5-B786-DE358F01241B}.Release|x64.Build.0 = Release|Any CPU {74143A5F-6987-4AB5-B786-DE358F01241B}.Release|x86.ActiveCfg = Release|Any CPU {74143A5F-6987-4AB5-B786-DE358F01241B}.Release|x86.Build.0 = Release|Any CPU - {74143A5F-6987-4AB5-B786-DE358F01241B}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {74143A5F-6987-4AB5-B786-DE358F01241B}.Checked|arm.ActiveCfg = Debug|Any CPU - {74143A5F-6987-4AB5-B786-DE358F01241B}.Checked|arm64.ActiveCfg = Debug|Any CPU - {74143A5F-6987-4AB5-B786-DE358F01241B}.Checked|x64.ActiveCfg = Debug|Any CPU - {74143A5F-6987-4AB5-B786-DE358F01241B}.Checked|x86.ActiveCfg = Debug|Any CPU + {CE5E53C1-F9B5-41EE-8D00-837913EC57D1}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {CE5E53C1-F9B5-41EE-8D00-837913EC57D1}.Checked|arm.ActiveCfg = Debug|Any CPU + {CE5E53C1-F9B5-41EE-8D00-837913EC57D1}.Checked|arm64.ActiveCfg = Debug|Any CPU + {CE5E53C1-F9B5-41EE-8D00-837913EC57D1}.Checked|x64.ActiveCfg = Debug|Any CPU + {CE5E53C1-F9B5-41EE-8D00-837913EC57D1}.Checked|x86.ActiveCfg = Debug|Any CPU {CE5E53C1-F9B5-41EE-8D00-837913EC57D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CE5E53C1-F9B5-41EE-8D00-837913EC57D1}.Debug|Any CPU.Build.0 = Debug|Any CPU {CE5E53C1-F9B5-41EE-8D00-837913EC57D1}.Debug|arm.ActiveCfg = Debug|Any CPU @@ -333,11 +342,11 @@ Global {CE5E53C1-F9B5-41EE-8D00-837913EC57D1}.Release|x64.Build.0 = Release|Any CPU {CE5E53C1-F9B5-41EE-8D00-837913EC57D1}.Release|x86.ActiveCfg = Release|Any CPU {CE5E53C1-F9B5-41EE-8D00-837913EC57D1}.Release|x86.Build.0 = Release|Any CPU - {CE5E53C1-F9B5-41EE-8D00-837913EC57D1}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {CE5E53C1-F9B5-41EE-8D00-837913EC57D1}.Checked|arm.ActiveCfg = Debug|Any CPU - {CE5E53C1-F9B5-41EE-8D00-837913EC57D1}.Checked|arm64.ActiveCfg = Debug|Any CPU - {CE5E53C1-F9B5-41EE-8D00-837913EC57D1}.Checked|x64.ActiveCfg = Debug|Any CPU - {CE5E53C1-F9B5-41EE-8D00-837913EC57D1}.Checked|x86.ActiveCfg = Debug|Any CPU + {28278E01-BF5C-4AB6-AA7A-8DD4E6C04DB1}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {28278E01-BF5C-4AB6-AA7A-8DD4E6C04DB1}.Checked|arm.ActiveCfg = Debug|Any CPU + {28278E01-BF5C-4AB6-AA7A-8DD4E6C04DB1}.Checked|arm64.ActiveCfg = Debug|Any CPU + {28278E01-BF5C-4AB6-AA7A-8DD4E6C04DB1}.Checked|x64.ActiveCfg = Debug|Any CPU + {28278E01-BF5C-4AB6-AA7A-8DD4E6C04DB1}.Checked|x86.ActiveCfg = Debug|Any CPU {28278E01-BF5C-4AB6-AA7A-8DD4E6C04DB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {28278E01-BF5C-4AB6-AA7A-8DD4E6C04DB1}.Debug|Any CPU.Build.0 = Debug|Any CPU {28278E01-BF5C-4AB6-AA7A-8DD4E6C04DB1}.Debug|arm.ActiveCfg = Debug|Any CPU @@ -354,11 +363,11 @@ Global {28278E01-BF5C-4AB6-AA7A-8DD4E6C04DB1}.Release|x64.Build.0 = Release|Any CPU {28278E01-BF5C-4AB6-AA7A-8DD4E6C04DB1}.Release|x86.ActiveCfg = Release|Any CPU {28278E01-BF5C-4AB6-AA7A-8DD4E6C04DB1}.Release|x86.Build.0 = Release|Any CPU - {28278E01-BF5C-4AB6-AA7A-8DD4E6C04DB1}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {28278E01-BF5C-4AB6-AA7A-8DD4E6C04DB1}.Checked|arm.ActiveCfg = Debug|Any CPU - {28278E01-BF5C-4AB6-AA7A-8DD4E6C04DB1}.Checked|arm64.ActiveCfg = Debug|Any CPU - {28278E01-BF5C-4AB6-AA7A-8DD4E6C04DB1}.Checked|x64.ActiveCfg = Debug|Any CPU - {28278E01-BF5C-4AB6-AA7A-8DD4E6C04DB1}.Checked|x86.ActiveCfg = Debug|Any CPU + {71A845ED-4344-41FC-8FCA-3AC9B6BA6C45}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {71A845ED-4344-41FC-8FCA-3AC9B6BA6C45}.Checked|arm.ActiveCfg = Debug|Any CPU + {71A845ED-4344-41FC-8FCA-3AC9B6BA6C45}.Checked|arm64.ActiveCfg = Debug|Any CPU + {71A845ED-4344-41FC-8FCA-3AC9B6BA6C45}.Checked|x64.ActiveCfg = Debug|Any CPU + {71A845ED-4344-41FC-8FCA-3AC9B6BA6C45}.Checked|x86.ActiveCfg = Debug|Any CPU {71A845ED-4344-41FC-8FCA-3AC9B6BA6C45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {71A845ED-4344-41FC-8FCA-3AC9B6BA6C45}.Debug|Any CPU.Build.0 = Debug|Any CPU {71A845ED-4344-41FC-8FCA-3AC9B6BA6C45}.Debug|arm.ActiveCfg = Debug|Any CPU @@ -375,11 +384,11 @@ Global {71A845ED-4344-41FC-8FCA-3AC9B6BA6C45}.Release|x64.Build.0 = Release|Any CPU {71A845ED-4344-41FC-8FCA-3AC9B6BA6C45}.Release|x86.ActiveCfg = Release|Any CPU {71A845ED-4344-41FC-8FCA-3AC9B6BA6C45}.Release|x86.Build.0 = Release|Any CPU - {71A845ED-4344-41FC-8FCA-3AC9B6BA6C45}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {71A845ED-4344-41FC-8FCA-3AC9B6BA6C45}.Checked|arm.ActiveCfg = Debug|Any CPU - {71A845ED-4344-41FC-8FCA-3AC9B6BA6C45}.Checked|arm64.ActiveCfg = Debug|Any CPU - {71A845ED-4344-41FC-8FCA-3AC9B6BA6C45}.Checked|x64.ActiveCfg = Debug|Any CPU - {71A845ED-4344-41FC-8FCA-3AC9B6BA6C45}.Checked|x86.ActiveCfg = Debug|Any CPU + {E6A30001-84E3-4C7A-9B56-B9DEA71B3CF9}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {E6A30001-84E3-4C7A-9B56-B9DEA71B3CF9}.Checked|arm.ActiveCfg = Debug|Any CPU + {E6A30001-84E3-4C7A-9B56-B9DEA71B3CF9}.Checked|arm64.ActiveCfg = Debug|Any CPU + {E6A30001-84E3-4C7A-9B56-B9DEA71B3CF9}.Checked|x64.ActiveCfg = Debug|Any CPU + {E6A30001-84E3-4C7A-9B56-B9DEA71B3CF9}.Checked|x86.ActiveCfg = Debug|Any CPU {E6A30001-84E3-4C7A-9B56-B9DEA71B3CF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E6A30001-84E3-4C7A-9B56-B9DEA71B3CF9}.Debug|Any CPU.Build.0 = Debug|Any CPU {E6A30001-84E3-4C7A-9B56-B9DEA71B3CF9}.Debug|arm.ActiveCfg = Debug|Any CPU @@ -396,11 +405,11 @@ Global {E6A30001-84E3-4C7A-9B56-B9DEA71B3CF9}.Release|x64.Build.0 = Release|Any CPU {E6A30001-84E3-4C7A-9B56-B9DEA71B3CF9}.Release|x86.ActiveCfg = Release|Any CPU {E6A30001-84E3-4C7A-9B56-B9DEA71B3CF9}.Release|x86.Build.0 = Release|Any CPU - {E6A30001-84E3-4C7A-9B56-B9DEA71B3CF9}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {E6A30001-84E3-4C7A-9B56-B9DEA71B3CF9}.Checked|arm.ActiveCfg = Debug|Any CPU - {E6A30001-84E3-4C7A-9B56-B9DEA71B3CF9}.Checked|arm64.ActiveCfg = Debug|Any CPU - {E6A30001-84E3-4C7A-9B56-B9DEA71B3CF9}.Checked|x64.ActiveCfg = Debug|Any CPU - {E6A30001-84E3-4C7A-9B56-B9DEA71B3CF9}.Checked|x86.ActiveCfg = Debug|Any CPU + {BFED925C-18F2-4C98-833E-66F205234598}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {BFED925C-18F2-4C98-833E-66F205234598}.Checked|arm.ActiveCfg = Debug|Any CPU + {BFED925C-18F2-4C98-833E-66F205234598}.Checked|arm64.ActiveCfg = Debug|Any CPU + {BFED925C-18F2-4C98-833E-66F205234598}.Checked|x64.ActiveCfg = Debug|Any CPU + {BFED925C-18F2-4C98-833E-66F205234598}.Checked|x86.ActiveCfg = Debug|Any CPU {BFED925C-18F2-4C98-833E-66F205234598}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BFED925C-18F2-4C98-833E-66F205234598}.Debug|Any CPU.Build.0 = Debug|Any CPU {BFED925C-18F2-4C98-833E-66F205234598}.Debug|arm.ActiveCfg = Debug|Any CPU @@ -417,11 +426,11 @@ Global {BFED925C-18F2-4C98-833E-66F205234598}.Release|x64.Build.0 = Release|Any CPU {BFED925C-18F2-4C98-833E-66F205234598}.Release|x86.ActiveCfg = Release|Any CPU {BFED925C-18F2-4C98-833E-66F205234598}.Release|x86.Build.0 = Release|Any CPU - {BFED925C-18F2-4C98-833E-66F205234598}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {BFED925C-18F2-4C98-833E-66F205234598}.Checked|arm.ActiveCfg = Debug|Any CPU - {BFED925C-18F2-4C98-833E-66F205234598}.Checked|arm64.ActiveCfg = Debug|Any CPU - {BFED925C-18F2-4C98-833E-66F205234598}.Checked|x64.ActiveCfg = Debug|Any CPU - {BFED925C-18F2-4C98-833E-66F205234598}.Checked|x86.ActiveCfg = Debug|Any CPU + {765B4AA5-723A-44FF-BC4E-EB0F03103F6D}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {765B4AA5-723A-44FF-BC4E-EB0F03103F6D}.Checked|arm.ActiveCfg = Debug|Any CPU + {765B4AA5-723A-44FF-BC4E-EB0F03103F6D}.Checked|arm64.ActiveCfg = Debug|Any CPU + {765B4AA5-723A-44FF-BC4E-EB0F03103F6D}.Checked|x64.ActiveCfg = Debug|Any CPU + {765B4AA5-723A-44FF-BC4E-EB0F03103F6D}.Checked|x86.ActiveCfg = Debug|Any CPU {765B4AA5-723A-44FF-BC4E-EB0F03103F6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {765B4AA5-723A-44FF-BC4E-EB0F03103F6D}.Debug|Any CPU.Build.0 = Debug|Any CPU {765B4AA5-723A-44FF-BC4E-EB0F03103F6D}.Debug|arm.ActiveCfg = Debug|Any CPU @@ -438,11 +447,11 @@ Global {765B4AA5-723A-44FF-BC4E-EB0F03103F6D}.Release|x64.Build.0 = Release|Any CPU {765B4AA5-723A-44FF-BC4E-EB0F03103F6D}.Release|x86.ActiveCfg = Release|Any CPU {765B4AA5-723A-44FF-BC4E-EB0F03103F6D}.Release|x86.Build.0 = Release|Any CPU - {765B4AA5-723A-44FF-BC4E-EB0F03103F6D}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {765B4AA5-723A-44FF-BC4E-EB0F03103F6D}.Checked|arm.ActiveCfg = Debug|Any CPU - {765B4AA5-723A-44FF-BC4E-EB0F03103F6D}.Checked|arm64.ActiveCfg = Debug|Any CPU - {765B4AA5-723A-44FF-BC4E-EB0F03103F6D}.Checked|x64.ActiveCfg = Debug|Any CPU - {765B4AA5-723A-44FF-BC4E-EB0F03103F6D}.Checked|x86.ActiveCfg = Debug|Any CPU + {09AA6758-0BD3-4312-9C07-AE9F1D50A3AD}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {09AA6758-0BD3-4312-9C07-AE9F1D50A3AD}.Checked|arm.ActiveCfg = Debug|Any CPU + {09AA6758-0BD3-4312-9C07-AE9F1D50A3AD}.Checked|arm64.ActiveCfg = Debug|Any CPU + {09AA6758-0BD3-4312-9C07-AE9F1D50A3AD}.Checked|x64.ActiveCfg = Debug|Any CPU + {09AA6758-0BD3-4312-9C07-AE9F1D50A3AD}.Checked|x86.ActiveCfg = Debug|Any CPU {09AA6758-0BD3-4312-9C07-AE9F1D50A3AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {09AA6758-0BD3-4312-9C07-AE9F1D50A3AD}.Debug|Any CPU.Build.0 = Debug|Any CPU {09AA6758-0BD3-4312-9C07-AE9F1D50A3AD}.Debug|arm.ActiveCfg = Debug|Any CPU @@ -459,11 +468,11 @@ Global {09AA6758-0BD3-4312-9C07-AE9F1D50A3AD}.Release|x64.Build.0 = Release|Any CPU {09AA6758-0BD3-4312-9C07-AE9F1D50A3AD}.Release|x86.ActiveCfg = Release|Any CPU {09AA6758-0BD3-4312-9C07-AE9F1D50A3AD}.Release|x86.Build.0 = Release|Any CPU - {09AA6758-0BD3-4312-9C07-AE9F1D50A3AD}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {09AA6758-0BD3-4312-9C07-AE9F1D50A3AD}.Checked|arm.ActiveCfg = Debug|Any CPU - {09AA6758-0BD3-4312-9C07-AE9F1D50A3AD}.Checked|arm64.ActiveCfg = Debug|Any CPU - {09AA6758-0BD3-4312-9C07-AE9F1D50A3AD}.Checked|x64.ActiveCfg = Debug|Any CPU - {09AA6758-0BD3-4312-9C07-AE9F1D50A3AD}.Checked|x86.ActiveCfg = Debug|Any CPU + {B4E3E774-2C16-4CBF-87EF-88C547529B94}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {B4E3E774-2C16-4CBF-87EF-88C547529B94}.Checked|arm.ActiveCfg = Debug|Any CPU + {B4E3E774-2C16-4CBF-87EF-88C547529B94}.Checked|arm64.ActiveCfg = Debug|Any CPU + {B4E3E774-2C16-4CBF-87EF-88C547529B94}.Checked|x64.ActiveCfg = Debug|Any CPU + {B4E3E774-2C16-4CBF-87EF-88C547529B94}.Checked|x86.ActiveCfg = Debug|Any CPU {B4E3E774-2C16-4CBF-87EF-88C547529B94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B4E3E774-2C16-4CBF-87EF-88C547529B94}.Debug|Any CPU.Build.0 = Debug|Any CPU {B4E3E774-2C16-4CBF-87EF-88C547529B94}.Debug|arm.ActiveCfg = Debug|Any CPU @@ -480,11 +489,11 @@ Global {B4E3E774-2C16-4CBF-87EF-88C547529B94}.Release|x64.Build.0 = Release|Any CPU {B4E3E774-2C16-4CBF-87EF-88C547529B94}.Release|x86.ActiveCfg = Release|Any CPU {B4E3E774-2C16-4CBF-87EF-88C547529B94}.Release|x86.Build.0 = Release|Any CPU - {B4E3E774-2C16-4CBF-87EF-88C547529B94}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {B4E3E774-2C16-4CBF-87EF-88C547529B94}.Checked|arm.ActiveCfg = Debug|Any CPU - {B4E3E774-2C16-4CBF-87EF-88C547529B94}.Checked|arm64.ActiveCfg = Debug|Any CPU - {B4E3E774-2C16-4CBF-87EF-88C547529B94}.Checked|x64.ActiveCfg = Debug|Any CPU - {B4E3E774-2C16-4CBF-87EF-88C547529B94}.Checked|x86.ActiveCfg = Debug|Any CPU + {EC3ADEFA-1FF3-482C-8CCB-FE4C77292532}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {EC3ADEFA-1FF3-482C-8CCB-FE4C77292532}.Checked|arm.ActiveCfg = Debug|Any CPU + {EC3ADEFA-1FF3-482C-8CCB-FE4C77292532}.Checked|arm64.ActiveCfg = Debug|Any CPU + {EC3ADEFA-1FF3-482C-8CCB-FE4C77292532}.Checked|x64.ActiveCfg = Debug|Any CPU + {EC3ADEFA-1FF3-482C-8CCB-FE4C77292532}.Checked|x86.ActiveCfg = Debug|Any CPU {EC3ADEFA-1FF3-482C-8CCB-FE4C77292532}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EC3ADEFA-1FF3-482C-8CCB-FE4C77292532}.Debug|Any CPU.Build.0 = Debug|Any CPU {EC3ADEFA-1FF3-482C-8CCB-FE4C77292532}.Debug|arm.ActiveCfg = Debug|Any CPU @@ -501,11 +510,11 @@ Global {EC3ADEFA-1FF3-482C-8CCB-FE4C77292532}.Release|x64.Build.0 = Release|Any CPU {EC3ADEFA-1FF3-482C-8CCB-FE4C77292532}.Release|x86.ActiveCfg = Release|Any CPU {EC3ADEFA-1FF3-482C-8CCB-FE4C77292532}.Release|x86.Build.0 = Release|Any CPU - {EC3ADEFA-1FF3-482C-8CCB-FE4C77292532}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {EC3ADEFA-1FF3-482C-8CCB-FE4C77292532}.Checked|arm.ActiveCfg = Debug|Any CPU - {EC3ADEFA-1FF3-482C-8CCB-FE4C77292532}.Checked|arm64.ActiveCfg = Debug|Any CPU - {EC3ADEFA-1FF3-482C-8CCB-FE4C77292532}.Checked|x64.ActiveCfg = Debug|Any CPU - {EC3ADEFA-1FF3-482C-8CCB-FE4C77292532}.Checked|x86.ActiveCfg = Debug|Any CPU + {44BAE6F1-94C2-415B-9A16-3B8EC429B09B}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {44BAE6F1-94C2-415B-9A16-3B8EC429B09B}.Checked|arm.ActiveCfg = Debug|Any CPU + {44BAE6F1-94C2-415B-9A16-3B8EC429B09B}.Checked|arm64.ActiveCfg = Debug|Any CPU + {44BAE6F1-94C2-415B-9A16-3B8EC429B09B}.Checked|x64.ActiveCfg = Debug|Any CPU + {44BAE6F1-94C2-415B-9A16-3B8EC429B09B}.Checked|x86.ActiveCfg = Debug|Any CPU {44BAE6F1-94C2-415B-9A16-3B8EC429B09B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {44BAE6F1-94C2-415B-9A16-3B8EC429B09B}.Debug|Any CPU.Build.0 = Debug|Any CPU {44BAE6F1-94C2-415B-9A16-3B8EC429B09B}.Debug|arm.ActiveCfg = Debug|Any CPU @@ -522,11 +531,11 @@ Global {44BAE6F1-94C2-415B-9A16-3B8EC429B09B}.Release|x64.Build.0 = Release|Any CPU {44BAE6F1-94C2-415B-9A16-3B8EC429B09B}.Release|x86.ActiveCfg = Release|Any CPU {44BAE6F1-94C2-415B-9A16-3B8EC429B09B}.Release|x86.Build.0 = Release|Any CPU - {44BAE6F1-94C2-415B-9A16-3B8EC429B09B}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {44BAE6F1-94C2-415B-9A16-3B8EC429B09B}.Checked|arm.ActiveCfg = Debug|Any CPU - {44BAE6F1-94C2-415B-9A16-3B8EC429B09B}.Checked|arm64.ActiveCfg = Debug|Any CPU - {44BAE6F1-94C2-415B-9A16-3B8EC429B09B}.Checked|x64.ActiveCfg = Debug|Any CPU - {44BAE6F1-94C2-415B-9A16-3B8EC429B09B}.Checked|x86.ActiveCfg = Debug|Any CPU + {1EB2EBE2-12EA-4545-B390-098F083329A1}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {1EB2EBE2-12EA-4545-B390-098F083329A1}.Checked|arm.ActiveCfg = Debug|Any CPU + {1EB2EBE2-12EA-4545-B390-098F083329A1}.Checked|arm64.ActiveCfg = Debug|Any CPU + {1EB2EBE2-12EA-4545-B390-098F083329A1}.Checked|x64.ActiveCfg = Debug|Any CPU + {1EB2EBE2-12EA-4545-B390-098F083329A1}.Checked|x86.ActiveCfg = Debug|Any CPU {1EB2EBE2-12EA-4545-B390-098F083329A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1EB2EBE2-12EA-4545-B390-098F083329A1}.Debug|Any CPU.Build.0 = Debug|Any CPU {1EB2EBE2-12EA-4545-B390-098F083329A1}.Debug|arm.ActiveCfg = Debug|Any CPU @@ -543,11 +552,11 @@ Global {1EB2EBE2-12EA-4545-B390-098F083329A1}.Release|x64.Build.0 = Release|Any CPU {1EB2EBE2-12EA-4545-B390-098F083329A1}.Release|x86.ActiveCfg = Release|Any CPU {1EB2EBE2-12EA-4545-B390-098F083329A1}.Release|x86.Build.0 = Release|Any CPU - {1EB2EBE2-12EA-4545-B390-098F083329A1}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {1EB2EBE2-12EA-4545-B390-098F083329A1}.Checked|arm.ActiveCfg = Debug|Any CPU - {1EB2EBE2-12EA-4545-B390-098F083329A1}.Checked|arm64.ActiveCfg = Debug|Any CPU - {1EB2EBE2-12EA-4545-B390-098F083329A1}.Checked|x64.ActiveCfg = Debug|Any CPU - {1EB2EBE2-12EA-4545-B390-098F083329A1}.Checked|x86.ActiveCfg = Debug|Any CPU + {B18C5A3A-CAB0-4B62-9C01-7A046E05089F}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {B18C5A3A-CAB0-4B62-9C01-7A046E05089F}.Checked|arm.ActiveCfg = Debug|Any CPU + {B18C5A3A-CAB0-4B62-9C01-7A046E05089F}.Checked|arm64.ActiveCfg = Debug|Any CPU + {B18C5A3A-CAB0-4B62-9C01-7A046E05089F}.Checked|x64.ActiveCfg = Debug|Any CPU + {B18C5A3A-CAB0-4B62-9C01-7A046E05089F}.Checked|x86.ActiveCfg = Debug|Any CPU {B18C5A3A-CAB0-4B62-9C01-7A046E05089F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B18C5A3A-CAB0-4B62-9C01-7A046E05089F}.Debug|Any CPU.Build.0 = Debug|Any CPU {B18C5A3A-CAB0-4B62-9C01-7A046E05089F}.Debug|arm.ActiveCfg = Debug|Any CPU @@ -564,11 +573,11 @@ Global {B18C5A3A-CAB0-4B62-9C01-7A046E05089F}.Release|x64.Build.0 = Release|Any CPU {B18C5A3A-CAB0-4B62-9C01-7A046E05089F}.Release|x86.ActiveCfg = Release|Any CPU {B18C5A3A-CAB0-4B62-9C01-7A046E05089F}.Release|x86.Build.0 = Release|Any CPU - {B18C5A3A-CAB0-4B62-9C01-7A046E05089F}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {B18C5A3A-CAB0-4B62-9C01-7A046E05089F}.Checked|arm.ActiveCfg = Debug|Any CPU - {B18C5A3A-CAB0-4B62-9C01-7A046E05089F}.Checked|arm64.ActiveCfg = Debug|Any CPU - {B18C5A3A-CAB0-4B62-9C01-7A046E05089F}.Checked|x64.ActiveCfg = Debug|Any CPU - {B18C5A3A-CAB0-4B62-9C01-7A046E05089F}.Checked|x86.ActiveCfg = Debug|Any CPU + {04A40E6C-DD10-473D-AFF8-9033E936DC46}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {04A40E6C-DD10-473D-AFF8-9033E936DC46}.Checked|arm.ActiveCfg = Debug|Any CPU + {04A40E6C-DD10-473D-AFF8-9033E936DC46}.Checked|arm64.ActiveCfg = Debug|Any CPU + {04A40E6C-DD10-473D-AFF8-9033E936DC46}.Checked|x64.ActiveCfg = Debug|Any CPU + {04A40E6C-DD10-473D-AFF8-9033E936DC46}.Checked|x86.ActiveCfg = Debug|Any CPU {04A40E6C-DD10-473D-AFF8-9033E936DC46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {04A40E6C-DD10-473D-AFF8-9033E936DC46}.Debug|Any CPU.Build.0 = Debug|Any CPU {04A40E6C-DD10-473D-AFF8-9033E936DC46}.Debug|arm.ActiveCfg = Debug|Any CPU @@ -585,11 +594,11 @@ Global {04A40E6C-DD10-473D-AFF8-9033E936DC46}.Release|x64.Build.0 = Release|Any CPU {04A40E6C-DD10-473D-AFF8-9033E936DC46}.Release|x86.ActiveCfg = Release|Any CPU {04A40E6C-DD10-473D-AFF8-9033E936DC46}.Release|x86.Build.0 = Release|Any CPU - {04A40E6C-DD10-473D-AFF8-9033E936DC46}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {04A40E6C-DD10-473D-AFF8-9033E936DC46}.Checked|arm.ActiveCfg = Debug|Any CPU - {04A40E6C-DD10-473D-AFF8-9033E936DC46}.Checked|arm64.ActiveCfg = Debug|Any CPU - {04A40E6C-DD10-473D-AFF8-9033E936DC46}.Checked|x64.ActiveCfg = Debug|Any CPU - {04A40E6C-DD10-473D-AFF8-9033E936DC46}.Checked|x86.ActiveCfg = Debug|Any CPU + {B86E4599-88CF-4662-96BA-3FCB926D0BA1}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {B86E4599-88CF-4662-96BA-3FCB926D0BA1}.Checked|arm.ActiveCfg = Debug|Any CPU + {B86E4599-88CF-4662-96BA-3FCB926D0BA1}.Checked|arm64.ActiveCfg = Debug|Any CPU + {B86E4599-88CF-4662-96BA-3FCB926D0BA1}.Checked|x64.ActiveCfg = Debug|Any CPU + {B86E4599-88CF-4662-96BA-3FCB926D0BA1}.Checked|x86.ActiveCfg = Debug|Any CPU {B86E4599-88CF-4662-96BA-3FCB926D0BA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B86E4599-88CF-4662-96BA-3FCB926D0BA1}.Debug|Any CPU.Build.0 = Debug|Any CPU {B86E4599-88CF-4662-96BA-3FCB926D0BA1}.Debug|arm.ActiveCfg = Debug|Any CPU @@ -606,11 +615,11 @@ Global {B86E4599-88CF-4662-96BA-3FCB926D0BA1}.Release|x64.Build.0 = Release|Any CPU {B86E4599-88CF-4662-96BA-3FCB926D0BA1}.Release|x86.ActiveCfg = Release|Any CPU {B86E4599-88CF-4662-96BA-3FCB926D0BA1}.Release|x86.Build.0 = Release|Any CPU - {B86E4599-88CF-4662-96BA-3FCB926D0BA1}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {B86E4599-88CF-4662-96BA-3FCB926D0BA1}.Checked|arm.ActiveCfg = Debug|Any CPU - {B86E4599-88CF-4662-96BA-3FCB926D0BA1}.Checked|arm64.ActiveCfg = Debug|Any CPU - {B86E4599-88CF-4662-96BA-3FCB926D0BA1}.Checked|x64.ActiveCfg = Debug|Any CPU - {B86E4599-88CF-4662-96BA-3FCB926D0BA1}.Checked|x86.ActiveCfg = Debug|Any CPU + {424A7718-F5B7-41FB-A74B-1E23A9BF13EA}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {424A7718-F5B7-41FB-A74B-1E23A9BF13EA}.Checked|arm.ActiveCfg = Debug|Any CPU + {424A7718-F5B7-41FB-A74B-1E23A9BF13EA}.Checked|arm64.ActiveCfg = Debug|Any CPU + {424A7718-F5B7-41FB-A74B-1E23A9BF13EA}.Checked|x64.ActiveCfg = Debug|Any CPU + {424A7718-F5B7-41FB-A74B-1E23A9BF13EA}.Checked|x86.ActiveCfg = Debug|Any CPU {424A7718-F5B7-41FB-A74B-1E23A9BF13EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {424A7718-F5B7-41FB-A74B-1E23A9BF13EA}.Debug|Any CPU.Build.0 = Debug|Any CPU {424A7718-F5B7-41FB-A74B-1E23A9BF13EA}.Debug|arm.ActiveCfg = Debug|Any CPU @@ -627,11 +636,11 @@ Global {424A7718-F5B7-41FB-A74B-1E23A9BF13EA}.Release|x64.Build.0 = Release|Any CPU {424A7718-F5B7-41FB-A74B-1E23A9BF13EA}.Release|x86.ActiveCfg = Release|Any CPU {424A7718-F5B7-41FB-A74B-1E23A9BF13EA}.Release|x86.Build.0 = Release|Any CPU - {424A7718-F5B7-41FB-A74B-1E23A9BF13EA}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {424A7718-F5B7-41FB-A74B-1E23A9BF13EA}.Checked|arm.ActiveCfg = Debug|Any CPU - {424A7718-F5B7-41FB-A74B-1E23A9BF13EA}.Checked|arm64.ActiveCfg = Debug|Any CPU - {424A7718-F5B7-41FB-A74B-1E23A9BF13EA}.Checked|x64.ActiveCfg = Debug|Any CPU - {424A7718-F5B7-41FB-A74B-1E23A9BF13EA}.Checked|x86.ActiveCfg = Debug|Any CPU + {D620CBA3-326B-4E4A-81C2-3D9E9258E45C}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {D620CBA3-326B-4E4A-81C2-3D9E9258E45C}.Checked|arm.ActiveCfg = Debug|Any CPU + {D620CBA3-326B-4E4A-81C2-3D9E9258E45C}.Checked|arm64.ActiveCfg = Debug|Any CPU + {D620CBA3-326B-4E4A-81C2-3D9E9258E45C}.Checked|x64.ActiveCfg = Debug|Any CPU + {D620CBA3-326B-4E4A-81C2-3D9E9258E45C}.Checked|x86.ActiveCfg = Debug|Any CPU {D620CBA3-326B-4E4A-81C2-3D9E9258E45C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D620CBA3-326B-4E4A-81C2-3D9E9258E45C}.Debug|Any CPU.Build.0 = Debug|Any CPU {D620CBA3-326B-4E4A-81C2-3D9E9258E45C}.Debug|arm.ActiveCfg = Debug|Any CPU @@ -648,11 +657,11 @@ Global {D620CBA3-326B-4E4A-81C2-3D9E9258E45C}.Release|x64.Build.0 = Release|Any CPU {D620CBA3-326B-4E4A-81C2-3D9E9258E45C}.Release|x86.ActiveCfg = Release|Any CPU {D620CBA3-326B-4E4A-81C2-3D9E9258E45C}.Release|x86.Build.0 = Release|Any CPU - {D620CBA3-326B-4E4A-81C2-3D9E9258E45C}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {D620CBA3-326B-4E4A-81C2-3D9E9258E45C}.Checked|arm.ActiveCfg = Debug|Any CPU - {D620CBA3-326B-4E4A-81C2-3D9E9258E45C}.Checked|arm64.ActiveCfg = Debug|Any CPU - {D620CBA3-326B-4E4A-81C2-3D9E9258E45C}.Checked|x64.ActiveCfg = Debug|Any CPU - {D620CBA3-326B-4E4A-81C2-3D9E9258E45C}.Checked|x86.ActiveCfg = Debug|Any CPU + {8683B814-5459-4412-A881-ECAFF9ED1781}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {8683B814-5459-4412-A881-ECAFF9ED1781}.Checked|arm.ActiveCfg = Debug|Any CPU + {8683B814-5459-4412-A881-ECAFF9ED1781}.Checked|arm64.ActiveCfg = Debug|Any CPU + {8683B814-5459-4412-A881-ECAFF9ED1781}.Checked|x64.ActiveCfg = Debug|Any CPU + {8683B814-5459-4412-A881-ECAFF9ED1781}.Checked|x86.ActiveCfg = Debug|Any CPU {8683B814-5459-4412-A881-ECAFF9ED1781}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8683B814-5459-4412-A881-ECAFF9ED1781}.Debug|Any CPU.Build.0 = Debug|Any CPU {8683B814-5459-4412-A881-ECAFF9ED1781}.Debug|arm.ActiveCfg = Debug|Any CPU @@ -669,11 +678,11 @@ Global {8683B814-5459-4412-A881-ECAFF9ED1781}.Release|x64.Build.0 = Release|Any CPU {8683B814-5459-4412-A881-ECAFF9ED1781}.Release|x86.ActiveCfg = Release|Any CPU {8683B814-5459-4412-A881-ECAFF9ED1781}.Release|x86.Build.0 = Release|Any CPU - {8683B814-5459-4412-A881-ECAFF9ED1781}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {8683B814-5459-4412-A881-ECAFF9ED1781}.Checked|arm.ActiveCfg = Debug|Any CPU - {8683B814-5459-4412-A881-ECAFF9ED1781}.Checked|arm64.ActiveCfg = Debug|Any CPU - {8683B814-5459-4412-A881-ECAFF9ED1781}.Checked|x64.ActiveCfg = Debug|Any CPU - {8683B814-5459-4412-A881-ECAFF9ED1781}.Checked|x86.ActiveCfg = Debug|Any CPU + {4D8B7538-D933-4F3A-818D-4E19ABA7E182}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {4D8B7538-D933-4F3A-818D-4E19ABA7E182}.Checked|arm.ActiveCfg = Debug|Any CPU + {4D8B7538-D933-4F3A-818D-4E19ABA7E182}.Checked|arm64.ActiveCfg = Debug|Any CPU + {4D8B7538-D933-4F3A-818D-4E19ABA7E182}.Checked|x64.ActiveCfg = Debug|Any CPU + {4D8B7538-D933-4F3A-818D-4E19ABA7E182}.Checked|x86.ActiveCfg = Debug|Any CPU {4D8B7538-D933-4F3A-818D-4E19ABA7E182}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4D8B7538-D933-4F3A-818D-4E19ABA7E182}.Debug|Any CPU.Build.0 = Debug|Any CPU {4D8B7538-D933-4F3A-818D-4E19ABA7E182}.Debug|arm.ActiveCfg = Debug|Any CPU @@ -690,11 +699,11 @@ Global {4D8B7538-D933-4F3A-818D-4E19ABA7E182}.Release|x64.Build.0 = Release|Any CPU {4D8B7538-D933-4F3A-818D-4E19ABA7E182}.Release|x86.ActiveCfg = Release|Any CPU {4D8B7538-D933-4F3A-818D-4E19ABA7E182}.Release|x86.Build.0 = Release|Any CPU - {4D8B7538-D933-4F3A-818D-4E19ABA7E182}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {4D8B7538-D933-4F3A-818D-4E19ABA7E182}.Checked|arm.ActiveCfg = Debug|Any CPU - {4D8B7538-D933-4F3A-818D-4E19ABA7E182}.Checked|arm64.ActiveCfg = Debug|Any CPU - {4D8B7538-D933-4F3A-818D-4E19ABA7E182}.Checked|x64.ActiveCfg = Debug|Any CPU - {4D8B7538-D933-4F3A-818D-4E19ABA7E182}.Checked|x86.ActiveCfg = Debug|Any CPU + {6C60944F-4FE1-450F-884B-D523EDFCFAB3}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {6C60944F-4FE1-450F-884B-D523EDFCFAB3}.Checked|arm.ActiveCfg = Debug|Any CPU + {6C60944F-4FE1-450F-884B-D523EDFCFAB3}.Checked|arm64.ActiveCfg = Debug|Any CPU + {6C60944F-4FE1-450F-884B-D523EDFCFAB3}.Checked|x64.ActiveCfg = Debug|Any CPU + {6C60944F-4FE1-450F-884B-D523EDFCFAB3}.Checked|x86.ActiveCfg = Debug|Any CPU {6C60944F-4FE1-450F-884B-D523EDFCFAB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6C60944F-4FE1-450F-884B-D523EDFCFAB3}.Debug|Any CPU.Build.0 = Debug|Any CPU {6C60944F-4FE1-450F-884B-D523EDFCFAB3}.Debug|arm.ActiveCfg = Debug|Any CPU @@ -711,11 +720,11 @@ Global {6C60944F-4FE1-450F-884B-D523EDFCFAB3}.Release|x64.Build.0 = Release|Any CPU {6C60944F-4FE1-450F-884B-D523EDFCFAB3}.Release|x86.ActiveCfg = Release|Any CPU {6C60944F-4FE1-450F-884B-D523EDFCFAB3}.Release|x86.Build.0 = Release|Any CPU - {6C60944F-4FE1-450F-884B-D523EDFCFAB3}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {6C60944F-4FE1-450F-884B-D523EDFCFAB3}.Checked|arm.ActiveCfg = Debug|Any CPU - {6C60944F-4FE1-450F-884B-D523EDFCFAB3}.Checked|arm64.ActiveCfg = Debug|Any CPU - {6C60944F-4FE1-450F-884B-D523EDFCFAB3}.Checked|x64.ActiveCfg = Debug|Any CPU - {6C60944F-4FE1-450F-884B-D523EDFCFAB3}.Checked|x86.ActiveCfg = Debug|Any CPU + {B8F2E56D-6571-466D-9EF2-9FCAD3FC6E5B}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {B8F2E56D-6571-466D-9EF2-9FCAD3FC6E5B}.Checked|arm.ActiveCfg = Debug|Any CPU + {B8F2E56D-6571-466D-9EF2-9FCAD3FC6E5B}.Checked|arm64.ActiveCfg = Debug|Any CPU + {B8F2E56D-6571-466D-9EF2-9FCAD3FC6E5B}.Checked|x64.ActiveCfg = Debug|Any CPU + {B8F2E56D-6571-466D-9EF2-9FCAD3FC6E5B}.Checked|x86.ActiveCfg = Debug|Any CPU {B8F2E56D-6571-466D-9EF2-9FCAD3FC6E5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B8F2E56D-6571-466D-9EF2-9FCAD3FC6E5B}.Debug|Any CPU.Build.0 = Debug|Any CPU {B8F2E56D-6571-466D-9EF2-9FCAD3FC6E5B}.Debug|arm.ActiveCfg = Debug|Any CPU @@ -732,11 +741,11 @@ Global {B8F2E56D-6571-466D-9EF2-9FCAD3FC6E5B}.Release|x64.Build.0 = Release|Any CPU {B8F2E56D-6571-466D-9EF2-9FCAD3FC6E5B}.Release|x86.ActiveCfg = Release|Any CPU {B8F2E56D-6571-466D-9EF2-9FCAD3FC6E5B}.Release|x86.Build.0 = Release|Any CPU - {B8F2E56D-6571-466D-9EF2-9FCAD3FC6E5B}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {B8F2E56D-6571-466D-9EF2-9FCAD3FC6E5B}.Checked|arm.ActiveCfg = Debug|Any CPU - {B8F2E56D-6571-466D-9EF2-9FCAD3FC6E5B}.Checked|arm64.ActiveCfg = Debug|Any CPU - {B8F2E56D-6571-466D-9EF2-9FCAD3FC6E5B}.Checked|x64.ActiveCfg = Debug|Any CPU - {B8F2E56D-6571-466D-9EF2-9FCAD3FC6E5B}.Checked|x86.ActiveCfg = Debug|Any CPU + {42F9A600-BEC3-4F87-97EE-38E0DCAABC5A}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {42F9A600-BEC3-4F87-97EE-38E0DCAABC5A}.Checked|arm.ActiveCfg = Debug|Any CPU + {42F9A600-BEC3-4F87-97EE-38E0DCAABC5A}.Checked|arm64.ActiveCfg = Debug|Any CPU + {42F9A600-BEC3-4F87-97EE-38E0DCAABC5A}.Checked|x64.ActiveCfg = Debug|Any CPU + {42F9A600-BEC3-4F87-97EE-38E0DCAABC5A}.Checked|x86.ActiveCfg = Debug|Any CPU {42F9A600-BEC3-4F87-97EE-38E0DCAABC5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {42F9A600-BEC3-4F87-97EE-38E0DCAABC5A}.Debug|Any CPU.Build.0 = Debug|Any CPU {42F9A600-BEC3-4F87-97EE-38E0DCAABC5A}.Debug|arm.ActiveCfg = Debug|Any CPU @@ -753,11 +762,11 @@ Global {42F9A600-BEC3-4F87-97EE-38E0DCAABC5A}.Release|x64.Build.0 = Release|Any CPU {42F9A600-BEC3-4F87-97EE-38E0DCAABC5A}.Release|x86.ActiveCfg = Release|Any CPU {42F9A600-BEC3-4F87-97EE-38E0DCAABC5A}.Release|x86.Build.0 = Release|Any CPU - {42F9A600-BEC3-4F87-97EE-38E0DCAABC5A}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {42F9A600-BEC3-4F87-97EE-38E0DCAABC5A}.Checked|arm.ActiveCfg = Debug|Any CPU - {42F9A600-BEC3-4F87-97EE-38E0DCAABC5A}.Checked|arm64.ActiveCfg = Debug|Any CPU - {42F9A600-BEC3-4F87-97EE-38E0DCAABC5A}.Checked|x64.ActiveCfg = Debug|Any CPU - {42F9A600-BEC3-4F87-97EE-38E0DCAABC5A}.Checked|x86.ActiveCfg = Debug|Any CPU + {008873D5-9028-4FF3-8354-71F713748625}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {008873D5-9028-4FF3-8354-71F713748625}.Checked|arm.ActiveCfg = Debug|Any CPU + {008873D5-9028-4FF3-8354-71F713748625}.Checked|arm64.ActiveCfg = Debug|Any CPU + {008873D5-9028-4FF3-8354-71F713748625}.Checked|x64.ActiveCfg = Debug|Any CPU + {008873D5-9028-4FF3-8354-71F713748625}.Checked|x86.ActiveCfg = Debug|Any CPU {008873D5-9028-4FF3-8354-71F713748625}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {008873D5-9028-4FF3-8354-71F713748625}.Debug|Any CPU.Build.0 = Debug|Any CPU {008873D5-9028-4FF3-8354-71F713748625}.Debug|arm.ActiveCfg = Debug|Any CPU @@ -774,53 +783,53 @@ Global {008873D5-9028-4FF3-8354-71F713748625}.Release|x64.Build.0 = Release|Any CPU {008873D5-9028-4FF3-8354-71F713748625}.Release|x86.ActiveCfg = Release|Any CPU {008873D5-9028-4FF3-8354-71F713748625}.Release|x86.Build.0 = Release|Any CPU - {008873D5-9028-4FF3-8354-71F713748625}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {008873D5-9028-4FF3-8354-71F713748625}.Checked|arm.ActiveCfg = Debug|Any CPU - {008873D5-9028-4FF3-8354-71F713748625}.Checked|arm64.ActiveCfg = Debug|Any CPU - {008873D5-9028-4FF3-8354-71F713748625}.Checked|x64.ActiveCfg = Debug|Any CPU - {008873D5-9028-4FF3-8354-71F713748625}.Checked|x86.ActiveCfg = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {0F7BA062-C34C-41A8-840F-F0B074B18686} = {D819DEB6-6F6B-484B-9F0F-BDBCEDC83A1A} + {ED86AB26-1CFB-457D-BF87-B7A0D8FAF272} = {26A72FFB-871A-4F2F-A513-B2F6E09F358C} {FC1007CC-9E52-49B7-A47B-A8AE76E75986} = {D819DEB6-6F6B-484B-9F0F-BDBCEDC83A1A} + {8B1D80E9-AE0D-4E3C-9F91-E6862B49AEF3} = {32CDDDCD-5319-494C-AB41-42B87C467F04} {B79E5BB4-2595-48BC-A44C-0A7949AFBDEB} = {D819DEB6-6F6B-484B-9F0F-BDBCEDC83A1A} + {E00AE8BB-7C7F-4D07-949D-EDCC815AC8C8} = {32CDDDCD-5319-494C-AB41-42B87C467F04} {C1C606F3-A246-4EA0-A467-3AC4F31C2AFE} = {D819DEB6-6F6B-484B-9F0F-BDBCEDC83A1A} + {8CFB1155-26A2-43E3-B192-1F87D9E543AC} = {39B30F44-B141-44E9-B7A7-B1A9EDB1A61C} + {D549C13B-FC0D-4B5A-B50D-8F74CB5A3D08} = {32CDDDCD-5319-494C-AB41-42B87C467F04} {74143A5F-6987-4AB5-B786-DE358F01241B} = {D819DEB6-6F6B-484B-9F0F-BDBCEDC83A1A} + {CE5E53C1-F9B5-41EE-8D00-837913EC57D1} = {39B30F44-B141-44E9-B7A7-B1A9EDB1A61C} + {28278E01-BF5C-4AB6-AA7A-8DD4E6C04DB1} = {32CDDDCD-5319-494C-AB41-42B87C467F04} {71A845ED-4344-41FC-8FCA-3AC9B6BA6C45} = {D819DEB6-6F6B-484B-9F0F-BDBCEDC83A1A} - {1EB2EBE2-12EA-4545-B390-098F083329A1} = {D819DEB6-6F6B-484B-9F0F-BDBCEDC83A1A} - {04A40E6C-DD10-473D-AFF8-9033E936DC46} = {D819DEB6-6F6B-484B-9F0F-BDBCEDC83A1A} - {424A7718-F5B7-41FB-A74B-1E23A9BF13EA} = {D819DEB6-6F6B-484B-9F0F-BDBCEDC83A1A} - {8683B814-5459-4412-A881-ECAFF9ED1781} = {D819DEB6-6F6B-484B-9F0F-BDBCEDC83A1A} - {ED86AB26-1CFB-457D-BF87-B7A0D8FAF272} = {26A72FFB-871A-4F2F-A513-B2F6E09F358C} {E6A30001-84E3-4C7A-9B56-B9DEA71B3CF9} = {26A72FFB-871A-4F2F-A513-B2F6E09F358C} {BFED925C-18F2-4C98-833E-66F205234598} = {26A72FFB-871A-4F2F-A513-B2F6E09F358C} {765B4AA5-723A-44FF-BC4E-EB0F03103F6D} = {26A72FFB-871A-4F2F-A513-B2F6E09F358C} + {09AA6758-0BD3-4312-9C07-AE9F1D50A3AD} = {39B30F44-B141-44E9-B7A7-B1A9EDB1A61C} + {B4E3E774-2C16-4CBF-87EF-88C547529B94} = {39B30F44-B141-44E9-B7A7-B1A9EDB1A61C} {EC3ADEFA-1FF3-482C-8CCB-FE4C77292532} = {26A72FFB-871A-4F2F-A513-B2F6E09F358C} - {8B1D80E9-AE0D-4E3C-9F91-E6862B49AEF3} = {32CDDDCD-5319-494C-AB41-42B87C467F04} - {E00AE8BB-7C7F-4D07-949D-EDCC815AC8C8} = {32CDDDCD-5319-494C-AB41-42B87C467F04} - {D549C13B-FC0D-4B5A-B50D-8F74CB5A3D08} = {32CDDDCD-5319-494C-AB41-42B87C467F04} - {28278E01-BF5C-4AB6-AA7A-8DD4E6C04DB1} = {32CDDDCD-5319-494C-AB41-42B87C467F04} {44BAE6F1-94C2-415B-9A16-3B8EC429B09B} = {32CDDDCD-5319-494C-AB41-42B87C467F04} + {1EB2EBE2-12EA-4545-B390-098F083329A1} = {D819DEB6-6F6B-484B-9F0F-BDBCEDC83A1A} {B18C5A3A-CAB0-4B62-9C01-7A046E05089F} = {32CDDDCD-5319-494C-AB41-42B87C467F04} + {04A40E6C-DD10-473D-AFF8-9033E936DC46} = {D819DEB6-6F6B-484B-9F0F-BDBCEDC83A1A} {B86E4599-88CF-4662-96BA-3FCB926D0BA1} = {32CDDDCD-5319-494C-AB41-42B87C467F04} + {424A7718-F5B7-41FB-A74B-1E23A9BF13EA} = {D819DEB6-6F6B-484B-9F0F-BDBCEDC83A1A} {D620CBA3-326B-4E4A-81C2-3D9E9258E45C} = {32CDDDCD-5319-494C-AB41-42B87C467F04} - {8CFB1155-26A2-43E3-B192-1F87D9E543AC} = {39B30F44-B141-44E9-B7A7-B1A9EDB1A61C} - {CE5E53C1-F9B5-41EE-8D00-837913EC57D1} = {39B30F44-B141-44E9-B7A7-B1A9EDB1A61C} - {09AA6758-0BD3-4312-9C07-AE9F1D50A3AD} = {39B30F44-B141-44E9-B7A7-B1A9EDB1A61C} - {B4E3E774-2C16-4CBF-87EF-88C547529B94} = {39B30F44-B141-44E9-B7A7-B1A9EDB1A61C} + {8683B814-5459-4412-A881-ECAFF9ED1781} = {D819DEB6-6F6B-484B-9F0F-BDBCEDC83A1A} {4D8B7538-D933-4F3A-818D-4E19ABA7E182} = {1A04C5D7-1DE9-47C3-BCC1-147678B9085F} {6C60944F-4FE1-450F-884B-D523EDFCFAB3} = {1A04C5D7-1DE9-47C3-BCC1-147678B9085F} - {1A04C5D7-1DE9-47C3-BCC1-147678B9085F} = {7392B838-42AF-4F54-AD02-366397DAF640} {B8F2E56D-6571-466D-9EF2-9FCAD3FC6E5B} = {32733782-56D6-4EAF-B94E-5D10C759DD57} {42F9A600-BEC3-4F87-97EE-38E0DCAABC5A} = {32733782-56D6-4EAF-B94E-5D10C759DD57} - {32733782-56D6-4EAF-B94E-5D10C759DD57} = {7392B838-42AF-4F54-AD02-366397DAF640} {008873D5-9028-4FF3-8354-71F713748625} = {19EA33B4-0E87-451F-95E3-8F3959117654} + {1A04C5D7-1DE9-47C3-BCC1-147678B9085F} = {7392B838-42AF-4F54-AD02-366397DAF640} + {32733782-56D6-4EAF-B94E-5D10C759DD57} = {7392B838-42AF-4F54-AD02-366397DAF640} {19EA33B4-0E87-451F-95E3-8F3959117654} = {7392B838-42AF-4F54-AD02-366397DAF640} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {3FE64246-4AFA-424A-AE5D-7007E20451B5} EndGlobalSection + GlobalSection(SharedMSBuildProjectFiles) = preSolution + ..\System.Private.CoreLib\src\System.Private.CoreLib.Shared.projitems*{0f7ba062-c34c-41a8-840f-f0b074b18686}*SharedItemsImports = 5 + ..\..\tools\illink\src\ILLink.Shared\ILLink.Shared.projitems*{42f9a600-bec3-4f87-97ee-38e0dcaabc5a}*SharedItemsImports = 5 + ..\..\tools\illink\src\ILLink.Shared\ILLink.Shared.projitems*{6c60944f-4fe1-450f-884b-d523edfcfab3}*SharedItemsImports = 5 + EndGlobalSection EndGlobal diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSExportCodeGenerator.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSExportCodeGenerator.cs index c370849700555..19d0315a0a0b0 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSExportCodeGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSExportCodeGenerator.cs @@ -16,7 +16,8 @@ internal sealed class JSExportCodeGenerator : JSCodeGenerator { private readonly BoundGenerators _marshallers; - private readonly JSExportCodeContext _context; + private readonly StubCodeContext _context; + private readonly JSExportData _jsExportData; private readonly JSSignatureContext _signatureContext; public JSExportCodeGenerator( @@ -27,30 +28,29 @@ public JSExportCodeGenerator( IMarshallingGeneratorResolver generatorResolver) { _signatureContext = signatureContext; - NativeToManagedStubCodeContext innerContext = new NativeToManagedStubCodeContext(ReturnIdentifier, ReturnIdentifier) + _jsExportData = attributeData; + _context = new NativeToManagedStubCodeContext(ReturnIdentifier, ReturnIdentifier) { CodeEmitOptions = new(SkipInit: true) }; - _context = new JSExportCodeContext(attributeData, innerContext); _marshallers = BoundGenerators.Create(argTypes, generatorResolver, _context, new EmptyJSGenerator(), out var bindingFailures); diagnosticsBag.ReportGeneratorDiagnostics(bindingFailures); - if (_marshallers.ManagedReturnMarshaller.Generator.UsesNativeIdentifier(_marshallers.ManagedReturnMarshaller.TypeInfo, null)) + if (_marshallers.ManagedReturnMarshaller.UsesNativeIdentifier(_context)) { // If we need a different native return identifier, then recreate the context with the correct identifier before we generate any code. - innerContext = new NativeToManagedStubCodeContext(ReturnIdentifier, ReturnNativeIdentifier) + _context = new NativeToManagedStubCodeContext(ReturnIdentifier, ReturnNativeIdentifier) { CodeEmitOptions = new(SkipInit: true) }; - _context = new JSExportCodeContext(attributeData, innerContext); } // validate task + span mix if (_marshallers.ManagedReturnMarshaller.TypeInfo.MarshallingAttributeInfo is JSMarshallingInfo(_, JSTaskTypeInfo)) { - BoundGenerator spanArg = _marshallers.SignatureMarshallers.FirstOrDefault(m => m.TypeInfo.MarshallingAttributeInfo is JSMarshallingInfo(_, JSSpanTypeInfo)); + IBoundMarshallingGenerator spanArg = _marshallers.SignatureMarshallers.FirstOrDefault(m => m.TypeInfo.MarshallingAttributeInfo is JSMarshallingInfo(_, JSSpanTypeInfo)); if (spanArg != default) { diagnosticsBag.ReportGeneratorDiagnostic(new GeneratorDiagnostic.NotSupported(spanArg.TypeInfo, _context) @@ -160,8 +160,9 @@ public StatementSyntax GenerateJSExportRegistration() private ArgumentSyntax CreateSignaturesSyntax() { - var types = ((IJSMarshallingGenerator)_marshallers.ManagedReturnMarshaller.Generator).GenerateBind(_marshallers.ManagedReturnMarshaller.TypeInfo, _context) - .Concat(_marshallers.NativeParameterMarshallers.SelectMany(p => ((IJSMarshallingGenerator)p.Generator).GenerateBind(p.TypeInfo, _context))); + IEnumerable types = _marshallers.ManagedReturnMarshaller is IJSMarshallingGenerator jsGen ? jsGen.GenerateBind(_context) : []; + types = types + .Concat(_marshallers.NativeParameterMarshallers.OfType().SelectMany(p => p.GenerateBind(_context))); return Argument(ArrayCreationExpression(ArrayType(IdentifierName(Constants.JSMarshalerTypeGlobal)) .WithRankSpecifiers(SingletonList(ArrayRankSpecifier(SingletonSeparatedList(OmittedArraySizeExpression()))))) @@ -170,7 +171,7 @@ private ArgumentSyntax CreateSignaturesSyntax() private void SetupSyntax(List statementsToUpdate) { - foreach (BoundGenerator marshaller in _marshallers.NativeParameterMarshallers) + foreach (IBoundMarshallingGenerator marshaller in _marshallers.NativeParameterMarshallers) { statementsToUpdate.Add(LocalDeclarationStatement(VariableDeclaration(marshaller.TypeInfo.ManagedType.Syntax) .WithVariables(SingletonSeparatedList(VariableDeclarator(marshaller.TypeInfo.InstanceIdentifier))))); @@ -195,10 +196,10 @@ private List InvokeSyntax() var arguments = new List(); // Generate code for each parameter for the current stage - foreach (BoundGenerator marshaller in _marshallers.NativeParameterMarshallers) + foreach (IBoundMarshallingGenerator marshaller in _marshallers.NativeParameterMarshallers) { // convert arguments for invocation - statements.AddRange(marshaller.Generator.Generate(marshaller.TypeInfo, _context)); + statements.AddRange(marshaller.Generate(_context)); arguments.Add(Argument(IdentifierName(marshaller.TypeInfo.InstanceIdentifier))); } diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSExportGenerator.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSExportGenerator.cs index 9925f2c86be85..824bc6b6d6c05 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSExportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSExportGenerator.cs @@ -119,13 +119,15 @@ public void Initialize(IncrementalGeneratorInitializationContext context) StringBuilder source = new(); // Mark in source that the file is auto-generated. - source.AppendLine("// "); + source.Append("// \r\n"); // this is the assembly level registration - source.AppendLine(generatedSources[0].Item2); + source.Append(generatedSources[0].Item2); + source.Append("\r\n"); // this is the method wrappers to be called from JS foreach (var generated in generatedSources) { - source.AppendLine(generated.Item1); + source.Append(generated.Item1); + source.Append("\r\n"); } // Once https://github.com/dotnet/roslyn/issues/61326 is resolved, we can avoid the ToString() here. diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSGeneratorFactory.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSGeneratorFactory.cs index 16f2dda426a1c..dd9cc9eb56ec6 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSGeneratorFactory.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSGeneratorFactory.cs @@ -19,7 +19,7 @@ public ResolvedGenerator Create(TypePositionInfo info, StubCodeContext context) if (info.IsByRef || info.ByValueContentsMarshalKind != ByValueContentsMarshalKind.Default) { // out of scope for Net7.0 - return ResolvedGenerator.NotSupported(new(info, context) + return ResolvedGenerator.NotSupported(info, new(info, context) { NotSupportedDetails = SR.InOutRefNotSupported }); @@ -28,27 +28,27 @@ public ResolvedGenerator Create(TypePositionInfo info, StubCodeContext context) ResolvedGenerator fail(string failReason) { - return ResolvedGenerator.NotSupported(new(info, context) + return ResolvedGenerator.NotSupported(info, new(info, context) { NotSupportedDetails = failReason }); } - bool isToJs = info.ManagedIndex != TypePositionInfo.ReturnIndex ^ context is JSExportCodeContext; + bool isToJs = info.ManagedIndex != TypePositionInfo.ReturnIndex ^ context.Direction == MarshalDirection.UnmanagedToManaged; switch (jsMarshalingInfo) { // invalid case { TypeInfo: JSInvalidTypeInfo }: - return ResolvedGenerator.NotSupported(new(info, context)); + return ResolvedGenerator.NotSupported(info, new(info, context)); // void case { TypeInfo: JSSimpleTypeInfo(KnownManagedType.Void), JSType: JSTypeFlags.DiscardNoWait }: - return ResolvedGenerator.Resolved(new VoidGenerator(MarshalerType.DiscardNoWait)); + return ResolvedGenerator.Resolved(new VoidGenerator(info, MarshalerType.DiscardNoWait)); case { TypeInfo: JSSimpleTypeInfo(KnownManagedType.Void), JSType: JSTypeFlags.Discard }: case { TypeInfo: JSSimpleTypeInfo(KnownManagedType.Void), JSType: JSTypeFlags.Void }: case { TypeInfo: JSSimpleTypeInfo(KnownManagedType.Void), JSType: JSTypeFlags.None }: case { TypeInfo: JSSimpleTypeInfo(KnownManagedType.Void), JSType: JSTypeFlags.Missing }: - return ResolvedGenerator.Resolved(new VoidGenerator(jsMarshalingInfo.JSType == JSTypeFlags.Void ? MarshalerType.Void : MarshalerType.Discard)); + return ResolvedGenerator.Resolved(new VoidGenerator(info, jsMarshalingInfo.JSType == JSTypeFlags.Void ? MarshalerType.Void : MarshalerType.Discard)); // discard no void case { JSType: JSTypeFlags.Discard }: @@ -89,7 +89,7 @@ ResolvedGenerator fail(string failReason) return Create(info, isToJs, function.KnownType, function.ArgsTypeInfo.Select(a => a.KnownType).ToArray(), jsMarshalingInfo.JSType, jsMarshalingInfo.JSTypeArguments, fail); default: - return ResolvedGenerator.NotSupported(new(info, context)); + return ResolvedGenerator.NotSupported(info, new(info, context)); } } @@ -98,35 +98,35 @@ internal static ResolvedGenerator Create(TypePositionInfo info, bool isToJs, Kno switch (marshaledType) { // primitive - case KnownManagedType.Boolean when jsType == JSTypeFlags.Boolean: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(MarshalerType.Boolean)); - case KnownManagedType.Byte when jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(MarshalerType.Byte)); - case KnownManagedType.Char when jsType == JSTypeFlags.String: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(MarshalerType.Char)); - case KnownManagedType.Int16 when jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(MarshalerType.Int16)); - case KnownManagedType.Int32 when jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(MarshalerType.Int32)); - case KnownManagedType.Int64 when jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(MarshalerType.Int52)); - case KnownManagedType.Int64 when jsType == JSTypeFlags.BigInt: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(MarshalerType.BigInt64)); - case KnownManagedType.Single when jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(MarshalerType.Single)); - case KnownManagedType.Double when jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(MarshalerType.Double)); - case KnownManagedType.IntPtr when jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(MarshalerType.IntPtr)); - case KnownManagedType.DateTime when jsType == JSTypeFlags.Date: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(MarshalerType.DateTime)); - case KnownManagedType.DateTimeOffset when jsType == JSTypeFlags.Date: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(MarshalerType.DateTimeOffset)); - case KnownManagedType.Exception when jsType == JSTypeFlags.Error: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(MarshalerType.Exception)); - case KnownManagedType.JSObject when jsType == JSTypeFlags.Object: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(MarshalerType.JSObject)); - case KnownManagedType.String when jsType == JSTypeFlags.String: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(MarshalerType.String)); - case KnownManagedType.Object when jsType == JSTypeFlags.Any: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(MarshalerType.Object)); + case KnownManagedType.Boolean when jsType == JSTypeFlags.Boolean: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, MarshalerType.Boolean)); + case KnownManagedType.Byte when jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, MarshalerType.Byte)); + case KnownManagedType.Char when jsType == JSTypeFlags.String: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, MarshalerType.Char)); + case KnownManagedType.Int16 when jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, MarshalerType.Int16)); + case KnownManagedType.Int32 when jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, MarshalerType.Int32)); + case KnownManagedType.Int64 when jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, MarshalerType.Int52)); + case KnownManagedType.Int64 when jsType == JSTypeFlags.BigInt: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, MarshalerType.BigInt64)); + case KnownManagedType.Single when jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, MarshalerType.Single)); + case KnownManagedType.Double when jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, MarshalerType.Double)); + case KnownManagedType.IntPtr when jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, MarshalerType.IntPtr)); + case KnownManagedType.DateTime when jsType == JSTypeFlags.Date: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, MarshalerType.DateTime)); + case KnownManagedType.DateTimeOffset when jsType == JSTypeFlags.Date: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, MarshalerType.DateTimeOffset)); + case KnownManagedType.Exception when jsType == JSTypeFlags.Error: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, MarshalerType.Exception)); + case KnownManagedType.JSObject when jsType == JSTypeFlags.Object: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, MarshalerType.JSObject)); + case KnownManagedType.String when jsType == JSTypeFlags.String: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, MarshalerType.String)); + case KnownManagedType.Object when jsType == JSTypeFlags.Any: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, MarshalerType.Object)); // primitive missing - case KnownManagedType.Boolean when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(MarshalerType.Boolean)); - case KnownManagedType.Byte when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(MarshalerType.Byte)); - case KnownManagedType.Char when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(MarshalerType.Char)); - case KnownManagedType.Int16 when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(MarshalerType.Int16)); - case KnownManagedType.Int32 when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(MarshalerType.Int32)); - case KnownManagedType.Single when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(MarshalerType.Single)); - case KnownManagedType.Double when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(MarshalerType.Double)); - case KnownManagedType.IntPtr when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(MarshalerType.IntPtr)); - case KnownManagedType.Exception when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(MarshalerType.Exception)); - case KnownManagedType.JSObject when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(MarshalerType.JSObject)); - case KnownManagedType.String when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(MarshalerType.String)); + case KnownManagedType.Boolean when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, MarshalerType.Boolean)); + case KnownManagedType.Byte when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, MarshalerType.Byte)); + case KnownManagedType.Char when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, MarshalerType.Char)); + case KnownManagedType.Int16 when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, MarshalerType.Int16)); + case KnownManagedType.Int32 when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, MarshalerType.Int32)); + case KnownManagedType.Single when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, MarshalerType.Single)); + case KnownManagedType.Double when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, MarshalerType.Double)); + case KnownManagedType.IntPtr when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, MarshalerType.IntPtr)); + case KnownManagedType.Exception when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, MarshalerType.Exception)); + case KnownManagedType.JSObject when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, MarshalerType.JSObject)); + case KnownManagedType.String when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, MarshalerType.String)); // primitive forced case KnownManagedType.Int64 when jsType == JSTypeFlags.Missing: @@ -136,28 +136,28 @@ internal static ResolvedGenerator Create(TypePositionInfo info, bool isToJs, Kno return failWithReason(SR.Format(SR.UseJSMarshalAsAttribute, info.ManagedType.FullTypeName)); // nullable - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Boolean && jsType == JSTypeFlags.Boolean: return ResolvedGenerator.Resolved(new NullableJSGenerator(MarshalerType.Boolean)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Byte && jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new NullableJSGenerator(MarshalerType.Byte)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Char && jsType == JSTypeFlags.String: return ResolvedGenerator.Resolved(new NullableJSGenerator(MarshalerType.Byte)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Int16 && jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new NullableJSGenerator(MarshalerType.Int16)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Int32 && jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new NullableJSGenerator(MarshalerType.Int32)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Int64 && jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new NullableJSGenerator(MarshalerType.Int52)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Int64 && jsType == JSTypeFlags.BigInt: return ResolvedGenerator.Resolved(new NullableJSGenerator(MarshalerType.BigInt64)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Double && jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new NullableJSGenerator(MarshalerType.Double)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Single && jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new NullableJSGenerator(MarshalerType.Single)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.IntPtr && jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new NullableJSGenerator(MarshalerType.IntPtr)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.DateTime && jsType == JSTypeFlags.Date: return ResolvedGenerator.Resolved(new NullableJSGenerator(MarshalerType.DateTime)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.DateTimeOffset && jsType == JSTypeFlags.Date: return ResolvedGenerator.Resolved(new NullableJSGenerator(MarshalerType.DateTimeOffset)); + case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Boolean && jsType == JSTypeFlags.Boolean: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, MarshalerType.Boolean)); + case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Byte && jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, MarshalerType.Byte)); + case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Char && jsType == JSTypeFlags.String: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, MarshalerType.Byte)); + case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Int16 && jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, MarshalerType.Int16)); + case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Int32 && jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, MarshalerType.Int32)); + case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Int64 && jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, MarshalerType.Int52)); + case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Int64 && jsType == JSTypeFlags.BigInt: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, MarshalerType.BigInt64)); + case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Double && jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, MarshalerType.Double)); + case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Single && jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, MarshalerType.Single)); + case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.IntPtr && jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, MarshalerType.IntPtr)); + case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.DateTime && jsType == JSTypeFlags.Date: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, MarshalerType.DateTime)); + case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.DateTimeOffset && jsType == JSTypeFlags.Date: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, MarshalerType.DateTimeOffset)); // nullable missing - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Boolean && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new NullableJSGenerator(MarshalerType.Boolean)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Byte && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new NullableJSGenerator(MarshalerType.Byte)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Char && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new NullableJSGenerator(MarshalerType.Byte)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Int16 && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new NullableJSGenerator(MarshalerType.Int16)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Int32 && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new NullableJSGenerator(MarshalerType.Int32)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Single && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new NullableJSGenerator(MarshalerType.Single)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Double && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new NullableJSGenerator(MarshalerType.Double)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.IntPtr && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new NullableJSGenerator(MarshalerType.IntPtr)); + case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Boolean && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, MarshalerType.Boolean)); + case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Byte && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, MarshalerType.Byte)); + case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Char && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, MarshalerType.Byte)); + case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Int16 && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, MarshalerType.Int16)); + case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Int32 && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, MarshalerType.Int32)); + case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Single && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, MarshalerType.Single)); + case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Double && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, MarshalerType.Double)); + case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.IntPtr && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, MarshalerType.IntPtr)); // nullable forced case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Int64 && jsType == JSTypeFlags.Missing: @@ -169,37 +169,37 @@ internal static ResolvedGenerator Create(TypePositionInfo info, bool isToJs, Kno return failWithReason(SR.Format(SR.TypeNotSupportedName, info.ManagedType.FullTypeName)); // task - case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes.Length == 0 && jsTypeArguments[0] == JSTypeFlags.Void: return ResolvedGenerator.Resolved(new TaskJSGenerator(MarshalerType.Void)); - case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.Byte && jsTypeArguments[0] == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new TaskJSGenerator(MarshalerType.Byte)); - case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.Boolean && jsTypeArguments[0] == JSTypeFlags.Boolean: return ResolvedGenerator.Resolved(new TaskJSGenerator(MarshalerType.Boolean)); - case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.Char && jsTypeArguments[0] == JSTypeFlags.String: return ResolvedGenerator.Resolved(new TaskJSGenerator(MarshalerType.Char)); - case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.Int16 && jsTypeArguments[0] == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new TaskJSGenerator(MarshalerType.Int16)); - case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.Int32 && jsTypeArguments[0] == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new TaskJSGenerator(MarshalerType.Int32)); - case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.Int64 && jsTypeArguments[0] == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new TaskJSGenerator(MarshalerType.Int52)); - case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.Int64 && jsTypeArguments[0] == JSTypeFlags.BigInt: return ResolvedGenerator.Resolved(new TaskJSGenerator(MarshalerType.BigInt64)); - case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.IntPtr && jsTypeArguments[0] == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new TaskJSGenerator(MarshalerType.IntPtr)); - case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.Double && jsTypeArguments[0] == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new TaskJSGenerator(MarshalerType.Double)); - case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.Single && jsTypeArguments[0] == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new TaskJSGenerator(MarshalerType.Single)); - case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.JSObject && jsTypeArguments[0] == JSTypeFlags.Object: return ResolvedGenerator.Resolved(new TaskJSGenerator(MarshalerType.JSObject)); - case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.String && jsTypeArguments[0] == JSTypeFlags.String: return ResolvedGenerator.Resolved(new TaskJSGenerator(MarshalerType.String)); - case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.Exception && jsTypeArguments[0] == JSTypeFlags.Error: return ResolvedGenerator.Resolved(new TaskJSGenerator(MarshalerType.Exception)); - case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.DateTime && jsTypeArguments[0] == JSTypeFlags.Date: return ResolvedGenerator.Resolved(new TaskJSGenerator(MarshalerType.DateTime)); - case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.DateTimeOffset && jsTypeArguments[0] == JSTypeFlags.Date: return ResolvedGenerator.Resolved(new TaskJSGenerator(MarshalerType.DateTimeOffset)); - case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.Object && jsTypeArguments[0] == JSTypeFlags.Any: return ResolvedGenerator.Resolved(new TaskJSGenerator(MarshalerType.Object)); + case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes.Length == 0 && jsTypeArguments[0] == JSTypeFlags.Void: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, MarshalerType.Void)); + case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.Byte && jsTypeArguments[0] == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, MarshalerType.Byte)); + case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.Boolean && jsTypeArguments[0] == JSTypeFlags.Boolean: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, MarshalerType.Boolean)); + case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.Char && jsTypeArguments[0] == JSTypeFlags.String: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, MarshalerType.Char)); + case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.Int16 && jsTypeArguments[0] == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, MarshalerType.Int16)); + case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.Int32 && jsTypeArguments[0] == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, MarshalerType.Int32)); + case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.Int64 && jsTypeArguments[0] == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, MarshalerType.Int52)); + case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.Int64 && jsTypeArguments[0] == JSTypeFlags.BigInt: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, MarshalerType.BigInt64)); + case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.IntPtr && jsTypeArguments[0] == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, MarshalerType.IntPtr)); + case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.Double && jsTypeArguments[0] == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, MarshalerType.Double)); + case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.Single && jsTypeArguments[0] == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, MarshalerType.Single)); + case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.JSObject && jsTypeArguments[0] == JSTypeFlags.Object: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, MarshalerType.JSObject)); + case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.String && jsTypeArguments[0] == JSTypeFlags.String: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, MarshalerType.String)); + case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.Exception && jsTypeArguments[0] == JSTypeFlags.Error: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, MarshalerType.Exception)); + case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.DateTime && jsTypeArguments[0] == JSTypeFlags.Date: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, MarshalerType.DateTime)); + case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.DateTimeOffset && jsTypeArguments[0] == JSTypeFlags.Date: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, MarshalerType.DateTimeOffset)); + case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.Object && jsTypeArguments[0] == JSTypeFlags.Any: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, MarshalerType.Object)); // task missing - case KnownManagedType.Task when jsType == JSTypeFlags.Missing && argumentTypes.Length == 0: return ResolvedGenerator.Resolved(new TaskJSGenerator(MarshalerType.Void)); - case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.Boolean && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(MarshalerType.Boolean)); - case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.Byte && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(MarshalerType.Byte)); - case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.Char && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(MarshalerType.Char)); - case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.Int16 && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(MarshalerType.Int16)); - case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.Int32 && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(MarshalerType.Int32)); - case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.Single && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(MarshalerType.Single)); - case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.Double && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(MarshalerType.Double)); - case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.IntPtr && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(MarshalerType.IntPtr)); - case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.JSObject && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(MarshalerType.JSObject)); - case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.String && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(MarshalerType.String)); - case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.Exception && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(MarshalerType.Exception)); + case KnownManagedType.Task when jsType == JSTypeFlags.Missing && argumentTypes.Length == 0: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, MarshalerType.Void)); + case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.Boolean && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, MarshalerType.Boolean)); + case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.Byte && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, MarshalerType.Byte)); + case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.Char && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, MarshalerType.Char)); + case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.Int16 && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, MarshalerType.Int16)); + case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.Int32 && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, MarshalerType.Int32)); + case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.Single && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, MarshalerType.Single)); + case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.Double && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, MarshalerType.Double)); + case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.IntPtr && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, MarshalerType.IntPtr)); + case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.JSObject && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, MarshalerType.JSObject)); + case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.String && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, MarshalerType.String)); + case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.Exception && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, MarshalerType.Exception)); // task forced case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.Int64 && jsType == JSTypeFlags.Missing: @@ -212,19 +212,19 @@ internal static ResolvedGenerator Create(TypePositionInfo info, bool isToJs, Kno return failWithReason(SR.Format(SR.TypeNotSupportedName, info.ManagedType.FullTypeName)); // array - case KnownManagedType.Array when jsType == JSTypeFlags.Array && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.Byte && jsTypeArguments[0] == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new ArrayJSGenerator(MarshalerType.Byte)); - case KnownManagedType.Array when jsType == JSTypeFlags.Array && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.String && jsTypeArguments[0] == JSTypeFlags.String: return ResolvedGenerator.Resolved(new ArrayJSGenerator(MarshalerType.String)); - case KnownManagedType.Array when jsType == JSTypeFlags.Array && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.Double && jsTypeArguments[0] == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new ArrayJSGenerator(MarshalerType.Double)); - case KnownManagedType.Array when jsType == JSTypeFlags.Array && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.Int32 && jsTypeArguments[0] == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new ArrayJSGenerator(MarshalerType.Int32)); - case KnownManagedType.Array when jsType == JSTypeFlags.Array && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.JSObject && jsTypeArguments[0] == JSTypeFlags.Object: return ResolvedGenerator.Resolved(new ArrayJSGenerator(MarshalerType.JSObject)); - case KnownManagedType.Array when jsType == JSTypeFlags.Array && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.Object && jsTypeArguments[0] == JSTypeFlags.Any: return ResolvedGenerator.Resolved(new ArrayJSGenerator(MarshalerType.Object)); + case KnownManagedType.Array when jsType == JSTypeFlags.Array && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.Byte && jsTypeArguments[0] == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new ArrayJSGenerator(info, MarshalerType.Byte)); + case KnownManagedType.Array when jsType == JSTypeFlags.Array && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.String && jsTypeArguments[0] == JSTypeFlags.String: return ResolvedGenerator.Resolved(new ArrayJSGenerator(info, MarshalerType.String)); + case KnownManagedType.Array when jsType == JSTypeFlags.Array && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.Double && jsTypeArguments[0] == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new ArrayJSGenerator(info, MarshalerType.Double)); + case KnownManagedType.Array when jsType == JSTypeFlags.Array && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.Int32 && jsTypeArguments[0] == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new ArrayJSGenerator(info, MarshalerType.Int32)); + case KnownManagedType.Array when jsType == JSTypeFlags.Array && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.JSObject && jsTypeArguments[0] == JSTypeFlags.Object: return ResolvedGenerator.Resolved(new ArrayJSGenerator(info, MarshalerType.JSObject)); + case KnownManagedType.Array when jsType == JSTypeFlags.Array && jsTypeArguments.Length == 1 && argumentTypes[0] == KnownManagedType.Object && jsTypeArguments[0] == JSTypeFlags.Any: return ResolvedGenerator.Resolved(new ArrayJSGenerator(info, MarshalerType.Object)); // array missing - case KnownManagedType.Array when argumentTypes[0] == KnownManagedType.Byte && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new ArrayJSGenerator(MarshalerType.Byte)); - case KnownManagedType.Array when argumentTypes[0] == KnownManagedType.String && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new ArrayJSGenerator(MarshalerType.String)); - case KnownManagedType.Array when argumentTypes[0] == KnownManagedType.Double && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new ArrayJSGenerator(MarshalerType.Double)); - case KnownManagedType.Array when argumentTypes[0] == KnownManagedType.Int32 && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new ArrayJSGenerator(MarshalerType.Int32)); - case KnownManagedType.Array when argumentTypes[0] == KnownManagedType.JSObject && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new ArrayJSGenerator(MarshalerType.JSObject)); + case KnownManagedType.Array when argumentTypes[0] == KnownManagedType.Byte && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new ArrayJSGenerator(info, MarshalerType.Byte)); + case KnownManagedType.Array when argumentTypes[0] == KnownManagedType.String && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new ArrayJSGenerator(info, MarshalerType.String)); + case KnownManagedType.Array when argumentTypes[0] == KnownManagedType.Double && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new ArrayJSGenerator(info, MarshalerType.Double)); + case KnownManagedType.Array when argumentTypes[0] == KnownManagedType.Int32 && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new ArrayJSGenerator(info, MarshalerType.Int32)); + case KnownManagedType.Array when argumentTypes[0] == KnownManagedType.JSObject && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new ArrayJSGenerator(info, MarshalerType.JSObject)); case KnownManagedType.Array when jsType == JSTypeFlags.Array && jsTypeArguments.Length == 1: return failWithReason(SR.Format(SR.TypeNotSupportedName, info.ManagedType.FullTypeName)); @@ -235,9 +235,9 @@ internal static ResolvedGenerator Create(TypePositionInfo info, bool isToJs, Kno // span view case KnownManagedType.Span when jsType == JSTypeFlags.MemoryView && jsTypeArguments.Length != 0: return failWithReason(null); - case KnownManagedType.Span when jsType == JSTypeFlags.MemoryView && argumentTypes[0] == KnownManagedType.Byte: return ResolvedGenerator.Resolved(new SpanJSGenerator(MarshalerType.Byte)); - case KnownManagedType.Span when jsType == JSTypeFlags.MemoryView && argumentTypes[0] == KnownManagedType.Int32: return ResolvedGenerator.Resolved(new SpanJSGenerator(MarshalerType.Int32)); - case KnownManagedType.Span when jsType == JSTypeFlags.MemoryView && argumentTypes[0] == KnownManagedType.Double: return ResolvedGenerator.Resolved(new SpanJSGenerator(MarshalerType.Double)); + case KnownManagedType.Span when jsType == JSTypeFlags.MemoryView && argumentTypes[0] == KnownManagedType.Byte: return ResolvedGenerator.Resolved(new SpanJSGenerator(info, MarshalerType.Byte)); + case KnownManagedType.Span when jsType == JSTypeFlags.MemoryView && argumentTypes[0] == KnownManagedType.Int32: return ResolvedGenerator.Resolved(new SpanJSGenerator(info, MarshalerType.Int32)); + case KnownManagedType.Span when jsType == JSTypeFlags.MemoryView && argumentTypes[0] == KnownManagedType.Double: return ResolvedGenerator.Resolved(new SpanJSGenerator(info, MarshalerType.Double)); case KnownManagedType.Span when jsType == JSTypeFlags.MemoryView: return failWithReason(SR.Format(SR.TypeNotSupportedName, info.ManagedType.FullTypeName)); @@ -251,9 +251,9 @@ internal static ResolvedGenerator Create(TypePositionInfo info, bool isToJs, Kno // segment view case KnownManagedType.ArraySegment when jsType == JSTypeFlags.MemoryView && jsTypeArguments.Length != 0: return failWithReason(null); - case KnownManagedType.ArraySegment when jsType == JSTypeFlags.MemoryView && argumentTypes[0] == KnownManagedType.Byte: return ResolvedGenerator.Resolved(new ArraySegmentJSGenerator(MarshalerType.Byte)); - case KnownManagedType.ArraySegment when jsType == JSTypeFlags.MemoryView && argumentTypes[0] == KnownManagedType.Int32: return ResolvedGenerator.Resolved(new ArraySegmentJSGenerator(MarshalerType.Int32)); - case KnownManagedType.ArraySegment when jsType == JSTypeFlags.MemoryView && argumentTypes[0] == KnownManagedType.Double: return ResolvedGenerator.Resolved(new ArraySegmentJSGenerator(MarshalerType.Double)); + case KnownManagedType.ArraySegment when jsType == JSTypeFlags.MemoryView && argumentTypes[0] == KnownManagedType.Byte: return ResolvedGenerator.Resolved(new ArraySegmentJSGenerator(info, MarshalerType.Byte)); + case KnownManagedType.ArraySegment when jsType == JSTypeFlags.MemoryView && argumentTypes[0] == KnownManagedType.Int32: return ResolvedGenerator.Resolved(new ArraySegmentJSGenerator(info, MarshalerType.Int32)); + case KnownManagedType.ArraySegment when jsType == JSTypeFlags.MemoryView && argumentTypes[0] == KnownManagedType.Double: return ResolvedGenerator.Resolved(new ArraySegmentJSGenerator(info, MarshalerType.Double)); case KnownManagedType.ArraySegment when jsType == JSTypeFlags.MemoryView: return failWithReason(SR.Format(SR.TypeNotSupportedName, info.ManagedType.FullTypeName)); @@ -290,7 +290,7 @@ internal static ResolvedGenerator Create(TypePositionInfo info, bool isToJs, Kno { return failWithReason(SR.FuncTooManyArgs); } - return ResolvedGenerator.Resolved(new FuncJSGenerator(marshaledType == KnownManagedType.Action, argsMarshallerTypes)); + return ResolvedGenerator.Resolved(new FuncJSGenerator(info, marshaledType == KnownManagedType.Action, argsMarshallerTypes)); case KnownManagedType.Action when jsType == JSTypeFlags.Function: case KnownManagedType.Function when jsType == JSTypeFlags.Function: return failWithReason(SR.FuncWrongArgumentCount); diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportCodeGenerator.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportCodeGenerator.cs index 80a9a2338b993..fe5d0459624b7 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportCodeGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportCodeGenerator.cs @@ -23,7 +23,8 @@ internal sealed class JSImportCodeGenerator : JSCodeGenerator { private readonly BoundGenerators _marshallers; - private readonly JSImportCodeContext _context; + private readonly StubCodeContext _context; + private readonly JSImportData _jsImportData; private readonly JSSignatureContext _signatureContext; public JSImportCodeGenerator( @@ -33,30 +34,29 @@ public JSImportCodeGenerator( GeneratorDiagnosticsBag diagnosticsBag, IMarshallingGeneratorResolver generatorResolver) { + _jsImportData = attributeData; _signatureContext = signatureContext; - ManagedToNativeStubCodeContext innerContext = new ManagedToNativeStubCodeContext(ReturnIdentifier, ReturnIdentifier) + _context = new ManagedToNativeStubCodeContext(ReturnIdentifier, ReturnIdentifier) { CodeEmitOptions = new(SkipInit: true) }; - _context = new JSImportCodeContext(attributeData, innerContext); _marshallers = BoundGenerators.Create(argTypes, generatorResolver, _context, new EmptyJSGenerator(), out var bindingFailures); diagnosticsBag.ReportGeneratorDiagnostics(bindingFailures); - if (_marshallers.ManagedReturnMarshaller.Generator.UsesNativeIdentifier(_marshallers.ManagedReturnMarshaller.TypeInfo, null)) + if (_marshallers.ManagedReturnMarshaller.UsesNativeIdentifier(_context)) { // If we need a different native return identifier, then recreate the context with the correct identifier before we generate any code. - innerContext = new ManagedToNativeStubCodeContext(ReturnIdentifier, ReturnNativeIdentifier) + _context = new ManagedToNativeStubCodeContext(ReturnIdentifier, ReturnNativeIdentifier) { CodeEmitOptions = new(SkipInit: true) }; - _context = new JSImportCodeContext(attributeData, innerContext); } // validate task + span mix if (_marshallers.ManagedReturnMarshaller.TypeInfo.MarshallingAttributeInfo is JSMarshallingInfo(_, JSTaskTypeInfo)) { - BoundGenerator spanArg = _marshallers.SignatureMarshallers.FirstOrDefault(m => m.TypeInfo.MarshallingAttributeInfo is JSMarshallingInfo(_, JSSpanTypeInfo)); + IBoundMarshallingGenerator spanArg = _marshallers.SignatureMarshallers.FirstOrDefault(m => m.TypeInfo.MarshallingAttributeInfo is JSMarshallingInfo(_, JSSpanTypeInfo)); if (spanArg != default) { diagnosticsBag.ReportGeneratorDiagnostic(new GeneratorDiagnostic.NotSupported(spanArg.TypeInfo, _context) @@ -132,11 +132,11 @@ private void BindSyntax(List statementsToUpdate) { var bindingParameters = (new ArgumentSyntax[] { - Argument(LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(_context.AttributeData.FunctionName))), + Argument(LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(_jsImportData.FunctionName))), Argument( - _context.AttributeData.ModuleName == null + _jsImportData.ModuleName == null ? LiteralExpression(SyntaxKind.NullLiteralExpression) - : LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(_context.AttributeData.ModuleName))), + : LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(_jsImportData.ModuleName))), CreateSignaturesSyntax(), }); @@ -151,8 +151,9 @@ private void BindSyntax(List statementsToUpdate) private ArgumentSyntax CreateSignaturesSyntax() { - var types = ((IJSMarshallingGenerator)_marshallers.ManagedReturnMarshaller.Generator).GenerateBind(_marshallers.ManagedReturnMarshaller.TypeInfo, _context) - .Concat(_marshallers.NativeParameterMarshallers.SelectMany(p => ((IJSMarshallingGenerator)p.Generator).GenerateBind(p.TypeInfo, _context))); + IEnumerable types = _marshallers.ManagedReturnMarshaller is IJSMarshallingGenerator jsGen ? jsGen.GenerateBind(_context) : []; + types = types + .Concat(_marshallers.NativeParameterMarshallers.OfType().SelectMany(p => p.GenerateBind(_context))); return Argument(ArrayCreationExpression(ArrayType(IdentifierName(Constants.JSMarshalerTypeGlobal)) .WithRankSpecifiers(SingletonList(ArrayRankSpecifier(SingletonSeparatedList(OmittedArraySizeExpression()))))) diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSSignatureContext.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSSignatureContext.cs index 6d0fd6a7c9b0c..3f058a5c7eeb4 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSSignatureContext.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSSignatureContext.cs @@ -52,7 +52,10 @@ public static JSSignatureContext Create( { foreach (var param in sigContext.ElementTypeInformation) { - hash = hash * 31 + (uint)param.ManagedType.FullTypeName.GetHashCode(); + // Manually hash the managed type names character by character as + // string hashes are not stable across runs. + foreach (char c in param.ManagedType.FullTypeName) + hash = hash * 31 + c; } }; int typesHash = Math.Abs((int)hash); diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSStubCodeContext.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSStubCodeContext.cs deleted file mode 100644 index 7a696dbb2c493..0000000000000 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSStubCodeContext.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; - -namespace Microsoft.Interop.JavaScript -{ - internal abstract record JSStubCodeContext : StubCodeContext - { - public StubCodeContext _inner; - public override bool SingleFrameSpansNativeContext => _inner.SingleFrameSpansNativeContext; - - public override bool AdditionalTemporaryStateLivesAcrossStages => _inner.AdditionalTemporaryStateLivesAcrossStages; - - public override (string managed, string native) GetIdentifiers(TypePositionInfo info) - { - return _inner.GetIdentifiers(info); - } - } - - internal sealed record JSImportCodeContext : JSStubCodeContext - { - public JSImportCodeContext(JSImportData attributeData, StubCodeContext inner) - { - _inner = inner; - Direction = MarshalDirection.ManagedToUnmanaged; - AttributeData = attributeData; - CodeEmitOptions = inner.CodeEmitOptions; - } - - public JSImportData AttributeData { get; set; } - } - - internal sealed record JSExportCodeContext : JSStubCodeContext - { - public JSExportCodeContext(JSExportData attributeData, StubCodeContext inner) - { - _inner = inner; - Direction = MarshalDirection.UnmanagedToManaged; - AttributeData = attributeData; - CodeEmitOptions = inner.CodeEmitOptions; - } - - public JSExportData AttributeData { get; set; } - } -} diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/ArrayJSGenerator.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/ArrayJSGenerator.cs index 816c9d7b5550d..f6c7e6e6cab83 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/ArrayJSGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/ArrayJSGenerator.cs @@ -13,16 +13,18 @@ internal sealed class ArrayJSGenerator : PrimitiveJSGenerator { private readonly MarshalerType _elementMarshalerType; - public ArrayJSGenerator(MarshalerType elementMarshalerType) - : base(MarshalerType.Array) + public ArrayJSGenerator(TypePositionInfo info, MarshalerType elementMarshalerType) + : base(info, MarshalerType.Array) { _elementMarshalerType = elementMarshalerType; } - public override IEnumerable GenerateBind(TypePositionInfo info, StubCodeContext context) + public override IEnumerable GenerateBind(StubCodeContext context) { yield return InvocationExpression(MarshalerTypeName(Type), ArgumentList(SingletonSeparatedList(Argument(MarshalerTypeName(_elementMarshalerType))))); } + + public override IBoundMarshallingGenerator Rebind(TypePositionInfo info) => new ArrayJSGenerator(info, _elementMarshalerType); } } diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/ArraySegmentJSGenerator.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/ArraySegmentJSGenerator.cs index ef6ef06107b40..9e9cd1aabb0ed 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/ArraySegmentJSGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/ArraySegmentJSGenerator.cs @@ -12,16 +12,18 @@ internal sealed class ArraySegmentJSGenerator : PrimitiveJSGenerator { private readonly MarshalerType _elementMarshalerType; - public ArraySegmentJSGenerator(MarshalerType elementMarshalerType) - : base(MarshalerType.ArraySegment) + public ArraySegmentJSGenerator(TypePositionInfo info, MarshalerType elementMarshalerType) + : base(info, MarshalerType.ArraySegment) { _elementMarshalerType = elementMarshalerType; } - public override IEnumerable GenerateBind(TypePositionInfo info, StubCodeContext context) + public override IEnumerable GenerateBind(StubCodeContext context) { yield return InvocationExpression(MarshalerTypeName(Type), ArgumentList(SingletonSeparatedList(Argument(MarshalerTypeName(_elementMarshalerType))))); } + + public override IBoundMarshallingGenerator Rebind(TypePositionInfo info) => new ArraySegmentJSGenerator(info, _elementMarshalerType); } } diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/BaseJSGenerator.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/BaseJSGenerator.cs index 798be15bc45df..8b4d324fc589c 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/BaseJSGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/BaseJSGenerator.cs @@ -12,44 +12,50 @@ namespace Microsoft.Interop.JavaScript { internal abstract class BaseJSGenerator : IJSMarshallingGenerator { - protected IMarshallingGenerator _inner; + protected IBoundMarshallingGenerator _inner; public MarshalerType Type; - protected BaseJSGenerator(MarshalerType marshalerType, IMarshallingGenerator inner) + protected BaseJSGenerator(MarshalerType marshalerType, IBoundMarshallingGenerator inner) { _inner = inner; Type = marshalerType; } - public ManagedTypeInfo AsNativeType(TypePositionInfo info) => _inner.AsNativeType(info); - public virtual bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => _inner.UsesNativeIdentifier(info, context); - public SignatureBehavior GetNativeSignatureBehavior(TypePositionInfo info) => _inner.GetNativeSignatureBehavior(info); - public ValueBoundaryBehavior GetValueBoundaryBehavior(TypePositionInfo info, StubCodeContext context) => _inner.GetValueBoundaryBehavior(info, context); - public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, TypePositionInfo info, StubCodeContext context, out GeneratorDiagnostic? diagnostic) - => _inner.SupportsByValueMarshalKind(marshalKind, info, context, out diagnostic); + public TypePositionInfo TypeInfo => _inner.TypeInfo; - public virtual IEnumerable GenerateBind(TypePositionInfo info, StubCodeContext context) + public ManagedTypeInfo NativeType => _inner.NativeType; + + public SignatureBehavior NativeSignatureBehavior => _inner.NativeSignatureBehavior; + + public ValueBoundaryBehavior GetValueBoundaryBehavior(StubCodeContext context) => _inner.GetValueBoundaryBehavior(context); + + public virtual bool UsesNativeIdentifier(StubCodeContext context) => _inner.UsesNativeIdentifier(context); + + public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context, out GeneratorDiagnostic? diagnostic) + => _inner.SupportsByValueMarshalKind(marshalKind, context, out diagnostic); + + public virtual IEnumerable GenerateBind(StubCodeContext context) { yield return MarshalerTypeName(Type); } - public virtual IEnumerable Generate(TypePositionInfo info, StubCodeContext context) + public virtual IEnumerable Generate(StubCodeContext context) { - string argName = context.GetAdditionalIdentifier(info, "js_arg"); + string argName = context.GetAdditionalIdentifier(TypeInfo, "js_arg"); if (context.CurrentStage == StubCodeContext.Stage.Setup) { - if (!info.IsManagedReturnPosition) + if (!TypeInfo.IsManagedReturnPosition) { yield return LocalDeclarationStatement(VariableDeclaration(RefType(IdentifierName(Constants.JSMarshalerArgumentGlobal))) .WithVariables(SingletonSeparatedList(VariableDeclarator(Identifier(argName)) .WithInitializer(EqualsValueClause(RefExpression(ElementAccessExpression(IdentifierName(Constants.ArgumentsBuffer)) .WithArgumentList(BracketedArgumentList(SingletonSeparatedList( - Argument(LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(info.ManagedIndex + 2)))))))))))); + Argument(LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(TypeInfo.ManagedIndex + 2)))))))))))); } } - foreach (var x in _inner.Generate(info, context)) + foreach (var x in _inner.Generate(context)) { yield return x; } @@ -81,5 +87,7 @@ protected static IdentifierNameSyntax GetToJSMethod(MarshalerType marshalerType) return IdentifierName(Constants.ToJSMethod); } } + + public abstract IBoundMarshallingGenerator Rebind(TypePositionInfo info); } } diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/EmptyJSGenerator.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/EmptyJSGenerator.cs index 060902fc1098a..4cd1b3aa9e803 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/EmptyJSGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/EmptyJSGenerator.cs @@ -7,11 +7,10 @@ namespace Microsoft.Interop.JavaScript { - internal sealed class EmptyJSGenerator : IJSMarshallingGenerator + internal sealed class EmptyJSGenerator : IUnboundMarshallingGenerator { public ManagedTypeInfo AsNativeType(TypePositionInfo info) => info.ManagedType; public IEnumerable Generate(TypePositionInfo info, StubCodeContext context) => Array.Empty(); - public IEnumerable GenerateBind(TypePositionInfo info, StubCodeContext context) => Array.Empty(); public SignatureBehavior GetNativeSignatureBehavior(TypePositionInfo info) => SignatureBehavior.ManagedTypeAndAttributes; public ValueBoundaryBehavior GetValueBoundaryBehavior(TypePositionInfo info, StubCodeContext context) => ValueBoundaryBehavior.ManagedIdentifier; public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, TypePositionInfo info, StubCodeContext context, out GeneratorDiagnostic? diagnostic) diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/FuncJSGenerator.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/FuncJSGenerator.cs index b70986a9b3afa..bb2101993f943 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/FuncJSGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/FuncJSGenerator.cs @@ -16,56 +16,56 @@ internal sealed class FuncJSGenerator : BaseJSGenerator private readonly bool _isAction; private readonly MarshalerType[] _argumentMarshalerTypes; - public FuncJSGenerator(bool isAction, MarshalerType[] argumentMarshalerTypes) - : base(isAction ? MarshalerType.Action : MarshalerType.Function, new Forwarder()) + public FuncJSGenerator(TypePositionInfo info, bool isAction, MarshalerType[] argumentMarshalerTypes) + : base(isAction ? MarshalerType.Action : MarshalerType.Function, new Forwarder().Bind(info)) { _isAction = isAction; _argumentMarshalerTypes = argumentMarshalerTypes; } - public override IEnumerable GenerateBind(TypePositionInfo info, StubCodeContext context) + public override IEnumerable GenerateBind(StubCodeContext context) { var args = _argumentMarshalerTypes.Select(x => Argument(MarshalerTypeName(x))).ToList(); yield return InvocationExpression(MarshalerTypeName(Type), ArgumentList(SeparatedList(args))); } - public override IEnumerable Generate(TypePositionInfo info, StubCodeContext context) + public override IEnumerable Generate(StubCodeContext context) { - string argName = context.GetAdditionalIdentifier(info, "js_arg"); - var target = info.IsManagedReturnPosition + string argName = context.GetAdditionalIdentifier(TypeInfo, "js_arg"); + var target = TypeInfo.IsManagedReturnPosition ? Constants.ArgumentReturn : argName; - var source = info.IsManagedReturnPosition - ? Argument(IdentifierName(context.GetIdentifiers(info).native)) - : _inner.AsArgument(info, context); + var source = TypeInfo.IsManagedReturnPosition + ? Argument(IdentifierName(context.GetIdentifiers(TypeInfo).native)) + : _inner.AsArgument(context); - var jsty = (JSFunctionTypeInfo)((JSMarshallingInfo)info.MarshallingAttributeInfo).TypeInfo; + var jsty = (JSFunctionTypeInfo)((JSMarshallingInfo)TypeInfo.MarshallingAttributeInfo).TypeInfo; var sourceTypes = jsty.ArgsTypeInfo .Select(a => a.Syntax) .ToArray(); - if (context.CurrentStage == StubCodeContext.Stage.UnmarshalCapture && context.Direction == MarshalDirection.ManagedToUnmanaged && info.IsManagedReturnPosition) + if (context.CurrentStage == StubCodeContext.Stage.UnmarshalCapture && context.Direction == MarshalDirection.ManagedToUnmanaged && TypeInfo.IsManagedReturnPosition) { yield return ToManagedMethod(target, source, jsty); } - if (context.CurrentStage == StubCodeContext.Stage.Marshal && context.Direction == MarshalDirection.UnmanagedToManaged && info.IsManagedReturnPosition) + if (context.CurrentStage == StubCodeContext.Stage.Marshal && context.Direction == MarshalDirection.UnmanagedToManaged && TypeInfo.IsManagedReturnPosition) { yield return ToJSMethod(target, source, jsty); } - foreach (var x in base.Generate(info, context)) + foreach (var x in base.Generate(context)) { yield return x; } - if (context.CurrentStage == StubCodeContext.Stage.PinnedMarshal && context.Direction == MarshalDirection.ManagedToUnmanaged && !info.IsManagedReturnPosition) + if (context.CurrentStage == StubCodeContext.Stage.PinnedMarshal && context.Direction == MarshalDirection.ManagedToUnmanaged && !TypeInfo.IsManagedReturnPosition) { yield return ToJSMethod(target, source, jsty); } - if (context.CurrentStage == StubCodeContext.Stage.Unmarshal && context.Direction == MarshalDirection.UnmanagedToManaged && !info.IsManagedReturnPosition) + if (context.CurrentStage == StubCodeContext.Stage.Unmarshal && context.Direction == MarshalDirection.UnmanagedToManaged && !TypeInfo.IsManagedReturnPosition) { yield return ToManagedMethod(target, source, jsty); } @@ -115,6 +115,8 @@ private ExpressionStatementSyntax ToJSMethod(string target, ArgumentSyntax sourc .WithArgumentList(ArgumentList(SeparatedList(arguments)))); } + public override IBoundMarshallingGenerator Rebind(TypePositionInfo info) => new FuncJSGenerator(info, _isAction, _argumentMarshalerTypes); + private static ArgumentSyntax ArgToJS(int i, TypeSyntax sourceType, MarshalerType marshalerType) => Argument(ParenthesizedLambdaExpression() .WithModifiers(TokenList(Token(SyntaxKind.StaticKeyword))) diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/IJSMarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/IJSMarshallingGenerator.cs index ec665b5d904cf..d250048c393c8 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/IJSMarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/IJSMarshallingGenerator.cs @@ -6,8 +6,8 @@ namespace Microsoft.Interop.JavaScript { - internal interface IJSMarshallingGenerator : IMarshallingGenerator + internal interface IJSMarshallingGenerator : IBoundMarshallingGenerator { - IEnumerable GenerateBind(TypePositionInfo info, StubCodeContext context); + IEnumerable GenerateBind(StubCodeContext context); } } diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/NullableJSGenerator.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/NullableJSGenerator.cs index a943e6cf06c11..2b9a5f5175d49 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/NullableJSGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/NullableJSGenerator.cs @@ -10,15 +10,17 @@ namespace Microsoft.Interop.JavaScript { internal sealed class NullableJSGenerator : PrimitiveJSGenerator { - public NullableJSGenerator(MarshalerType resultMarshalerType) - : base(resultMarshalerType) + public NullableJSGenerator(TypePositionInfo info, MarshalerType resultMarshalerType) + : base(info, resultMarshalerType) { } - public override IEnumerable GenerateBind(TypePositionInfo info, StubCodeContext context) + public override IEnumerable GenerateBind(StubCodeContext context) { yield return InvocationExpression(MarshalerTypeName(MarshalerType.Nullable), ArgumentList(SingletonSeparatedList(Argument(MarshalerTypeName(Type))))); } + + public override IBoundMarshallingGenerator Rebind(TypePositionInfo info) => new NullableJSGenerator(info, Type); } } diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/PrimitiveJSGenerator.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/PrimitiveJSGenerator.cs index 7690aa4fe43c8..5d2ed3963ae6d 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/PrimitiveJSGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/PrimitiveJSGenerator.cs @@ -11,49 +11,49 @@ namespace Microsoft.Interop.JavaScript { internal class PrimitiveJSGenerator : BaseJSGenerator { - public PrimitiveJSGenerator(MarshalerType marshalerType, IMarshallingGenerator inner) + public PrimitiveJSGenerator(MarshalerType marshalerType, IBoundMarshallingGenerator inner) : base(marshalerType, inner) { } - public PrimitiveJSGenerator(MarshalerType marshalerType) - : base(marshalerType, new Forwarder()) + public PrimitiveJSGenerator(TypePositionInfo info, MarshalerType marshalerType) + : base(marshalerType, new Forwarder().Bind(info)) { } // TODO order parameters in such way that affinity capturing parameters are emitted first - public override IEnumerable Generate(TypePositionInfo info, StubCodeContext context) + public override IEnumerable Generate(StubCodeContext context) { - string argName = context.GetAdditionalIdentifier(info, "js_arg"); - var target = info.IsManagedReturnPosition + string argName = context.GetAdditionalIdentifier(TypeInfo, "js_arg"); + var target = TypeInfo.IsManagedReturnPosition ? Constants.ArgumentReturn : argName; - var source = info.IsManagedReturnPosition - ? Argument(IdentifierName(context.GetIdentifiers(info).native)) - : _inner.AsArgument(info, context); + var source = TypeInfo.IsManagedReturnPosition + ? Argument(IdentifierName(context.GetIdentifiers(TypeInfo).native)) + : _inner.AsArgument(context); - if (context.CurrentStage == StubCodeContext.Stage.UnmarshalCapture && context.Direction == MarshalDirection.ManagedToUnmanaged && info.IsManagedReturnPosition) + if (context.CurrentStage == StubCodeContext.Stage.UnmarshalCapture && context.Direction == MarshalDirection.ManagedToUnmanaged && TypeInfo.IsManagedReturnPosition) { yield return ToManagedMethod(target, source); } - if (context.CurrentStage == StubCodeContext.Stage.Marshal && context.Direction == MarshalDirection.UnmanagedToManaged && info.IsManagedReturnPosition) + if (context.CurrentStage == StubCodeContext.Stage.Marshal && context.Direction == MarshalDirection.UnmanagedToManaged && TypeInfo.IsManagedReturnPosition) { yield return ToJSMethod(target, source); } - foreach (var x in base.Generate(info, context)) + foreach (var x in base.Generate(context)) { yield return x; } - if (context.CurrentStage == StubCodeContext.Stage.PinnedMarshal && context.Direction == MarshalDirection.ManagedToUnmanaged && !info.IsManagedReturnPosition) + if (context.CurrentStage == StubCodeContext.Stage.PinnedMarshal && context.Direction == MarshalDirection.ManagedToUnmanaged && !TypeInfo.IsManagedReturnPosition) { yield return ToJSMethod(target, source); } - if (context.CurrentStage == StubCodeContext.Stage.Unmarshal && context.Direction == MarshalDirection.UnmanagedToManaged && !info.IsManagedReturnPosition) + if (context.CurrentStage == StubCodeContext.Stage.Unmarshal && context.Direction == MarshalDirection.UnmanagedToManaged && !TypeInfo.IsManagedReturnPosition) { yield return ToManagedMethod(target, source); } @@ -82,5 +82,8 @@ private ExpressionStatementSyntax ToJSMethod(string target, ArgumentSyntax sourc IdentifierName(target), GetToJSMethod(Type))) .WithArgumentList(ArgumentList(SingletonSeparatedList(ToJSMethodRefOrOut(source))))); } + + public override IBoundMarshallingGenerator Rebind(TypePositionInfo info) + => new PrimitiveJSGenerator(Type, _inner.Rebind(info)); } } diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/SpanJSGenerator.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/SpanJSGenerator.cs index 6d53af9ba8df2..8319c6477172c 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/SpanJSGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/SpanJSGenerator.cs @@ -12,16 +12,18 @@ internal sealed class SpanJSGenerator : PrimitiveJSGenerator { private readonly MarshalerType _elementMarshalerType; - public SpanJSGenerator(MarshalerType elementMarshalerType) - : base(MarshalerType.Span) + public SpanJSGenerator(TypePositionInfo info, MarshalerType elementMarshalerType) + : base(info, MarshalerType.Span) { _elementMarshalerType = elementMarshalerType; } - public override IEnumerable GenerateBind(TypePositionInfo info, StubCodeContext context) + public override IEnumerable GenerateBind(StubCodeContext context) { yield return InvocationExpression(MarshalerTypeName(Type), ArgumentList(SingletonSeparatedList(Argument(MarshalerTypeName(_elementMarshalerType))))); } + + public override IBoundMarshallingGenerator Rebind(TypePositionInfo info) => new SpanJSGenerator(info, _elementMarshalerType); } } diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/TaskJSGenerator.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/TaskJSGenerator.cs index f4a42613b9dcd..5f8023de1e66b 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/TaskJSGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/TaskJSGenerator.cs @@ -13,15 +13,15 @@ internal sealed class TaskJSGenerator : BaseJSGenerator { private readonly MarshalerType _resultMarshalerType; - public TaskJSGenerator(MarshalerType resultMarshalerType) - : base(MarshalerType.Task, new Forwarder()) + public TaskJSGenerator(TypePositionInfo info, MarshalerType resultMarshalerType) + : base(MarshalerType.Task, new Forwarder().Bind(info)) { _resultMarshalerType = resultMarshalerType; } - public override IEnumerable GenerateBind(TypePositionInfo info, StubCodeContext context) + public override IEnumerable GenerateBind(StubCodeContext context) { - var jsty = (JSTaskTypeInfo)((JSMarshallingInfo)info.MarshallingAttributeInfo).TypeInfo; + var jsty = (JSTaskTypeInfo)((JSMarshallingInfo)TypeInfo.MarshallingAttributeInfo).TypeInfo; if (jsty.ResultTypeInfo is JSSimpleTypeInfo(KnownManagedType.Void)) { yield return InvocationExpression(MarshalerTypeName(MarshalerType.Task), ArgumentList()); @@ -33,46 +33,46 @@ public override IEnumerable GenerateBind(TypePositionInfo info } } - public override IEnumerable Generate(TypePositionInfo info, StubCodeContext context) + public override IEnumerable Generate(StubCodeContext context) { - var jsty = (JSTaskTypeInfo)((JSMarshallingInfo)info.MarshallingAttributeInfo).TypeInfo; + var jsty = (JSTaskTypeInfo)((JSMarshallingInfo)TypeInfo.MarshallingAttributeInfo).TypeInfo; - string argName = context.GetAdditionalIdentifier(info, "js_arg"); - var target = info.IsManagedReturnPosition + string argName = context.GetAdditionalIdentifier(TypeInfo, "js_arg"); + var target = TypeInfo.IsManagedReturnPosition ? Constants.ArgumentReturn : argName; - var source = info.IsManagedReturnPosition - ? Argument(IdentifierName(context.GetIdentifiers(info).native)) - : _inner.AsArgument(info, context); + var source = TypeInfo.IsManagedReturnPosition + ? Argument(IdentifierName(context.GetIdentifiers(TypeInfo).native)) + : _inner.AsArgument(context); - if (context.CurrentStage == StubCodeContext.Stage.UnmarshalCapture && context.Direction == MarshalDirection.ManagedToUnmanaged && info.IsManagedReturnPosition) + if (context.CurrentStage == StubCodeContext.Stage.UnmarshalCapture && context.Direction == MarshalDirection.ManagedToUnmanaged && TypeInfo.IsManagedReturnPosition) { yield return jsty.ResultTypeInfo is JSSimpleTypeInfo(KnownManagedType.Void) ? ToManagedMethodVoid(target, source) : ToManagedMethod(target, source, jsty.ResultTypeInfo.Syntax); } - if (context.CurrentStage == StubCodeContext.Stage.Marshal && context.Direction == MarshalDirection.UnmanagedToManaged && info.IsManagedReturnPosition) + if (context.CurrentStage == StubCodeContext.Stage.Marshal && context.Direction == MarshalDirection.UnmanagedToManaged && TypeInfo.IsManagedReturnPosition) { yield return jsty.ResultTypeInfo is JSSimpleTypeInfo(KnownManagedType.Void) ? ToJSMethodVoid(target, source) : ToJSMethod(target, source, jsty.ResultTypeInfo.Syntax); } - foreach (var x in base.Generate(info, context)) + foreach (var x in base.Generate(context)) { yield return x; } - if (context.CurrentStage == StubCodeContext.Stage.PinnedMarshal && context.Direction == MarshalDirection.ManagedToUnmanaged && !info.IsManagedReturnPosition) + if (context.CurrentStage == StubCodeContext.Stage.PinnedMarshal && context.Direction == MarshalDirection.ManagedToUnmanaged && !TypeInfo.IsManagedReturnPosition) { yield return jsty.ResultTypeInfo is JSSimpleTypeInfo(KnownManagedType.Void) ? ToJSMethodVoid(target, source) : ToJSMethod(target, source, jsty.ResultTypeInfo.Syntax); } - if (context.CurrentStage == StubCodeContext.Stage.Unmarshal && context.Direction == MarshalDirection.UnmanagedToManaged && !info.IsManagedReturnPosition) + if (context.CurrentStage == StubCodeContext.Stage.Unmarshal && context.Direction == MarshalDirection.UnmanagedToManaged && !TypeInfo.IsManagedReturnPosition) { yield return jsty.ResultTypeInfo is JSSimpleTypeInfo(KnownManagedType.Void) ? ToManagedMethodVoid(target, source) @@ -138,5 +138,7 @@ private ExpressionStatementSyntax ToJSMethod(string target, ArgumentSyntax sourc Argument(IdentifierName("__task_result")), }))))))))})))); } + + public override IBoundMarshallingGenerator Rebind(TypePositionInfo info) => new TaskJSGenerator(info, _resultMarshalerType); } } diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/VoidGenerator.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/VoidGenerator.cs index 2205323cb7ce9..c1def8aa74fef 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/VoidGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/VoidGenerator.cs @@ -5,11 +5,9 @@ namespace Microsoft.Interop.JavaScript { - internal sealed class VoidGenerator : BaseJSGenerator + internal sealed class VoidGenerator(TypePositionInfo info, MarshalerType marshalerType) : BaseJSGenerator(marshalerType, new Forwarder().Bind(info)) { - public VoidGenerator(MarshalerType marshalerType) - : base(marshalerType, new Forwarder()) - { - } + public override IBoundMarshallingGenerator Rebind(TypePositionInfo info) + => new VoidGenerator(info, Type); } } diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/tests/JSImportGenerator.UnitTest/CodeSnippets.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/tests/JSImportGenerator.UnitTest/CodeSnippets.cs index 18599cf18c052..3e4cb0f6dcfd5 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/tests/JSImportGenerator.UnitTest/CodeSnippets.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/tests/JSImportGenerator.UnitTest/CodeSnippets.cs @@ -61,6 +61,35 @@ internal static partial void Annotated( } """; + public static readonly string AllAnnotatedExport = """ + //AllAnnotated + using System; + using System.Runtime.InteropServices.JavaScript; + using System.Threading.Tasks; + partial class Basic + { + [JSExport] + internal static void AnnotatedExport( + [JSMarshalAs] object a1, + [JSMarshalAs] long a2, + [JSMarshalAs] long a3, + [JSMarshalAs] Action a4, + [JSMarshalAs>] Func a5, + [JSMarshalAs] Span a6, + [JSMarshalAs] ArraySegment a7, + [JSMarshalAs>] Task a8, + [JSMarshalAs>] object[] a9, + [JSMarshalAs] DateTime a10, + [JSMarshalAs] DateTimeOffset a11, + [JSMarshalAs>] Task a12, + [JSMarshalAs>] Task a13, + [JSMarshalAs>] Task a14, + [JSMarshalAs>] Task a15 + ) + {} + } + """; + public static readonly string AllMissing = """ //AllMissing using System; diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/tests/JSImportGenerator.UnitTest/Compiles.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/tests/JSImportGenerator.UnitTest/Compiles.cs index ecb257c544b3a..e276aaaf80b5d 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/tests/JSImportGenerator.UnitTest/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/tests/JSImportGenerator.UnitTest/Compiles.cs @@ -8,6 +8,10 @@ using System; using Xunit; using Microsoft.Interop.UnitTests; +using Microsoft.CodeAnalysis.CSharp.Testing; +using Microsoft.CodeAnalysis.Testing; +using Microsoft.CodeAnalysis.Text; +using System.Text; namespace JSImportGenerator.Unit.Tests { @@ -45,5 +49,220 @@ public async Task ValidateSnippets(string source) TestUtils.AssertPostSourceGeneratorCompilation(newComp); } + + [Fact] + public async Task ValidateGeneratedSourceOutput() + { + var test = new Test() + { + TestState = + { + Sources = { CodeSnippets.AllAnnotated, CodeSnippets.AllAnnotatedExport }, + GeneratedSources = + { + (typeof(Microsoft.Interop.JavaScript.JSImportGenerator), + "JSImports.g.cs", + SourceText.From(""" + // + unsafe partial class Basic + { + [global::System.Diagnostics.DebuggerNonUserCode] + internal static partial void Annotated(object a1, long a2, long a3, global::System.Action a4, global::System.Func a5, global::System.Span a6, global::System.ArraySegment a7, global::System.Threading.Tasks.Task a8, object[] a9, global::System.DateTime a10, global::System.DateTimeOffset a11, global::System.Threading.Tasks.Task a12, global::System.Threading.Tasks.Task a13, global::System.Threading.Tasks.Task a14, global::System.Threading.Tasks.Task a15) + { + if (__signature_Annotated_564258462 == null) + { + __signature_Annotated_564258462 = global::System.Runtime.InteropServices.JavaScript.JSFunctionBinding.BindJSFunction("DoesNotExist", null, new global::System.Runtime.InteropServices.JavaScript.JSMarshalerType[] { global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Discard, global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Object, global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Int52, global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.BigInt64, global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Action(), global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Function(global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Int32), global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Span(global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Byte), global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.ArraySegment(global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Byte), global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Task(global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Object), global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Array(global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Object), global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.DateTime, global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.DateTimeOffset, global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Task(global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.DateTime), global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Task(global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.DateTimeOffset), global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Task(global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Int52), global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Task(global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.BigInt64) }); + } + + global::System.Span __arguments_buffer = stackalloc global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument[17]; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __arg_exception = ref __arguments_buffer[0]; + __arg_exception.Initialize(); + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __arg_return = ref __arguments_buffer[1]; + __arg_return.Initialize(); + // Setup - Perform required setup. + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a15_native__js_arg = ref __arguments_buffer[16]; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a14_native__js_arg = ref __arguments_buffer[15]; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a13_native__js_arg = ref __arguments_buffer[14]; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a12_native__js_arg = ref __arguments_buffer[13]; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a11_native__js_arg = ref __arguments_buffer[12]; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a10_native__js_arg = ref __arguments_buffer[11]; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a9_native__js_arg = ref __arguments_buffer[10]; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a8_native__js_arg = ref __arguments_buffer[9]; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a7_native__js_arg = ref __arguments_buffer[8]; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a6_native__js_arg = ref __arguments_buffer[7]; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a5_native__js_arg = ref __arguments_buffer[6]; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a4_native__js_arg = ref __arguments_buffer[5]; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a3_native__js_arg = ref __arguments_buffer[4]; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a2_native__js_arg = ref __arguments_buffer[3]; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a1_native__js_arg = ref __arguments_buffer[2]; + // PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned. + __a15_native__js_arg.ToJS(a15, static (ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __task_result_arg, long __task_result) => + { + __task_result_arg.ToJSBig(__task_result); + }); + __a14_native__js_arg.ToJS(a14, static (ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __task_result_arg, long __task_result) => + { + __task_result_arg.ToJS(__task_result); + }); + __a13_native__js_arg.ToJS(a13, static (ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __task_result_arg, global::System.DateTimeOffset __task_result) => + { + __task_result_arg.ToJS(__task_result); + }); + __a12_native__js_arg.ToJS(a12, static (ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __task_result_arg, global::System.DateTime __task_result) => + { + __task_result_arg.ToJS(__task_result); + }); + __a11_native__js_arg.ToJS(a11); + __a10_native__js_arg.ToJS(a10); + __a9_native__js_arg.ToJS(a9); + __a8_native__js_arg.ToJS(a8, static (ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __task_result_arg, object __task_result) => + { + __task_result_arg.ToJS(__task_result); + }); + __a7_native__js_arg.ToJS(a7); + __a6_native__js_arg.ToJS(a6); + __a5_native__js_arg.ToJS(a5, static (ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __delegate_arg_arg1, int __delegate_arg1) => + { + __delegate_arg_arg1.ToJS(__delegate_arg1); + }); + __a4_native__js_arg.ToJS(a4); + __a3_native__js_arg.ToJSBig(a3); + __a2_native__js_arg.ToJS(a2); + __a1_native__js_arg.ToJS(a1); + global::System.Runtime.InteropServices.JavaScript.JSFunctionBinding.InvokeJS(__signature_Annotated_564258462, __arguments_buffer); + } + + static global::System.Runtime.InteropServices.JavaScript.JSFunctionBinding __signature_Annotated_564258462; + } + + """.ReplaceLineEndings("\r\n"), Encoding.UTF8)), + (typeof(Microsoft.Interop.JavaScript.JSExportGenerator), + "JSExports.g.cs", + SourceText.From(""" + // + namespace System.Runtime.InteropServices.JavaScript + { + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute] + unsafe class __GeneratedInitializer + { + [global::System.ThreadStaticAttribute] + static bool initialized; + [global::System.Runtime.CompilerServices.ModuleInitializerAttribute, global::System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicMethods | global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicMethods, "System.Runtime.InteropServices.JavaScript.__GeneratedInitializer", "TestProject")] + static internal void __TrimmingPreserve_() + { + } + + [global::System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute("__Wrapper_AnnotatedExport_564258462", "Basic", "TestProject")] + static void __Register_() + { + if (initialized || global::System.Runtime.InteropServices.RuntimeInformation.OSArchitecture != global::System.Runtime.InteropServices.Architecture.Wasm) + return; + initialized = true; + global::System.Runtime.InteropServices.JavaScript.JSFunctionBinding.BindManagedFunction("[TestProject]Basic:AnnotatedExport", 564258462, new global::System.Runtime.InteropServices.JavaScript.JSMarshalerType[] { global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Discard, global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Object, global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Int52, global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.BigInt64, global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Action(), global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Function(global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Int32), global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Span(global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Byte), global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.ArraySegment(global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Byte), global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Task(global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Object), global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Array(global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Object), global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.DateTime, global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.DateTimeOffset, global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Task(global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.DateTime), global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Task(global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.DateTimeOffset), global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Task(global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Int52), global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Task(global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.BigInt64) }); + } + } + } + unsafe partial class Basic + { + [global::System.Diagnostics.DebuggerNonUserCode] + internal static unsafe void __Wrapper_AnnotatedExport_564258462(global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument* __arguments_buffer) + { + object a1; + long a2; + long a3; + global::System.Action a4; + global::System.Func a5; + global::System.Span a6; + global::System.ArraySegment a7; + global::System.Threading.Tasks.Task a8; + object[] a9; + global::System.DateTime a10; + global::System.DateTimeOffset a11; + global::System.Threading.Tasks.Task a12; + global::System.Threading.Tasks.Task a13; + global::System.Threading.Tasks.Task a14; + global::System.Threading.Tasks.Task a15; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __arg_exception = ref __arguments_buffer[0]; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __arg_return = ref __arguments_buffer[1]; + // Setup - Perform required setup. + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a15_native__js_arg = ref __arguments_buffer[16]; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a14_native__js_arg = ref __arguments_buffer[15]; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a13_native__js_arg = ref __arguments_buffer[14]; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a12_native__js_arg = ref __arguments_buffer[13]; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a11_native__js_arg = ref __arguments_buffer[12]; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a10_native__js_arg = ref __arguments_buffer[11]; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a9_native__js_arg = ref __arguments_buffer[10]; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a8_native__js_arg = ref __arguments_buffer[9]; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a7_native__js_arg = ref __arguments_buffer[8]; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a6_native__js_arg = ref __arguments_buffer[7]; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a5_native__js_arg = ref __arguments_buffer[6]; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a4_native__js_arg = ref __arguments_buffer[5]; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a3_native__js_arg = ref __arguments_buffer[4]; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a2_native__js_arg = ref __arguments_buffer[3]; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a1_native__js_arg = ref __arguments_buffer[2]; + try + { + // Unmarshal - Convert native data to managed data. + __a15_native__js_arg.ToManaged(out a15, static (ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __task_result_arg, out long __task_result) => + { + __task_result_arg.ToManagedBig(out __task_result); + }); + __a14_native__js_arg.ToManaged(out a14, static (ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __task_result_arg, out long __task_result) => + { + __task_result_arg.ToManaged(out __task_result); + }); + __a13_native__js_arg.ToManaged(out a13, static (ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __task_result_arg, out global::System.DateTimeOffset __task_result) => + { + __task_result_arg.ToManaged(out __task_result); + }); + __a12_native__js_arg.ToManaged(out a12, static (ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __task_result_arg, out global::System.DateTime __task_result) => + { + __task_result_arg.ToManaged(out __task_result); + }); + __a11_native__js_arg.ToManaged(out a11); + __a10_native__js_arg.ToManaged(out a10); + __a9_native__js_arg.ToManaged(out a9); + __a8_native__js_arg.ToManaged(out a8, static (ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __task_result_arg, out object __task_result) => + { + __task_result_arg.ToManaged(out __task_result); + }); + __a7_native__js_arg.ToManaged(out a7); + __a6_native__js_arg.ToManaged(out a6); + __a5_native__js_arg.ToManaged(out a5, static (ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __delegate_arg_arg1, out int __delegate_arg1) => + { + __delegate_arg_arg1.ToManaged(out __delegate_arg1); + }); + __a4_native__js_arg.ToManaged(out a4); + __a3_native__js_arg.ToManagedBig(out a3); + __a2_native__js_arg.ToManaged(out a2); + __a1_native__js_arg.ToManaged(out a1); + Basic.AnnotatedExport(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15); + } + catch (global::System.Exception ex) + { + __arg_exception.ToJS(ex); + } + } + } + + """.ReplaceLineEndings("\r\n"), Encoding.UTF8)), + } + }, + }; + + await test.RunAsync(); + } + + private sealed class Test : CSharpAnalyzerTest + { + public Test() + { + ReferenceAssemblies = new ReferenceAssemblies(string.Empty); + TestState.AdditionalReferences.AddRange(SourceGenerators.Tests.LiveReferencePack.GetMetadataReferences()); + } + + protected override IEnumerable GetSourceGenerators() + => [typeof(Microsoft.Interop.JavaScript.JSImportGenerator), typeof(Microsoft.Interop.JavaScript.JSExportGenerator)]; + } } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Analyzers/ConvertComImportToGeneratedComInterfaceAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Analyzers/ConvertComImportToGeneratedComInterfaceAnalyzer.cs index f9b96eb7e3018..ad3b8d97f8f45 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Analyzers/ConvertComImportToGeneratedComInterfaceAnalyzer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Analyzers/ConvertComImportToGeneratedComInterfaceAnalyzer.cs @@ -97,17 +97,17 @@ public override void Initialize(AnalysisContext context) if (s_unsupportedTypeNames.Contains(info.ManagedType.FullTypeName)) { anyExplicitlyUnsupportedInfo = true; - return ResolvedGenerator.Resolved(forwarder); + return ResolvedGenerator.Resolved(forwarder.Bind(info)); } if (HasUnsupportedMarshalAsInfo(info)) { anyExplicitlyUnsupportedInfo = true; - return ResolvedGenerator.Resolved(forwarder); + return ResolvedGenerator.Resolved(forwarder.Bind(info)); } if (info.MarshallingAttributeInfo is TrackedMarshallingInfo(TrackedMarshallingInfoAnnotation.ExplicitlyUnsupported, _)) { anyExplicitlyUnsupportedInfo = true; - return ResolvedGenerator.Resolved(forwarder); + return ResolvedGenerator.Resolved(forwarder.Bind(info)); } if (info.MarshallingAttributeInfo is TrackedMarshallingInfo(TrackedMarshallingInfoAnnotation annotation, var inner)) { diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ComMethodContext.cs b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ComMethodContext.cs index f0cb535607b10..c194e771e139f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ComMethodContext.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ComMethodContext.cs @@ -142,7 +142,7 @@ private MethodDeclarationSyntax GenerateShadow() CastExpression(OriginalDeclaringInterface.Info.Type.Syntax, IdentifierName("this"))), IdentifierName(MethodInfo.MethodName)), ArgumentList( - SeparatedList(GenerationContext.SignatureContext.ManagedParameters.Select(p => forwarder.AsArgument(p, new ManagedStubCodeContext()))))))) + SeparatedList(GenerationContext.SignatureContext.ManagedParameters.Select(p => forwarder.Bind(p).AsArgument(new ManagedStubCodeContext()))))))) .WithSemicolonToken(Token(SyntaxKind.SemicolonToken)); } diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ManagedToNativeVTableMethodGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ManagedToNativeVTableMethodGenerator.cs index 81183b32b9e70..91c6d3a64ba2c 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ManagedToNativeVTableMethodGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ManagedToNativeVTableMethodGenerator.cs @@ -77,7 +77,7 @@ public ManagedToNativeVTableMethodGenerator( diagnosticsBag.ReportGeneratorDiagnostics(bindingFailures); - if (_marshallers.ManagedReturnMarshaller.Generator.UsesNativeIdentifier(_marshallers.ManagedReturnMarshaller.TypeInfo, _context)) + if (_marshallers.ManagedReturnMarshaller.UsesNativeIdentifier(_context)) { // If we need a different native return identifier, then recreate the context with the correct identifier before we generate any code. _context = new ManagedToNativeStubCodeContext(ReturnIdentifier, $"{ReturnIdentifier}{StubCodeContext.GeneratedNativeIdentifierSuffix}"); diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ComInterfaceDispatchMarshallingResolver.cs b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ComInterfaceDispatchMarshallingResolver.cs index f93be2ed9931b..899fe56175b57 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ComInterfaceDispatchMarshallingResolver.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ComInterfaceDispatchMarshallingResolver.cs @@ -17,9 +17,9 @@ internal sealed record ComInterfaceDispatchMarshallingInfo : MarshallingInfo internal sealed class ComInterfaceDispatchMarshallingResolver : IMarshallingGeneratorResolver { public ResolvedGenerator Create(TypePositionInfo info, StubCodeContext context) - => info.MarshallingAttributeInfo is ComInterfaceDispatchMarshallingInfo ? ResolvedGenerator.Resolved(new Marshaller()) : ResolvedGenerator.UnresolvedGenerator; + => info.MarshallingAttributeInfo is ComInterfaceDispatchMarshallingInfo ? ResolvedGenerator.Resolved(new Marshaller().Bind(info)) : ResolvedGenerator.UnresolvedGenerator; - private sealed class Marshaller : IMarshallingGenerator + private sealed class Marshaller : IUnboundMarshallingGenerator { public ManagedTypeInfo AsNativeType(TypePositionInfo info) => new PointerTypeInfo( diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ManagedHResultExceptionGeneratorResolver.cs b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ManagedHResultExceptionGeneratorResolver.cs index 5812392631655..1af732f2b47f5 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ManagedHResultExceptionGeneratorResolver.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ManagedHResultExceptionGeneratorResolver.cs @@ -32,8 +32,8 @@ public ResolvedGenerator Create(TypePositionInfo info, StubCodeContext context) { return ResolvedGenerator.Resolved(_direction switch { - MarshalDirection.UnmanagedToManaged => new UnmanagedToManagedMarshaller(), - MarshalDirection.ManagedToUnmanaged => new ManagedToUnmanagedMarshaller(), + MarshalDirection.UnmanagedToManaged => new UnmanagedToManagedMarshaller().Bind(info), + MarshalDirection.ManagedToUnmanaged => new ManagedToUnmanagedMarshaller().Bind(info), _ => throw new UnreachableException() }); } @@ -43,7 +43,7 @@ public ResolvedGenerator Create(TypePositionInfo info, StubCodeContext context) } } - private sealed class ManagedToUnmanagedMarshaller : IMarshallingGenerator + private sealed class ManagedToUnmanagedMarshaller : IUnboundMarshallingGenerator { public ManagedTypeInfo AsNativeType(TypePositionInfo info) => info.ManagedType; public IEnumerable Generate(TypePositionInfo info, StubCodeContext context) @@ -71,7 +71,7 @@ public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarsh public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => false; } - private sealed class UnmanagedToManagedMarshaller : IMarshallingGenerator + private sealed class UnmanagedToManagedMarshaller : IUnboundMarshallingGenerator { public ManagedTypeInfo AsNativeType(TypePositionInfo info) => info.ManagedType; public IEnumerable Generate(TypePositionInfo info, StubCodeContext context) diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ObjectUnwrapperResolver.cs b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ObjectUnwrapperResolver.cs index 9f76b8bf19d92..7b1fe405f27ec 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ObjectUnwrapperResolver.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ObjectUnwrapperResolver.cs @@ -15,9 +15,9 @@ internal sealed record ObjectUnwrapperInfo(TypeSyntax UnwrapperType) : Marshalli internal sealed class ObjectUnwrapperResolver : IMarshallingGeneratorResolver { public ResolvedGenerator Create(TypePositionInfo info, StubCodeContext context) - => info.MarshallingAttributeInfo is ObjectUnwrapperInfo ? ResolvedGenerator.Resolved(new Marshaller()) : ResolvedGenerator.UnresolvedGenerator; + => info.MarshallingAttributeInfo is ObjectUnwrapperInfo ? ResolvedGenerator.Resolved(new Marshaller().Bind(info)) : ResolvedGenerator.UnresolvedGenerator; - private sealed class Marshaller : IMarshallingGenerator + private sealed class Marshaller : IUnboundMarshallingGenerator { public ManagedTypeInfo AsNativeType(TypePositionInfo info) => new PointerTypeInfo("void*", "void*", false); public IEnumerable Generate(TypePositionInfo info, StubCodeContext context) diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/StructAsHResultMarshallerFactory.cs b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/StructAsHResultMarshallerFactory.cs index 89b297b4e3578..a9bd1619b6429 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/StructAsHResultMarshallerFactory.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/StructAsHResultMarshallerFactory.cs @@ -19,13 +19,13 @@ public ResolvedGenerator Create(TypePositionInfo info, StubCodeContext context) // Value type with MarshalAs(UnmanagedType.Error), to be marshalled as an unmanaged HRESULT. if (info is { ManagedType: ValueTypeInfo, MarshallingAttributeInfo: MarshalAsInfo(UnmanagedType.Error, _) }) { - return ResolvedGenerator.Resolved(s_marshaller); + return ResolvedGenerator.Resolved(s_marshaller.Bind(info)); } return ResolvedGenerator.UnresolvedGenerator; } - private sealed class Marshaller : IMarshallingGenerator + private sealed class Marshaller : IUnboundMarshallingGenerator { public ManagedTypeInfo AsNativeType(TypePositionInfo info) => SpecialTypeInfo.Int32; diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/UnmanagedToManagedStubGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/UnmanagedToManagedStubGenerator.cs index ed94e5d127ad3..86938e1a98dfe 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/UnmanagedToManagedStubGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/UnmanagedToManagedStubGenerator.cs @@ -29,7 +29,7 @@ public UnmanagedToManagedStubGenerator( diagnosticsBag.ReportGeneratorDiagnostics(bindingDiagnostics); - if (_marshallers.NativeReturnMarshaller.Generator.UsesNativeIdentifier(_marshallers.NativeReturnMarshaller.TypeInfo, _context)) + if (_marshallers.NativeReturnMarshaller.UsesNativeIdentifier(_context)) { // If we need a different native return identifier, then recreate the context with the correct identifier before we generate any code. _context = new NativeToManagedStubCodeContext(ReturnIdentifier, $"{ReturnIdentifier}{StubCodeContext.GeneratedNativeIdentifierSuffix}"); diff --git a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Analyzers/ConvertToLibraryImportAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Analyzers/ConvertToLibraryImportAnalyzer.cs index 609cdf26746df..08cc38766e301 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Analyzers/ConvertToLibraryImportAnalyzer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Analyzers/ConvertToLibraryImportAnalyzer.cs @@ -133,12 +133,12 @@ private static void AnalyzeSymbol(SymbolAnalysisContext context, INamedTypeSymbo if (s_unsupportedTypeNames.Contains(info.ManagedType.FullTypeName)) { anyExplicitlyUnsupportedInfo = true; - return ResolvedGenerator.Resolved(forwarder); + return ResolvedGenerator.Resolved(forwarder.Bind(info)); } if (HasUnsupportedMarshalAsInfo(info)) { anyExplicitlyUnsupportedInfo = true; - return ResolvedGenerator.Resolved(forwarder); + return ResolvedGenerator.Resolved(forwarder.Bind(info)); } return factory.Create(info, stubCodeContext); }), stubCodeContext, forwarder, out var bindingFailures); diff --git a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/ForwarderResolver.cs b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/ForwarderResolver.cs index 5570372bd31d0..a87be394a86fc 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/ForwarderResolver.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/ForwarderResolver.cs @@ -11,6 +11,6 @@ internal sealed class ForwarderResolver : IMarshallingGeneratorResolver { private static readonly Forwarder s_forwarder = new Forwarder(); - public ResolvedGenerator Create(TypePositionInfo info, StubCodeContext context) => ResolvedGenerator.Resolved(s_forwarder); + public ResolvedGenerator Create(TypePositionInfo info, StubCodeContext context) => ResolvedGenerator.Resolved(s_forwarder.Bind(info)); } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/PInvokeStubCodeGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/PInvokeStubCodeGenerator.cs index 0d5c8a06d14f0..55720b6ed8051 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/PInvokeStubCodeGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/PInvokeStubCodeGenerator.cs @@ -61,7 +61,7 @@ public PInvokeStubCodeGenerator( diagnosticsBag.ReportGeneratorDiagnostics(bindingDiagnostics); - if (_marshallers.ManagedReturnMarshaller.Generator.UsesNativeIdentifier(_marshallers.ManagedReturnMarshaller.TypeInfo, _context)) + if (_marshallers.ManagedReturnMarshaller.UsesNativeIdentifier(_context)) { // If we need a different native return identifier, then recreate the context with the correct identifier before we generate any code. _context = new ManagedToNativeStubCodeContext(ReturnIdentifier, $"{ReturnIdentifier}{StubCodeContext.GeneratedNativeIdentifierSuffix}"); @@ -71,17 +71,16 @@ public PInvokeStubCodeGenerator( bool noMarshallingNeeded = true; - foreach (BoundGenerator generator in _marshallers.SignatureMarshallers) + foreach (IBoundMarshallingGenerator generator in _marshallers.SignatureMarshallers) { // Check if generator is either blittable or just a forwarder. - noMarshallingNeeded &= generator is { Generator: BlittableMarshaller, TypeInfo.IsByRef: false } - or { Generator: Forwarder }; + noMarshallingNeeded &= (generator.IsBlittable() && !generator.TypeInfo.IsByRef) || generator.IsForwarder(); // Track if any generators are just forwarders - for types other than void, this indicates // types that can't be marshalled by the source generated. // In .NET 7+ support, we would have emitted a diagnostic error about lack of support // In down-level support, we do not error - tracking this allows us to switch to generating a basic forwarder (DllImport declaration) - HasForwardedTypes |= generator is { Generator: Forwarder, TypeInfo.ManagedType: not SpecialTypeInfo { SpecialType: Microsoft.CodeAnalysis.SpecialType.System_Void } }; + HasForwardedTypes |= generator.IsForwarder() && generator is { TypeInfo.ManagedType: not SpecialTypeInfo { SpecialType: Microsoft.CodeAnalysis.SpecialType.System_Void } }; } StubIsBasicForwarder = !setLastError diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/BoundGenerators.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/BoundGenerators.cs index 99e15793754b2..c98ab2d263c5a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/BoundGenerators.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/BoundGenerators.cs @@ -14,24 +14,22 @@ namespace Microsoft.Interop { - public readonly record struct BoundGenerator(TypePositionInfo TypeInfo, IMarshallingGenerator Generator); - public sealed class BoundGenerators { private BoundGenerators() { } - public static BoundGenerators Create(ImmutableArray elementTypeInfo, IMarshallingGeneratorResolver generatorResolver, StubCodeContext context, IMarshallingGenerator fallbackGenerator, out ImmutableArray generatorBindingDiagnostics) + public static BoundGenerators Create(ImmutableArray elementTypeInfo, IMarshallingGeneratorResolver generatorResolver, StubCodeContext context, IUnboundMarshallingGenerator fallbackGenerator, out ImmutableArray generatorBindingDiagnostics) { - BoundGenerator defaultBoundGenerator = new BoundGenerator(new TypePositionInfo(SpecialTypeInfo.Void, NoMarshallingInfo.Instance), fallbackGenerator); + IBoundMarshallingGenerator defaultBoundGenerator = fallbackGenerator.Bind(new TypePositionInfo(SpecialTypeInfo.Void, NoMarshallingInfo.Instance)); BoundGenerators result = new(); - ImmutableArray.Builder signatureMarshallers = ImmutableArray.CreateBuilder(); - ImmutableArray.Builder nativeParamMarshallers = ImmutableArray.CreateBuilder(); - ImmutableArray.Builder managedParamMarshallers = ImmutableArray.CreateBuilder(); + ImmutableArray.Builder signatureMarshallers = ImmutableArray.CreateBuilder(); + ImmutableArray.Builder nativeParamMarshallers = ImmutableArray.CreateBuilder(); + ImmutableArray.Builder managedParamMarshallers = ImmutableArray.CreateBuilder(); ImmutableArray.Builder generatorDiagnostics = ImmutableArray.CreateBuilder(); - BoundGenerator managedReturnMarshaller = defaultBoundGenerator; - BoundGenerator nativeReturnMarshaller = defaultBoundGenerator; - BoundGenerator managedExceptionMarshaller = defaultBoundGenerator; + IBoundMarshallingGenerator managedReturnMarshaller = defaultBoundGenerator; + IBoundMarshallingGenerator nativeReturnMarshaller = defaultBoundGenerator; + IBoundMarshallingGenerator managedExceptionMarshaller = defaultBoundGenerator; TypePositionInfo? managedExceptionInfo = null; foreach (TypePositionInfo argType in elementTypeInfo) @@ -45,7 +43,7 @@ public static BoundGenerators Create(ImmutableArray elementTyp continue; } - BoundGenerator generator = new BoundGenerator(argType, CreateGenerator(argType, generatorResolver)); + IBoundMarshallingGenerator generator = CreateGenerator(argType, generatorResolver); signatureMarshallers.Add(generator); if (argType.IsManagedReturnPosition) @@ -80,15 +78,15 @@ public static BoundGenerators Create(ImmutableArray elementTyp { managedExceptionInfo = managedExceptionInfo with { - MarshallingAttributeInfo = ComExceptionMarshalling.CreateSpecificMarshallingInfo(nativeReturnMarshaller.Generator.AsNativeType(nativeReturnMarshaller.TypeInfo)) + MarshallingAttributeInfo = ComExceptionMarshalling.CreateSpecificMarshallingInfo(nativeReturnMarshaller.NativeType) }; } - IMarshallingGeneratorResolver exceptionHandlerFactory = new ExtendedInvariantsValidator(nativeReturnMarshaller.Generator.AsNativeType(nativeReturnMarshaller.TypeInfo), generatorResolver); + IMarshallingGeneratorResolver exceptionHandlerFactory = new ExtendedInvariantsValidator(nativeReturnMarshaller.NativeType, generatorResolver); // We explicitly don't include exceptionMarshaller in the signatureMarshallers collection // as it needs to be specially emitted. - managedExceptionMarshaller = new(managedExceptionInfo, CreateGenerator(managedExceptionInfo, generatorResolver)); + managedExceptionMarshaller = CreateGenerator(managedExceptionInfo, generatorResolver); } generatorBindingDiagnostics = generatorDiagnostics.ToImmutable(); @@ -153,34 +151,34 @@ public static BoundGenerators Create(ImmutableArray elementTyp return (false, info.NativeIndex); } - IMarshallingGenerator CreateGenerator(TypePositionInfo p, IMarshallingGeneratorResolver factory) + IBoundMarshallingGenerator CreateGenerator(TypePositionInfo p, IMarshallingGeneratorResolver factory) { ResolvedGenerator generator = factory.Create(p, context); generatorDiagnostics.AddRange(generator.Diagnostics); - return generator.IsResolvedWithoutErrors ? generator.Generator : fallbackGenerator; + return generator.IsResolvedWithoutErrors ? generator.Generator : fallbackGenerator.Bind(p); } } - public BoundGenerator ManagedReturnMarshaller { get; private init; } + public IBoundMarshallingGenerator ManagedReturnMarshaller { get; private init; } - public BoundGenerator NativeReturnMarshaller { get; private init; } + public IBoundMarshallingGenerator NativeReturnMarshaller { get; private init; } - public BoundGenerator ManagedExceptionMarshaller { get; private init; } + public IBoundMarshallingGenerator ManagedExceptionMarshaller { get; private init; } - public ImmutableArray SignatureMarshallers { get; private init; } + public ImmutableArray SignatureMarshallers { get; private init; } - public ImmutableArray ManagedParameterMarshallers { get; private init; } + public ImmutableArray ManagedParameterMarshallers { get; private init; } - public ImmutableArray NativeParameterMarshallers { get; private init; } + public ImmutableArray NativeParameterMarshallers { get; private init; } public (ParameterListSyntax ParameterList, TypeSyntax ReturnType, AttributeListSyntax? ReturnTypeAttributes) GenerateTargetMethodSignatureData(StubCodeContext context) { return ( ParameterList( SeparatedList( - NativeParameterMarshallers.Select(marshaler => marshaler.Generator.AsParameter(marshaler.TypeInfo, context)))), - NativeReturnMarshaller.Generator.AsReturnType(NativeReturnMarshaller.TypeInfo), - NativeReturnMarshaller.Generator.GenerateAttributesForReturnType(NativeReturnMarshaller.TypeInfo) + NativeParameterMarshallers.Select(marshaler => marshaler.AsParameter(context)))), + NativeReturnMarshaller.AsReturnType(), + NativeReturnMarshaller.GenerateAttributesForReturnType() ); } @@ -190,7 +188,7 @@ IMarshallingGenerator CreateGenerator(TypePositionInfo p, IMarshallingGeneratorR public bool IsUnmanagedVoidReturn => NativeReturnMarshaller.TypeInfo.ManagedType == SpecialTypeInfo.Void; - public bool HasManagedExceptionMarshaller => ManagedExceptionMarshaller.Generator is not Forwarder; + public bool HasManagedExceptionMarshaller => !ManagedExceptionMarshaller.IsForwarder(); private sealed class ExtendedInvariantsValidator : IMarshallingGeneratorResolver { @@ -212,9 +210,9 @@ public ResolvedGenerator Create(TypePositionInfo info, StubCodeContext context) } // Marshallers that share the native return position must have the same native return type. if (info.IsNativeReturnPosition - && generator.Generator.AsNativeType(info) != _nativeReturnType) + && generator.Generator.NativeType != _nativeReturnType) { - return ResolvedGenerator.NotSupported(new(info, context) + return ResolvedGenerator.NotSupported(info, new(info, context) { NotSupportedDetails = SR.MarshallerInNativeReturnPositionMustMatchNativeReturnType }); diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/GeneratedStatements.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/GeneratedStatements.cs index 896487328de53..1376235bf1b47 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/GeneratedStatements.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/GeneratedStatements.cs @@ -71,9 +71,9 @@ public static GeneratedStatements Create(BoundGenerators marshallers, StubCodeCo private static ImmutableArray GenerateStatementsForStubContext(BoundGenerators marshallers, StubCodeContext context) { ImmutableArray.Builder statementsToUpdate = ImmutableArray.CreateBuilder(); - foreach (BoundGenerator marshaller in marshallers.SignatureMarshallers) + foreach (IBoundMarshallingGenerator marshaller in marshallers.SignatureMarshallers) { - statementsToUpdate.AddRange(marshaller.Generator.Generate(marshaller.TypeInfo, context)); + statementsToUpdate.AddRange(marshaller.Generate(context)); } if (statementsToUpdate.Count > 0) @@ -95,10 +95,10 @@ private static ExpressionStatementSyntax GenerateStatementForNativeInvoke(BoundG } InvocationExpressionSyntax invoke = InvocationExpression(expressionToInvoke); // Generate code for each parameter for the current stage - foreach (BoundGenerator marshaller in marshallers.NativeParameterMarshallers) + foreach (IBoundMarshallingGenerator marshaller in marshallers.NativeParameterMarshallers) { // Get arguments for invocation - ArgumentSyntax argSyntax = marshaller.Generator.AsArgument(marshaller.TypeInfo, context); + ArgumentSyntax argSyntax = marshaller.AsArgument(context); invoke = invoke.AddArgumentListArguments(argSyntax); } // Assign to return value if necessary @@ -109,7 +109,7 @@ private static ExpressionStatementSyntax GenerateStatementForNativeInvoke(BoundG var (managed, native) = context.GetIdentifiers(marshallers.NativeReturnMarshaller.TypeInfo); - string targetIdentifier = marshallers.NativeReturnMarshaller.Generator.UsesNativeIdentifier(marshallers.NativeReturnMarshaller.TypeInfo, context) + string targetIdentifier = marshallers.NativeReturnMarshaller.UsesNativeIdentifier(context) ? native : managed; @@ -129,10 +129,10 @@ private static ExpressionStatementSyntax GenerateStatementForManagedInvoke(Bound } InvocationExpressionSyntax invoke = InvocationExpression(expressionToInvoke); // Generate code for each parameter for the current stage - foreach (BoundGenerator marshaller in marshallers.ManagedParameterMarshallers) + foreach (IBoundMarshallingGenerator marshaller in marshallers.ManagedParameterMarshallers) { // Get arguments for invocation - ArgumentSyntax argSyntax = marshaller.Generator.AsManagedArgument(marshaller.TypeInfo, context); + ArgumentSyntax argSyntax = marshaller.AsManagedArgument(context); invoke = invoke.AddArgumentListArguments(argSyntax); } // Assign to return value if necessary @@ -156,16 +156,14 @@ private static ImmutableArray GenerateCatchClauseForManagedEx } ImmutableArray.Builder catchClauseBuilder = ImmutableArray.CreateBuilder(); - BoundGenerator managedExceptionMarshaller = marshallers.ManagedExceptionMarshaller; + IBoundMarshallingGenerator managedExceptionMarshaller = marshallers.ManagedExceptionMarshaller; var (managed, _) = context.GetIdentifiers(managedExceptionMarshaller.TypeInfo); catchClauseBuilder.AddRange( - managedExceptionMarshaller.Generator.Generate( - managedExceptionMarshaller.TypeInfo, context with { CurrentStage = StubCodeContext.Stage.Marshal })); + managedExceptionMarshaller.Generate(context with { CurrentStage = StubCodeContext.Stage.Marshal })); catchClauseBuilder.AddRange( - managedExceptionMarshaller.Generator.Generate( - managedExceptionMarshaller.TypeInfo, context with { CurrentStage = StubCodeContext.Stage.PinnedMarshal })); + managedExceptionMarshaller.Generate(context with { CurrentStage = StubCodeContext.Stage.PinnedMarshal })); return ImmutableArray.Create( CatchClause( CatchDeclaration(TypeSyntaxes.System_Exception, Identifier(managed)), diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/IncrementalGeneratorInitializationContextExtensions.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/IncrementalGeneratorInitializationContextExtensions.cs index 48bfaf47297ff..88094b0cff851 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/IncrementalGeneratorInitializationContextExtensions.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/IncrementalGeneratorInitializationContextExtensions.cs @@ -84,10 +84,12 @@ public static void RegisterConcatenatedSyntaxOutputs(this IncrementalGene StringBuilder source = new(); // Mark in source that the file is auto-generated. - source.AppendLine("// "); + // Explicitly unify on "\r\n" line endings to avoid issues with different line endings in the generated sources. + source.Append("// \r\n"); foreach (string generated in generatedSources) { - source.AppendLine(generated); + source.Append(generated); + source.Append("\r\n"); } // Once https://github.com/dotnet/roslyn/issues/61326 is resolved, we can avoid the ToString() here. diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/AttributedMarshallingModelGeneratorResolver.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/AttributedMarshallingModelGeneratorResolver.cs index 9a6c6c82d3469..69675f684204c 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/AttributedMarshallingModelGeneratorResolver.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/AttributedMarshallingModelGeneratorResolver.cs @@ -54,11 +54,11 @@ public ResolvedGenerator Create(TypePositionInfo info, StubCodeContext context) { if (Options.RuntimeMarshallingDisabled || blittableInfo.IsStrictlyBlittable) { - return ResolvedGenerator.Resolved(s_blittable); + return ResolvedGenerator.Resolved(s_blittable.Bind(info)); } return ResolvedGenerator.NotSupported( - new GeneratorDiagnostic.NotSupported(info, context) + info, new GeneratorDiagnostic.NotSupported(info, context) { NotSupportedDetails = SR.RuntimeMarshallingMustBeDisabled, DiagnosticProperties = AddDisableRuntimeMarshallingAttributeProperties @@ -67,7 +67,7 @@ public ResolvedGenerator Create(TypePositionInfo info, StubCodeContext context) if (info.MarshallingAttributeInfo is MissingSupportMarshallingInfo) { - return ResolvedGenerator.Resolved(s_forwarder); + return ResolvedGenerator.Resolved(s_forwarder.Bind(info)); } return ResolvedGenerator.UnresolvedGenerator; @@ -241,13 +241,13 @@ private ResolvedGenerator CreateCustomNativeTypeMarshaller(TypePositionInfo info { if (ValidateCustomNativeTypeMarshallingSupported(info, context, marshalInfo) is GeneratorDiagnostic.NotSupported diagnostic) { - return ResolvedGenerator.NotSupported(diagnostic); + return ResolvedGenerator.NotSupported(info, diagnostic); } CustomTypeMarshallerData marshallerData = GetMarshallerDataForTypePositionInfo(marshalInfo.Marshallers, info, context); if (!ValidateRuntimeMarshallingOptions(marshallerData)) { - return ResolvedGenerator.NotSupported(new(info, context) + return ResolvedGenerator.NotSupported(info, new(info, context) { NotSupportedDetails = SR.RuntimeMarshallingMustBeDisabled, DiagnosticProperties = AddDisableRuntimeMarshallingAttributeProperties @@ -289,7 +289,7 @@ private ResolvedGenerator CreateCustomNativeTypeMarshaller(TypePositionInfo info } } - IMarshallingGenerator marshallingGenerator = new CustomTypeMarshallingGenerator(marshallingStrategy, ByValueMarshalKindSupportDescriptor.Default, marshallerData.Shape.HasFlag(MarshallerShape.StatelessPinnableReference)); + IBoundMarshallingGenerator marshallingGenerator = new CustomTypeMarshallingGenerator(info, marshallingStrategy, ByValueMarshalKindSupportDescriptor.Default, marshallerData.Shape.HasFlag(MarshallerShape.StatelessPinnableReference)); if (marshallerData.Shape.HasFlag(MarshallerShape.StatelessPinnableReference)) { @@ -319,7 +319,7 @@ private ResolvedGenerator CreateNativeCollectionMarshaller( { return resolvedElementMarshaller; } - IMarshallingGenerator elementMarshaller = resolvedElementMarshaller.Generator; + IBoundMarshallingGenerator elementMarshaller = resolvedElementMarshaller.Generator; ExpressionSyntax numElementsExpression = LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(0)); if (MarshallerHelpers.GetMarshalDirection(info, context) != MarshalDirection.ManagedToUnmanaged) @@ -328,13 +328,13 @@ private ResolvedGenerator CreateNativeCollectionMarshaller( ExpressionOrNotSupported numElementsExpressionResult = GetNumElementsExpressionFromMarshallingInfo(info, marshalInfo.ElementCountInfo, context); if (numElementsExpressionResult is (_, GeneratorDiagnostic.NotSupported notSupportedDiagnostic)) { - return ResolvedGenerator.NotSupported(notSupportedDiagnostic); + return ResolvedGenerator.NotSupported(info, notSupportedDiagnostic); } numElementsExpression = numElementsExpressionResult.Expression; } // Insert the unmanaged element type into the marshaller type - TypeSyntax unmanagedElementType = elementMarshaller.AsNativeType(elementInfo).Syntax.GetCompatibleGenericTypeParameterSyntax(); + TypeSyntax unmanagedElementType = elementMarshaller.NativeType.Syntax.GetCompatibleGenericTypeParameterSyntax(); ManagedTypeInfo marshallerType = marshallerData.MarshallerType; TypeSyntax marshallerTypeSyntax = ReplacePlaceholderSyntaxWithUnmanagedTypeSyntax(marshallerType.Syntax, marshalInfo, unmanagedElementType); marshallerType = marshallerType with @@ -350,7 +350,7 @@ private ResolvedGenerator CreateNativeCollectionMarshaller( }; ICustomTypeMarshallingStrategy marshallingStrategy; - bool elementIsBlittable = elementMarshaller is BlittableMarshaller; + bool elementIsBlittable = elementMarshaller.IsBlittable(); if (marshallerData.HasState) { @@ -366,7 +366,7 @@ private ResolvedGenerator CreateNativeCollectionMarshaller( var freeStrategy = GetFreeStrategy(info, context); IElementsMarshallingCollectionSource collectionSource = new StatefulLinearCollectionSource(); - ElementsMarshalling elementsMarshalling = CreateElementsMarshalling(marshallerData, elementInfo, elementMarshaller, unmanagedElementType, collectionSource); + ElementsMarshalling elementsMarshalling = CreateElementsMarshalling(marshallerData, elementMarshaller, unmanagedElementType, collectionSource); if (freeStrategy == FreeStrategy.FreeOriginal) { @@ -397,7 +397,7 @@ private ResolvedGenerator CreateNativeCollectionMarshaller( marshallingStrategy = new UnmanagedToManagedOwnershipTrackingStrategy(marshallingStrategy); } - ElementsMarshalling elementsMarshalling = CreateElementsMarshalling(marshallerData, elementInfo, elementMarshaller, unmanagedElementType, collectionSource); + ElementsMarshalling elementsMarshalling = CreateElementsMarshalling(marshallerData, elementMarshaller, unmanagedElementType, collectionSource); marshallingStrategy = new StatelessLinearCollectionMarshalling(marshallingStrategy, elementsMarshalling, nativeType, marshallerData.Shape, numElementsExpression, freeStrategy != FreeStrategy.NoFree); @@ -434,7 +434,7 @@ private ResolvedGenerator CreateNativeCollectionMarshaller( // Elements in the collection must be blittable to use the pinnable marshaller. bool isPinned = marshallerData.Shape.HasFlag(MarshallerShape.StatelessPinnableReference) && elementIsBlittable; - IMarshallingGenerator marshallingGenerator = new CustomTypeMarshallingGenerator(marshallingStrategy, byValueMarshalKindSupport, isPinned); + IBoundMarshallingGenerator marshallingGenerator = new CustomTypeMarshallingGenerator(info, marshallingStrategy, byValueMarshalKindSupport, isPinned); if (isPinned) { marshallingGenerator = new StaticPinnableManagedValueMarshaller(marshallingGenerator, marshallerTypeSyntax); @@ -484,33 +484,23 @@ private static FreeStrategy GetFreeStrategy(TypePositionInfo info, StubCodeConte return FreeStrategy.NoFree; } - private static ElementsMarshalling CreateElementsMarshalling(CustomTypeMarshallerData marshallerData, TypePositionInfo elementInfo, IMarshallingGenerator elementMarshaller, TypeSyntax unmanagedElementType, IElementsMarshallingCollectionSource collectionSource) + private static ElementsMarshalling CreateElementsMarshalling(CustomTypeMarshallerData marshallerData, IBoundMarshallingGenerator elementMarshaller, TypeSyntax unmanagedElementType, IElementsMarshallingCollectionSource collectionSource) { ElementsMarshalling elementsMarshalling; - bool elementIsBlittable = elementMarshaller is BlittableMarshaller; + bool elementIsBlittable = elementMarshaller.IsBlittable(); if (elementIsBlittable) { elementsMarshalling = new BlittableElementsMarshalling(marshallerData.CollectionElementType.Syntax, unmanagedElementType, collectionSource); } else { - elementsMarshalling = new NonBlittableElementsMarshalling(unmanagedElementType, elementMarshaller, elementInfo, collectionSource); + elementsMarshalling = new NonBlittableElementsMarshalling(unmanagedElementType, elementMarshaller, collectionSource); } return elementsMarshalling; } - private static bool ElementTypeIsSometimesNonBlittable(TypePositionInfo elementInfo) - { - if (elementInfo.MarshallingAttributeInfo is NoMarshallingInfo - || elementInfo.MarshallingAttributeInfo is UnmanagedBlittableMarshallingInfo { IsStrictlyBlittable: true }) - { - return false; - } - return true; - } - private static TypeSyntax ReplacePlaceholderSyntaxWithUnmanagedTypeSyntax( TypeSyntax originalTypeSyntax, NativeLinearCollectionMarshallingInfo marshalInfo, diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BlittableMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BlittableMarshaller.cs index 76577d497cb82..d9efb372bc52b 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BlittableMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BlittableMarshaller.cs @@ -9,7 +9,7 @@ namespace Microsoft.Interop { - public sealed class BlittableMarshaller : IMarshallingGenerator + public sealed class BlittableMarshaller : IUnboundMarshallingGenerator { public ManagedTypeInfo AsNativeType(TypePositionInfo info) { diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BoolMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BoolMarshaller.cs index 24e2102eb7399..e50484399c980 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BoolMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BoolMarshaller.cs @@ -11,7 +11,7 @@ namespace Microsoft.Interop { - public abstract class BoolMarshallerBase : IMarshallingGenerator + public abstract class BoolMarshallerBase : IUnboundMarshallingGenerator { private readonly ManagedTypeInfo _nativeType; private readonly int _trueValue; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ByValueContentsMarshalKindValidator.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ByValueContentsMarshalKindValidator.cs index 9878cbdbc58ab..867bfb4102cb1 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ByValueContentsMarshalKindValidator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ByValueContentsMarshalKindValidator.cs @@ -22,24 +22,24 @@ public ByValueContentsMarshalKindValidator(IMarshallingGeneratorResolver inner) public ResolvedGenerator Create(TypePositionInfo info, StubCodeContext context) { ResolvedGenerator generator = _inner.Create(info, context); - return generator.IsResolvedWithoutErrors ? ValidateByValueMarshalKind(info, context, generator) : generator; + return generator.IsResolvedWithoutErrors ? ValidateByValueMarshalKind(context, generator) : generator; } - private static ResolvedGenerator ValidateByValueMarshalKind(TypePositionInfo info, StubCodeContext context, ResolvedGenerator generator) + private static ResolvedGenerator ValidateByValueMarshalKind(StubCodeContext context, ResolvedGenerator generator) { - if (generator.Generator is Forwarder) + if (generator.Generator.IsForwarder()) { // Forwarder allows everything since it just forwards to a P/Invoke. // The Default marshal kind is always valid. return generator; } - var support = generator.Generator.SupportsByValueMarshalKind(info.ByValueContentsMarshalKind, info, context, out GeneratorDiagnostic? diagnostic); + var support = generator.Generator.SupportsByValueMarshalKind(generator.Generator.TypeInfo.ByValueContentsMarshalKind, context, out GeneratorDiagnostic? diagnostic); Debug.Assert(support == ByValueMarshalKindSupport.Supported || diagnostic is not null); return support switch { ByValueMarshalKindSupport.Supported => generator, - ByValueMarshalKindSupport.NotSupported => ResolvedGenerator.ResolvedWithDiagnostics(s_forwarder, generator.Diagnostics.Add(diagnostic!)), + ByValueMarshalKindSupport.NotSupported => ResolvedGenerator.ResolvedWithDiagnostics(s_forwarder.Bind(generator.Generator.TypeInfo), generator.Diagnostics.Add(diagnostic!)), ByValueMarshalKindSupport.Unnecessary => generator with { Diagnostics = generator.Diagnostics.Add(diagnostic!) }, ByValueMarshalKindSupport.NotRecommended => generator with { Diagnostics = generator.Diagnostics.Add(diagnostic!) }, _ => throw new UnreachableException() diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ByValueMarshalKindSupportDescriptor.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ByValueMarshalKindSupportDescriptor.cs index 7754e177d6606..c2329f1e1eefc 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ByValueMarshalKindSupportDescriptor.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ByValueMarshalKindSupportDescriptor.cs @@ -40,7 +40,7 @@ public ByValueMarshalKindSupport GetSupport(TypePositionInfo info, StubCodeConte } /// - /// Provides an implementation of through + /// Provides an implementation of through /// public record ByValueMarshalKindSupportDescriptor( ByValueMarshalKindSupportInfo DefaultSupport, diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs index dc70548ff4f06..80b9a53d9fb7e 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs @@ -11,7 +11,7 @@ namespace Microsoft.Interop { - public sealed class Utf16CharMarshaller : IMarshallingGenerator + public sealed class Utf16CharMarshaller : IUnboundMarshallingGenerator { private static readonly ManagedTypeInfo s_nativeType = SpecialTypeInfo.UInt16; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshallingGeneratorResolver.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshallingGeneratorResolver.cs index 303f4a40a4c52..f4e7092a10194 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshallingGeneratorResolver.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshallingGeneratorResolver.cs @@ -9,8 +9,8 @@ namespace Microsoft.Interop { public sealed class CharMarshallingGeneratorResolver : IMarshallingGeneratorResolver { - private static readonly IMarshallingGenerator s_blittable = new BlittableMarshaller(); - private static readonly IMarshallingGenerator s_utf16Char = new Utf16CharMarshaller(); + private static readonly IUnboundMarshallingGenerator s_blittable = new BlittableMarshaller(); + private static readonly IUnboundMarshallingGenerator s_utf16Char = new Utf16CharMarshaller(); private readonly bool _useBlittableMarshallerForUtf16; private readonly string _stringMarshallingAttribute; @@ -37,7 +37,7 @@ private ResolvedGenerator CreateCharMarshaller(TypePositionInfo info, StubCodeCo if (marshalInfo is NoMarshallingInfo) { // [Compat] Require explicit marshalling information. - return ResolvedGenerator.NotSupported(new(info, context) + return ResolvedGenerator.NotSupported(info, new(info, context) { NotSupportedDetails = string.Format(SR.MarshallingStringOrCharAsUndefinedNotSupported, _stringMarshallingAttribute) }); @@ -50,7 +50,7 @@ private ResolvedGenerator CreateCharMarshaller(TypePositionInfo info, StubCodeCo { case UnmanagedType.I2: case UnmanagedType.U2: - return ResolvedGenerator.Resolved(_useBlittableMarshallerForUtf16 ? s_blittable : s_utf16Char); + return ResolvedGenerator.Resolved(_useBlittableMarshallerForUtf16 ? s_blittable.Bind(info) : s_utf16Char.Bind(info)); } } else if (marshalInfo is MarshallingInfoStringSupport marshalStringInfo) @@ -58,21 +58,21 @@ private ResolvedGenerator CreateCharMarshaller(TypePositionInfo info, StubCodeCo switch (marshalStringInfo.CharEncoding) { case CharEncoding.Utf16: - return ResolvedGenerator.Resolved(_useBlittableMarshallerForUtf16 ? s_blittable : s_utf16Char); + return ResolvedGenerator.Resolved(_useBlittableMarshallerForUtf16 ? s_blittable.Bind(info) : s_utf16Char.Bind(info)); case CharEncoding.Utf8: - return ResolvedGenerator.NotSupported(new(info, context) // [Compat] UTF-8 is not supported for char + return ResolvedGenerator.NotSupported(info, new(info, context) // [Compat] UTF-8 is not supported for char { NotSupportedDetails = SR.Format(SR.MarshallingCharAsSpecifiedStringMarshallingNotSupported, nameof(CharEncoding.Utf8)) }); case CharEncoding.Custom: - return ResolvedGenerator.NotSupported(new(info, context) + return ResolvedGenerator.NotSupported(info, new(info, context) { NotSupportedDetails = SR.MarshallingCharAsStringMarshallingCustomNotSupported }); } } - return ResolvedGenerator.NotSupported(new(info, context)); + return ResolvedGenerator.NotSupported(info, new(info, context)); } } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CustomTypeMarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CustomTypeMarshallingGenerator.cs index 9c65fdc5e7c50..5b59bdc655b8b 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CustomTypeMarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CustomTypeMarshallingGenerator.cs @@ -10,35 +10,21 @@ namespace Microsoft.Interop /// /// Implements generating code for an instance. /// - internal sealed class CustomTypeMarshallingGenerator : IMarshallingGenerator + internal sealed class CustomTypeMarshallingGenerator(TypePositionInfo info, ICustomTypeMarshallingStrategy nativeTypeMarshaller, ByValueMarshalKindSupportDescriptor byValueContentsMarshallingSupport, bool isPinned) + : IBoundMarshallingGenerator { - private readonly ICustomTypeMarshallingStrategy _nativeTypeMarshaller; - private readonly ByValueMarshalKindSupportDescriptor _byValueContentsMarshallingSupport; - private readonly bool _isPinned; - - public CustomTypeMarshallingGenerator(ICustomTypeMarshallingStrategy nativeTypeMarshaller, ByValueMarshalKindSupportDescriptor byValueContentsMarshallingSupport, bool isPinned) - { - _nativeTypeMarshaller = nativeTypeMarshaller; - _byValueContentsMarshallingSupport = byValueContentsMarshallingSupport; - _isPinned = isPinned; - } - - public ValueBoundaryBehavior GetValueBoundaryBehavior(TypePositionInfo info, StubCodeContext context) + public ValueBoundaryBehavior GetValueBoundaryBehavior(StubCodeContext context) { return info.IsByRef ? ValueBoundaryBehavior.AddressOfNativeIdentifier : ValueBoundaryBehavior.NativeIdentifier; } - public ManagedTypeInfo AsNativeType(TypePositionInfo info) - { - return _nativeTypeMarshaller.AsNativeType(info); - } + public ManagedTypeInfo NativeType => nativeTypeMarshaller.AsNativeType(info); - public SignatureBehavior GetNativeSignatureBehavior(TypePositionInfo info) - { - return info.IsByRef ? SignatureBehavior.PointerToNativeType : SignatureBehavior.NativeType; - } + public SignatureBehavior NativeSignatureBehavior => info.IsByRef ? SignatureBehavior.PointerToNativeType : SignatureBehavior.NativeType; - public IEnumerable Generate(TypePositionInfo info, StubCodeContext context) + public TypePositionInfo TypeInfo => info; + + public IEnumerable Generate(StubCodeContext context) { MarshalDirection elementMarshalDirection = MarshallerHelpers.GetMarshalDirection(info, context); // Although custom native type marshalling doesn't support [In] or [Out] by value marshalling, @@ -46,56 +32,56 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont switch (context.CurrentStage) { case StubCodeContext.Stage.Setup: - return _nativeTypeMarshaller.GenerateSetupStatements(info, context); + return nativeTypeMarshaller.GenerateSetupStatements(info, context); case StubCodeContext.Stage.Marshal: if (elementMarshalDirection is MarshalDirection.ManagedToUnmanaged or MarshalDirection.Bidirectional - || (context.Direction == MarshalDirection.UnmanagedToManaged && ShouldGenerateByValueOutMarshalling(info, context))) + || (context.Direction == MarshalDirection.UnmanagedToManaged && ShouldGenerateByValueOutMarshalling(context))) { - return _nativeTypeMarshaller.GenerateMarshalStatements(info, context); + return nativeTypeMarshaller.GenerateMarshalStatements(info, context); } break; case StubCodeContext.Stage.Pin: if (context.SingleFrameSpansNativeContext && elementMarshalDirection is MarshalDirection.ManagedToUnmanaged) { - return _nativeTypeMarshaller.GeneratePinStatements(info, context); + return nativeTypeMarshaller.GeneratePinStatements(info, context); } break; case StubCodeContext.Stage.PinnedMarshal: if (elementMarshalDirection is MarshalDirection.ManagedToUnmanaged or MarshalDirection.Bidirectional) { - return _nativeTypeMarshaller.GeneratePinnedMarshalStatements(info, context); + return nativeTypeMarshaller.GeneratePinnedMarshalStatements(info, context); } break; case StubCodeContext.Stage.NotifyForSuccessfulInvoke: if (elementMarshalDirection is MarshalDirection.ManagedToUnmanaged or MarshalDirection.Bidirectional) { - return _nativeTypeMarshaller.GenerateNotifyForSuccessfulInvokeStatements(info, context); + return nativeTypeMarshaller.GenerateNotifyForSuccessfulInvokeStatements(info, context); } break; case StubCodeContext.Stage.UnmarshalCapture: if (elementMarshalDirection is MarshalDirection.UnmanagedToManaged or MarshalDirection.Bidirectional) { - return _nativeTypeMarshaller.GenerateUnmarshalCaptureStatements(info, context); + return nativeTypeMarshaller.GenerateUnmarshalCaptureStatements(info, context); } break; case StubCodeContext.Stage.Unmarshal: if (elementMarshalDirection is MarshalDirection.UnmanagedToManaged or MarshalDirection.Bidirectional - || (context.Direction == MarshalDirection.ManagedToUnmanaged && ShouldGenerateByValueOutMarshalling(info, context))) + || (context.Direction == MarshalDirection.ManagedToUnmanaged && ShouldGenerateByValueOutMarshalling(context))) { - return _nativeTypeMarshaller.GenerateUnmarshalStatements(info, context); + return nativeTypeMarshaller.GenerateUnmarshalStatements(info, context); } break; case StubCodeContext.Stage.GuaranteedUnmarshal: if (elementMarshalDirection is MarshalDirection.UnmanagedToManaged or MarshalDirection.Bidirectional - || (context.Direction == MarshalDirection.ManagedToUnmanaged && ShouldGenerateByValueOutMarshalling(info, context))) + || (context.Direction == MarshalDirection.ManagedToUnmanaged && ShouldGenerateByValueOutMarshalling(context))) { - return _nativeTypeMarshaller.GenerateGuaranteedUnmarshalStatements(info, context); + return nativeTypeMarshaller.GenerateGuaranteedUnmarshalStatements(info, context); } break; case StubCodeContext.Stage.CleanupCallerAllocated: - return _nativeTypeMarshaller.GenerateCleanupCallerAllocatedResourcesStatements(info, context); + return nativeTypeMarshaller.GenerateCleanupCallerAllocatedResourcesStatements(info, context); case StubCodeContext.Stage.CleanupCalleeAllocated: - return _nativeTypeMarshaller.GenerateCleanupCalleeAllocatedResourcesStatements(info, context); + return nativeTypeMarshaller.GenerateCleanupCalleeAllocatedResourcesStatements(info, context); default: break; } @@ -103,23 +89,25 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont return Array.Empty(); } - private bool ShouldGenerateByValueOutMarshalling(TypePositionInfo info, StubCodeContext context) + private bool ShouldGenerateByValueOutMarshalling(StubCodeContext context) { return info.ByValueContentsMarshalKind.HasFlag(ByValueContentsMarshalKind.Out) - && _byValueContentsMarshallingSupport.GetSupport(info.ByValueContentsMarshalKind, info, context, out _) != ByValueMarshalKindSupport.NotSupported + && byValueContentsMarshallingSupport.GetSupport(info.ByValueContentsMarshalKind, info, context, out _) != ByValueMarshalKindSupport.NotSupported && !info.IsByRef - && !_isPinned; + && !isPinned; } - public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) + public bool UsesNativeIdentifier(StubCodeContext context) { - return _nativeTypeMarshaller.UsesNativeIdentifier(info, context); + return nativeTypeMarshaller.UsesNativeIdentifier(info, context); } - public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, TypePositionInfo info, StubCodeContext context, out GeneratorDiagnostic? diagnostic) + public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context, out GeneratorDiagnostic? diagnostic) { - return _byValueContentsMarshallingSupport.GetSupport(marshalKind, info, context, out diagnostic); + return byValueContentsMarshallingSupport.GetSupport(marshalKind, info, context, out diagnostic); } + + public IBoundMarshallingGenerator Rebind(TypePositionInfo newInfo) => new CustomTypeMarshallingGenerator(newInfo, nativeTypeMarshaller, byValueContentsMarshallingSupport, isPinned); } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/DelegateMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/DelegateMarshaller.cs index 5f52ad6e4e730..318af7b4e3f59 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/DelegateMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/DelegateMarshaller.cs @@ -10,7 +10,7 @@ namespace Microsoft.Interop { - public sealed class DelegateMarshaller : IMarshallingGenerator + public sealed class DelegateMarshaller : IUnboundMarshallingGenerator { public ManagedTypeInfo AsNativeType(TypePositionInfo info) { diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ElementsMarshalling.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ElementsMarshalling.cs index 633b1249f995c..95a3db5e47bcf 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ElementsMarshalling.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ElementsMarshalling.cs @@ -213,24 +213,11 @@ private ExpressionSyntax CastToManagedIfNecessary(ExpressionSyntax expression) /// /// Support for marshalling non-blittable elements /// - internal sealed class NonBlittableElementsMarshalling : ElementsMarshalling + internal sealed class NonBlittableElementsMarshalling( + TypeSyntax unmanagedElementType, + IBoundMarshallingGenerator elementMarshaller, + IElementsMarshallingCollectionSource collectionSource) : ElementsMarshalling(collectionSource) { - private readonly TypeSyntax _unmanagedElementType; - private readonly IMarshallingGenerator _elementMarshaller; - private readonly TypePositionInfo _elementInfo; - - public NonBlittableElementsMarshalling( - TypeSyntax unmanagedElementType, - IMarshallingGenerator elementMarshaller, - TypePositionInfo elementInfo, - IElementsMarshallingCollectionSource collectionSource) - : base(collectionSource) - { - _unmanagedElementType = unmanagedElementType; - _elementMarshaller = elementMarshaller; - _elementInfo = elementInfo; - } - public override StatementSyntax GenerateMarshalStatement(TypePositionInfo info, StubCodeContext context) { string managedSpanIdentifier = MarshallerHelpers.GetManagedSpanIdentifier(info, context); @@ -243,11 +230,11 @@ public override StatementSyntax GenerateMarshalStatement(TypePositionInfo info, var statements = new List() { Declare( - ReadOnlySpanOf(_elementInfo.ManagedType.Syntax), + ReadOnlySpanOf(elementMarshaller.TypeInfo.ManagedType.Syntax), managedSpanIdentifier, CollectionSource.GetManagedValuesSource(info, context)), Declare( - SpanOf(_unmanagedElementType), + SpanOf(unmanagedElementType), nativeSpanIdentifier, CollectionSource.GetUnmanagedValuesDestination(info, context)) }; @@ -265,7 +252,7 @@ public override StatementSyntax GenerateMarshalStatement(TypePositionInfo info, MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, IdentifierName(MarshallerHelpers.GetManagedSpanIdentifier(info, context)), IdentifierName("Length")), - _elementInfo, _elementMarshaller, StubCodeContext.Stage.Marshal)); + elementMarshaller, StubCodeContext.Stage.Marshal)); return Block(statements); } @@ -280,18 +267,18 @@ public override StatementSyntax GenerateUnmarshalStatement(TypePositionInfo info // << unmarshal contents >> return Block( Declare( - ReadOnlySpanOf(_unmanagedElementType), + ReadOnlySpanOf(unmanagedElementType), nativeSpanIdentifier, CollectionSource.GetUnmanagedValuesSource(info, context)), Declare( - SpanOf(_elementInfo.ManagedType.Syntax), + SpanOf(elementMarshaller.TypeInfo.ManagedType.Syntax), managedSpanIdentifier, CollectionSource.GetManagedValuesDestination(info, context)), GenerateContentsMarshallingStatement( info, context, IdentifierName(numElementsIdentifier), - _elementInfo, _elementMarshaller, StubCodeContext.Stage.UnmarshalCapture, + elementMarshaller, StubCodeContext.Stage.UnmarshalCapture, StubCodeContext.Stage.Unmarshal)); } @@ -307,7 +294,7 @@ public override StatementSyntax GenerateManagedToUnmanagedByValueOutUnmarshalSta var setNumElements = CollectionSource.GetNumElementsAssignmentFromManagedValuesSource(info, context); // Span = MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in .GetPinnableReference(), )); - LocalDeclarationStatementSyntax managedValuesDeclaration = Declare(SpanOf(_elementInfo.ManagedType.Syntax), + LocalDeclarationStatementSyntax managedValuesDeclaration = Declare(SpanOf(elementMarshaller.TypeInfo.ManagedType.Syntax), managedSpanIdentifier, MethodInvocation( TypeSyntaxes.System_Runtime_InteropServices_MemoryMarshal, @@ -325,7 +312,7 @@ public override StatementSyntax GenerateManagedToUnmanagedByValueOutUnmarshalSta // Span = string nativeSpanIdentifier = MarshallerHelpers.GetNativeSpanIdentifier(info, context); LocalDeclarationStatementSyntax unmanagedValuesDeclaration = Declare( - SpanOf(_unmanagedElementType), + SpanOf(unmanagedElementType), nativeSpanIdentifier, CollectionSource.GetUnmanagedValuesDestination(info, context)); @@ -337,7 +324,7 @@ public override StatementSyntax GenerateManagedToUnmanagedByValueOutUnmarshalSta info, context, IdentifierName(numElementsIdentifier), - _elementInfo, _elementMarshaller, StubCodeContext.Stage.UnmarshalCapture, + elementMarshaller, StubCodeContext.Stage.UnmarshalCapture, StubCodeContext.Stage.Unmarshal)); } @@ -359,8 +346,7 @@ public override StatementSyntax GenerateElementCleanupStatement(TypePositionInfo info, context, indexConstraintName, - _elementInfo, - _elementMarshaller, + elementMarshaller, context.CurrentStage); if (contentsCleanupStatements.IsKind(SyntaxKind.EmptyStatement)) @@ -376,7 +362,7 @@ public override StatementSyntax GenerateElementCleanupStatement(TypePositionInfo return Block( Declare( - ReadOnlySpanOf(_unmanagedElementType), + ReadOnlySpanOf(unmanagedElementType), nativeSpanIdentifier, MarshallerHelpers.GetMarshalDirection(info, context) == MarshalDirection.ManagedToUnmanaged ? CollectionSource.GetUnmanagedValuesDestination(info, context) @@ -398,7 +384,7 @@ public override StatementSyntax GenerateUnmanagedToManagedByValueOutMarshalState // Span = MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in .GetPinnableReference()), ); LocalDeclarationStatementSyntax unmanagedValuesSource = Declare( - SpanOf(_unmanagedElementType), + SpanOf(unmanagedElementType), nativeSpanIdentifier, MethodInvocation( TypeSyntaxes.System_Runtime_InteropServices_MemoryMarshal, @@ -417,7 +403,7 @@ public override StatementSyntax GenerateUnmanagedToManagedByValueOutMarshalState LocalDeclarationStatementSyntax managedValuesDestination = LocalDeclarationStatement(VariableDeclaration( GenericName( Identifier(TypeNames.System_Span), - TypeArgumentList(SingletonSeparatedList(_elementInfo.ManagedType.Syntax))), + TypeArgumentList(SingletonSeparatedList(elementMarshaller.TypeInfo.ManagedType.Syntax))), SingletonSeparatedList( VariableDeclarator( Identifier(managedSpanIdentifier)) @@ -444,16 +430,14 @@ public override StatementSyntax GenerateUnmanagedToManagedByValueOutMarshalState info, context, IdentifierName(numElementsIdentifier), - _elementInfo, - new FreeAlwaysOwnedOriginalValueGenerator(_elementMarshaller), + new FreeAlwaysOwnedOriginalValueGenerator(elementMarshaller), stagesToGenerate)); } private static List GenerateElementStages( TypePositionInfo info, StubCodeContext context, - IMarshallingGenerator elementMarshaller, - TypePositionInfo elementInfo, + IBoundMarshallingGenerator elementMarshaller, out LinearCollectionElementMarshallingCodeContext elementSetupSubContext, out TypePositionInfo localElementInfo, params StubCodeContext.Stage[] stagesToGeneratePerElement) @@ -466,19 +450,21 @@ private static List GenerateElementStages( nativeSpanIdentifier, context); - localElementInfo = elementInfo with + IBoundMarshallingGenerator localMarshaller = elementMarshaller.Rebind(elementMarshaller.TypeInfo with { InstanceIdentifier = info.InstanceIdentifier, RefKind = info.IsByRef ? info.RefKind : info.ByValueContentsMarshalKind.GetRefKindForByValueContentsKind(), ManagedIndex = info.ManagedIndex, NativeIndex = info.NativeIndex - }; + }); + + localElementInfo = localMarshaller.TypeInfo; List elementStatements = new(); foreach (StubCodeContext.Stage stage in stagesToGeneratePerElement) { var elementSubContext = elementSetupSubContext with { CurrentStage = stage }; - elementStatements.AddRange(elementMarshaller.Generate(localElementInfo, elementSubContext)); + elementStatements.AddRange(localMarshaller.Generate(elementSubContext)); } return elementStatements; } @@ -487,21 +473,20 @@ private static StatementSyntax GenerateContentsMarshallingStatement( TypePositionInfo info, StubCodeContext context, ExpressionSyntax lengthExpression, - TypePositionInfo elementInfo, - IMarshallingGenerator elementMarshaller, + IBoundMarshallingGenerator elementMarshaller, params StubCodeContext.Stage[] stagesToGeneratePerElement) { - var elementStatements = GenerateElementStages(info, context, elementMarshaller, elementInfo, out var elementSetupSubContext, out var localElementInfo, stagesToGeneratePerElement); + var elementStatements = GenerateElementStages(info, context, elementMarshaller, out var elementSetupSubContext, out var localElementInfo, stagesToGeneratePerElement); if (elementStatements.Count != 0) { StatementSyntax marshallingStatement = Block( - List(elementMarshaller.Generate(localElementInfo, elementSetupSubContext) + List(elementMarshaller.Generate(elementSetupSubContext) .Concat(elementStatements))); - if (elementMarshaller.AsNativeType(elementInfo).Syntax is PointerTypeSyntax elementNativeType) + if (elementMarshaller.NativeType is PointerTypeInfo nativeTypeInfo) { - PointerNativeTypeAssignmentRewriter rewriter = new(elementSetupSubContext.GetIdentifiers(localElementInfo).native, elementNativeType); + PointerNativeTypeAssignmentRewriter rewriter = new(elementSetupSubContext.GetIdentifiers(localElementInfo).native, (PointerTypeSyntax)nativeTypeInfo.Syntax); marshallingStatement = (StatementSyntax)rewriter.Visit(marshallingStatement); } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/Forwarder.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/Forwarder.cs index 9679a2e7449c9..e90ceb2327856 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/Forwarder.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/Forwarder.cs @@ -7,7 +7,7 @@ namespace Microsoft.Interop { - public sealed class Forwarder : IMarshallingGenerator + public sealed class Forwarder : IUnboundMarshallingGenerator { public ManagedTypeInfo AsNativeType(TypePositionInfo info) { diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/IMarshallingGeneratorResolver.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/IMarshallingGeneratorResolver.cs index 1a66935fda9bb..272d0a58701d7 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/IMarshallingGeneratorResolver.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/IMarshallingGeneratorResolver.cs @@ -8,7 +8,7 @@ namespace Microsoft.Interop public interface IMarshallingGeneratorResolver { /// - /// Create an instance for marshalling the supplied type in the given position and collect any diagnostics from generator resolution. + /// Create an instance for marshalling the supplied type in the given position and collect any diagnostics from generator resolution. /// /// Type details /// Metadata about the stub the type is associated with diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshalAsMarshallingGeneratorResolver.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshalAsMarshallingGeneratorResolver.cs index 05d9b5ab31c1a..55f9b2f2d0734 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshalAsMarshallingGeneratorResolver.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshalAsMarshallingGeneratorResolver.cs @@ -26,11 +26,11 @@ public MarshalAsMarshallingGeneratorResolver(InteropGenerationOptions options) } /// - /// Create an instance for marshalling the supplied type in the given position. + /// Create an instance for marshalling the supplied type in the given position. /// /// Type details /// Metadata about the stub the type is associated with - /// A instance. + /// A instance. public ResolvedGenerator Create( TypePositionInfo info, StubCodeContext context) @@ -51,7 +51,7 @@ public ResolvedGenerator Create( or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Single }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.R4, _) } or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Double }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.R8, _) }: // TODO: Report the MarshalAs attribute as unnecessary - return ResolvedGenerator.Resolved(s_blittable); + return ResolvedGenerator.Resolved(s_blittable.Bind(info)); // Enum with no marshalling info case { ManagedType: EnumTypeInfo enumType, MarshallingAttributeInfo: NoMarshallingInfo }: @@ -59,37 +59,37 @@ public ResolvedGenerator Create( SpecialType underlyingSpecialType = enumType.UnderlyingType; if (underlyingSpecialType == SpecialType.System_Boolean || underlyingSpecialType == SpecialType.System_Char) { - return ResolvedGenerator.NotSupported(new(info, context)); + return ResolvedGenerator.NotSupported(info, new(info, context)); } - return ResolvedGenerator.Resolved(s_blittable); + return ResolvedGenerator.Resolved(s_blittable.Bind(info)); // Pointer with no marshalling info case { ManagedType: PointerTypeInfo{ IsFunctionPointer: false }, MarshallingAttributeInfo: NoMarshallingInfo }: - return ResolvedGenerator.Resolved(s_blittable); + return ResolvedGenerator.Resolved(s_blittable.Bind(info)); // Function pointer with no marshalling info case { ManagedType: PointerTypeInfo { IsFunctionPointer: true }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.FunctionPtr, _) }: - return ResolvedGenerator.Resolved(s_blittable); + return ResolvedGenerator.Resolved(s_blittable.Bind(info)); // Bool with marshalling info case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo(UnmanagedType.U1, _) }: - return ResolvedGenerator.Resolved(s_byteBool); + return ResolvedGenerator.Resolved(s_byteBool.Bind(info)); case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo(UnmanagedType.I1, _) }: - return ResolvedGenerator.Resolved(s_signed_byteBool); + return ResolvedGenerator.Resolved(s_signed_byteBool.Bind(info)); case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo(UnmanagedType.U4, _) }: - return ResolvedGenerator.Resolved(s_winBool); + return ResolvedGenerator.Resolved(s_winBool.Bind(info)); case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo(UnmanagedType.I4 or UnmanagedType.Bool, _) }: - return ResolvedGenerator.Resolved(s_signed_winBool); + return ResolvedGenerator.Resolved(s_signed_winBool.Bind(info)); case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Boolean }, MarshallingAttributeInfo: MarshalAsInfo(UnmanagedType.VariantBool, _) }: - return ResolvedGenerator.Resolved(s_variantBool); + return ResolvedGenerator.Resolved(s_variantBool.Bind(info)); // Delegate types case { ManagedType: DelegateTypeInfo, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.FunctionPtr, _) }: - return ResolvedGenerator.Resolved(s_delegate); + return ResolvedGenerator.Resolved(s_delegate.Bind(info)); // void case { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Void } }: - return ResolvedGenerator.Resolved(s_forwarder); + return ResolvedGenerator.Resolved(s_forwarder.Bind(info)); default: return ResolvedGenerator.UnresolvedGenerator; diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGenerator.cs index a657c5c38651d..631a3fb171692 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGenerator.cs @@ -18,12 +18,12 @@ public enum SignatureBehavior ManagedTypeAndAttributes, /// - /// The native signature should be the type returned by passed by value. + /// The native signature should be the type returned by passed by value. /// NativeType, /// - /// The native signature should be a pointer to the type returned by passed by value. + /// The native signature should be a pointer to the type returned by passed by value. /// PointerToNativeType } @@ -80,7 +80,120 @@ public enum ByValueMarshalKindSupport /// /// Interface for generation of marshalling code for P/Invoke stubs /// - public interface IMarshallingGenerator + public interface IBoundMarshallingGenerator + { + /// + /// The managed type and position information this generator is bound to. + /// + TypePositionInfo TypeInfo { get; } + + /// + /// Get the native type for the bound element of the generator. + /// + ManagedTypeInfo NativeType { get; } + + /// + /// Get the shape that represents the bound element in the native signature + /// + SignatureBehavior NativeSignatureBehavior { get; } + + /// + /// Get the shape of how the value represented by this generator should be passed at the managed/native boundary in the provided + /// + /// Code generation context + /// How to represent the unmanaged value at the managed/unmanaged boudary + ValueBoundaryBehavior GetValueBoundaryBehavior(StubCodeContext context); + + /// + /// Generate code for marshalling + /// + /// Code generation context + /// List of statements to be added to the P/Invoke stub + /// + /// The generator should return the appropriate statements based on the + /// of . + /// For , any statements not of type + /// will be ignored. + /// + IEnumerable Generate(StubCodeContext context); + + /// + /// Returns whether or not this marshaller uses an identifier for the native value in addition + /// to an identifier for the managed value. + /// + /// Code generation context + /// If the marshaller uses an identifier for the native value, true; otherwise, false. + /// + /// of may not be valid. + /// + bool UsesNativeIdentifier(StubCodeContext context); + + /// + /// Returns if the given ByValueContentsMarshalKind is supported in the current marshalling context. + /// A supported marshal kind has a different behavior than the default behavior. + /// + /// The marshal kind. + /// The TypePositionInfo of the parameter. + /// The marshalling context. + /// + /// The diagnostic to report if the return value is not . + /// It should be non-null if the value is not + /// + /// If the provided is supported and if it is required to specify the requested behavior. + ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context, out GeneratorDiagnostic? diagnostic); + + /// + /// Create a new instance of this generator bound to a different . + /// + /// The new info to bind to. + /// A new instance of this marshaller bound to . + IBoundMarshallingGenerator Rebind(TypePositionInfo info); + } + + /// + /// A bound generator that binds an to a specific . + /// + /// The element info. + /// The unbound generator + internal sealed class BoundMarshallingGenerator(TypePositionInfo info, IUnboundMarshallingGenerator unbound) : IBoundMarshallingGenerator + { + internal bool IsForwarder => unbound is Forwarder; + + internal bool IsBlittable => unbound is BlittableMarshaller; + + public TypePositionInfo TypeInfo => info; + + public ManagedTypeInfo NativeType => unbound.AsNativeType(TypeInfo); + + public SignatureBehavior NativeSignatureBehavior => unbound.GetNativeSignatureBehavior(TypeInfo); + + public IEnumerable Generate(StubCodeContext context) => unbound.Generate(TypeInfo, context); + + public ValueBoundaryBehavior GetValueBoundaryBehavior(StubCodeContext context) => unbound.GetValueBoundaryBehavior(TypeInfo, context); + + public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context, out GeneratorDiagnostic? diagnostic) + => unbound.SupportsByValueMarshalKind(marshalKind, TypeInfo, context, out diagnostic); + + public bool UsesNativeIdentifier(StubCodeContext context) => unbound.UsesNativeIdentifier(TypeInfo, context); + + public IBoundMarshallingGenerator Rebind(TypePositionInfo info) => new BoundMarshallingGenerator(info, unbound); + } + + public static class UnboundMarshallingGeneratorExtensions + { + /// + /// Bind this marshalling generator to a specific element info. + /// + /// The unbound generator + /// The element info + /// A generator wrapper that is bound to this info. + public static IBoundMarshallingGenerator Bind(this IUnboundMarshallingGenerator unbound, TypePositionInfo info) => new BoundMarshallingGenerator(info, unbound); + } + + /// + /// Interface for generation of marshalling code for P/Invoke stubs + /// + public interface IUnboundMarshallingGenerator { /// /// Get the native type syntax for diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGeneratorExtensions.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGeneratorExtensions.cs index 9b9ad2589b102..cedc6f8aad1d9 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGeneratorExtensions.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGeneratorExtensions.cs @@ -17,13 +17,13 @@ public static class MarshallingGeneratorExtensions /// /// The marshalling generator for this /// Object to marshal - public static TypeSyntax AsReturnType(this IMarshallingGenerator generator, TypePositionInfo info) + public static TypeSyntax AsReturnType(this IBoundMarshallingGenerator generator) { - return generator.GetNativeSignatureBehavior(info) switch + return generator.NativeSignatureBehavior switch { - SignatureBehavior.ManagedTypeAndAttributes => info.ManagedType.Syntax, - SignatureBehavior.NativeType => generator.AsNativeType(info).Syntax, - SignatureBehavior.PointerToNativeType => PointerType(generator.AsNativeType(info).Syntax), + SignatureBehavior.ManagedTypeAndAttributes => generator.TypeInfo.ManagedType.Syntax, + SignatureBehavior.NativeType => generator.NativeType.Syntax, + SignatureBehavior.PointerToNativeType => PointerType(generator.NativeType.Syntax), _ => throw new InvalidOperationException() }; } @@ -33,14 +33,14 @@ public static TypeSyntax AsReturnType(this IMarshallingGenerator generator, Type /// The marshalling generator for this /// Object to marshal /// Attributes for the return type for this , or null if no attributes should be added. - public static AttributeListSyntax? GenerateAttributesForReturnType(this IMarshallingGenerator generator, TypePositionInfo info) + public static AttributeListSyntax? GenerateAttributesForReturnType(this IBoundMarshallingGenerator generator) { - if (generator.GetNativeSignatureBehavior(info) != SignatureBehavior.ManagedTypeAndAttributes) + if (generator.NativeSignatureBehavior != SignatureBehavior.ManagedTypeAndAttributes) { return null; } - if (info.MarshallingAttributeInfo is IForwardedMarshallingInfo forwarded + if (generator.TypeInfo.MarshallingAttributeInfo is IForwardedMarshallingInfo forwarded && forwarded.TryCreateAttributeSyntax(out AttributeSyntax forwardedAttribute)) { return AttributeList(SingletonSeparatedList(forwardedAttribute)); @@ -55,21 +55,20 @@ public static TypeSyntax AsReturnType(this IMarshallingGenerator generator, Type /// Gets a parameter for the unmanaged signature that represents the provided in the given . /// /// The marshalling generator for this - /// Object to marshal /// The stub marshalling context - public static ParameterSyntax AsParameter(this IMarshallingGenerator generator, TypePositionInfo info, StubCodeContext context) + public static ParameterSyntax AsParameter(this IBoundMarshallingGenerator generator, StubCodeContext context) { - SignatureBehavior behavior = generator.GetNativeSignatureBehavior(info); + SignatureBehavior behavior = generator.NativeSignatureBehavior; if (behavior == SignatureBehavior.ManagedTypeAndAttributes) { - return GenerateForwardingParameter(info, context.GetIdentifiers(info).managed); + return GenerateForwardingParameter(generator.TypeInfo, context.GetIdentifiers(generator.TypeInfo).managed); } string identifierName; if (context.Direction == MarshalDirection.ManagedToUnmanaged) { // This name doesn't get introduced into the stub's scope, so we can make it pretty // and reuse the native identifier - identifierName = context.GetIdentifiers(info).native; + identifierName = context.GetIdentifiers(generator.TypeInfo).native; } else if (context.Direction == MarshalDirection.UnmanagedToManaged) { @@ -79,11 +78,11 @@ public static ParameterSyntax AsParameter(this IMarshallingGenerator generator, // we can use the native identifier. // When we're passing the address of the native identifier, we need to introduce a new name to hold this value // before we assign it to the managed value. - (string managed, string native) = context.GetIdentifiers(info); - string param = context.GetAdditionalIdentifier(info, ParameterIdentifierSuffix); - identifierName = generator.GetValueBoundaryBehavior(info, context) switch + (string managed, string native) = context.GetIdentifiers(generator.TypeInfo); + string param = context.GetAdditionalIdentifier(generator.TypeInfo, ParameterIdentifierSuffix); + identifierName = generator.GetValueBoundaryBehavior(context) switch { - ValueBoundaryBehavior.ManagedIdentifier => info.IsByRef ? param : managed, + ValueBoundaryBehavior.ManagedIdentifier => generator.TypeInfo.IsByRef ? param : managed, ValueBoundaryBehavior.NativeIdentifier or ValueBoundaryBehavior.CastNativeIdentifier => native, ValueBoundaryBehavior.AddressOfNativeIdentifier => param, _ => throw new UnreachableException() @@ -96,8 +95,8 @@ public static ParameterSyntax AsParameter(this IMarshallingGenerator generator, return Parameter(Identifier(identifierName)) .WithType(behavior switch { - SignatureBehavior.NativeType => generator.AsNativeType(info).Syntax, - SignatureBehavior.PointerToNativeType => PointerType(generator.AsNativeType(info).Syntax), + SignatureBehavior.NativeType => generator.NativeType.Syntax, + SignatureBehavior.PointerToNativeType => PointerType(generator.NativeType.Syntax), _ => throw new InvalidOperationException() }); } @@ -137,22 +136,24 @@ private static ParameterSyntax GenerateForwardingParameter(TypePositionInfo info /// The marshalling generator for this /// Object to marshal /// Marshalling context - public static ArgumentSyntax AsArgument(this IMarshallingGenerator generator, TypePositionInfo info, StubCodeContext context) + public static ArgumentSyntax AsArgument(this IBoundMarshallingGenerator generator, StubCodeContext context) { + TypePositionInfo info = generator.TypeInfo; (string managedIdentifier, string nativeIdentifier) = context.GetIdentifiers(info); - return generator.GetValueBoundaryBehavior(info, context) switch + return generator.GetValueBoundaryBehavior(context) switch { ValueBoundaryBehavior.ManagedIdentifier when !info.IsByRef => Argument(IdentifierName(managedIdentifier)), ValueBoundaryBehavior.ManagedIdentifier when info.IsByRef => Argument(IdentifierName(managedIdentifier)).WithRefKindKeyword(MarshallerHelpers.GetManagedArgumentRefKindKeyword(info)), ValueBoundaryBehavior.NativeIdentifier => Argument(IdentifierName(nativeIdentifier)), ValueBoundaryBehavior.AddressOfNativeIdentifier => Argument(PrefixUnaryExpression(SyntaxKind.AddressOfExpression, IdentifierName(nativeIdentifier))), - ValueBoundaryBehavior.CastNativeIdentifier => Argument(CastExpression(generator.AsParameter(info, context).Type, IdentifierName(nativeIdentifier))), + ValueBoundaryBehavior.CastNativeIdentifier => Argument(CastExpression(generator.AsParameter(context).Type, IdentifierName(nativeIdentifier))), _ => throw new InvalidOperationException() }; } - public static ArgumentSyntax AsManagedArgument(this IMarshallingGenerator generator, TypePositionInfo info, StubCodeContext context) + public static ArgumentSyntax AsManagedArgument(this IBoundMarshallingGenerator generator, StubCodeContext context) { + TypePositionInfo info = generator.TypeInfo; var (managedIdentifier, _) = context.GetIdentifiers(info); if (info.IsByRef) { @@ -161,10 +162,15 @@ public static ArgumentSyntax AsManagedArgument(this IMarshallingGenerator genera return Argument(IdentifierName(managedIdentifier)); } - public static ExpressionSyntax GenerateNativeByRefInitialization(this IMarshallingGenerator generator, TypePositionInfo info, StubCodeContext context) + public static ExpressionSyntax GenerateNativeByRefInitialization(this IBoundMarshallingGenerator generator, StubCodeContext context) { + TypePositionInfo info = generator.TypeInfo; string paramIdentifier = context.GetAdditionalIdentifier(info, ParameterIdentifierSuffix); return RefExpression(PrefixUnaryExpression(SyntaxKind.PointerIndirectionExpression, IdentifierName(paramIdentifier))); } + + public static bool IsForwarder(this IBoundMarshallingGenerator generator) => generator is BoundMarshallingGenerator { IsForwarder: true }; + + public static bool IsBlittable(this IBoundMarshallingGenerator generator) => generator is BoundMarshallingGenerator { IsBlittable: true }; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/NoMarshallingInfoErrorResolver.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/NoMarshallingInfoErrorResolver.cs index 4b57fb6c9ce5c..0d8668a3d2ddc 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/NoMarshallingInfoErrorResolver.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/NoMarshallingInfoErrorResolver.cs @@ -17,7 +17,7 @@ public ResolvedGenerator Create( { if (info.MarshallingAttributeInfo is NoMarshallingInfo && CustomTypeToErrorMessageMap.TryGetValue(info.ManagedType, out string errorMessage)) { - return ResolvedGenerator.NotSupported(new(info, context) + return ResolvedGenerator.NotSupported(info, new(info, context) { NotSupportedDetails = errorMessage }); diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/NotSupportedResolver.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/NotSupportedResolver.cs index 9b3d5e308858b..24bebb5f8b89c 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/NotSupportedResolver.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/NotSupportedResolver.cs @@ -6,6 +6,6 @@ namespace Microsoft.Interop public sealed class NotSupportedResolver : IMarshallingGeneratorResolver { public ResolvedGenerator Create(TypePositionInfo info, StubCodeContext context) => - ResolvedGenerator.NotSupported(new(info, context)); + ResolvedGenerator.NotSupported(info, new(info, context)); } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ResolvedGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ResolvedGenerator.cs index 496a89e42853f..bd446b0d75925 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ResolvedGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ResolvedGenerator.cs @@ -7,7 +7,7 @@ namespace Microsoft.Interop { - public record struct ResolvedGenerator([property: MemberNotNullWhen(true, nameof(ResolvedGenerator.IsResolved), nameof(ResolvedGenerator.IsResolvedWithoutErrors))] IMarshallingGenerator? Generator, ImmutableArray Diagnostics) + public record struct ResolvedGenerator([property: MemberNotNullWhen(true, nameof(ResolvedGenerator.IsResolved), nameof(ResolvedGenerator.IsResolvedWithoutErrors))] IBoundMarshallingGenerator? Generator, ImmutableArray Diagnostics) { private static readonly Forwarder s_forwarder = new(); @@ -17,17 +17,17 @@ public record struct ResolvedGenerator([property: MemberNotNullWhen(true, nameof public readonly bool IsResolved => Generator is not null; - public static ResolvedGenerator Resolved(IMarshallingGenerator generator) + public static ResolvedGenerator Resolved(IBoundMarshallingGenerator generator) { return new(generator, ImmutableArray.Empty); } - public static ResolvedGenerator NotSupported(GeneratorDiagnostic.NotSupported notSupportedDiagnostic) + public static ResolvedGenerator NotSupported(TypePositionInfo info, GeneratorDiagnostic.NotSupported notSupportedDiagnostic) { - return new(s_forwarder, ImmutableArray.Create(notSupportedDiagnostic)); + return new(s_forwarder.Bind(info), ImmutableArray.Create(notSupportedDiagnostic)); } - public static ResolvedGenerator ResolvedWithDiagnostics(IMarshallingGenerator generator, ImmutableArray diagnostics) + public static ResolvedGenerator ResolvedWithDiagnostics(IBoundMarshallingGenerator generator, ImmutableArray diagnostics) { return new(generator, diagnostics); } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StaticPinnableManagedValueMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StaticPinnableManagedValueMarshaller.cs index 07bb36a2edaba..366d1877b9e04 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StaticPinnableManagedValueMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StaticPinnableManagedValueMarshaller.cs @@ -10,22 +10,19 @@ namespace Microsoft.Interop { - public sealed class StaticPinnableManagedValueMarshaller : IMarshallingGenerator + public sealed class StaticPinnableManagedValueMarshaller(IBoundMarshallingGenerator innerMarshallingGenerator, TypeSyntax getPinnableReferenceType) : IBoundMarshallingGenerator { - private readonly IMarshallingGenerator _innerMarshallingGenerator; - private readonly TypeSyntax _getPinnableReferenceType; + public TypePositionInfo TypeInfo => innerMarshallingGenerator.TypeInfo; - public StaticPinnableManagedValueMarshaller(IMarshallingGenerator innerMarshallingGenerator, TypeSyntax getPinnableReferenceType) - { - _innerMarshallingGenerator = innerMarshallingGenerator; - _getPinnableReferenceType = getPinnableReferenceType; - } + public ManagedTypeInfo NativeType => innerMarshallingGenerator.NativeType; + + public SignatureBehavior NativeSignatureBehavior => innerMarshallingGenerator.NativeSignatureBehavior; - public ValueBoundaryBehavior GetValueBoundaryBehavior(TypePositionInfo info, StubCodeContext context) + public ValueBoundaryBehavior GetValueBoundaryBehavior(StubCodeContext context) { - if (IsPinningPathSupported(info, context)) + if (IsPinningPathSupported(context)) { - if (AsNativeType(info).Syntax is PointerTypeSyntax pointerType + if (NativeType.Syntax is PointerTypeSyntax pointerType && pointerType.ElementType is PredefinedTypeSyntax predefinedType && predefinedType.Keyword.IsKind(SyntaxKind.VoidKeyword)) { @@ -36,48 +33,39 @@ public ValueBoundaryBehavior GetValueBoundaryBehavior(TypePositionInfo info, Stu return ValueBoundaryBehavior.CastNativeIdentifier; } - return _innerMarshallingGenerator.GetValueBoundaryBehavior(info, context); - } - - public ManagedTypeInfo AsNativeType(TypePositionInfo info) - { - return _innerMarshallingGenerator.AsNativeType(info); + return innerMarshallingGenerator.GetValueBoundaryBehavior( context); } - public SignatureBehavior GetNativeSignatureBehavior(TypePositionInfo info) + public IEnumerable Generate(StubCodeContext context) { - return _innerMarshallingGenerator.GetNativeSignatureBehavior(info); - } - - public IEnumerable Generate(TypePositionInfo info, StubCodeContext context) - { - if (IsPinningPathSupported(info, context)) + if (IsPinningPathSupported(context)) { - return GeneratePinningPath(info, context); + return GeneratePinningPath(context); } - return _innerMarshallingGenerator.Generate(info, context); + return innerMarshallingGenerator.Generate(context); } - public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) + public bool UsesNativeIdentifier(StubCodeContext context) { - if (IsPinningPathSupported(info, context)) + if (IsPinningPathSupported(context)) { return false; } - return _innerMarshallingGenerator.UsesNativeIdentifier(info, context); + return innerMarshallingGenerator.UsesNativeIdentifier(context); } - private static bool IsPinningPathSupported(TypePositionInfo info, StubCodeContext context) + + private bool IsPinningPathSupported(StubCodeContext context) { - return context.SingleFrameSpansNativeContext && !info.IsByRef && !context.IsInStubReturnPosition(info); + return context.SingleFrameSpansNativeContext && !TypeInfo.IsByRef && !context.IsInStubReturnPosition(TypeInfo); } - private IEnumerable GeneratePinningPath(TypePositionInfo info, StubCodeContext context) + private IEnumerable GeneratePinningPath(StubCodeContext context) { if (context.CurrentStage == StubCodeContext.Stage.Pin) { - (string managedIdentifier, string nativeIdentifier) = context.GetIdentifiers(info); + (string managedIdentifier, string nativeIdentifier) = context.GetIdentifiers(innerMarshallingGenerator.TypeInfo); // fixed (void* = &.GetPinnableReference()) yield return FixedStatement( @@ -89,7 +77,7 @@ private IEnumerable GeneratePinningPath(TypePositionInfo info, PrefixUnaryExpression(SyntaxKind.AddressOfExpression, InvocationExpression( MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - _getPinnableReferenceType, + getPinnableReferenceType, IdentifierName(ShapeMemberNames.GetPinnableReference)), ArgumentList(SingletonSeparatedList( Argument(IdentifierName(managedIdentifier)))))) @@ -100,9 +88,11 @@ private IEnumerable GeneratePinningPath(TypePositionInfo info, } } - public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, TypePositionInfo info, StubCodeContext context, out GeneratorDiagnostic? diagnostic) + public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context, out GeneratorDiagnostic? diagnostic) { - return _innerMarshallingGenerator.SupportsByValueMarshalKind(marshalKind, info, context, out diagnostic); + return innerMarshallingGenerator.SupportsByValueMarshalKind(marshalKind, context, out diagnostic); } + + public IBoundMarshallingGenerator Rebind(TypePositionInfo info) => innerMarshallingGenerator.Rebind(info); } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/UnmanagedToManagedOwnershipTrackingStrategy.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/UnmanagedToManagedOwnershipTrackingStrategy.cs index d20e5c556df41..dd1b6a2e19209 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/UnmanagedToManagedOwnershipTrackingStrategy.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/UnmanagedToManagedOwnershipTrackingStrategy.cs @@ -136,17 +136,15 @@ public IEnumerable GenerateCleanupCalleeAllocatedResourcesState /// Marshalling strategy to cache the initial value of a given in a local variable and cleanup that value in the cleanup stage. /// Useful in scenarios where the value is always owned in all code-paths that reach the stage, so additional ownership tracking is extraneous. /// - internal sealed class FreeAlwaysOwnedOriginalValueGenerator : IMarshallingGenerator + internal sealed class FreeAlwaysOwnedOriginalValueGenerator(IBoundMarshallingGenerator inner) : IBoundMarshallingGenerator { - private readonly IMarshallingGenerator _inner; + public TypePositionInfo TypeInfo => inner.TypeInfo; - public FreeAlwaysOwnedOriginalValueGenerator(IMarshallingGenerator inner) - { - _inner = inner; - } + public ManagedTypeInfo NativeType => inner.NativeType; + + public SignatureBehavior NativeSignatureBehavior => inner.NativeSignatureBehavior; - public ManagedTypeInfo AsNativeType(TypePositionInfo info) => _inner.AsNativeType(info); - public IEnumerable Generate(TypePositionInfo info, StubCodeContext context) + public IEnumerable Generate(StubCodeContext context) { if (context.CurrentStage == StubCodeContext.Stage.Setup) { @@ -167,20 +165,20 @@ IEnumerable GenerateSetupStatements() yield return statement; } - yield return OwnershipTrackingHelpers.DeclareOriginalValueIdentifier(info, context, AsNativeType(info)); + yield return OwnershipTrackingHelpers.DeclareOriginalValueIdentifier(inner.TypeInfo, context, NativeType); } IEnumerable GenerateStatementsFromInner(StubCodeContext contextForStage) { - return _inner.Generate(info, contextForStage); + return inner.Generate(contextForStage); } } - public SignatureBehavior GetNativeSignatureBehavior(TypePositionInfo info) => _inner.GetNativeSignatureBehavior(info); - public ValueBoundaryBehavior GetValueBoundaryBehavior(TypePositionInfo info, StubCodeContext context) => _inner.GetValueBoundaryBehavior(info, context); - public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, TypePositionInfo info, StubCodeContext context, out GeneratorDiagnostic? diagnostic) - => _inner.SupportsByValueMarshalKind(marshalKind, info, context, out diagnostic); - public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => _inner.UsesNativeIdentifier(info, context); + public ValueBoundaryBehavior GetValueBoundaryBehavior(StubCodeContext context) => inner.GetValueBoundaryBehavior(context); + public IBoundMarshallingGenerator Rebind(TypePositionInfo info) => new FreeAlwaysOwnedOriginalValueGenerator(inner.Rebind(info)); + public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context, out GeneratorDiagnostic? diagnostic) + => inner.SupportsByValueMarshalKind(marshalKind, context, out diagnostic); + public bool UsesNativeIdentifier(StubCodeContext context) => inner.UsesNativeIdentifier(context); } #pragma warning disable SA1400 // Access modifier should be declared https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3659 diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/StubCodeContext.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/StubCodeContext.cs index 8bfd20eed83fc..8d57df05486b2 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/StubCodeContext.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/StubCodeContext.cs @@ -42,7 +42,7 @@ public enum Stage /// Call the generated P/Invoke /// /// - /// should provide the + /// should provide the /// argument to pass to the P/Invoke /// Invoke, diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/VariableDeclarations.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/VariableDeclarations.cs index 2d693334005d8..76436ca50b299 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/VariableDeclarations.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/VariableDeclarations.cs @@ -18,7 +18,7 @@ public static VariableDeclarations GenerateDeclarationsForManagedToUnmanaged(Bou ImmutableArray.Builder initializations = ImmutableArray.CreateBuilder(); ImmutableArray.Builder variables = ImmutableArray.CreateBuilder(); - foreach (BoundGenerator marshaller in marshallers.NativeParameterMarshallers) + foreach (IBoundMarshallingGenerator marshaller in marshallers.NativeParameterMarshallers) { TypePositionInfo info = marshaller.TypeInfo; if (info.IsManagedReturnPosition) @@ -52,7 +52,7 @@ public static VariableDeclarations GenerateDeclarationsForManagedToUnmanaged(Bou Variables = variables.ToImmutable() }; - static void AppendVariableDeclarations(ImmutableArray.Builder statementsToUpdate, BoundGenerator marshaller, StubCodeContext context, bool initializeToDefault) + static void AppendVariableDeclarations(ImmutableArray.Builder statementsToUpdate, IBoundMarshallingGenerator marshaller, StubCodeContext context, bool initializeToDefault) { (string managed, string native) = context.GetIdentifiers(marshaller.TypeInfo); @@ -66,10 +66,10 @@ static void AppendVariableDeclarations(ImmutableArray.Builder initializations = ImmutableArray.CreateBuilder(); ImmutableArray.Builder variables = ImmutableArray.CreateBuilder(); - foreach (BoundGenerator marshaller in marshallers.NativeParameterMarshallers) + foreach (IBoundMarshallingGenerator marshaller in marshallers.NativeParameterMarshallers) { TypePositionInfo info = marshaller.TypeInfo; if (info.IsNativeReturnPosition || info.IsManagedReturnPosition) @@ -109,14 +109,14 @@ public static VariableDeclarations GenerateDeclarationsForUnmanagedToManaged(Bou Variables = variables.ToImmutable() }; - static void AppendVariableDeclarations(ImmutableArray.Builder statementsToUpdate, BoundGenerator marshaller, StubCodeContext context, bool initializeToDefault) + static void AppendVariableDeclarations(ImmutableArray.Builder statementsToUpdate, IBoundMarshallingGenerator marshaller, StubCodeContext context, bool initializeToDefault) { (string managed, string native) = context.GetIdentifiers(marshaller.TypeInfo); // Declare variable for return value if (marshaller.TypeInfo.IsNativeReturnPosition) { - bool nativeReturnUsesNativeIdentifier = marshaller.Generator.UsesNativeIdentifier(marshaller.TypeInfo, context); + bool nativeReturnUsesNativeIdentifier = marshaller.UsesNativeIdentifier(context); // Always initialize the return value. statementsToUpdate.Add(Declare( @@ -127,23 +127,23 @@ static void AppendVariableDeclarations(ImmutableArray