From aae7145e14eb2114fcb126561443dfe6cec18360 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 11 Sep 2024 14:20:12 -0700 Subject: [PATCH 01/22] Use pattern matching to make the giant switch statement cleaner. --- .../JSImportGenerator/JSGeneratorFactory.cs | 420 +++++++++--------- .../JSImportGenerator.csproj | 1 + 2 files changed, 208 insertions(+), 213 deletions(-) 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 f5f61c413bc117..369a08680b2254 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSGeneratorFactory.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSGeneratorFactory.cs @@ -8,6 +8,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Data; +using Microsoft.CodeAnalysis.CSharp.Syntax; namespace Microsoft.Interop.JavaScript { @@ -26,14 +27,7 @@ public ResolvedGenerator Create(TypePositionInfo info, StubCodeContext context) } JSMarshallingInfo jsMarshalingInfo = info.MarshallingAttributeInfo as JSMarshallingInfo; - ResolvedGenerator fail(string failReason) - { - return ResolvedGenerator.NotSupported(info, context, new(info) - { - NotSupportedDetails = failReason - }); - } - bool isToJs = info.ManagedIndex != TypePositionInfo.ReturnIndex ^ context.Direction == MarshalDirection.UnmanagedToManaged; + bool isToJs = MarshallerHelpers.GetMarshalDirection(info, context) == MarshalDirection.ManagedToUnmanaged; switch (jsMarshalingInfo) { @@ -41,281 +35,281 @@ ResolvedGenerator fail(string failReason) case { TypeInfo: JSInvalidTypeInfo }: return ResolvedGenerator.NotSupported(info, context, new(info)); - // void - case { TypeInfo: JSSimpleTypeInfo(KnownManagedType.Void), JSType: JSTypeFlags.DiscardNoWait }: - return ResolvedGenerator.Resolved(new VoidGenerator(info, context, 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(info, context, jsMarshalingInfo.JSType == JSTypeFlags.Void ? MarshalerType.Void : MarshalerType.Discard)); - - // discard no void - case { JSType: JSTypeFlags.Discard }: - return fail(SR.DiscardOnlyVoid); - - // oneway no void - case { JSType: JSTypeFlags.DiscardNoWait }: - return fail(SR.DiscardNoWaitOnlyVoid); - // primitive case { TypeInfo: JSSimpleTypeInfo simple }: - return Create(info, context, isToJs, simple.KnownType, [], jsMarshalingInfo.JSType, Array.Empty(), fail); + return Create(info, context, isToJs, simple.KnownType, [], jsMarshalingInfo.JSType, Array.Empty()); // nullable case { TypeInfo: JSNullableTypeInfo nullable }: - return Create(info, context, isToJs, nullable.KnownType, [nullable.ResultTypeInfo.KnownType], jsMarshalingInfo.JSType, null, fail); + return Create(info, context, isToJs, nullable.KnownType, [nullable.ResultTypeInfo.KnownType], jsMarshalingInfo.JSType, null); // array case { TypeInfo: JSArrayTypeInfo array }: - return Create(info, context, isToJs, array.KnownType, [array.ElementTypeInfo.KnownType], jsMarshalingInfo.JSType, jsMarshalingInfo.JSTypeArguments, fail); + return Create(info, context, isToJs, array.KnownType, [array.ElementTypeInfo.KnownType], jsMarshalingInfo.JSType, jsMarshalingInfo.JSTypeArguments); // array segment case { TypeInfo: JSArraySegmentTypeInfo segment }: - return Create(info, context, isToJs, segment.KnownType, [segment.ElementTypeInfo.KnownType], jsMarshalingInfo.JSType, jsMarshalingInfo.JSTypeArguments, fail); + return Create(info, context, isToJs, segment.KnownType, [segment.ElementTypeInfo.KnownType], jsMarshalingInfo.JSType, jsMarshalingInfo.JSTypeArguments); // span case { TypeInfo: JSSpanTypeInfo span }: - return Create(info, context, isToJs, span.KnownType, [span.ElementTypeInfo.KnownType], jsMarshalingInfo.JSType, jsMarshalingInfo.JSTypeArguments, fail); + return Create(info, context, isToJs, span.KnownType, [span.ElementTypeInfo.KnownType], jsMarshalingInfo.JSType, jsMarshalingInfo.JSTypeArguments); // task case { TypeInfo: JSTaskTypeInfo(JSSimpleTypeInfo(KnownManagedType.Void)) task }: - return Create(info, context, isToJs, task.KnownType, [], jsMarshalingInfo.JSType, jsMarshalingInfo.JSTypeArguments, fail); + return Create(info, context, isToJs, task.KnownType, [], jsMarshalingInfo.JSType, jsMarshalingInfo.JSTypeArguments); case { TypeInfo: JSTaskTypeInfo task }: - return Create(info, context, isToJs, task.KnownType, [task.ResultTypeInfo.KnownType], jsMarshalingInfo.JSType, jsMarshalingInfo.JSTypeArguments, fail); + return Create(info, context, isToJs, task.KnownType, [task.ResultTypeInfo.KnownType], jsMarshalingInfo.JSType, jsMarshalingInfo.JSTypeArguments); // action + function case { TypeInfo: JSFunctionTypeInfo function }: - return Create(info, context, isToJs, function.KnownType, function.ArgsTypeInfo.Select(a => a.KnownType).ToArray(), jsMarshalingInfo.JSType, jsMarshalingInfo.JSTypeArguments, fail); + return Create(info, context, isToJs, function.KnownType, function.ArgsTypeInfo.Select(a => a.KnownType).ToArray(), jsMarshalingInfo.JSType, jsMarshalingInfo.JSTypeArguments); default: return ResolvedGenerator.NotSupported(info, context, new(info)); } } - internal static ResolvedGenerator Create(TypePositionInfo info, StubCodeContext context, bool isToJs, KnownManagedType marshaledType, KnownManagedType[] argumentTypes, JSTypeFlags jsType, JSTypeFlags[] jsTypeArguments, Func failWithReason) + private static ResolvedGenerator Create(TypePositionInfo info, StubCodeContext context, bool isToJs, KnownManagedType marshaledType, KnownManagedType[] argumentTypes, JSTypeFlags jsType, JSTypeFlags[] jsTypeArguments) { - switch (marshaledType) + return (marshaledType, jsType, argumentTypes, jsTypeArguments) switch { + // void + (KnownManagedType.Void, JSTypeFlags.Void, _, _) => resolved(new VoidGenerator(info, context, MarshalerType.Void)), + (KnownManagedType.Void, JSTypeFlags.None or JSTypeFlags.Discard, _, _) => resolved(new VoidGenerator(info, context, MarshalerType.Discard)), + (KnownManagedType.Void, JSTypeFlags.DiscardNoWait, _, _) => resolved(new VoidGenerator(info, context, MarshalerType.DiscardNoWait)), + + // void missing + (KnownManagedType.Void, JSTypeFlags.Missing, _, _) => resolved(new VoidGenerator(info, context, MarshalerType.Void)), + // primitive - case KnownManagedType.Boolean when jsType == JSTypeFlags.Boolean: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Boolean)); - case KnownManagedType.Byte when jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Byte)); - case KnownManagedType.Char when jsType == JSTypeFlags.String: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Char)); - case KnownManagedType.Int16 when jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Int16)); - case KnownManagedType.Int32 when jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Int32)); - case KnownManagedType.Int64 when jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Int52)); - case KnownManagedType.Int64 when jsType == JSTypeFlags.BigInt: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, context, MarshalerType.BigInt64)); - case KnownManagedType.Single when jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Single)); - case KnownManagedType.Double when jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Double)); - case KnownManagedType.IntPtr when jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, context, MarshalerType.IntPtr)); - case KnownManagedType.DateTime when jsType == JSTypeFlags.Date: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, context, MarshalerType.DateTime)); - case KnownManagedType.DateTimeOffset when jsType == JSTypeFlags.Date: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, context, MarshalerType.DateTimeOffset)); - case KnownManagedType.Exception when jsType == JSTypeFlags.Error: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Exception)); - case KnownManagedType.JSObject when jsType == JSTypeFlags.Object: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, context, MarshalerType.JSObject)); - case KnownManagedType.String when jsType == JSTypeFlags.String: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, context, MarshalerType.String)); - case KnownManagedType.Object when jsType == JSTypeFlags.Any: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Object)); + (KnownManagedType.Boolean, JSTypeFlags.Boolean, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Boolean)), + (KnownManagedType.Byte, JSTypeFlags.Number, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Byte)), + (KnownManagedType.Char, JSTypeFlags.String, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Char)), + (KnownManagedType.Int16, JSTypeFlags.Number, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Int16)), + (KnownManagedType.Int32, JSTypeFlags.Number, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Int32)), + (KnownManagedType.Int64, JSTypeFlags.Number, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Int52)), + (KnownManagedType.Int64, JSTypeFlags.BigInt, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.BigInt64)), + (KnownManagedType.Single, JSTypeFlags.Number, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Single)), + (KnownManagedType.Double, JSTypeFlags.Number, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Double)), + (KnownManagedType.IntPtr, JSTypeFlags.Number, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.IntPtr)), + (KnownManagedType.DateTime, JSTypeFlags.Date, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.DateTime)), + (KnownManagedType.DateTimeOffset, JSTypeFlags.Date, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.DateTime)), + (KnownManagedType.Exception, JSTypeFlags.Error, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Exception)), + (KnownManagedType.JSObject, JSTypeFlags.Object, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.JSObject)), + (KnownManagedType.String, JSTypeFlags.String, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.String)), + (KnownManagedType.Object, JSTypeFlags.Any, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Object)), // primitive missing - case KnownManagedType.Boolean when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Boolean)); - case KnownManagedType.Byte when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Byte)); - case KnownManagedType.Char when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Char)); - case KnownManagedType.Int16 when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Int16)); - case KnownManagedType.Int32 when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Int32)); - case KnownManagedType.Single when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Single)); - case KnownManagedType.Double when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Double)); - case KnownManagedType.IntPtr when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, context, MarshalerType.IntPtr)); - case KnownManagedType.Exception when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Exception)); - case KnownManagedType.JSObject when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, context, MarshalerType.JSObject)); - case KnownManagedType.String when jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new PrimitiveJSGenerator(info, context, MarshalerType.String)); + (KnownManagedType.Boolean, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Boolean)), + (KnownManagedType.Byte, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Byte)), + (KnownManagedType.Char, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Char)), + (KnownManagedType.Int16, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Int16)), + (KnownManagedType.Int32, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Int32)), + (KnownManagedType.Single, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Single)), + (KnownManagedType.Double, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Double)), + (KnownManagedType.IntPtr, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.IntPtr)), + (KnownManagedType.Exception, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Exception)), + (KnownManagedType.JSObject, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.JSObject)), + (KnownManagedType.String, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.String)), // primitive forced - case KnownManagedType.Int64 when jsType == JSTypeFlags.Missing: - case KnownManagedType.DateTime when jsType == JSTypeFlags.Missing: - case KnownManagedType.DateTimeOffset when jsType == JSTypeFlags.Missing: - case KnownManagedType.Object when jsType == JSTypeFlags.Missing: - return failWithReason(SR.Format(SR.UseJSMarshalAsAttribute, info.ManagedType.FullTypeName)); + (KnownManagedType.Int64, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Int52)), + (KnownManagedType.DateTime, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.DateTime)), + (KnownManagedType.DateTimeOffset, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.DateTime)), + (KnownManagedType.Object, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Object)), // nullable - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Boolean && jsType == JSTypeFlags.Boolean: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, context, MarshalerType.Boolean)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Byte && jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, context, MarshalerType.Byte)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Char && jsType == JSTypeFlags.String: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, context, MarshalerType.Byte)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Int16 && jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, context, MarshalerType.Int16)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Int32 && jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, context, MarshalerType.Int32)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Int64 && jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, context, MarshalerType.Int52)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Int64 && jsType == JSTypeFlags.BigInt: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, context, MarshalerType.BigInt64)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Double && jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, context, MarshalerType.Double)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Single && jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, context, MarshalerType.Single)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.IntPtr && jsType == JSTypeFlags.Number: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, context, MarshalerType.IntPtr)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.DateTime && jsType == JSTypeFlags.Date: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, context, MarshalerType.DateTime)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.DateTimeOffset && jsType == JSTypeFlags.Date: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, context, MarshalerType.DateTimeOffset)); + (KnownManagedType.Nullable, JSTypeFlags.Boolean, [KnownManagedType.Boolean], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Boolean)), + (KnownManagedType.Nullable, JSTypeFlags.Number, [KnownManagedType.Byte], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Byte)), + (KnownManagedType.Nullable, JSTypeFlags.String, [KnownManagedType.Char], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Char)), + (KnownManagedType.Nullable, JSTypeFlags.Number, [KnownManagedType.Int16], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Int16)), + (KnownManagedType.Nullable, JSTypeFlags.Number, [KnownManagedType.Int32], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Int32)), + (KnownManagedType.Nullable, JSTypeFlags.Number, [KnownManagedType.Int64], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Int52)), + (KnownManagedType.Nullable, JSTypeFlags.BigInt, [KnownManagedType.Int64], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.BigInt64)), + (KnownManagedType.Nullable, JSTypeFlags.Number, [KnownManagedType.Single], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Single)), + (KnownManagedType.Nullable, JSTypeFlags.Number, [KnownManagedType.Double], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Double)), + (KnownManagedType.Nullable, JSTypeFlags.Number, [KnownManagedType.IntPtr], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.IntPtr)), + (KnownManagedType.Nullable, JSTypeFlags.Date, [KnownManagedType.DateTime], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.DateTime)), + (KnownManagedType.Nullable, JSTypeFlags.Date, [KnownManagedType.DateTimeOffset], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.DateTime)), // nullable missing - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Boolean && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, context, MarshalerType.Boolean)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Byte && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, context, MarshalerType.Byte)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Char && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, context, MarshalerType.Byte)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Int16 && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, context, MarshalerType.Int16)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Int32 && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, context, MarshalerType.Int32)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Single && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, context, MarshalerType.Single)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Double && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, context, MarshalerType.Double)); - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.IntPtr && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new NullableJSGenerator(info, context, MarshalerType.IntPtr)); + (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.Boolean], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Boolean)), + (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.Byte], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Byte)), + (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.Char], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Char)), + (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.Int16], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Int16)), + (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.Int32], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Int32)), + (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.Single], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Single)), + (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.Double], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Double)), + (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.IntPtr], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.IntPtr)), + (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.Exception], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Exception)), + (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.JSObject], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.JSObject)), + (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.String], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.String)), // nullable forced - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.Int64 && jsType == JSTypeFlags.Missing: - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.DateTime && jsType == JSTypeFlags.Missing: - case KnownManagedType.Nullable when argumentTypes[0] == KnownManagedType.DateTimeOffset && jsType == JSTypeFlags.Missing: - return failWithReason(SR.Format(SR.UseJSMarshalAsAttribute, info.ManagedType.FullTypeName)); + (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.Int64], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Int52)), + (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.DateTime], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.DateTime)), + (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.DateTimeOffset], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.DateTime)), + + (KnownManagedType.Nullable, _, _, _) => failWithReason(SR.Format(SR.TypeNotSupportedName, info.ManagedType.FullTypeName)), - case KnownManagedType.Nullable: - 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(info, context, 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, context, 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, context, 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, context, 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, context, 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, context, 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, context, 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, context, 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, context, 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, context, 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, context, 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, context, 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, context, 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, context, 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, context, 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, context, 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, context, MarshalerType.Object)); + (KnownManagedType.Task, JSTypeFlags.Promise, [], [JSTypeFlags.Void]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Void)), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Boolean], [JSTypeFlags.Boolean]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Boolean)), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Byte], [JSTypeFlags.Number]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Byte)), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Char], [JSTypeFlags.String]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Char)), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Int16], [JSTypeFlags.Number]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Int16)), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Int32], [JSTypeFlags.Number]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Int32)), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Int64], [JSTypeFlags.Number]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Int52)), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Int64], [JSTypeFlags.BigInt]) => resolved(new TaskJSGenerator(info, context, MarshalerType.BigInt64)), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Single], [JSTypeFlags.Number]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Single)), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Double], [JSTypeFlags.Number]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Double)), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.IntPtr], [JSTypeFlags.Number]) => resolved(new TaskJSGenerator(info, context, MarshalerType.IntPtr)), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.DateTime], [JSTypeFlags.Date]) => resolved(new TaskJSGenerator(info, context, MarshalerType.DateTime)), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.DateTimeOffset], [JSTypeFlags.Date]) => resolved(new TaskJSGenerator(info, context, MarshalerType.DateTime)), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Exception], [JSTypeFlags.Error]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Exception)), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.JSObject], [JSTypeFlags.Object]) => resolved(new TaskJSGenerator(info, context, MarshalerType.JSObject)), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.String], [JSTypeFlags.String]) => resolved(new TaskJSGenerator(info, context, MarshalerType.String)), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Object], [JSTypeFlags.Any]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Object)), // task missing - case KnownManagedType.Task when jsType == JSTypeFlags.Missing && argumentTypes.Length == 0: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, context, MarshalerType.Void)); - case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.Boolean && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, context, MarshalerType.Boolean)); - case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.Byte && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, context, MarshalerType.Byte)); - case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.Char && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, context, MarshalerType.Char)); - case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.Int16 && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, context, MarshalerType.Int16)); - case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.Int32 && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, context, MarshalerType.Int32)); - case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.Single && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, context, MarshalerType.Single)); - case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.Double && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, context, MarshalerType.Double)); - case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.IntPtr && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, context, MarshalerType.IntPtr)); - case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.JSObject && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, context, MarshalerType.JSObject)); - case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.String && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, context, MarshalerType.String)); - case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.Exception && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new TaskJSGenerator(info, context, MarshalerType.Exception)); + (KnownManagedType.Task, JSTypeFlags.Missing, [], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Void)), + (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Boolean], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Boolean)), + (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Byte], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Byte)), + (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Char], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Char)), + (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Int16], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Int16)), + (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Int32], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Int32)), + (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Single], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Single)), + (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Double], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Double)), + (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.IntPtr], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.IntPtr)), + (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Exception], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Exception)), + (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.JSObject], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.JSObject)), + (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.String], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.String)), // task forced - case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.Int64 && jsType == JSTypeFlags.Missing: - case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.DateTime && jsType == JSTypeFlags.Missing: - case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.DateTimeOffset && jsType == JSTypeFlags.Missing: - case KnownManagedType.Task when argumentTypes[0] == KnownManagedType.Object && jsType == JSTypeFlags.Missing: - return failWithReason(SR.Format(SR.UseJSMarshalAsAttribute, info.ManagedType.FullTypeName)); + (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Int64], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Int52)), + (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.DateTime], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.DateTime)), + (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.DateTimeOffset], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.DateTime)), + (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Object], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Object)), - case KnownManagedType.Task when jsType == JSTypeFlags.Promise && jsTypeArguments.Length == 1: - return failWithReason(SR.Format(SR.TypeNotSupportedName, info.ManagedType.FullTypeName)); + (KnownManagedType.Task, JSTypeFlags.Promise, _, [_]) => 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(info, context, 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, context, 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, context, 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, context, 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, context, 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, context, MarshalerType.Object)); + (KnownManagedType.Array, JSTypeFlags.Array, [KnownManagedType.Byte], [JSTypeFlags.Number]) => resolved(new ArrayJSGenerator(info, context, MarshalerType.Byte)), + (KnownManagedType.Array, JSTypeFlags.Array, [KnownManagedType.String], [JSTypeFlags.String]) => resolved(new ArrayJSGenerator(info, context, MarshalerType.String)), + (KnownManagedType.Array, JSTypeFlags.Array, [KnownManagedType.Double], [JSTypeFlags.Number]) => resolved(new ArrayJSGenerator(info, context, MarshalerType.Double)), + (KnownManagedType.Array, JSTypeFlags.Array, [KnownManagedType.Int32], [JSTypeFlags.Number]) => resolved(new ArrayJSGenerator(info, context, MarshalerType.Int32)), + (KnownManagedType.Array, JSTypeFlags.Array, [KnownManagedType.JSObject], [JSTypeFlags.Object]) => resolved(new ArrayJSGenerator(info, context, MarshalerType.JSObject)), + (KnownManagedType.Array, JSTypeFlags.Array, [KnownManagedType.Object], [JSTypeFlags.Any]) => resolved(new ArrayJSGenerator(info, context, MarshalerType.Object)), // array missing - case KnownManagedType.Array when argumentTypes[0] == KnownManagedType.Byte && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new ArrayJSGenerator(info, context, MarshalerType.Byte)); - case KnownManagedType.Array when argumentTypes[0] == KnownManagedType.String && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new ArrayJSGenerator(info, context, MarshalerType.String)); - case KnownManagedType.Array when argumentTypes[0] == KnownManagedType.Double && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new ArrayJSGenerator(info, context, MarshalerType.Double)); - case KnownManagedType.Array when argumentTypes[0] == KnownManagedType.Int32 && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new ArrayJSGenerator(info, context, MarshalerType.Int32)); - case KnownManagedType.Array when argumentTypes[0] == KnownManagedType.JSObject && jsType == JSTypeFlags.Missing: return ResolvedGenerator.Resolved(new ArrayJSGenerator(info, context, MarshalerType.JSObject)); - case KnownManagedType.Array when jsType == JSTypeFlags.Array && jsTypeArguments.Length == 1: - return failWithReason(SR.Format(SR.TypeNotSupportedName, info.ManagedType.FullTypeName)); + (KnownManagedType.Array, JSTypeFlags.Missing, [KnownManagedType.Byte], _) => resolved(new ArrayJSGenerator(info, context, MarshalerType.Byte)), + (KnownManagedType.Array, JSTypeFlags.Missing, [KnownManagedType.String], _) => resolved(new ArrayJSGenerator(info, context, MarshalerType.String)), + (KnownManagedType.Array, JSTypeFlags.Missing, [KnownManagedType.Double], _) => resolved(new ArrayJSGenerator(info, context, MarshalerType.Double)), + (KnownManagedType.Array, JSTypeFlags.Missing, [KnownManagedType.Int32], _) => resolved(new ArrayJSGenerator(info, context, MarshalerType.Int32)), + (KnownManagedType.Array, JSTypeFlags.Missing, [KnownManagedType.JSObject], _) => resolved(new ArrayJSGenerator(info, context, MarshalerType.JSObject)), + + (KnownManagedType.Array, JSTypeFlags.Array, _, [_]) => failWithReason(SR.Format(SR.TypeNotSupportedName, info.ManagedType.FullTypeName)), // array forced - case KnownManagedType.Array when argumentTypes[0] == KnownManagedType.Object && jsType == JSTypeFlags.Missing: - return failWithReason(SR.Format(SR.UseJSMarshalAsAttribute, info.ManagedType.FullTypeName)); + (KnownManagedType.Array, JSTypeFlags.Missing, [KnownManagedType.Object], _) => failWithReason(SR.Format(SR.UseJSMarshalAsAttribute, info.ManagedType.FullTypeName)), // 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(info, context, MarshalerType.Byte)); - case KnownManagedType.Span when jsType == JSTypeFlags.MemoryView && argumentTypes[0] == KnownManagedType.Int32: return ResolvedGenerator.Resolved(new SpanJSGenerator(info, context, MarshalerType.Int32)); - case KnownManagedType.Span when jsType == JSTypeFlags.MemoryView && argumentTypes[0] == KnownManagedType.Double: return ResolvedGenerator.Resolved(new SpanJSGenerator(info, context, MarshalerType.Double)); + (KnownManagedType.Span, JSTypeFlags.MemoryView, _, [_]) => failWithReason(null!), + (KnownManagedType.Span, JSTypeFlags.MemoryView, [KnownManagedType.Byte], _) => resolved(new SpanJSGenerator(info, context, MarshalerType.Byte)), + (KnownManagedType.Span, JSTypeFlags.MemoryView, [KnownManagedType.Int32], _) => resolved(new SpanJSGenerator(info, context, MarshalerType.Int32)), + (KnownManagedType.Span, JSTypeFlags.MemoryView, [KnownManagedType.Double], _) => resolved(new SpanJSGenerator(info, context, MarshalerType.Double)), - case KnownManagedType.Span when jsType == JSTypeFlags.MemoryView: - return failWithReason(SR.Format(SR.TypeNotSupportedName, info.ManagedType.FullTypeName)); + (KnownManagedType.Span, JSTypeFlags.MemoryView, _, _) => failWithReason(SR.Format(SR.TypeNotSupportedName, info.ManagedType.FullTypeName)), // span forced - case KnownManagedType.Span when argumentTypes[0] == KnownManagedType.Byte && jsType == JSTypeFlags.Missing: - case KnownManagedType.Span when argumentTypes[0] == KnownManagedType.Int32 && jsType == JSTypeFlags.Missing: - case KnownManagedType.Span when argumentTypes[0] == KnownManagedType.Double && jsType == JSTypeFlags.Missing: - return failWithReason(SR.Format(SR.UseJSMarshalAsAttribute, info.ManagedType.FullTypeName)); + (KnownManagedType.Span, JSTypeFlags.Missing, [KnownManagedType.Byte], _) => failWithReason(SR.Format(SR.UseJSMarshalAsAttribute, info.ManagedType.FullTypeName)), + (KnownManagedType.Span, JSTypeFlags.Missing, [KnownManagedType.Int32], _) => failWithReason(SR.Format(SR.UseJSMarshalAsAttribute, info.ManagedType.FullTypeName)), + (KnownManagedType.Span, JSTypeFlags.Missing, [KnownManagedType.Double], _) => failWithReason(SR.Format(SR.UseJSMarshalAsAttribute, info.ManagedType.FullTypeName)), // 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(info, context, MarshalerType.Byte)); - case KnownManagedType.ArraySegment when jsType == JSTypeFlags.MemoryView && argumentTypes[0] == KnownManagedType.Int32: return ResolvedGenerator.Resolved(new ArraySegmentJSGenerator(info, context, MarshalerType.Int32)); - case KnownManagedType.ArraySegment when jsType == JSTypeFlags.MemoryView && argumentTypes[0] == KnownManagedType.Double: return ResolvedGenerator.Resolved(new ArraySegmentJSGenerator(info, context, MarshalerType.Double)); - case KnownManagedType.ArraySegment when jsType == JSTypeFlags.MemoryView: - return failWithReason(SR.Format(SR.TypeNotSupportedName, info.ManagedType.FullTypeName)); + (KnownManagedType.ArraySegment, JSTypeFlags.MemoryView, _, [_]) => failWithReason(null!), + (KnownManagedType.ArraySegment, JSTypeFlags.MemoryView, [KnownManagedType.Byte], _) => resolved(new ArraySegmentJSGenerator(info, context, MarshalerType.Byte)), + (KnownManagedType.ArraySegment, JSTypeFlags.MemoryView, [KnownManagedType.Int32], _) => resolved(new ArraySegmentJSGenerator(info, context, MarshalerType.Int32)), + (KnownManagedType.ArraySegment, JSTypeFlags.MemoryView, [KnownManagedType.Double], _) => resolved(new ArraySegmentJSGenerator(info, context, MarshalerType.Double)), + + (KnownManagedType.ArraySegment, JSTypeFlags.MemoryView, _, _) => failWithReason(SR.Format(SR.TypeNotSupportedName, info.ManagedType.FullTypeName)), // segment forced - case KnownManagedType.ArraySegment when argumentTypes[0] == KnownManagedType.Byte && jsType == JSTypeFlags.Missing: - case KnownManagedType.ArraySegment when argumentTypes[0] == KnownManagedType.Int32 && jsType == JSTypeFlags.Missing: - case KnownManagedType.ArraySegment when argumentTypes[0] == KnownManagedType.Double && jsType == JSTypeFlags.Missing: - return failWithReason(SR.Format(SR.UseJSMarshalAsAttribute, info.ManagedType.FullTypeName)); + (KnownManagedType.ArraySegment, JSTypeFlags.Missing, [KnownManagedType.Byte], _) => failWithReason(SR.Format(SR.UseJSMarshalAsAttribute, info.ManagedType.FullTypeName)), + (KnownManagedType.ArraySegment, JSTypeFlags.Missing, [KnownManagedType.Int32], _) => failWithReason(SR.Format(SR.UseJSMarshalAsAttribute, info.ManagedType.FullTypeName)), + (KnownManagedType.ArraySegment, JSTypeFlags.Missing, [KnownManagedType.Double], _) => failWithReason(SR.Format(SR.UseJSMarshalAsAttribute, info.ManagedType.FullTypeName)), // function + action - case KnownManagedType.Function when jsType == JSTypeFlags.Function && jsTypeArguments.Length == argumentTypes.Length: - case KnownManagedType.Action when jsType == JSTypeFlags.Function && jsTypeArguments.Length == argumentTypes.Length: - var argsMarshalers = new List(); - for (int i = 0; i < argumentTypes.Length; i++) - { - var isReturn = marshaledType == KnownManagedType.Function && i == jsTypeArguments.Length - 1; - if (argumentTypes[i] == KnownManagedType.Array - || argumentTypes[i] == KnownManagedType.Span - || argumentTypes[i] == KnownManagedType.ArraySegment - || argumentTypes[i] == KnownManagedType.Task - || argumentTypes[i] == KnownManagedType.Function - || argumentTypes[i] == KnownManagedType.Action - || argumentTypes[i] == KnownManagedType.Unknown - ) - { - return failWithReason(SR.Format(SR.FuncArgumentNotSupported, argumentTypes[i])); - } - var gen = Create(info, context, isToJs ^ (!isReturn), argumentTypes[i], Array.Empty(), jsTypeArguments[i], Array.Empty(), failWithReason); - argsMarshalers.Add(((BaseJSGenerator)gen.Generator).Type); - } - var maxArgs = marshaledType == KnownManagedType.Action ? 3 : 4; - var argsMarshallerTypes = argsMarshalers.ToArray(); - if (argsMarshallerTypes.Length > maxArgs) - { - return failWithReason(SR.FuncTooManyArgs); - } - return ResolvedGenerator.Resolved(new FuncJSGenerator(info, context, marshaledType == KnownManagedType.Action, argsMarshallerTypes)); - case KnownManagedType.Action when jsType == JSTypeFlags.Function: - case KnownManagedType.Function when jsType == JSTypeFlags.Function: - return failWithReason(SR.FuncWrongArgumentCount); + (KnownManagedType.Function or KnownManagedType.Action, JSTypeFlags.Function, var argTypes, var argJSTypes) when argTypes.Length != argJSTypes.Length + => failWithReason(SR.Format(SR.TypeNotSupportedName, info.ManagedType.FullTypeName)), + + (KnownManagedType.Function or KnownManagedType.Action, JSTypeFlags.Function or JSTypeFlags.Missing, var argTypes, _) when FindFirstInvalidArgType(argTypes) is KnownManagedType invalidArgType + => failWithReason(SR.Format(SR.FuncArgumentNotSupported, invalidArgType)), + + (KnownManagedType.Function or KnownManagedType.Action, JSTypeFlags.Function, var argTypes, var argJSTypes) => ResolveCallback(marshaledType, argTypes, argJSTypes), // function + action forced - case KnownManagedType.Function when jsType == JSTypeFlags.Missing: - case KnownManagedType.Action when jsType == JSTypeFlags.Missing: - for (int i = 0; i < argumentTypes.Length; i++) + (KnownManagedType.Function or KnownManagedType.Action, JSTypeFlags.Missing, _, _) => failWithReason(SR.Format(SR.UseJSMarshalAsAttribute, info.ManagedType.FullTypeName)), + + // void only JSType on non-void + (not KnownManagedType.Void, JSTypeFlags.Discard, _, _) => failWithReason(SR.DiscardOnlyVoid), + (not KnownManagedType.Void, JSTypeFlags.DiscardNoWait, _, _) => failWithReason(SR.DiscardNoWaitOnlyVoid), + + + _ => failWithReason(SR.Format(SR.TypeNotSupportedName, info.ManagedType.FullTypeName)), + }; + + KnownManagedType? FindFirstInvalidArgType(KnownManagedType[] argumentTypes) + { + foreach (KnownManagedType type in argumentTypes) + { + if (type is KnownManagedType.Array + or KnownManagedType.Span + or KnownManagedType.ArraySegment + or KnownManagedType.Task + or KnownManagedType.Function + or KnownManagedType.Action + or KnownManagedType.Unknown + ) { - if (argumentTypes[i] == KnownManagedType.Array - || argumentTypes[i] == KnownManagedType.Span - || argumentTypes[i] == KnownManagedType.ArraySegment - || argumentTypes[i] == KnownManagedType.Task - || argumentTypes[i] == KnownManagedType.Function - || argumentTypes[i] == KnownManagedType.Action - || argumentTypes[i] == KnownManagedType.Unknown - ) - { - return failWithReason(SR.Format(SR.FuncArgumentNotSupported, argumentTypes[i])); - } + return type; } - return failWithReason(SR.Format(SR.UseJSMarshalAsAttribute, info.ManagedType.FullTypeName)); + } + return null; + } - default: - return failWithReason(SR.Format(SR.TypeNotSupportedName, info.ManagedType.FullTypeName)); + ResolvedGenerator ResolveCallback(KnownManagedType managedType, KnownManagedType[] argTypes, JSTypeFlags[] argJSTypes) + { + var argsMarshalers = new List(); + for (int i = 0; i < argTypes.Length; i++) + { + var isReturn = managedType == KnownManagedType.Function && i == argJSTypes.Length - 1; + + var gen = Create(info, context, isToJs ^ (!isReturn), argTypes[i], Array.Empty(), argJSTypes[i], Array.Empty()); + argsMarshalers.Add(((BaseJSGenerator)gen.Generator).Type); + } + var maxArgs = managedType == KnownManagedType.Action ? 3 : 4; + MarshalerType[] argsMarshallerTypes = [.. argsMarshalers]; + if (argsMarshallerTypes.Length > maxArgs) + { + return failWithReason(SR.FuncTooManyArgs); + } + return resolved(new FuncJSGenerator(info, context, managedType == KnownManagedType.Action, argsMarshallerTypes)); + } + + ResolvedGenerator failWithReason(string failReason) + { + return ResolvedGenerator.NotSupported(info, context, new(info) + { + NotSupportedDetails = failReason + }); + } + + ResolvedGenerator resolved(IBoundMarshallingGenerator generator) + { + return ResolvedGenerator.Resolved(generator); } } } diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.csproj b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.csproj index d973b24132c6a8..0af96384ebbe8c 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.csproj +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.csproj @@ -27,6 +27,7 @@ + From fdef13218afa1ffd81609ceb759aa5314895c3a0 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 12 Sep 2024 14:52:16 -0700 Subject: [PATCH 02/22] Replat the JS generators to use the same stub generators as LibraryImport and GeneratedComInterface by using local functions to shim from the JS generator signatures (which take a buffer) to the more standard "separate arguments" format used by those generators. Split out the MarshalerType/Bind logic to not run through the generators, which allows removing the IJSMarshallingGenerator concept. --- ...tem.Runtime.InteropServices.JavaScript.sln | 399 +++++++++--------- .../gen/JSImportGenerator/Constants.cs | 1 + .../JSExportCodeGenerator.cs | 236 ----------- .../JSImportGenerator/JSExportGenerator.cs | 125 +++++- .../JSImportGenerator/JSGeneratorFactory.cs | 267 ++++++------ .../JSImportCodeGenerator.cs | 212 ---------- .../JSImportGenerator/JSImportGenerator.cs | 90 +++- .../Marshaling/ArrayJSGenerator.cs | 28 -- .../Marshaling/ArraySegmentJSGenerator.cs | 27 -- .../Marshaling/BaseJSGenerator.cs | 56 +-- .../Marshaling/EmptyJSGenerator.cs | 20 - .../Marshaling/FuncJSGenerator.cs | 56 +-- .../Marshaling/IJSMarshallingGenerator.cs | 13 - .../Marshaling/NullableJSGenerator.cs | 24 -- .../Marshaling/PrimitiveJSGenerator.cs | 62 +-- .../Marshaling/SpanJSGenerator.cs | 27 -- .../Marshaling/TaskJSGenerator.cs | 70 +-- .../Marshaling/VoidGenerator.cs | 9 - .../NoSpanAndTaskMixingResolver.cs | 42 ++ .../SignatureBindingHelpers.cs | 40 ++ .../JavaScript/JSFunctionBinding.cs | 52 +-- .../JSImportGenerator.UnitTest/Compiles.cs | 256 +++++------ .../gen/Common/Resources/Strings.resx | 4 +- .../gen/Common/Resources/xlf/Strings.cs.xlf | 6 +- .../gen/Common/Resources/xlf/Strings.de.xlf | 6 +- .../gen/Common/Resources/xlf/Strings.es.xlf | 6 +- .../gen/Common/Resources/xlf/Strings.fr.xlf | 6 +- .../gen/Common/Resources/xlf/Strings.it.xlf | 6 +- .../gen/Common/Resources/xlf/Strings.ja.xlf | 6 +- .../gen/Common/Resources/xlf/Strings.ko.xlf | 6 +- .../gen/Common/Resources/xlf/Strings.pl.xlf | 6 +- .../Common/Resources/xlf/Strings.pt-BR.xlf | 6 +- .../gen/Common/Resources/xlf/Strings.ru.xlf | 6 +- .../gen/Common/Resources/xlf/Strings.tr.xlf | 6 +- .../Common/Resources/xlf/Strings.zh-Hans.xlf | 6 +- .../Common/Resources/xlf/Strings.zh-Hant.xlf | 6 +- .../BoundGenerators.cs | 70 ++- .../UnmanagedToManagedStubGenerator.cs | 2 +- .../VariableDeclarations.cs | 4 +- 39 files changed, 929 insertions(+), 1341 deletions(-) delete mode 100644 src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSExportCodeGenerator.cs delete mode 100644 src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportCodeGenerator.cs delete mode 100644 src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/ArrayJSGenerator.cs delete mode 100644 src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/ArraySegmentJSGenerator.cs delete mode 100644 src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/EmptyJSGenerator.cs delete mode 100644 src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/IJSMarshallingGenerator.cs delete mode 100644 src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/NullableJSGenerator.cs delete mode 100644 src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/SpanJSGenerator.cs delete mode 100644 src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/VoidGenerator.cs create mode 100644 src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/NoSpanAndTaskMixingResolver.cs create mode 100644 src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/SignatureBindingHelpers.cs rename src/libraries/System.Runtime.InteropServices/gen/{ComInterfaceGenerator => Microsoft.Interop.SourceGeneration}/UnmanagedToManagedStubGenerator.cs (98%) 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 9be1cf583e2740..322f5bf805e6b1 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.12.35229.201 +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}" @@ -73,16 +77,21 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{19EA33B4-0E8 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "gen", "{1A04C5D7-1DE9-47C3-BCC1-147678B9085F}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "tools\gen", "{F81BA54D-38C5-4493-BB5C-344825706D3A}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "gen", "{F81BA54D-38C5-4493-BB5C-344825706D3A}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "tools\src", "{F0448246-E8A1-49FD-878C-7A6B8486A66B}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{F0448246-E8A1-49FD-878C-7A6B8486A66B}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "tools\ref", "{9BB52E31-4890-4F4B-8B2B-6282EF13B8D2}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{9BB52E31-4890-4F4B-8B2B-6282EF13B8D2}" 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 @@ -93,13 +102,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 @@ -120,16 +134,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 @@ -146,11 +155,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 @@ -167,11 +176,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 @@ -188,11 +197,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 @@ -209,11 +218,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 @@ -230,11 +239,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 @@ -251,11 +260,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 @@ -272,11 +281,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 @@ -293,11 +302,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 @@ -314,11 +323,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 @@ -335,11 +344,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 @@ -356,11 +365,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 @@ -377,11 +386,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 @@ -398,11 +407,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 @@ -419,11 +428,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 @@ -440,11 +449,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 + {DE207B2C-A0CC-47C8-AC20-46A8C0970287}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {DE207B2C-A0CC-47C8-AC20-46A8C0970287}.Checked|arm.ActiveCfg = Debug|Any CPU + {DE207B2C-A0CC-47C8-AC20-46A8C0970287}.Checked|arm64.ActiveCfg = Debug|Any CPU + {DE207B2C-A0CC-47C8-AC20-46A8C0970287}.Checked|x64.ActiveCfg = Debug|Any CPU + {DE207B2C-A0CC-47C8-AC20-46A8C0970287}.Checked|x86.ActiveCfg = Debug|Any CPU {DE207B2C-A0CC-47C8-AC20-46A8C0970287}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DE207B2C-A0CC-47C8-AC20-46A8C0970287}.Debug|Any CPU.Build.0 = Debug|Any CPU {DE207B2C-A0CC-47C8-AC20-46A8C0970287}.Debug|arm.ActiveCfg = Debug|Any CPU @@ -461,11 +470,11 @@ Global {DE207B2C-A0CC-47C8-AC20-46A8C0970287}.Release|x64.Build.0 = Release|Any CPU {DE207B2C-A0CC-47C8-AC20-46A8C0970287}.Release|x86.ActiveCfg = Release|Any CPU {DE207B2C-A0CC-47C8-AC20-46A8C0970287}.Release|x86.Build.0 = Release|Any CPU - {DE207B2C-A0CC-47C8-AC20-46A8C0970287}.Checked|Any CPU.ActiveCfg = Debug|Any CPU - {DE207B2C-A0CC-47C8-AC20-46A8C0970287}.Checked|arm.ActiveCfg = Debug|Any CPU - {DE207B2C-A0CC-47C8-AC20-46A8C0970287}.Checked|arm64.ActiveCfg = Debug|Any CPU - {DE207B2C-A0CC-47C8-AC20-46A8C0970287}.Checked|x64.ActiveCfg = Debug|Any CPU - {DE207B2C-A0CC-47C8-AC20-46A8C0970287}.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 @@ -482,11 +491,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 @@ -503,11 +512,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 @@ -524,11 +533,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 @@ -545,11 +554,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 @@ -566,11 +575,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 @@ -587,11 +596,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 @@ -608,11 +617,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 @@ -629,11 +638,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 @@ -650,11 +659,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 @@ -671,11 +680,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 @@ -692,11 +701,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 @@ -713,11 +722,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 @@ -734,11 +743,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 @@ -755,11 +764,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 @@ -776,11 +785,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 @@ -797,54 +806,54 @@ 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} = {32733782-56D6-4EAF-B94E-5D10C759DD57} + {ED86AB26-1CFB-457D-BF87-B7A0D8FAF272} = {26A72FFB-871A-4F2F-A513-B2F6E09F358C} {FC1007CC-9E52-49B7-A47B-A8AE76E75986} = {32733782-56D6-4EAF-B94E-5D10C759DD57} + {8B1D80E9-AE0D-4E3C-9F91-E6862B49AEF3} = {19EA33B4-0E87-451F-95E3-8F3959117654} {B79E5BB4-2595-48BC-A44C-0A7949AFBDEB} = {32733782-56D6-4EAF-B94E-5D10C759DD57} + {E00AE8BB-7C7F-4D07-949D-EDCC815AC8C8} = {19EA33B4-0E87-451F-95E3-8F3959117654} {C1C606F3-A246-4EA0-A467-3AC4F31C2AFE} = {32733782-56D6-4EAF-B94E-5D10C759DD57} + {8CFB1155-26A2-43E3-B192-1F87D9E543AC} = {1A04C5D7-1DE9-47C3-BCC1-147678B9085F} + {D549C13B-FC0D-4B5A-B50D-8F74CB5A3D08} = {19EA33B4-0E87-451F-95E3-8F3959117654} {74143A5F-6987-4AB5-B786-DE358F01241B} = {32733782-56D6-4EAF-B94E-5D10C759DD57} + {CE5E53C1-F9B5-41EE-8D00-837913EC57D1} = {1A04C5D7-1DE9-47C3-BCC1-147678B9085F} + {28278E01-BF5C-4AB6-AA7A-8DD4E6C04DB1} = {19EA33B4-0E87-451F-95E3-8F3959117654} {71A845ED-4344-41FC-8FCA-3AC9B6BA6C45} = {32733782-56D6-4EAF-B94E-5D10C759DD57} - {1EB2EBE2-12EA-4545-B390-098F083329A1} = {32733782-56D6-4EAF-B94E-5D10C759DD57} - {04A40E6C-DD10-473D-AFF8-9033E936DC46} = {32733782-56D6-4EAF-B94E-5D10C759DD57} - {424A7718-F5B7-41FB-A74B-1E23A9BF13EA} = {32733782-56D6-4EAF-B94E-5D10C759DD57} - {8683B814-5459-4412-A881-ECAFF9ED1781} = {32733782-56D6-4EAF-B94E-5D10C759DD57} - {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} + {DE207B2C-A0CC-47C8-AC20-46A8C0970287} = {1A04C5D7-1DE9-47C3-BCC1-147678B9085F} + {09AA6758-0BD3-4312-9C07-AE9F1D50A3AD} = {1A04C5D7-1DE9-47C3-BCC1-147678B9085F} + {B4E3E774-2C16-4CBF-87EF-88C547529B94} = {1A04C5D7-1DE9-47C3-BCC1-147678B9085F} {EC3ADEFA-1FF3-482C-8CCB-FE4C77292532} = {26A72FFB-871A-4F2F-A513-B2F6E09F358C} - {8B1D80E9-AE0D-4E3C-9F91-E6862B49AEF3} = {19EA33B4-0E87-451F-95E3-8F3959117654} - {E00AE8BB-7C7F-4D07-949D-EDCC815AC8C8} = {19EA33B4-0E87-451F-95E3-8F3959117654} - {D549C13B-FC0D-4B5A-B50D-8F74CB5A3D08} = {19EA33B4-0E87-451F-95E3-8F3959117654} - {28278E01-BF5C-4AB6-AA7A-8DD4E6C04DB1} = {19EA33B4-0E87-451F-95E3-8F3959117654} {44BAE6F1-94C2-415B-9A16-3B8EC429B09B} = {19EA33B4-0E87-451F-95E3-8F3959117654} + {1EB2EBE2-12EA-4545-B390-098F083329A1} = {32733782-56D6-4EAF-B94E-5D10C759DD57} {B18C5A3A-CAB0-4B62-9C01-7A046E05089F} = {19EA33B4-0E87-451F-95E3-8F3959117654} + {04A40E6C-DD10-473D-AFF8-9033E936DC46} = {32733782-56D6-4EAF-B94E-5D10C759DD57} {B86E4599-88CF-4662-96BA-3FCB926D0BA1} = {19EA33B4-0E87-451F-95E3-8F3959117654} + {424A7718-F5B7-41FB-A74B-1E23A9BF13EA} = {32733782-56D6-4EAF-B94E-5D10C759DD57} {D620CBA3-326B-4E4A-81C2-3D9E9258E45C} = {19EA33B4-0E87-451F-95E3-8F3959117654} - {8CFB1155-26A2-43E3-B192-1F87D9E543AC} = {1A04C5D7-1DE9-47C3-BCC1-147678B9085F} - {CE5E53C1-F9B5-41EE-8D00-837913EC57D1} = {1A04C5D7-1DE9-47C3-BCC1-147678B9085F} - {DE207B2C-A0CC-47C8-AC20-46A8C0970287} = {1A04C5D7-1DE9-47C3-BCC1-147678B9085F} - {09AA6758-0BD3-4312-9C07-AE9F1D50A3AD} = {1A04C5D7-1DE9-47C3-BCC1-147678B9085F} - {B4E3E774-2C16-4CBF-87EF-88C547529B94} = {1A04C5D7-1DE9-47C3-BCC1-147678B9085F} + {8683B814-5459-4412-A881-ECAFF9ED1781} = {32733782-56D6-4EAF-B94E-5D10C759DD57} {4D8B7538-D933-4F3A-818D-4E19ABA7E182} = {F81BA54D-38C5-4493-BB5C-344825706D3A} {6C60944F-4FE1-450F-884B-D523EDFCFAB3} = {F81BA54D-38C5-4493-BB5C-344825706D3A} - {F81BA54D-38C5-4493-BB5C-344825706D3A} = {7392B838-42AF-4F54-AD02-366397DAF640} {B8F2E56D-6571-466D-9EF2-9FCAD3FC6E5B} = {F0448246-E8A1-49FD-878C-7A6B8486A66B} {42F9A600-BEC3-4F87-97EE-38E0DCAABC5A} = {F0448246-E8A1-49FD-878C-7A6B8486A66B} - {F0448246-E8A1-49FD-878C-7A6B8486A66B} = {7392B838-42AF-4F54-AD02-366397DAF640} {008873D5-9028-4FF3-8354-71F713748625} = {9BB52E31-4890-4F4B-8B2B-6282EF13B8D2} + {F81BA54D-38C5-4493-BB5C-344825706D3A} = {7392B838-42AF-4F54-AD02-366397DAF640} + {F0448246-E8A1-49FD-878C-7A6B8486A66B} = {7392B838-42AF-4F54-AD02-366397DAF640} {9BB52E31-4890-4F4B-8B2B-6282EF13B8D2} = {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/Constants.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Constants.cs index a5475e27c70a46..5dd5fa98ceb1b4 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Constants.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Constants.cs @@ -14,6 +14,7 @@ internal static class Constants public const string JSFunctionSignatureGlobal = "global::System.Runtime.InteropServices.JavaScript.JSFunctionBinding"; public const string JSMarshalerArgumentGlobal = "global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument"; + public const string JSMarshalerArgument = "System.Runtime.InteropServices.JavaScript.JSMarshalerArgument"; public const string ModuleInitializerAttributeGlobal = "global::System.Runtime.CompilerServices.ModuleInitializerAttribute"; public const string CompilerGeneratedAttributeGlobal = "global::System.Runtime.CompilerServices.CompilerGeneratedAttribute"; public const string DynamicDependencyAttributeGlobal = "global::System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute"; diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSExportCodeGenerator.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSExportCodeGenerator.cs deleted file mode 100644 index 33b08510d4fe8a..00000000000000 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSExportCodeGenerator.cs +++ /dev/null @@ -1,236 +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; -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Linq; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; - -namespace Microsoft.Interop.JavaScript -{ - internal sealed class JSExportCodeGenerator : JSCodeGenerator - { - private readonly BoundGenerators _marshallers; - - private readonly StubIdentifierContext _context; - private readonly JSExportData _jsExportData; - private readonly JSSignatureContext _signatureContext; - - public JSExportCodeGenerator( - ImmutableArray argTypes, - JSExportData attributeData, - JSSignatureContext signatureContext, - GeneratorDiagnosticsBag diagnosticsBag, - IMarshallingGeneratorResolver generatorResolver) - { - _signatureContext = signatureContext; - _jsExportData = attributeData; - - _marshallers = BoundGenerators.Create(argTypes, generatorResolver, StubCodeContext.DefaultNativeToManagedStub, new EmptyJSGenerator(), out var bindingFailures); - - diagnosticsBag.ReportGeneratorDiagnostics(bindingFailures); - - if (_marshallers.ManagedReturnMarshaller.UsesNativeIdentifier) - { - // If we need a different native return identifier, then recreate the context with the correct identifier before we generate any code. - _context = new DefaultIdentifierContext(ReturnIdentifier, ReturnNativeIdentifier, MarshalDirection.UnmanagedToManaged) - { - CodeEmitOptions = new(SkipInit: true), - }; - } - else - { - _context = new DefaultIdentifierContext(ReturnIdentifier, ReturnIdentifier, MarshalDirection.UnmanagedToManaged) - { - CodeEmitOptions = new(SkipInit: true), - }; - } - - // validate task + span mix - if (_marshallers.ManagedReturnMarshaller.TypeInfo.MarshallingAttributeInfo is JSMarshallingInfo(_, JSTaskTypeInfo)) - { - IBoundMarshallingGenerator spanArg = _marshallers.SignatureMarshallers.FirstOrDefault(m => m.TypeInfo.MarshallingAttributeInfo is JSMarshallingInfo(_, JSSpanTypeInfo)); - if (spanArg != default) - { - diagnosticsBag.ReportGeneratorDiagnostic(new GeneratorDiagnostic.NotSupported(spanArg.TypeInfo) - { - NotSupportedDetails = SR.SpanAndTaskNotSupported - }); - } - } - } - - public BlockSyntax GenerateJSExportBody() - { - List invoke = InvokeSyntax(); - GeneratedStatements statements = GeneratedStatements.Create(_marshallers, _context); - bool shouldInitializeVariables = !statements.GuaranteedUnmarshal.IsEmpty || !statements.CleanupCallerAllocated.IsEmpty || !statements.CleanupCalleeAllocated.IsEmpty; - VariableDeclarations declarations = VariableDeclarations.GenerateDeclarationsForUnmanagedToManaged(_marshallers, _context, shouldInitializeVariables); - - var setupStatements = new List(); - SetupSyntax(setupStatements); - - if (!(statements.GuaranteedUnmarshal.IsEmpty && statements.CleanupCalleeAllocated.IsEmpty)) - { - setupStatements.Add(SyntaxFactoryExtensions.Declare(PredefinedType(Token(SyntaxKind.BoolKeyword)), InvokeSucceededIdentifier, initializeToDefault: true)); - } - - setupStatements.AddRange(declarations.Initializations); - setupStatements.AddRange(declarations.Variables); - setupStatements.AddRange(statements.Setup); - - var tryStatements = new List(); - tryStatements.AddRange(statements.Unmarshal); - - tryStatements.AddRange(invoke); - - if (!(statements.GuaranteedUnmarshal.IsEmpty && statements.CleanupCalleeAllocated.IsEmpty)) - { - tryStatements.Add(ExpressionStatement(AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, - IdentifierName(InvokeSucceededIdentifier), - LiteralExpression(SyntaxKind.TrueLiteralExpression)))); - } - - tryStatements.AddRange(statements.NotifyForSuccessfulInvoke); - tryStatements.AddRange(statements.PinnedMarshal); - tryStatements.AddRange(statements.Marshal); - - List allStatements = setupStatements; - - // Wrap unmarshall, invocation and return value marshalling in try-catch. - // In case of exception, marshal exception instead of return value. - var tryInvokeAndMarshal = TryStatement(SingletonList(CatchClause() - .WithDeclaration(CatchDeclaration(IdentifierName(Constants.ExceptionGlobal)).WithIdentifier(Identifier("ex"))) - .WithBlock(Block(SingletonList( - ExpressionStatement(InvocationExpression( - MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(Constants.ArgumentException), IdentifierName(Constants.ToJSMethod))) - .WithArgumentList(ArgumentList(SingletonSeparatedList(Argument(IdentifierName("ex"))))))))))) - .WithBlock(Block(tryStatements)); - - List finallyStatements = new List(); - if (!(statements.GuaranteedUnmarshal.IsEmpty && statements.CleanupCalleeAllocated.IsEmpty)) - { - finallyStatements.Add(IfStatement(IdentifierName(InvokeSucceededIdentifier), Block(statements.GuaranteedUnmarshal.Concat(statements.CleanupCalleeAllocated)))); - } - - finallyStatements.AddRange(statements.CleanupCallerAllocated); - - if (finallyStatements.Count > 0) - { - tryInvokeAndMarshal = TryStatement(Block(tryInvokeAndMarshal), default, FinallyClause(Block(finallyStatements))); - } - - allStatements.Add(tryInvokeAndMarshal); - - return Block(allStatements); - } - - public static StatementSyntax[] GenerateJSExportArchitectureCheck() - { - return new StatementSyntax[]{ - IfStatement( - BinaryExpression(SyntaxKind.LogicalOrExpression, - IdentifierName("initialized"), - BinaryExpression(SyntaxKind.NotEqualsExpression, - IdentifierName(Constants.OSArchitectureGlobal), - IdentifierName(Constants.ArchitectureWasmGlobal))), - ReturnStatement()), - ExpressionStatement( - AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, - IdentifierName("initialized"), - LiteralExpression(SyntaxKind.TrueLiteralExpression))), - }; - } - - public StatementSyntax GenerateJSExportRegistration() - { - var signatureArgs = new List - { - Argument(LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(_signatureContext.QualifiedMethodName))), - Argument(LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(_signatureContext.TypesHash))), - CreateSignaturesSyntax() - }; - - return ExpressionStatement(InvocationExpression(MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(Constants.JSFunctionSignatureGlobal), IdentifierName(Constants.BindCSFunctionMethod))) - .WithArgumentList(ArgumentList(SeparatedList(signatureArgs)))); - } - - private ArgumentSyntax CreateSignaturesSyntax() - { - IEnumerable types = _marshallers.ManagedReturnMarshaller is IJSMarshallingGenerator jsGen ? jsGen.GenerateBind() : []; - types = types - .Concat(_marshallers.NativeParameterMarshallers.OfType().SelectMany(p => p.GenerateBind())); - - return Argument(ArrayCreationExpression(ArrayType(IdentifierName(Constants.JSMarshalerTypeGlobal)) - .WithRankSpecifiers(SingletonList(ArrayRankSpecifier(SingletonSeparatedList(OmittedArraySizeExpression()))))) - .WithInitializer(InitializerExpression(SyntaxKind.ArrayInitializerExpression, SeparatedList(types)))); - } - - private void SetupSyntax(List statementsToUpdate) - { - foreach (IBoundMarshallingGenerator marshaller in _marshallers.NativeParameterMarshallers) - { - statementsToUpdate.Add(LocalDeclarationStatement(VariableDeclaration(marshaller.TypeInfo.ManagedType.Syntax) - .WithVariables(SingletonSeparatedList(VariableDeclarator(marshaller.TypeInfo.InstanceIdentifier))))); - } - - statementsToUpdate.Add(LocalDeclarationStatement(VariableDeclaration(RefType(IdentifierName(Constants.JSMarshalerArgumentGlobal))) - .WithVariables(SingletonSeparatedList(VariableDeclarator(Identifier(Constants.ArgumentException)) - .WithInitializer(EqualsValueClause(RefExpression(ElementAccessExpression(IdentifierName(Constants.ArgumentsBuffer)) - .WithArgumentList(BracketedArgumentList(SingletonSeparatedList( - Argument(LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(0))))))))))))); - - statementsToUpdate.Add(LocalDeclarationStatement(VariableDeclaration(RefType(IdentifierName(Constants.JSMarshalerArgumentGlobal))) - .WithVariables(SingletonSeparatedList(VariableDeclarator(Identifier(Constants.ArgumentReturn)) - .WithInitializer(EqualsValueClause(RefExpression(ElementAccessExpression(IdentifierName(Constants.ArgumentsBuffer)) - .WithArgumentList(BracketedArgumentList(SingletonSeparatedList( - Argument(LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(1))))))))))))); - } - - private List InvokeSyntax() - { - var statements = new List(); - var arguments = new List(); - - // Generate code for each parameter for the current stage - foreach (IBoundMarshallingGenerator marshaller in _marshallers.NativeParameterMarshallers) - { - // convert arguments for invocation - statements.AddRange(marshaller.Generate(_context)); - arguments.Add(Argument(IdentifierName(marshaller.TypeInfo.InstanceIdentifier))); - } - - if (_marshallers.IsManagedVoidReturn) - { - statements.Add(ExpressionStatement(InvocationExpression(IdentifierName(_signatureContext.MethodName)) - .WithArgumentList(ArgumentList(SeparatedList(arguments))))); - } - else - { - ExpressionSyntax invocation = InvocationExpression(IdentifierName(_signatureContext.MethodName)) - .WithArgumentList(ArgumentList(SeparatedList(arguments))); - - (string _, string nativeIdentifier) = _context.GetIdentifiers(_marshallers.ManagedReturnMarshaller.TypeInfo); - - ExpressionStatementSyntax statement = ExpressionStatement(AssignmentExpression( - SyntaxKind.SimpleAssignmentExpression, - IdentifierName(nativeIdentifier), invocation)); - - statements.Add(statement); - } - return statements; - - } - - public (ParameterListSyntax ParameterList, TypeSyntax ReturnType, AttributeListSyntax? ReturnTypeAttributes) GenerateTargetMethodSignatureData() - { - return _marshallers.GenerateTargetMethodSignatureData(_context); - } - } -} 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 824bc6b6d6c05e..336153c554057a 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSExportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSExportGenerator.cs @@ -146,7 +146,7 @@ private static MemberDeclarationSyntax PrintGeneratedSource( .WithAttributeLists(SingletonList(AttributeList(SingletonSeparatedList( Attribute(IdentifierName(Constants.DebuggerNonUserCodeAttribute)))))) .WithParameterList(ParameterList(SingletonSeparatedList( - Parameter(Identifier("__arguments_buffer")).WithType(PointerType(ParseTypeName(Constants.JSMarshalerArgumentGlobal)))))) + Parameter(Identifier(Constants.ArgumentsBuffer)).WithType(PointerType(ParseTypeName(Constants.JSMarshalerArgumentGlobal)))))) .WithBody(wrapperStatements); MemberDeclarationSyntax toPrint = containingSyntaxContext.WrapMembersInContainingSyntaxWithUnsafeModifier(wrappperMethod); @@ -225,7 +225,7 @@ private static NamespaceDeclarationSyntax GenerateRegSource( if (methods.IsEmpty) return NamespaceDeclaration(IdentifierName(generatedNamespace)); var registerStatements = new List(); - registerStatements.AddRange(JSExportCodeGenerator.GenerateJSExportArchitectureCheck()); + registerStatements.AddRange(GenerateJSExportArchitectureCheck()); var attributes = new List(); foreach (var m in methods) @@ -302,23 +302,61 @@ private static NamespaceDeclarationSyntax GenerateRegSource( return ns; } + private static StatementSyntax[] GenerateJSExportArchitectureCheck() + { + return [ + IfStatement( + BinaryExpression(SyntaxKind.LogicalOrExpression, + IdentifierName("initialized"), + BinaryExpression(SyntaxKind.NotEqualsExpression, + IdentifierName(Constants.OSArchitectureGlobal), + IdentifierName(Constants.ArchitectureWasmGlobal))), + ReturnStatement()), + ExpressionStatement( + AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, + IdentifierName("initialized"), + LiteralExpression(SyntaxKind.TrueLiteralExpression))), + ]; + } + private static (MemberDeclarationSyntax, StatementSyntax, AttributeListSyntax, ImmutableArray) GenerateSource( IncrementalStubGenerationContext incrementalContext) { var diagnostics = new GeneratorDiagnosticsBag(new DescriptorProvider(), incrementalContext.DiagnosticLocation, SR.ResourceManager, typeof(FxResources.Microsoft.Interop.JavaScript.JSImportGenerator.SR)); // Generate stub code - var stubGenerator = new JSExportCodeGenerator( - incrementalContext.SignatureContext.SignatureContext.ElementTypeInformation, - incrementalContext.JSExportData, - incrementalContext.SignatureContext, + ImmutableArray signatureElements = incrementalContext.SignatureContext.SignatureContext.ElementTypeInformation; + + ImmutableArray allElements = signatureElements + .Add(new TypePositionInfo( + new ReferenceTypeInfo(Constants.ExceptionGlobal, Constants.ExceptionGlobal), + new JSMarshallingInfo(NoMarshallingInfo.Instance, new JSSimpleTypeInfo(KnownManagedType.Exception, ParseTypeName(Constants.ExceptionGlobal))) + { + JSType = System.Runtime.InteropServices.JavaScript.JSTypeFlags.Error, + }) + { + InstanceIdentifier = Constants.ArgumentException, + ManagedIndex = TypePositionInfo.ExceptionIndex, + NativeIndex = signatureElements.Length, // Insert at the end of the argument list + RefKind = RefKind.Out, // We'll treat it as a separate out parameter. + }); + + var stubGenerator = new UnmanagedToManagedStubGenerator( + allElements, diagnostics, - new JSGeneratorResolver()); + new CompositeMarshallingGeneratorResolver( + new NoSpanAndTaskMixingResolver(), + new JSGeneratorResolver())); var wrapperName = "__Wrapper_" + incrementalContext.StubMethodSyntaxTemplate.Identifier + "_" + incrementalContext.SignatureContext.TypesHash; - BlockSyntax wrapper = stubGenerator.GenerateJSExportBody(); - StatementSyntax registration = stubGenerator.GenerateJSExportRegistration(); + const string innerWrapperName = "__Stub"; + + BlockSyntax wrapperToInnerStubBlock = Block( + CreateWrapperToInnerStubCall(signatureElements, innerWrapperName), + GenerateInnerLocalFunction(incrementalContext, innerWrapperName, stubGenerator)); + + StatementSyntax registration = GenerateJSExportRegistration(incrementalContext.SignatureContext); AttributeListSyntax registrationAttribute = AttributeList(SingletonSeparatedList(Attribute(IdentifierName(Constants.DynamicDependencyAttributeGlobal)) .WithArgumentList(AttributeArgumentList(SeparatedList(new[]{ AttributeArgument(LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(wrapperName))), @@ -327,11 +365,78 @@ private static (MemberDeclarationSyntax, StatementSyntax, AttributeListSyntax, I } ))))); - return (PrintGeneratedSource(incrementalContext.ContainingSyntaxContext, wrapper, wrapperName), + return (PrintGeneratedSource(incrementalContext.ContainingSyntaxContext, wrapperToInnerStubBlock, wrapperName), registration, registrationAttribute, incrementalContext.Diagnostics.Array.AddRange(diagnostics.Diagnostics)); } + private static ExpressionStatementSyntax CreateWrapperToInnerStubCall(ImmutableArray signatureElements, string innerWrapperName) + { + List arguments = []; + bool hasReturn = true; + foreach (var nativeArg in signatureElements.Where(e => e.NativeIndex != TypePositionInfo.UnsetIndex).OrderBy(e => e.NativeIndex)) + { + if (nativeArg.IsNativeReturnPosition) + { + if (nativeArg.ManagedType == SpecialTypeInfo.Void) + { + hasReturn = false; + } + continue; + } + arguments.Add( + Argument( + ElementAccessExpression( + IdentifierName(Constants.ArgumentsBuffer), + BracketedArgumentList(SingletonSeparatedList(Argument( + LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(nativeArg.NativeIndex + 2)))))))); + } + + arguments.Add(Argument(IdentifierName(Constants.ArgumentsBuffer))); + + ExpressionSyntax invocation = InvocationExpression(IdentifierName(innerWrapperName)) + .WithArgumentList(ArgumentList(SeparatedList(arguments))); + + if (!hasReturn) + { + return ExpressionStatement(invocation); + } + + return ExpressionStatement( + AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, + ElementAccessExpression( + IdentifierName(Constants.ArgumentsBuffer), + BracketedArgumentList(SingletonSeparatedList(Argument( + LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(1)))))), + invocation)); + } + + private static LocalFunctionStatementSyntax GenerateInnerLocalFunction(IncrementalStubGenerationContext context, string innerFunctionName, UnmanagedToManagedStubGenerator stubGenerator) + { + var (parameters, returnType, _) = stubGenerator.GenerateAbiMethodSignatureData(); + return LocalFunctionStatement( + returnType, + innerFunctionName) + .WithBody(stubGenerator.GenerateStubBody(IdentifierName(context.SignatureContext.MethodName))) + .WithParameterList(parameters) + .WithAttributeLists(SingletonList(AttributeList(SingletonSeparatedList( + Attribute(IdentifierName(Constants.DebuggerNonUserCodeAttribute)))))); + } + + private static ExpressionStatementSyntax GenerateJSExportRegistration(JSSignatureContext context) + { + var signatureArgs = new List + { + Argument(LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(context.QualifiedMethodName))), + Argument(LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(context.TypesHash))), + SignatureBindingHelpers.CreateSignaturesArgument(context.SignatureContext.ElementTypeInformation, StubCodeContext.DefaultNativeToManagedStub) + }; + + return ExpressionStatement(InvocationExpression(MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(Constants.JSFunctionSignatureGlobal), IdentifierName(Constants.BindCSFunctionMethod))) + .WithArgumentList(ArgumentList(SeparatedList(signatureArgs)))); + } + private static Diagnostic? GetDiagnosticIfInvalidMethodForGeneration(MethodDeclarationSyntax methodSyntax, IMethodSymbol method) { // Verify the method has no generic types or defined implementation 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 369a08680b2254..411a827a4546a5 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSGeneratorFactory.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSGeneratorFactory.cs @@ -17,7 +17,7 @@ internal sealed class JSGeneratorResolver : IMarshallingGeneratorResolver public ResolvedGenerator Create(TypePositionInfo info, StubCodeContext context) { Debug.Assert(context != null); - if (info.IsByRef || info.ByValueContentsMarshalKind != ByValueContentsMarshalKind.Default) + if (!info.IsManagedExceptionPosition && (info.IsByRef || info.ByValueContentsMarshalKind != ByValueContentsMarshalKind.Default)) { // out of scope for Net7.0 return ResolvedGenerator.NotSupported(info, context, new(info) @@ -25,19 +25,30 @@ public ResolvedGenerator Create(TypePositionInfo info, StubCodeContext context) NotSupportedDetails = SR.InOutRefNotSupported }); } - JSMarshallingInfo jsMarshalingInfo = info.MarshallingAttributeInfo as JSMarshallingInfo; + return Create(info, info.MarshallingAttributeInfo as JSMarshallingInfo, context).Generator; + } + + public static (MarshalerType BaseType, IEnumerable? SubTypes) GetMarshallerTypeForBinding(TypePositionInfo info, StubCodeContext context) + { + var (_, baseType, subTypes) = Create(info, info.MarshallingAttributeInfo as JSMarshallingInfo, context); + return (baseType, subTypes); + } + + private record struct ResolvedGeneratorAndType(ResolvedGenerator Generator, MarshalerType Type, IEnumerable? SubTypes = null); + private static ResolvedGeneratorAndType Create(TypePositionInfo info, JSMarshallingInfo jsMarshalingInfo, StubCodeContext context) + { bool isToJs = MarshallerHelpers.GetMarshalDirection(info, context) == MarshalDirection.ManagedToUnmanaged; switch (jsMarshalingInfo) { // invalid case { TypeInfo: JSInvalidTypeInfo }: - return ResolvedGenerator.NotSupported(info, context, new(info)); + return new(ResolvedGenerator.NotSupported(info, context, new(info)), MarshalerType.None); // primitive case { TypeInfo: JSSimpleTypeInfo simple }: - return Create(info, context, isToJs, simple.KnownType, [], jsMarshalingInfo.JSType, Array.Empty()); + return Create(info, context, isToJs, simple.KnownType, [], jsMarshalingInfo.JSType, []); // nullable case { TypeInfo: JSNullableTypeInfo nullable }: @@ -66,149 +77,146 @@ public ResolvedGenerator Create(TypePositionInfo info, StubCodeContext context) return Create(info, context, isToJs, function.KnownType, function.ArgsTypeInfo.Select(a => a.KnownType).ToArray(), jsMarshalingInfo.JSType, jsMarshalingInfo.JSTypeArguments); default: - return ResolvedGenerator.NotSupported(info, context, new(info)); + return new(ResolvedGenerator.NotSupported(info, context, new(info)), MarshalerType.None); } } - private static ResolvedGenerator Create(TypePositionInfo info, StubCodeContext context, bool isToJs, KnownManagedType marshaledType, KnownManagedType[] argumentTypes, JSTypeFlags jsType, JSTypeFlags[] jsTypeArguments) + private static ResolvedGeneratorAndType Create(TypePositionInfo info, StubCodeContext context, bool isToJs, KnownManagedType marshaledType, KnownManagedType[] argumentTypes, JSTypeFlags jsType, JSTypeFlags[] jsTypeArguments) { return (marshaledType, jsType, argumentTypes, jsTypeArguments) switch { // void - (KnownManagedType.Void, JSTypeFlags.Void, _, _) => resolved(new VoidGenerator(info, context, MarshalerType.Void)), - (KnownManagedType.Void, JSTypeFlags.None or JSTypeFlags.Discard, _, _) => resolved(new VoidGenerator(info, context, MarshalerType.Discard)), - (KnownManagedType.Void, JSTypeFlags.DiscardNoWait, _, _) => resolved(new VoidGenerator(info, context, MarshalerType.DiscardNoWait)), + (KnownManagedType.Void, JSTypeFlags.Void, _, _) => resolved(new Forwarder().Bind(info, context), MarshalerType.Void), + (KnownManagedType.Void, JSTypeFlags.None or JSTypeFlags.Discard, _, _) => resolved(new Forwarder().Bind(info, context), MarshalerType.Discard), + (KnownManagedType.Void, JSTypeFlags.DiscardNoWait, _, _) => resolved(new Forwarder().Bind(info, context), MarshalerType.DiscardNoWait), // void missing - (KnownManagedType.Void, JSTypeFlags.Missing, _, _) => resolved(new VoidGenerator(info, context, MarshalerType.Void)), + (KnownManagedType.Void, JSTypeFlags.Missing, _, _) => resolved(new Forwarder().Bind(info, context), MarshalerType.Discard), // primitive - (KnownManagedType.Boolean, JSTypeFlags.Boolean, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Boolean)), - (KnownManagedType.Byte, JSTypeFlags.Number, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Byte)), - (KnownManagedType.Char, JSTypeFlags.String, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Char)), - (KnownManagedType.Int16, JSTypeFlags.Number, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Int16)), - (KnownManagedType.Int32, JSTypeFlags.Number, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Int32)), - (KnownManagedType.Int64, JSTypeFlags.Number, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Int52)), - (KnownManagedType.Int64, JSTypeFlags.BigInt, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.BigInt64)), - (KnownManagedType.Single, JSTypeFlags.Number, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Single)), - (KnownManagedType.Double, JSTypeFlags.Number, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Double)), - (KnownManagedType.IntPtr, JSTypeFlags.Number, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.IntPtr)), - (KnownManagedType.DateTime, JSTypeFlags.Date, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.DateTime)), - (KnownManagedType.DateTimeOffset, JSTypeFlags.Date, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.DateTime)), - (KnownManagedType.Exception, JSTypeFlags.Error, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Exception)), - (KnownManagedType.JSObject, JSTypeFlags.Object, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.JSObject)), - (KnownManagedType.String, JSTypeFlags.String, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.String)), - (KnownManagedType.Object, JSTypeFlags.Any, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Object)), + (KnownManagedType.Boolean, JSTypeFlags.Boolean, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Boolean), MarshalerType.Boolean), + (KnownManagedType.Byte, JSTypeFlags.Number, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Byte), MarshalerType.Byte), + (KnownManagedType.Char, JSTypeFlags.String, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Char), MarshalerType.Char), + (KnownManagedType.Int16, JSTypeFlags.Number, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Int16), MarshalerType.Int16), + (KnownManagedType.Int32, JSTypeFlags.Number, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Int32), MarshalerType.Int32), + (KnownManagedType.Int64, JSTypeFlags.Number, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Int52), MarshalerType.Int52), + (KnownManagedType.Int64, JSTypeFlags.BigInt, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.BigInt64), MarshalerType.BigInt64), + (KnownManagedType.Single, JSTypeFlags.Number, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Single), MarshalerType.Single), + (KnownManagedType.Double, JSTypeFlags.Number, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Double), MarshalerType.Double), + (KnownManagedType.IntPtr, JSTypeFlags.Number, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.IntPtr), MarshalerType.IntPtr), + (KnownManagedType.DateTime, JSTypeFlags.Date, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.DateTime), MarshalerType.DateTime), + (KnownManagedType.DateTimeOffset, JSTypeFlags.Date, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.DateTime), MarshalerType.DateTime), + (KnownManagedType.Exception, JSTypeFlags.Error, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Exception), MarshalerType.Exception), + (KnownManagedType.JSObject, JSTypeFlags.Object, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.JSObject), MarshalerType.JSObject), + (KnownManagedType.String, JSTypeFlags.String, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.String), MarshalerType.String), + (KnownManagedType.Object, JSTypeFlags.Any, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Object), MarshalerType.Object), // primitive missing - (KnownManagedType.Boolean, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Boolean)), - (KnownManagedType.Byte, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Byte)), - (KnownManagedType.Char, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Char)), - (KnownManagedType.Int16, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Int16)), - (KnownManagedType.Int32, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Int32)), - (KnownManagedType.Single, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Single)), - (KnownManagedType.Double, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Double)), - (KnownManagedType.IntPtr, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.IntPtr)), - (KnownManagedType.Exception, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Exception)), - (KnownManagedType.JSObject, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.JSObject)), - (KnownManagedType.String, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.String)), + (KnownManagedType.Boolean, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Boolean), MarshalerType.Boolean), + (KnownManagedType.Byte, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Byte), MarshalerType.Byte), + (KnownManagedType.Char, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Char), MarshalerType.Char), + (KnownManagedType.Int16, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Int16), MarshalerType.Int16), + (KnownManagedType.Int32, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Int32), MarshalerType.Int32), + (KnownManagedType.Single, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Single), MarshalerType.Single), + (KnownManagedType.Double, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Double), MarshalerType.Double), + (KnownManagedType.IntPtr, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.IntPtr), MarshalerType.IntPtr), + (KnownManagedType.Exception, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Exception), MarshalerType.Exception), + (KnownManagedType.JSObject, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.JSObject), MarshalerType.JSObject), + (KnownManagedType.String, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.String), MarshalerType.String), // primitive forced - (KnownManagedType.Int64, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Int52)), - (KnownManagedType.DateTime, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.DateTime)), - (KnownManagedType.DateTimeOffset, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.DateTime)), - (KnownManagedType.Object, JSTypeFlags.Missing, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Object)), + (KnownManagedType.Int64, JSTypeFlags.Missing, _, _) => failWithReason(SR.Format(SR.UseJSMarshalAsAttribute, info.ManagedType.FullTypeName)), + (KnownManagedType.DateTime, JSTypeFlags.Missing, _, _) => failWithReason(SR.Format(SR.UseJSMarshalAsAttribute, info.ManagedType.FullTypeName)), + (KnownManagedType.DateTimeOffset, JSTypeFlags.Missing, _, _) => failWithReason(SR.Format(SR.UseJSMarshalAsAttribute, info.ManagedType.FullTypeName)), + (KnownManagedType.Object, JSTypeFlags.Missing, _, _) => failWithReason(SR.Format(SR.UseJSMarshalAsAttribute, info.ManagedType.FullTypeName)), // nullable - (KnownManagedType.Nullable, JSTypeFlags.Boolean, [KnownManagedType.Boolean], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Boolean)), - (KnownManagedType.Nullable, JSTypeFlags.Number, [KnownManagedType.Byte], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Byte)), - (KnownManagedType.Nullable, JSTypeFlags.String, [KnownManagedType.Char], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Char)), - (KnownManagedType.Nullable, JSTypeFlags.Number, [KnownManagedType.Int16], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Int16)), - (KnownManagedType.Nullable, JSTypeFlags.Number, [KnownManagedType.Int32], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Int32)), - (KnownManagedType.Nullable, JSTypeFlags.Number, [KnownManagedType.Int64], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Int52)), - (KnownManagedType.Nullable, JSTypeFlags.BigInt, [KnownManagedType.Int64], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.BigInt64)), - (KnownManagedType.Nullable, JSTypeFlags.Number, [KnownManagedType.Single], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Single)), - (KnownManagedType.Nullable, JSTypeFlags.Number, [KnownManagedType.Double], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Double)), - (KnownManagedType.Nullable, JSTypeFlags.Number, [KnownManagedType.IntPtr], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.IntPtr)), - (KnownManagedType.Nullable, JSTypeFlags.Date, [KnownManagedType.DateTime], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.DateTime)), - (KnownManagedType.Nullable, JSTypeFlags.Date, [KnownManagedType.DateTimeOffset], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.DateTime)), + (KnownManagedType.Nullable, JSTypeFlags.Boolean, [KnownManagedType.Boolean], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Boolean), MarshalerType.Nullable, [MarshalerType.Boolean]), + (KnownManagedType.Nullable, JSTypeFlags.Number, [KnownManagedType.Byte], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Byte), MarshalerType.Nullable, [MarshalerType.Byte]), + (KnownManagedType.Nullable, JSTypeFlags.String, [KnownManagedType.Char], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Char), MarshalerType.Nullable, [MarshalerType.Char]), + (KnownManagedType.Nullable, JSTypeFlags.Number, [KnownManagedType.Int16], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Int16), MarshalerType.Nullable, [MarshalerType.Int16]), + (KnownManagedType.Nullable, JSTypeFlags.Number, [KnownManagedType.Int32], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Int32), MarshalerType.Nullable, [MarshalerType.Int32]), + (KnownManagedType.Nullable, JSTypeFlags.Number, [KnownManagedType.Int64], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Int52), MarshalerType.Nullable, [MarshalerType.Int52]), + (KnownManagedType.Nullable, JSTypeFlags.BigInt, [KnownManagedType.Int64], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.BigInt64), MarshalerType.Nullable, [MarshalerType.BigInt64]), + (KnownManagedType.Nullable, JSTypeFlags.Number, [KnownManagedType.Single], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Single), MarshalerType.Nullable, [MarshalerType.Single]), + (KnownManagedType.Nullable, JSTypeFlags.Number, [KnownManagedType.Double], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Double), MarshalerType.Nullable, [MarshalerType.Double]), + (KnownManagedType.Nullable, JSTypeFlags.Number, [KnownManagedType.IntPtr], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.IntPtr), MarshalerType.Nullable, [MarshalerType.IntPtr]), + (KnownManagedType.Nullable, JSTypeFlags.Date, [KnownManagedType.DateTime], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.DateTime), MarshalerType.Nullable, [MarshalerType.DateTime]), + (KnownManagedType.Nullable, JSTypeFlags.Date, [KnownManagedType.DateTimeOffset], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.DateTime), MarshalerType.Nullable, [MarshalerType.DateTime]), // nullable missing - (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.Boolean], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Boolean)), - (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.Byte], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Byte)), - (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.Char], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Char)), - (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.Int16], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Int16)), - (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.Int32], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Int32)), - (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.Single], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Single)), - (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.Double], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Double)), - (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.IntPtr], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.IntPtr)), - (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.Exception], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Exception)), - (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.JSObject], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.JSObject)), - (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.String], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.String)), + (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.Boolean], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Boolean), MarshalerType.Nullable, [MarshalerType.Boolean]), + (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.Byte], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Byte), MarshalerType.Nullable, [MarshalerType.Byte]), + (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.Char], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Char), MarshalerType.Nullable, [MarshalerType.Char]), + (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.Int16], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Int16), MarshalerType.Nullable, [MarshalerType.Int16]), + (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.Int32], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Int32), MarshalerType.Nullable, [MarshalerType.Int32]), + (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.Single], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Single), MarshalerType.Nullable, [MarshalerType.Single]), + (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.Double], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Double), MarshalerType.Nullable, [MarshalerType.Double]), + (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.IntPtr], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.IntPtr), MarshalerType.Nullable, [MarshalerType.IntPtr]), // nullable forced - (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.Int64], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.Int52)), - (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.DateTime], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.DateTime)), - (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.DateTimeOffset], _) => resolved(new NullableJSGenerator(info, context, MarshalerType.DateTime)), + (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.Int64], _) => failWithReason(SR.Format(SR.UseJSMarshalAsAttribute, info.ManagedType.FullTypeName)), + (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.DateTime], _) => failWithReason(SR.Format(SR.UseJSMarshalAsAttribute, info.ManagedType.FullTypeName)), + (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.DateTimeOffset], _) => failWithReason(SR.Format(SR.UseJSMarshalAsAttribute, info.ManagedType.FullTypeName)), (KnownManagedType.Nullable, _, _, _) => failWithReason(SR.Format(SR.TypeNotSupportedName, info.ManagedType.FullTypeName)), // task - (KnownManagedType.Task, JSTypeFlags.Promise, [], [JSTypeFlags.Void]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Void)), - (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Boolean], [JSTypeFlags.Boolean]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Boolean)), - (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Byte], [JSTypeFlags.Number]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Byte)), - (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Char], [JSTypeFlags.String]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Char)), - (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Int16], [JSTypeFlags.Number]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Int16)), - (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Int32], [JSTypeFlags.Number]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Int32)), - (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Int64], [JSTypeFlags.Number]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Int52)), - (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Int64], [JSTypeFlags.BigInt]) => resolved(new TaskJSGenerator(info, context, MarshalerType.BigInt64)), - (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Single], [JSTypeFlags.Number]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Single)), - (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Double], [JSTypeFlags.Number]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Double)), - (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.IntPtr], [JSTypeFlags.Number]) => resolved(new TaskJSGenerator(info, context, MarshalerType.IntPtr)), - (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.DateTime], [JSTypeFlags.Date]) => resolved(new TaskJSGenerator(info, context, MarshalerType.DateTime)), - (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.DateTimeOffset], [JSTypeFlags.Date]) => resolved(new TaskJSGenerator(info, context, MarshalerType.DateTime)), - (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Exception], [JSTypeFlags.Error]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Exception)), - (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.JSObject], [JSTypeFlags.Object]) => resolved(new TaskJSGenerator(info, context, MarshalerType.JSObject)), - (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.String], [JSTypeFlags.String]) => resolved(new TaskJSGenerator(info, context, MarshalerType.String)), - (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Object], [JSTypeFlags.Any]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Object)), + (KnownManagedType.Task, JSTypeFlags.Promise, [], [JSTypeFlags.Void]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Void), MarshalerType.Task), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Boolean], [JSTypeFlags.Boolean]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Boolean), MarshalerType.Task, [MarshalerType.Boolean]), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Byte], [JSTypeFlags.Number]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Byte), MarshalerType.Task, [MarshalerType.Byte]), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Char], [JSTypeFlags.String]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Char), MarshalerType.Task, [MarshalerType.Char]), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Int16], [JSTypeFlags.Number]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Int16), MarshalerType.Task, [MarshalerType.Int16]), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Int32], [JSTypeFlags.Number]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Int32), MarshalerType.Task, [MarshalerType.Int32]), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Int64], [JSTypeFlags.Number]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Int52), MarshalerType.Task, [MarshalerType.Int52]), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Int64], [JSTypeFlags.BigInt]) => resolved(new TaskJSGenerator(info, context, MarshalerType.BigInt64), MarshalerType.Task, [MarshalerType.BigInt64]), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Single], [JSTypeFlags.Number]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Single), MarshalerType.Task, [MarshalerType.Single]), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Double], [JSTypeFlags.Number]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Double), MarshalerType.Task, [MarshalerType.Double]), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.IntPtr], [JSTypeFlags.Number]) => resolved(new TaskJSGenerator(info, context, MarshalerType.IntPtr), MarshalerType.Task, [MarshalerType.IntPtr]), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.DateTime], [JSTypeFlags.Date]) => resolved(new TaskJSGenerator(info, context, MarshalerType.DateTime), MarshalerType.Task, [MarshalerType.DateTime]), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.DateTimeOffset], [JSTypeFlags.Date]) => resolved(new TaskJSGenerator(info, context, MarshalerType.DateTime), MarshalerType.Task, [MarshalerType.DateTime]), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Exception], [JSTypeFlags.Error]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Exception), MarshalerType.Task, [MarshalerType.Exception]), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.JSObject], [JSTypeFlags.Object]) => resolved(new TaskJSGenerator(info, context, MarshalerType.JSObject), MarshalerType.Task, [MarshalerType.JSObject]), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.String], [JSTypeFlags.String]) => resolved(new TaskJSGenerator(info, context, MarshalerType.String), MarshalerType.Task, [MarshalerType.String]), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Object], [JSTypeFlags.Any]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Object), MarshalerType.Task, [MarshalerType.Object]), // task missing - (KnownManagedType.Task, JSTypeFlags.Missing, [], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Void)), - (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Boolean], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Boolean)), - (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Byte], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Byte)), - (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Char], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Char)), - (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Int16], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Int16)), - (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Int32], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Int32)), - (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Single], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Single)), - (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Double], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Double)), - (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.IntPtr], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.IntPtr)), - (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Exception], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Exception)), - (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.JSObject], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.JSObject)), - (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.String], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.String)), + (KnownManagedType.Task, JSTypeFlags.Missing, [], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Void), MarshalerType.Task), + (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Boolean], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Boolean), MarshalerType.Task, [MarshalerType.Boolean]), + (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Byte], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Byte), MarshalerType.Task, [MarshalerType.Byte]), + (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Char], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Char), MarshalerType.Task, [MarshalerType.Char]), + (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Int16], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Int16), MarshalerType.Task, [MarshalerType.Int16]), + (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Int32], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Int32), MarshalerType.Task, [MarshalerType.Int32]), + (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Single], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Single), MarshalerType.Task, [MarshalerType.Single]), + (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Double], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Double), MarshalerType.Task, [MarshalerType.Double]), + (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.IntPtr], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.IntPtr), MarshalerType.Task, [MarshalerType.IntPtr]), + (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Exception], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Exception), MarshalerType.Task, [MarshalerType.Exception]), + (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.JSObject], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.JSObject), MarshalerType.Task, [MarshalerType.JSObject]), + (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.String], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.String), MarshalerType.Task, [MarshalerType.String]), // task forced - (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Int64], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Int52)), - (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.DateTime], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.DateTime)), - (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.DateTimeOffset], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.DateTime)), - (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Object], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Object)), + (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Int64], _) => failWithReason(SR.Format(SR.UseJSMarshalAsAttribute, info.ManagedType.FullTypeName)), + (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.DateTime], _) => failWithReason(SR.Format(SR.UseJSMarshalAsAttribute, info.ManagedType.FullTypeName)), + (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.DateTimeOffset], _) => failWithReason(SR.Format(SR.UseJSMarshalAsAttribute, info.ManagedType.FullTypeName)), + (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Object], _) => failWithReason(SR.Format(SR.UseJSMarshalAsAttribute, info.ManagedType.FullTypeName)), (KnownManagedType.Task, JSTypeFlags.Promise, _, [_]) => failWithReason(SR.Format(SR.TypeNotSupportedName, info.ManagedType.FullTypeName)), // array - (KnownManagedType.Array, JSTypeFlags.Array, [KnownManagedType.Byte], [JSTypeFlags.Number]) => resolved(new ArrayJSGenerator(info, context, MarshalerType.Byte)), - (KnownManagedType.Array, JSTypeFlags.Array, [KnownManagedType.String], [JSTypeFlags.String]) => resolved(new ArrayJSGenerator(info, context, MarshalerType.String)), - (KnownManagedType.Array, JSTypeFlags.Array, [KnownManagedType.Double], [JSTypeFlags.Number]) => resolved(new ArrayJSGenerator(info, context, MarshalerType.Double)), - (KnownManagedType.Array, JSTypeFlags.Array, [KnownManagedType.Int32], [JSTypeFlags.Number]) => resolved(new ArrayJSGenerator(info, context, MarshalerType.Int32)), - (KnownManagedType.Array, JSTypeFlags.Array, [KnownManagedType.JSObject], [JSTypeFlags.Object]) => resolved(new ArrayJSGenerator(info, context, MarshalerType.JSObject)), - (KnownManagedType.Array, JSTypeFlags.Array, [KnownManagedType.Object], [JSTypeFlags.Any]) => resolved(new ArrayJSGenerator(info, context, MarshalerType.Object)), + (KnownManagedType.Array, JSTypeFlags.Array, [KnownManagedType.Byte], [JSTypeFlags.Number]) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Array), MarshalerType.Array, [MarshalerType.Byte]), + (KnownManagedType.Array, JSTypeFlags.Array, [KnownManagedType.String], [JSTypeFlags.String]) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Array), MarshalerType.Array, [MarshalerType.String]), + (KnownManagedType.Array, JSTypeFlags.Array, [KnownManagedType.Double], [JSTypeFlags.Number]) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Array), MarshalerType.Array, [MarshalerType.Double]), + (KnownManagedType.Array, JSTypeFlags.Array, [KnownManagedType.Int32], [JSTypeFlags.Number]) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Array), MarshalerType.Array, [MarshalerType.Int32]), + (KnownManagedType.Array, JSTypeFlags.Array, [KnownManagedType.JSObject], [JSTypeFlags.Object]) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Array), MarshalerType.Array, [MarshalerType.JSObject]), + (KnownManagedType.Array, JSTypeFlags.Array, [KnownManagedType.Object], [JSTypeFlags.Any]) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Array), MarshalerType.Array, [MarshalerType.Object]), // array missing - (KnownManagedType.Array, JSTypeFlags.Missing, [KnownManagedType.Byte], _) => resolved(new ArrayJSGenerator(info, context, MarshalerType.Byte)), - (KnownManagedType.Array, JSTypeFlags.Missing, [KnownManagedType.String], _) => resolved(new ArrayJSGenerator(info, context, MarshalerType.String)), - (KnownManagedType.Array, JSTypeFlags.Missing, [KnownManagedType.Double], _) => resolved(new ArrayJSGenerator(info, context, MarshalerType.Double)), - (KnownManagedType.Array, JSTypeFlags.Missing, [KnownManagedType.Int32], _) => resolved(new ArrayJSGenerator(info, context, MarshalerType.Int32)), - (KnownManagedType.Array, JSTypeFlags.Missing, [KnownManagedType.JSObject], _) => resolved(new ArrayJSGenerator(info, context, MarshalerType.JSObject)), + (KnownManagedType.Array, JSTypeFlags.Missing, [KnownManagedType.Byte], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Array), MarshalerType.Array, [MarshalerType.Byte]), + (KnownManagedType.Array, JSTypeFlags.Missing, [KnownManagedType.String], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Array), MarshalerType.Array, [MarshalerType.String]), + (KnownManagedType.Array, JSTypeFlags.Missing, [KnownManagedType.Double], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Array), MarshalerType.Array, [MarshalerType.Double]), + (KnownManagedType.Array, JSTypeFlags.Missing, [KnownManagedType.Int32], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Array), MarshalerType.Array, [MarshalerType.Int32]), + (KnownManagedType.Array, JSTypeFlags.Missing, [KnownManagedType.JSObject], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Array), MarshalerType.Array, [MarshalerType.JSObject]), (KnownManagedType.Array, JSTypeFlags.Array, _, [_]) => failWithReason(SR.Format(SR.TypeNotSupportedName, info.ManagedType.FullTypeName)), @@ -217,9 +225,9 @@ private static ResolvedGenerator Create(TypePositionInfo info, StubCodeContext c // span view (KnownManagedType.Span, JSTypeFlags.MemoryView, _, [_]) => failWithReason(null!), - (KnownManagedType.Span, JSTypeFlags.MemoryView, [KnownManagedType.Byte], _) => resolved(new SpanJSGenerator(info, context, MarshalerType.Byte)), - (KnownManagedType.Span, JSTypeFlags.MemoryView, [KnownManagedType.Int32], _) => resolved(new SpanJSGenerator(info, context, MarshalerType.Int32)), - (KnownManagedType.Span, JSTypeFlags.MemoryView, [KnownManagedType.Double], _) => resolved(new SpanJSGenerator(info, context, MarshalerType.Double)), + (KnownManagedType.Span, JSTypeFlags.MemoryView, [KnownManagedType.Byte], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Span), MarshalerType.Span, [MarshalerType.Byte]), + (KnownManagedType.Span, JSTypeFlags.MemoryView, [KnownManagedType.Int32], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Span), MarshalerType.Span, [MarshalerType.Int32]), + (KnownManagedType.Span, JSTypeFlags.MemoryView, [KnownManagedType.Double], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Span), MarshalerType.Span, [MarshalerType.Double]), (KnownManagedType.Span, JSTypeFlags.MemoryView, _, _) => failWithReason(SR.Format(SR.TypeNotSupportedName, info.ManagedType.FullTypeName)), @@ -230,9 +238,9 @@ private static ResolvedGenerator Create(TypePositionInfo info, StubCodeContext c // segment view (KnownManagedType.ArraySegment, JSTypeFlags.MemoryView, _, [_]) => failWithReason(null!), - (KnownManagedType.ArraySegment, JSTypeFlags.MemoryView, [KnownManagedType.Byte], _) => resolved(new ArraySegmentJSGenerator(info, context, MarshalerType.Byte)), - (KnownManagedType.ArraySegment, JSTypeFlags.MemoryView, [KnownManagedType.Int32], _) => resolved(new ArraySegmentJSGenerator(info, context, MarshalerType.Int32)), - (KnownManagedType.ArraySegment, JSTypeFlags.MemoryView, [KnownManagedType.Double], _) => resolved(new ArraySegmentJSGenerator(info, context, MarshalerType.Double)), + (KnownManagedType.ArraySegment, JSTypeFlags.MemoryView, [KnownManagedType.Byte], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.ArraySegment), MarshalerType.ArraySegment, [MarshalerType.Byte]), + (KnownManagedType.ArraySegment, JSTypeFlags.MemoryView, [KnownManagedType.Int32], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.ArraySegment), MarshalerType.ArraySegment, [MarshalerType.Int32]), + (KnownManagedType.ArraySegment, JSTypeFlags.MemoryView, [KnownManagedType.Double], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.ArraySegment), MarshalerType.ArraySegment, [MarshalerType.Double]), (KnownManagedType.ArraySegment, JSTypeFlags.MemoryView, _, _) => failWithReason(SR.Format(SR.TypeNotSupportedName, info.ManagedType.FullTypeName)), @@ -280,7 +288,7 @@ or KnownManagedType.Unknown return null; } - ResolvedGenerator ResolveCallback(KnownManagedType managedType, KnownManagedType[] argTypes, JSTypeFlags[] argJSTypes) + ResolvedGeneratorAndType ResolveCallback(KnownManagedType managedType, KnownManagedType[] argTypes, JSTypeFlags[] argJSTypes) { var argsMarshalers = new List(); for (int i = 0; i < argTypes.Length; i++) @@ -288,7 +296,7 @@ ResolvedGenerator ResolveCallback(KnownManagedType managedType, KnownManagedType var isReturn = managedType == KnownManagedType.Function && i == argJSTypes.Length - 1; var gen = Create(info, context, isToJs ^ (!isReturn), argTypes[i], Array.Empty(), argJSTypes[i], Array.Empty()); - argsMarshalers.Add(((BaseJSGenerator)gen.Generator).Type); + argsMarshalers.Add(gen.Type); } var maxArgs = managedType == KnownManagedType.Action ? 3 : 4; MarshalerType[] argsMarshallerTypes = [.. argsMarshalers]; @@ -296,20 +304,25 @@ ResolvedGenerator ResolveCallback(KnownManagedType managedType, KnownManagedType { return failWithReason(SR.FuncTooManyArgs); } - return resolved(new FuncJSGenerator(info, context, managedType == KnownManagedType.Action, argsMarshallerTypes)); + return resolved( + new FuncJSGenerator(info, context, managedType == KnownManagedType.Action, argsMarshallerTypes), + managedType == KnownManagedType.Action ? MarshalerType.Action : MarshalerType.Function, + argsMarshallerTypes); } - ResolvedGenerator failWithReason(string failReason) + ResolvedGeneratorAndType failWithReason(string failReason) { - return ResolvedGenerator.NotSupported(info, context, new(info) - { - NotSupportedDetails = failReason - }); + return new( + ResolvedGenerator.NotSupported(info, context, new(info) + { + NotSupportedDetails = failReason + }), + MarshalerType.None); } - ResolvedGenerator resolved(IBoundMarshallingGenerator generator) + ResolvedGeneratorAndType resolved(IBoundMarshallingGenerator generator, MarshalerType baseType, IEnumerable? subTypes = null) { - return ResolvedGenerator.Resolved(generator); + return new(ResolvedGenerator.Resolved(generator), baseType, subTypes); } } } diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportCodeGenerator.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportCodeGenerator.cs deleted file mode 100644 index 7891bec53f2186..00000000000000 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportCodeGenerator.cs +++ /dev/null @@ -1,212 +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; -using System.Linq; -using System.Collections.Generic; -using System.Collections.Immutable; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; -using Microsoft.CodeAnalysis; - -namespace Microsoft.Interop.JavaScript -{ - internal abstract class JSCodeGenerator - { - public const string ReturnIdentifier = "__retVal"; - public const string ReturnNativeIdentifier = $"{ReturnIdentifier}{StubIdentifierContext.GeneratedNativeIdentifierSuffix}"; - public const string InvokeSucceededIdentifier = "__invokeSucceeded"; - } - - internal sealed class JSImportCodeGenerator : JSCodeGenerator - { - private readonly BoundGenerators _marshallers; - - private readonly StubIdentifierContext _context; - private readonly JSImportData _jsImportData; - private readonly JSSignatureContext _signatureContext; - - public JSImportCodeGenerator( - ImmutableArray argTypes, - JSImportData attributeData, - JSSignatureContext signatureContext, - GeneratorDiagnosticsBag diagnosticsBag, - IMarshallingGeneratorResolver generatorResolver) - { - _jsImportData = attributeData; - _signatureContext = signatureContext; - - _marshallers = BoundGenerators.Create(argTypes, generatorResolver, StubCodeContext.DefaultManagedToNativeStub, new EmptyJSGenerator(), out var bindingFailures); - - diagnosticsBag.ReportGeneratorDiagnostics(bindingFailures); - - if (_marshallers.ManagedReturnMarshaller.UsesNativeIdentifier) - { - // If we need a different native return identifier, then recreate the context with the correct identifier before we generate any code. - _context = new DefaultIdentifierContext(ReturnIdentifier, ReturnNativeIdentifier, MarshalDirection.ManagedToUnmanaged) - { - CodeEmitOptions = new(SkipInit: true) - }; - } - else - { - _context = new DefaultIdentifierContext(ReturnIdentifier, ReturnIdentifier, MarshalDirection.ManagedToUnmanaged) - { - CodeEmitOptions = new(SkipInit: true) - }; - } - - // validate task + span mix - if (_marshallers.ManagedReturnMarshaller.TypeInfo.MarshallingAttributeInfo is JSMarshallingInfo(_, JSTaskTypeInfo)) - { - IBoundMarshallingGenerator spanArg = _marshallers.SignatureMarshallers.FirstOrDefault(m => m.TypeInfo.MarshallingAttributeInfo is JSMarshallingInfo(_, JSSpanTypeInfo)); - if (spanArg != default) - { - diagnosticsBag.ReportGeneratorDiagnostic(new GeneratorDiagnostic.NotSupported(spanArg.TypeInfo) - { - NotSupportedDetails = SR.SpanAndTaskNotSupported - }); - } - } - } - - public BlockSyntax GenerateJSImportBody() - { - StatementSyntax invoke = InvokeSyntax(); - GeneratedStatements statements = GeneratedStatements.Create(_marshallers, _context); - bool shouldInitializeVariables = !statements.GuaranteedUnmarshal.IsEmpty || !statements.CleanupCallerAllocated.IsEmpty || !statements.CleanupCalleeAllocated.IsEmpty; - VariableDeclarations declarations = VariableDeclarations.GenerateDeclarationsForManagedToUnmanaged(_marshallers, _context, shouldInitializeVariables); - - var setupStatements = new List(); - BindSyntax(setupStatements); - SetupSyntax(setupStatements); - - if (!(statements.GuaranteedUnmarshal.IsEmpty && statements.CleanupCalleeAllocated.IsEmpty)) - { - setupStatements.Add(SyntaxFactoryExtensions.Declare(PredefinedType(Token(SyntaxKind.BoolKeyword)), InvokeSucceededIdentifier, initializeToDefault: true)); - } - - setupStatements.AddRange(declarations.Initializations); - setupStatements.AddRange(declarations.Variables); - setupStatements.AddRange(statements.Setup); - - var tryStatements = new List(); - tryStatements.AddRange(statements.Marshal); - tryStatements.AddRange(statements.PinnedMarshal); - - tryStatements.Add(invoke); - if (!(statements.GuaranteedUnmarshal.IsEmpty && statements.CleanupCalleeAllocated.IsEmpty)) - { - tryStatements.Add(ExpressionStatement(AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, - IdentifierName(InvokeSucceededIdentifier), - LiteralExpression(SyntaxKind.TrueLiteralExpression)))); - } - - tryStatements.AddRange(statements.NotifyForSuccessfulInvoke); - tryStatements.AddRange(statements.Unmarshal); - - List allStatements = setupStatements; - List finallyStatements = new List(); - if (!(statements.GuaranteedUnmarshal.IsEmpty && statements.CleanupCalleeAllocated.IsEmpty)) - { - finallyStatements.Add(IfStatement(IdentifierName(InvokeSucceededIdentifier), Block(statements.GuaranteedUnmarshal.Concat(statements.CleanupCalleeAllocated)))); - } - - finallyStatements.AddRange(statements.CleanupCallerAllocated); - if (finallyStatements.Count > 0) - { - // Add try-finally block if there are any statements in the finally block - allStatements.Add( - TryStatement(Block(tryStatements), default, FinallyClause(Block(finallyStatements)))); - } - else - { - allStatements.AddRange(tryStatements); - } - - // Return - if (!_marshallers.IsManagedVoidReturn) - allStatements.Add(ReturnStatement(IdentifierName(_context.GetIdentifiers(_marshallers.ManagedReturnMarshaller.TypeInfo).managed))); - - return Block(allStatements); - } - - private void BindSyntax(List statementsToUpdate) - { - var bindingParameters = - (new ArgumentSyntax[] { - Argument(LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(_jsImportData.FunctionName))), - Argument( - _jsImportData.ModuleName == null - ? LiteralExpression(SyntaxKind.NullLiteralExpression) - : LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(_jsImportData.ModuleName))), - CreateSignaturesSyntax(), - }); - - statementsToUpdate.Add(IfStatement(BinaryExpression(SyntaxKind.EqualsExpression, IdentifierName(_signatureContext.BindingName), LiteralExpression(SyntaxKind.NullLiteralExpression)), - Block(SingletonList( - ExpressionStatement(AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, - IdentifierName(_signatureContext.BindingName), - InvocationExpression(MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(Constants.JSFunctionSignatureGlobal), IdentifierName(Constants.BindJSFunctionMethod))) - .WithArgumentList(ArgumentList(SeparatedList(bindingParameters))))))))); - } - - private ArgumentSyntax CreateSignaturesSyntax() - { - IEnumerable types = _marshallers.ManagedReturnMarshaller is IJSMarshallingGenerator jsGen ? jsGen.GenerateBind() : []; - types = types - .Concat(_marshallers.NativeParameterMarshallers.OfType().SelectMany(p => p.GenerateBind())); - - return Argument(ArrayCreationExpression(ArrayType(IdentifierName(Constants.JSMarshalerTypeGlobal)) - .WithRankSpecifiers(SingletonList(ArrayRankSpecifier(SingletonSeparatedList(OmittedArraySizeExpression()))))) - .WithInitializer(InitializerExpression(SyntaxKind.ArrayInitializerExpression, SeparatedList(types)))); - } - - private void SetupSyntax(List statementsToUpdate) - { - statementsToUpdate.Add(LocalDeclarationStatement( - VariableDeclaration(GenericName(Identifier(Constants.SpanGlobal)).WithTypeArgumentList( - TypeArgumentList(SingletonSeparatedList(IdentifierName(Constants.JSMarshalerArgumentGlobal))))) - .WithVariables(SingletonSeparatedList(VariableDeclarator(Identifier(Constants.ArgumentsBuffer)) - .WithInitializer(EqualsValueClause(StackAllocArrayCreationExpression(ArrayType(IdentifierName(Constants.JSMarshalerArgumentGlobal)) - .WithRankSpecifiers(SingletonList(ArrayRankSpecifier(SingletonSeparatedList( - LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(2 + _marshallers.NativeParameterMarshallers.Length))))))))))))); - - statementsToUpdate.Add(LocalDeclarationStatement(VariableDeclaration(RefType(IdentifierName(Constants.JSMarshalerArgumentGlobal))) - .WithVariables(SingletonSeparatedList(VariableDeclarator(Identifier(Constants.ArgumentException)) - .WithInitializer(EqualsValueClause(RefExpression(ElementAccessExpression(IdentifierName(Constants.ArgumentsBuffer)) - .WithArgumentList(BracketedArgumentList(SingletonSeparatedList( - Argument(LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(0))))))))))))); - - statementsToUpdate.Add(ExpressionStatement( - InvocationExpression(MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(Constants.ArgumentException), IdentifierName("Initialize"))))); - - statementsToUpdate.Add(LocalDeclarationStatement(VariableDeclaration(RefType(IdentifierName(Constants.JSMarshalerArgumentGlobal))) - .WithVariables(SingletonSeparatedList(VariableDeclarator(Identifier(Constants.ArgumentReturn)) - .WithInitializer(EqualsValueClause(RefExpression(ElementAccessExpression(IdentifierName(Constants.ArgumentsBuffer)) - .WithArgumentList(BracketedArgumentList(SingletonSeparatedList( - Argument(LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(1))))))))))))); - - statementsToUpdate.Add(ExpressionStatement( - InvocationExpression(MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(Constants.ArgumentReturn), IdentifierName("Initialize"))))); - } - - private ExpressionStatementSyntax InvokeSyntax() - { - return ExpressionStatement(InvocationExpression( - MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, IdentifierName(Constants.JSFunctionSignatureGlobal), IdentifierName("InvokeJS"))) - .WithArgumentList(ArgumentList(SeparatedList(new[]{ - Argument(IdentifierName(_signatureContext.BindingName)), - Argument(IdentifierName(Constants.ArgumentsBuffer))})))); - } - - public (ParameterListSyntax ParameterList, TypeSyntax ReturnType, AttributeListSyntax? ReturnTypeAttributes) GenerateTargetMethodSignatureData() - { - return _marshallers.GenerateTargetMethodSignatureData(_context); - } - } -} diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs index c97f6998de9e69..78e821ecd2e505 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs @@ -2,14 +2,17 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Collections.Generic; using System.Collections.Immutable; using System.Diagnostics; using System.Linq; +using System.Runtime.InteropServices.JavaScript; using System.Threading; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; +using static Microsoft.Interop.SyntaxFactoryExtensions; [assembly: System.Resources.NeutralResourcesLanguage("en-US")] @@ -199,16 +202,93 @@ private static (MemberDeclarationSyntax, ImmutableArray) Generat var diagnostics = new GeneratorDiagnosticsBag(new DescriptorProvider(), incrementalContext.DiagnosticLocation, SR.ResourceManager, typeof(FxResources.Microsoft.Interop.JavaScript.JSImportGenerator.SR)); // Generate stub code - var stubGenerator = new JSImportCodeGenerator( + var stubGenerator = new ManagedToNativeStubGenerator( incrementalContext.SignatureContext.SignatureContext.ElementTypeInformation, + setLastError: false, + diagnostics, + new CompositeMarshallingGeneratorResolver( + new NoSpanAndTaskMixingResolver(), + new JSGeneratorResolver()), + new CodeEmitOptions(SkipInit: true)); + + const string LocalFunctionName = "__InvokeJSFunction"; + + BlockSyntax code = stubGenerator.GenerateStubBody(LocalFunctionName); + + StatementSyntax bindStatement = GenerateBindSyntax( incrementalContext.JSImportData, incrementalContext.SignatureContext, - diagnostics, - new JSGeneratorResolver()); + SignatureBindingHelpers.CreateSignaturesArgument(incrementalContext.SignatureContext.SignatureContext.ElementTypeInformation, StubCodeContext.DefaultManagedToNativeStub)); + + LocalFunctionStatementSyntax localFunction = GenerateInvokeFunction(LocalFunctionName, incrementalContext.SignatureContext, stubGenerator); - BlockSyntax code = stubGenerator.GenerateJSImportBody(); + return (PrintGeneratedSource(incrementalContext.StubMethodSyntaxTemplate, incrementalContext.SignatureContext, incrementalContext.ContainingSyntaxContext, Block(bindStatement, code, localFunction)), incrementalContext.Diagnostics.Array.AddRange(diagnostics.Diagnostics)); + } + + private static IfStatementSyntax GenerateBindSyntax(JSImportData jsImportData, JSSignatureContext signatureContext, ArgumentSyntax signaturesArgument) + { + var bindingParameters = + (new ArgumentSyntax[] { + Argument(LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(jsImportData.FunctionName))), + Argument( + jsImportData.ModuleName == null + ? LiteralExpression(SyntaxKind.NullLiteralExpression) + : LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(jsImportData.ModuleName))), + signaturesArgument, + }); + + return IfStatement(BinaryExpression(SyntaxKind.EqualsExpression, IdentifierName(signatureContext.BindingName), LiteralExpression(SyntaxKind.NullLiteralExpression)), + Block(SingletonList( + ExpressionStatement(AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, + IdentifierName(signatureContext.BindingName), + InvocationExpression(MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(Constants.JSFunctionSignatureGlobal), IdentifierName(Constants.BindJSFunctionMethod))) + .WithArgumentList(ArgumentList(SeparatedList(bindingParameters)))))))); + } - return (PrintGeneratedSource(incrementalContext.StubMethodSyntaxTemplate, incrementalContext.SignatureContext, incrementalContext.ContainingSyntaxContext, code), incrementalContext.Diagnostics.Array.AddRange(diagnostics.Diagnostics)); + private static LocalFunctionStatementSyntax GenerateInvokeFunction(string functionName, JSSignatureContext signatureContext, ManagedToNativeStubGenerator stubGenerator) + { + var (parameters, returnType, _) = stubGenerator.GenerateTargetMethodSignatureData(); + TypeSyntax jsMarshalerArgument = ParseTypeName(Constants.JSMarshalerArgumentGlobal); + + return LocalFunctionStatement( + jsMarshalerArgument, + functionName) + .WithBody( + Block( + List( + [ + Declare(jsMarshalerArgument, Constants.ArgumentException, true), + MethodInvocationStatement( + IdentifierName(Constants.ArgumentException), + IdentifierName("Initialize")), + Declare(jsMarshalerArgument, Constants.ArgumentReturn, true), + MethodInvocationStatement( + IdentifierName(Constants.ArgumentReturn), + IdentifierName("Initialize")), + Declare(SpanOf(jsMarshalerArgument), Constants.ArgumentsBuffer, + CollectionExpression( + SeparatedList( + (IEnumerable)[ + ExpressionElement(IdentifierName(Constants.ArgumentException)), + ExpressionElement(IdentifierName(Constants.ArgumentReturn)), + ..parameters.Parameters + .Select(p => ExpressionElement(IdentifierName(p.Identifier))) + ]))), + MethodInvocationStatement( + IdentifierName(Constants.JSFunctionSignatureGlobal), + IdentifierName("InvokeJS"), + Argument(IdentifierName(signatureContext.BindingName)), + Argument(IdentifierName(Constants.ArgumentsBuffer))), + ReturnStatement( + ElementAccessExpression( + IdentifierName(Constants.ArgumentsBuffer), + BracketedArgumentList(SingletonSeparatedList(Argument( + LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(1))))))) + ]))) + .WithParameterList(parameters) + .WithAttributeLists(SingletonList(AttributeList(SingletonSeparatedList( + Attribute(IdentifierName(Constants.DebuggerNonUserCodeAttribute)))))); } private static Diagnostic? GetDiagnosticIfInvalidMethodForGeneration(MethodDeclarationSyntax methodSyntax, IMethodSymbol method) 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 deleted file mode 100644 index 5d7d55c644bd7f..00000000000000 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/ArrayJSGenerator.cs +++ /dev/null @@ -1,28 +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; -using System.Collections.Generic; -using System.Runtime.InteropServices.JavaScript; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; - -namespace Microsoft.Interop.JavaScript -{ - internal sealed class ArrayJSGenerator : PrimitiveJSGenerator - { - private readonly MarshalerType _elementMarshalerType; - - public ArrayJSGenerator(TypePositionInfo info, StubCodeContext context, MarshalerType elementMarshalerType) - : base(info, context, MarshalerType.Array) - { - _elementMarshalerType = elementMarshalerType; - } - - public override IEnumerable GenerateBind() - { - yield return InvocationExpression(MarshalerTypeName(Type), - ArgumentList(SingletonSeparatedList(Argument(MarshalerTypeName(_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 deleted file mode 100644 index f3785d8bf7e121..00000000000000 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/ArraySegmentJSGenerator.cs +++ /dev/null @@ -1,27 +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.Collections.Generic; -using System.Runtime.InteropServices.JavaScript; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; - -namespace Microsoft.Interop.JavaScript -{ - internal sealed class ArraySegmentJSGenerator : PrimitiveJSGenerator - { - private readonly MarshalerType _elementMarshalerType; - - public ArraySegmentJSGenerator(TypePositionInfo info, StubCodeContext context, MarshalerType elementMarshalerType) - : base(info, context, MarshalerType.ArraySegment) - { - _elementMarshalerType = elementMarshalerType; - } - - public override IEnumerable GenerateBind() - { - yield return InvocationExpression(MarshalerTypeName(Type), - ArgumentList(SingletonSeparatedList(Argument(MarshalerTypeName(_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 1f6eef2346545d..2ec0067b894def 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 @@ -10,63 +10,29 @@ namespace Microsoft.Interop.JavaScript { - internal abstract class BaseJSGenerator : IJSMarshallingGenerator + internal abstract class BaseJSGenerator(TypePositionInfo info, StubCodeContext codeContext) : IBoundMarshallingGenerator { - protected IBoundMarshallingGenerator _inner; - public MarshalerType Type; + private static ValueTypeInfo JSMarshalerArgument = new ValueTypeInfo(Constants.JSMarshalerArgumentGlobal, Constants.JSMarshalerArgument, IsByRefLike: false); - protected BaseJSGenerator(MarshalerType marshalerType, IBoundMarshallingGenerator inner) - { - _inner = inner; - Type = marshalerType; - } + public TypePositionInfo TypeInfo => info; - public TypePositionInfo TypeInfo => _inner.TypeInfo; + public StubCodeContext CodeContext => codeContext; - public StubCodeContext CodeContext => _inner.CodeContext; + public ManagedTypeInfo NativeType => JSMarshalerArgument; - public ManagedTypeInfo NativeType => _inner.NativeType; + public SignatureBehavior NativeSignatureBehavior => TypeInfo.IsByRef ? SignatureBehavior.PointerToNativeType : SignatureBehavior.NativeType; - public SignatureBehavior NativeSignatureBehavior => _inner.NativeSignatureBehavior; + public ValueBoundaryBehavior ValueBoundaryBehavior => TypeInfo.IsByRef ? ValueBoundaryBehavior.AddressOfNativeIdentifier : ValueBoundaryBehavior.NativeIdentifier; - public ValueBoundaryBehavior ValueBoundaryBehavior => _inner.ValueBoundaryBehavior; - - public virtual bool UsesNativeIdentifier => _inner.UsesNativeIdentifier; + public virtual bool UsesNativeIdentifier => true; public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, out GeneratorDiagnostic? diagnostic) - => _inner.SupportsByValueMarshalKind(marshalKind, out diagnostic); - - public virtual IEnumerable GenerateBind() { - yield return MarshalerTypeName(Type); + diagnostic = null; + return ByValueMarshalKindSupport.NotSupported; } - public virtual IEnumerable Generate(StubIdentifierContext context) - { - string argName = context.GetAdditionalIdentifier(TypeInfo, "js_arg"); - - if (context.CurrentStage == StubIdentifierContext.Stage.Setup) - { - 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(TypeInfo.ManagedIndex + 2)))))))))))); - } - } - - foreach (var x in _inner.Generate(context)) - { - yield return x; - } - } - - protected static IdentifierNameSyntax MarshalerTypeName(MarshalerType marshalerType) - { - return IdentifierName(Constants.JSMarshalerTypeGlobalDot + marshalerType.ToString()); - } + public abstract IEnumerable Generate(StubIdentifierContext context); protected static IdentifierNameSyntax GetToManagedMethod(MarshalerType marshalerType) { 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 deleted file mode 100644 index e9704fbdc04d2b..00000000000000 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/EmptyJSGenerator.cs +++ /dev/null @@ -1,20 +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; -using System.Collections.Generic; -using Microsoft.CodeAnalysis.CSharp.Syntax; - -namespace Microsoft.Interop.JavaScript -{ - internal sealed class EmptyJSGenerator : IUnboundMarshallingGenerator - { - public ManagedTypeInfo AsNativeType(TypePositionInfo info) => info.ManagedType; - public IEnumerable Generate(TypePositionInfo info, StubCodeContext codeContext, StubIdentifierContext identifierContext) => 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, out GeneratorDiagnostic? diagnostic) - => ByValueMarshalKindSupportDescriptor.Default.GetSupport(marshalKind, info, out diagnostic); - public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => false; - } -} 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 d4d7f785c55367..f4c0da89466c25 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 @@ -11,34 +11,11 @@ namespace Microsoft.Interop.JavaScript { - internal sealed class FuncJSGenerator : BaseJSGenerator + internal sealed class FuncJSGenerator(TypePositionInfo info, StubCodeContext context, bool isAction, MarshalerType[] argumentMarshalerTypes) : BaseJSGenerator(info, context) { - private readonly bool _isAction; - private readonly MarshalerType[] _argumentMarshalerTypes; - - public FuncJSGenerator(TypePositionInfo info, StubCodeContext context, bool isAction, MarshalerType[] argumentMarshalerTypes) - : base(isAction ? MarshalerType.Action : MarshalerType.Function, new Forwarder().Bind(info, context)) - { - _isAction = isAction; - _argumentMarshalerTypes = argumentMarshalerTypes; - } - - public override IEnumerable GenerateBind() - { - var args = _argumentMarshalerTypes.Select(x => Argument(MarshalerTypeName(x))).ToList(); - yield return InvocationExpression(MarshalerTypeName(Type), ArgumentList(SeparatedList(args))); - } - public override IEnumerable Generate(StubIdentifierContext context) { - string argName = context.GetAdditionalIdentifier(TypeInfo, "js_arg"); - var target = TypeInfo.IsManagedReturnPosition - ? Constants.ArgumentReturn - : argName; - - var source = TypeInfo.IsManagedReturnPosition - ? Argument(IdentifierName(context.GetIdentifiers(TypeInfo).native)) - : _inner.AsArgument(context); + var (managed, js) = context.GetIdentifiers(TypeInfo); var jsty = (JSFunctionTypeInfo)((JSMarshallingInfo)TypeInfo.MarshallingAttributeInfo).TypeInfo; var sourceTypes = jsty.ArgsTypeInfo @@ -47,27 +24,22 @@ public override IEnumerable Generate(StubIdentifierContext cont if (context.CurrentStage == StubIdentifierContext.Stage.UnmarshalCapture && CodeContext.Direction == MarshalDirection.ManagedToUnmanaged && TypeInfo.IsManagedReturnPosition) { - yield return ToManagedMethod(target, source, jsty); + yield return ToManagedMethod(js, Argument(IdentifierName(managed)), jsty); } if (context.CurrentStage == StubIdentifierContext.Stage.Marshal && CodeContext.Direction == MarshalDirection.UnmanagedToManaged && TypeInfo.IsManagedReturnPosition) { - yield return ToJSMethod(target, source, jsty); - } - - foreach (var x in base.Generate(context)) - { - yield return x; + yield return ToJSMethod(js, Argument(IdentifierName(managed)), jsty); } if (context.CurrentStage == StubIdentifierContext.Stage.PinnedMarshal && CodeContext.Direction == MarshalDirection.ManagedToUnmanaged && !TypeInfo.IsManagedReturnPosition) { - yield return ToJSMethod(target, source, jsty); + yield return ToJSMethod(js, Argument(IdentifierName(managed)), jsty); } if (context.CurrentStage == StubIdentifierContext.Stage.Unmarshal && CodeContext.Direction == MarshalDirection.UnmanagedToManaged && !TypeInfo.IsManagedReturnPosition) { - yield return ToManagedMethod(target, source, jsty); + yield return ToManagedMethod(js, Argument(IdentifierName(managed)), jsty); } } @@ -77,18 +49,18 @@ private ExpressionStatementSyntax ToManagedMethod(string target, ArgumentSyntax for (int i = 0; i < info.ArgsTypeInfo.Length; i++) { var sourceType = info.ArgsTypeInfo[i]; - if (!_isAction && i + 1 == info.ArgsTypeInfo.Length) + if (!isAction && i + 1 == info.ArgsTypeInfo.Length) { - arguments.Add(ArgToManaged(i, sourceType.Syntax, _argumentMarshalerTypes[i])); + arguments.Add(ArgToManaged(i, sourceType.Syntax, argumentMarshalerTypes[i])); } else { - arguments.Add(ArgToJS(i, sourceType.Syntax, _argumentMarshalerTypes[i])); + arguments.Add(ArgToJS(i, sourceType.Syntax, argumentMarshalerTypes[i])); } } return ExpressionStatement(InvocationExpression(MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(target), GetToManagedMethod(Type))) + IdentifierName(target), GetToManagedMethod(isAction ? MarshalerType.Action : MarshalerType.Function))) .WithArgumentList(ArgumentList(SeparatedList(arguments)))); } @@ -98,18 +70,18 @@ private ExpressionStatementSyntax ToJSMethod(string target, ArgumentSyntax sourc for (int i = 0; i < info.ArgsTypeInfo.Length; i++) { var sourceType = info.ArgsTypeInfo[i]; - if (!_isAction && i + 1 == info.ArgsTypeInfo.Length) + if (!isAction && i + 1 == info.ArgsTypeInfo.Length) { - arguments.Add(ArgToJS(i, sourceType.Syntax, _argumentMarshalerTypes[i])); + arguments.Add(ArgToJS(i, sourceType.Syntax, argumentMarshalerTypes[i])); } else { - arguments.Add(ArgToManaged(i, sourceType.Syntax, _argumentMarshalerTypes[i])); + arguments.Add(ArgToManaged(i, sourceType.Syntax, argumentMarshalerTypes[i])); } } return ExpressionStatement(InvocationExpression(MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(target), GetToJSMethod(Type))) + IdentifierName(target), GetToJSMethod(isAction ? MarshalerType.Action : MarshalerType.Function))) .WithArgumentList(ArgumentList(SeparatedList(arguments)))); } 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 deleted file mode 100644 index f60406b21e8695..00000000000000 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/IJSMarshallingGenerator.cs +++ /dev/null @@ -1,13 +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.Collections.Generic; -using Microsoft.CodeAnalysis.CSharp.Syntax; - -namespace Microsoft.Interop.JavaScript -{ - internal interface IJSMarshallingGenerator : IBoundMarshallingGenerator - { - IEnumerable GenerateBind(); - } -} 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 deleted file mode 100644 index 191c475f1330fa..00000000000000 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/NullableJSGenerator.cs +++ /dev/null @@ -1,24 +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.Collections.Generic; -using System.Runtime.InteropServices.JavaScript; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; - -namespace Microsoft.Interop.JavaScript -{ - internal sealed class NullableJSGenerator : PrimitiveJSGenerator - { - public NullableJSGenerator(TypePositionInfo info, StubCodeContext context, MarshalerType resultMarshalerType) - : base(info, context, resultMarshalerType) - { - } - - public override IEnumerable GenerateBind() - { - yield return InvocationExpression(MarshalerTypeName(MarshalerType.Nullable), - ArgumentList(SingletonSeparatedList(Argument(MarshalerTypeName(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 5da5c9db179751..9a7f548397f4b4 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 @@ -9,78 +9,38 @@ namespace Microsoft.Interop.JavaScript { - internal class PrimitiveJSGenerator : BaseJSGenerator + internal sealed class PrimitiveJSGenerator(TypePositionInfo info, StubCodeContext context, MarshalerType elementMarshallerType) : BaseJSGenerator(info, context) { - public PrimitiveJSGenerator(MarshalerType marshalerType, IBoundMarshallingGenerator inner) - : base(marshalerType, inner) - { - } - - public PrimitiveJSGenerator(TypePositionInfo info, StubCodeContext context, MarshalerType marshalerType) - : base(marshalerType, new Forwarder().Bind(info, context)) - { - } - // TODO order parameters in such way that affinity capturing parameters are emitted first public override IEnumerable Generate(StubIdentifierContext context) { - string argName = context.GetAdditionalIdentifier(TypeInfo, "js_arg"); - var target = TypeInfo.IsManagedReturnPosition - ? Constants.ArgumentReturn - : argName; + var (managed, js) = context.GetIdentifiers(TypeInfo); - var source = TypeInfo.IsManagedReturnPosition - ? Argument(IdentifierName(context.GetIdentifiers(TypeInfo).native)) - : _inner.AsArgument(context); + MarshalDirection marshalDirection = MarshallerHelpers.GetMarshalDirection(TypeInfo, CodeContext); - if (context.CurrentStage == StubIdentifierContext.Stage.UnmarshalCapture && CodeContext.Direction == MarshalDirection.ManagedToUnmanaged && TypeInfo.IsManagedReturnPosition) + if (context.CurrentStage == StubIdentifierContext.Stage.UnmarshalCapture && marshalDirection is MarshalDirection.UnmanagedToManaged or MarshalDirection.Bidirectional) { - yield return ToManagedMethod(target, source); + yield return ToManagedMethod(js, Argument(IdentifierName(managed))); } - if (context.CurrentStage == StubIdentifierContext.Stage.Marshal && CodeContext.Direction == MarshalDirection.UnmanagedToManaged && TypeInfo.IsManagedReturnPosition) + if (context.CurrentStage == StubIdentifierContext.Stage.Marshal && marshalDirection is MarshalDirection.ManagedToUnmanaged or MarshalDirection.Bidirectional) { - yield return ToJSMethod(target, source); + yield return ToJSMethod(js, Argument(IdentifierName(managed))); } - - foreach (var x in base.Generate(context)) - { - yield return x; - } - - if (context.CurrentStage == StubIdentifierContext.Stage.PinnedMarshal && CodeContext.Direction == MarshalDirection.ManagedToUnmanaged && !TypeInfo.IsManagedReturnPosition) - { - yield return ToJSMethod(target, source); - } - - if (context.CurrentStage == StubIdentifierContext.Stage.Unmarshal && CodeContext.Direction == MarshalDirection.UnmanagedToManaged && !TypeInfo.IsManagedReturnPosition) - { - yield return ToManagedMethod(target, source); - } - } - - protected virtual ArgumentSyntax ToManagedMethodRefOrOut(ArgumentSyntax argument) - { - return argument.WithRefOrOutKeyword(Token(SyntaxKind.OutKeyword)); - } - - protected virtual ArgumentSyntax ToJSMethodRefOrOut(ArgumentSyntax argument) - { - return argument; } private ExpressionStatementSyntax ToManagedMethod(string target, ArgumentSyntax source) { return ExpressionStatement(InvocationExpression(MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(target), GetToManagedMethod(Type))) - .WithArgumentList(ArgumentList(SingletonSeparatedList(ToManagedMethodRefOrOut(source))))); + IdentifierName(target), GetToManagedMethod(elementMarshallerType))) + .WithArgumentList(ArgumentList(SingletonSeparatedList(source.WithRefOrOutKeyword(Token(SyntaxKind.OutKeyword)))))); } private ExpressionStatementSyntax ToJSMethod(string target, ArgumentSyntax source) { return ExpressionStatement(InvocationExpression(MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(target), GetToJSMethod(Type))) - .WithArgumentList(ArgumentList(SingletonSeparatedList(ToJSMethodRefOrOut(source))))); + IdentifierName(target), GetToJSMethod(elementMarshallerType))) + .WithArgumentList(ArgumentList(SingletonSeparatedList(source)))); } } } 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 deleted file mode 100644 index afaedf597b6fe5..00000000000000 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/SpanJSGenerator.cs +++ /dev/null @@ -1,27 +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.Collections.Generic; -using System.Runtime.InteropServices.JavaScript; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; - -namespace Microsoft.Interop.JavaScript -{ - internal sealed class SpanJSGenerator : PrimitiveJSGenerator - { - private readonly MarshalerType _elementMarshalerType; - - public SpanJSGenerator(TypePositionInfo info, StubCodeContext context, MarshalerType elementMarshalerType) - : base(info, context, MarshalerType.Span) - { - _elementMarshalerType = elementMarshalerType; - } - - public override IEnumerable GenerateBind() - { - yield return InvocationExpression(MarshalerTypeName(Type), - ArgumentList(SingletonSeparatedList(Argument(MarshalerTypeName(_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 381f4dac813740..af22d4707fef37 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 @@ -9,95 +9,61 @@ namespace Microsoft.Interop.JavaScript { - internal sealed class TaskJSGenerator : BaseJSGenerator + internal sealed class TaskJSGenerator(TypePositionInfo info, StubCodeContext context, MarshalerType resultMarshalerType) : BaseJSGenerator(info, context) { - private readonly MarshalerType _resultMarshalerType; - - public TaskJSGenerator(TypePositionInfo info, StubCodeContext context, MarshalerType resultMarshalerType) - : base(MarshalerType.Task, new Forwarder().Bind(info, context)) - { - _resultMarshalerType = resultMarshalerType; - } - - public override IEnumerable GenerateBind() - { - var jsty = (JSTaskTypeInfo)((JSMarshallingInfo)TypeInfo.MarshallingAttributeInfo).TypeInfo; - if (jsty.ResultTypeInfo is JSSimpleTypeInfo(KnownManagedType.Void)) - { - yield return InvocationExpression(MarshalerTypeName(MarshalerType.Task), ArgumentList()); - } - else - { - yield return InvocationExpression(MarshalerTypeName(MarshalerType.Task), - ArgumentList(SingletonSeparatedList(Argument(MarshalerTypeName(_resultMarshalerType))))); - } - } - public override IEnumerable Generate(StubIdentifierContext context) { var jsty = (JSTaskTypeInfo)((JSMarshallingInfo)TypeInfo.MarshallingAttributeInfo).TypeInfo; - string argName = context.GetAdditionalIdentifier(TypeInfo, "js_arg"); - var target = TypeInfo.IsManagedReturnPosition - ? Constants.ArgumentReturn - : argName; - - var source = TypeInfo.IsManagedReturnPosition - ? Argument(IdentifierName(context.GetIdentifiers(TypeInfo).native)) - : _inner.AsArgument(context); + var (managed, js) = context.GetIdentifiers(TypeInfo); if (context.CurrentStage == StubIdentifierContext.Stage.UnmarshalCapture && CodeContext.Direction == MarshalDirection.ManagedToUnmanaged && TypeInfo.IsManagedReturnPosition) { yield return jsty.ResultTypeInfo is JSSimpleTypeInfo(KnownManagedType.Void) - ? ToManagedMethodVoid(target, source) - : ToManagedMethod(target, source, jsty.ResultTypeInfo.Syntax); + ? ToManagedMethodVoid(js, Argument(IdentifierName(managed))) + : ToManagedMethod(js, Argument(IdentifierName(managed)), jsty.ResultTypeInfo.Syntax); } if (context.CurrentStage == StubIdentifierContext.Stage.Marshal && CodeContext.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(context)) - { - yield return x; + ? ToJSMethodVoid(js, Argument(IdentifierName(managed))) + : ToJSMethod(js, Argument(IdentifierName(managed)), jsty.ResultTypeInfo.Syntax); } if (context.CurrentStage == StubIdentifierContext.Stage.PinnedMarshal && CodeContext.Direction == MarshalDirection.ManagedToUnmanaged && !TypeInfo.IsManagedReturnPosition) { yield return jsty.ResultTypeInfo is JSSimpleTypeInfo(KnownManagedType.Void) - ? ToJSMethodVoid(target, source) - : ToJSMethod(target, source, jsty.ResultTypeInfo.Syntax); + ? ToJSMethodVoid(js, Argument(IdentifierName(managed))) + : ToJSMethod(js, Argument(IdentifierName(managed)), jsty.ResultTypeInfo.Syntax); } if (context.CurrentStage == StubIdentifierContext.Stage.Unmarshal && CodeContext.Direction == MarshalDirection.UnmanagedToManaged && !TypeInfo.IsManagedReturnPosition) { yield return jsty.ResultTypeInfo is JSSimpleTypeInfo(KnownManagedType.Void) - ? ToManagedMethodVoid(target, source) - : ToManagedMethod(target, source, jsty.ResultTypeInfo.Syntax); + ? ToManagedMethodVoid(js, Argument(IdentifierName(managed))) + : ToManagedMethod(js, Argument(IdentifierName(managed)), jsty.ResultTypeInfo.Syntax); } } - private ExpressionStatementSyntax ToManagedMethodVoid(string target, ArgumentSyntax source) + private static ExpressionStatementSyntax ToManagedMethodVoid(string target, ArgumentSyntax source) { return ExpressionStatement(InvocationExpression(MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(target), GetToManagedMethod(Type))) + IdentifierName(target), GetToManagedMethod(MarshalerType.Task))) .WithArgumentList(ArgumentList(SingletonSeparatedList(source.WithRefOrOutKeyword(Token(SyntaxKind.OutKeyword)))))); } - private ExpressionStatementSyntax ToJSMethodVoid(string target, ArgumentSyntax source) + private static ExpressionStatementSyntax ToJSMethodVoid(string target, ArgumentSyntax source) { return ExpressionStatement(InvocationExpression(MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(target), GetToJSMethod(Type))) + IdentifierName(target), GetToJSMethod(MarshalerType.Task))) .WithArgumentList(ArgumentList(SingletonSeparatedList(source)))); } private ExpressionStatementSyntax ToManagedMethod(string target, ArgumentSyntax source, TypeSyntax sourceType) { return ExpressionStatement(InvocationExpression(MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(target), GetToManagedMethod(Type))) + IdentifierName(target), GetToManagedMethod(MarshalerType.Task))) .WithArgumentList(ArgumentList(SeparatedList(new[]{ source.WithRefOrOutKeyword(Token(SyntaxKind.OutKeyword)), Argument(ParenthesizedLambdaExpression() @@ -111,7 +77,7 @@ private ExpressionStatementSyntax ToManagedMethod(string target, ArgumentSyntax .WithType(sourceType)}))) .WithBlock(Block(SingletonList(ExpressionStatement( InvocationExpression(MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - IdentifierName("__task_result_arg"), GetToManagedMethod(_resultMarshalerType))) + IdentifierName("__task_result_arg"), GetToManagedMethod(resultMarshalerType))) .WithArgumentList(ArgumentList(SeparatedList(new[]{ Argument(IdentifierName("__task_result")).WithRefOrOutKeyword(Token(SyntaxKind.OutKeyword)), }))))))))})))); @@ -120,7 +86,7 @@ private ExpressionStatementSyntax ToManagedMethod(string target, ArgumentSyntax private ExpressionStatementSyntax ToJSMethod(string target, ArgumentSyntax source, TypeSyntax sourceType) { return ExpressionStatement(InvocationExpression(MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(target), GetToJSMethod(Type))) + IdentifierName(target), GetToJSMethod(MarshalerType.Task))) .WithArgumentList(ArgumentList(SeparatedList(new[]{ source, Argument(ParenthesizedLambdaExpression() @@ -133,7 +99,7 @@ private ExpressionStatementSyntax ToJSMethod(string target, ArgumentSyntax sourc .WithType(sourceType)}))) .WithBlock(Block(SingletonList(ExpressionStatement( InvocationExpression(MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - IdentifierName("__task_result_arg"), GetToJSMethod(_resultMarshalerType))) + IdentifierName("__task_result_arg"), GetToJSMethod(resultMarshalerType))) .WithArgumentList(ArgumentList(SeparatedList(new[]{ Argument(IdentifierName("__task_result")), }))))))))})))); 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 deleted file mode 100644 index 2177f5436e431e..00000000000000 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/VoidGenerator.cs +++ /dev/null @@ -1,9 +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.Runtime.InteropServices.JavaScript; - -namespace Microsoft.Interop.JavaScript -{ - internal sealed class VoidGenerator(TypePositionInfo info, StubCodeContext context, MarshalerType marshalerType) : BaseJSGenerator(marshalerType, new Forwarder().Bind(info, context)); -} diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/NoSpanAndTaskMixingResolver.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/NoSpanAndTaskMixingResolver.cs new file mode 100644 index 00000000000000..1d46d530a958ea --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/NoSpanAndTaskMixingResolver.cs @@ -0,0 +1,42 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; +using System.Text; + +namespace Microsoft.Interop.JavaScript +{ + internal sealed class NoSpanAndTaskMixingResolver : IMarshallingGeneratorResolver + { + private bool _hasSpan; + private bool _hasTask; + + public ResolvedGenerator Create(TypePositionInfo info, StubCodeContext context) + { + bool foundInteresting = false; + if (info.MarshallingAttributeInfo is JSMarshallingInfo(_, JSSpanTypeInfo)) + { + _hasSpan = true; + foundInteresting = true; + } + + if (info.MarshallingAttributeInfo is JSMarshallingInfo(_, JSTaskTypeInfo) && info.IsManagedReturnPosition) + { + _hasTask = true; + foundInteresting = true; + } + + if (foundInteresting && _hasSpan && _hasTask) + { + return ResolvedGenerator.NotSupported(info, context, + new GeneratorDiagnostic.NotSupported(info) + { + NotSupportedDetails = SR.SpanAndTaskNotSupported + }); + } + + return ResolvedGenerator.UnresolvedGenerator; + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/SignatureBindingHelpers.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/SignatureBindingHelpers.cs new file mode 100644 index 00000000000000..d8a3a8231904fc --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/SignatureBindingHelpers.cs @@ -0,0 +1,40 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Linq; +using System.Runtime.InteropServices.JavaScript; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; + +namespace Microsoft.Interop.JavaScript +{ + internal static class SignatureBindingHelpers + { + public static ArgumentSyntax CreateSignaturesArgument(ImmutableArray elements, StubCodeContext context) + { + List arguments = []; + + foreach (TypePositionInfo element in elements.Where(e => e.NativeIndex != TypePositionInfo.UnsetIndex).OrderBy(e => e.NativeIndex)) + { + var (baseType, subTypes) = JSGeneratorResolver.GetMarshallerTypeForBinding(element, context); + ExpressionSyntax bindSyntax = MarshalerTypeName(baseType); + if (subTypes is not null) + { + bindSyntax = InvocationExpression(bindSyntax, + ArgumentList(SeparatedList(subTypes.Select(s => Argument(MarshalerTypeName(s)))))); + } + arguments.Add(ExpressionElement(bindSyntax)); + } + + return Argument(CollectionExpression(SeparatedList(arguments))); + } + + private static IdentifierNameSyntax MarshalerTypeName(MarshalerType marshalerType) + { + return IdentifierName(Constants.JSMarshalerTypeGlobalDot + marshalerType.ToString()); + } + + } +} diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSFunctionBinding.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSFunctionBinding.cs index f6be095eecab92..7f1447673f85e6 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSFunctionBinding.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSFunctionBinding.cs @@ -261,19 +261,22 @@ internal static unsafe void DispatchJSFunctionSync(JSObject jsFunction, Span arguments) { - var args = (nint)Unsafe.AsPointer(ref arguments[0]); - var sig = (nint)signature.Header; + fixed (JSMarshalerArgument* argsPtr = arguments) + { + var args = (nint)argsPtr; + var sig = (nint)signature.Header; - ref JSMarshalerArgument exc = ref arguments[0]; + ref JSMarshalerArgument exc = ref arguments[0]; - // we already know that we are not on the right thread - // this will be blocking until resolved by that thread - Interop.Runtime.InvokeJSImportSyncSend(targetContext.JSNativeTID, sig, args); + // we already know that we are not on the right thread + // this will be blocking until resolved by that thread + Interop.Runtime.InvokeJSImportSyncSend(targetContext.JSNativeTID, sig, args); - if (exc.slot.Type != MarshalerType.None) - { - JSHostImplementation.ThrowException(ref exc); + if (exc.slot.Type != MarshalerType.None) + { + JSHostImplementation.ThrowException(ref exc); + } } } @@ -412,8 +418,7 @@ internal static unsafe void DispatchJSImportAsyncPost(JSFunctionBinding signatur var bytes = sizeof(JSMarshalerArgument) * arguments.Length; void* cpy = (void*)Marshal.AllocHGlobal(bytes); - void* src = Unsafe.AsPointer(ref arguments[0]); - Unsafe.CopyBlock(cpy, src, (uint)bytes); + arguments.CopyTo(new Span(cpy, arguments.Length)); var sig = (nint)signature.Header; // we already know that we are not on the right thread @@ -476,8 +481,7 @@ internal static unsafe void ResolveOrRejectPromise(JSProxyContext targetContext, // this copy is freed in mono_wasm_resolve_or_reject_promise var bytes = sizeof(JSMarshalerArgument) * arguments.Length; void* cpy = (void*)Marshal.AllocHGlobal(bytes); - void* src = Unsafe.AsPointer(ref arguments[0]); - Unsafe.CopyBlock(cpy, src, (uint)bytes); + arguments.CopyTo(new Span(cpy, arguments.Length)); // async Interop.Runtime.ResolveOrRejectPromisePost(targetContext.JSNativeTID, (nint)cpy); 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 ff7af2116d4fb8..8a04f1a875051b 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 @@ -71,70 +71,81 @@ internal static partial void Annotated(object a1, long a2, long a3, global::Syst { 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) }); + __signature_Annotated_564258462 = global::System.Runtime.InteropServices.JavaScript.JSFunctionBinding.BindJSFunction("DoesNotExist", null, [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.DateTime, 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.DateTime), 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) => + global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a1_native; + global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a2_native; + global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a3_native; + global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a4_native; + global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a5_native; + global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a6_native; + global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a7_native; + global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a8_native; + global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a9_native; + global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a10_native; + global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a11_native; + global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a12_native; + global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a13_native; + global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a14_native; + global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a15_native; + // Marshal - Convert managed data to native data. + __a11_native.ToJS(a11); + __a10_native.ToJS(a10); + __a9_native.ToJS(a9); + __a7_native.ToJS(a7); + __a6_native.ToJS(a6); + __a3_native.ToJSBig(a3); + __a2_native.ToJS(a2); + __a1_native.ToJS(a1); + { + // PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned. + __a15_native.ToJS(a15, static (ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __task_result_arg, long __task_result) => + { + __task_result_arg.ToJSBig(__task_result); + }); + __a14_native.ToJS(a14, static (ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __task_result_arg, long __task_result) => + { + __task_result_arg.ToJS(__task_result); + }); + __a13_native.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.ToJS(a12, static (ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __task_result_arg, global::System.DateTime __task_result) => + { + __task_result_arg.ToJS(__task_result); + }); + __a8_native.ToJS(a8, static (ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __task_result_arg, object __task_result) => + { + __task_result_arg.ToJS(__task_result); + }); + __a5_native.ToJS(a5, static (ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __delegate_arg_arg1, int __delegate_arg1) => + { + __delegate_arg_arg1.ToJS(__delegate_arg1); + }); + __a4_native.ToJS(a4); + __InvokeJSFunction(__a1_native, __a2_native, __a3_native, __a4_native, __a5_native, __a6_native, __a7_native, __a8_native, __a9_native, __a10_native, __a11_native, __a12_native, __a13_native, __a14_native, __a15_native); + } + } + + [global::System.Diagnostics.DebuggerNonUserCode] + global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __InvokeJSFunction(global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a1_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a2_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a3_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a4_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a5_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a6_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a7_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a8_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a9_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a10_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a11_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a12_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a13_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a14_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a15_native) { - __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); + global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __arg_exception = default; + __arg_exception.Initialize(); + global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __arg_return = default; + __arg_return.Initialize(); + global::System.Span __arguments_buffer = [__arg_exception, __arg_return, __a1_native, __a2_native, __a3_native, __a4_native, __a5_native, __a6_native, __a7_native, __a8_native, __a9_native, __a10_native, __a11_native, __a12_native, __a13_native, __a14_native, __a15_native]; + global::System.Runtime.InteropServices.JavaScript.JSFunctionBinding.InvokeJS(__signature_Annotated_564258462, __arguments_buffer); + return __arguments_buffer[1]; + } } static global::System.Runtime.InteropServices.JavaScript.JSFunctionBinding __signature_Annotated_564258462; } - + """.ReplaceLineEndings("\r\n"), Encoding.UTF8)), (typeof(Microsoft.Interop.JavaScript.JSExportGenerator), "JSExports.g.cs", @@ -158,7 +169,7 @@ 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) }); + global::System.Runtime.InteropServices.JavaScript.JSFunctionBinding.BindManagedFunction("[TestProject]Basic:AnnotatedExport", 564258462, [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.DateTime, 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.DateTime), 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)]); } } } @@ -167,80 +178,69 @@ 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 + __Stub(__arguments_buffer[2], __arguments_buffer[3], __arguments_buffer[4], __arguments_buffer[5], __arguments_buffer[6], __arguments_buffer[7], __arguments_buffer[8], __arguments_buffer[9], __arguments_buffer[10], __arguments_buffer[11], __arguments_buffer[12], __arguments_buffer[13], __arguments_buffer[14], __arguments_buffer[15], __arguments_buffer[16], __arguments_buffer); + [global::System.Diagnostics.DebuggerNonUserCode] + void __Stub(global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a1_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a2_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a3_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a4_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a5_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a6_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a7_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a8_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a9_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a10_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a11_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a12_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a13_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a14_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a15_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument* ____arg_exception_native__param) { - // 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) => + object a1 = default; + long a2 = default; + long a3 = default; + global::System.Action a4 = default; + global::System.Func a5 = default; + global::System.Span a6 = default; + global::System.ArraySegment a7 = default; + global::System.Threading.Tasks.Task a8 = default; + object[] a9 = default; + global::System.DateTime a10 = default; + global::System.DateTimeOffset a11 = default; + global::System.Threading.Tasks.Task a12 = default; + global::System.Threading.Tasks.Task a13 = default; + global::System.Threading.Tasks.Task a14 = default; + global::System.Threading.Tasks.Task a15 = default; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument ____arg_exception_native = ref *____arg_exception_native__param; + try { - __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) => + // UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception. + __a11_native.ToManaged(out a11); + __a10_native.ToManaged(out a10); + __a9_native.ToManaged(out a9); + __a7_native.ToManaged(out a7); + __a6_native.ToManaged(out a6); + __a3_native.ToManagedBig(out a3); + __a2_native.ToManaged(out a2); + __a1_native.ToManaged(out a1); + // Unmarshal - Convert native data to managed data. + __a15_native.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.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.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.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); + }); + __a8_native.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); + }); + __a5_native.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.ToManaged(out a4); + Basic.AnnotatedExport(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15); + } + catch (global::System.Exception __arg_exception) { - __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); + ____arg_exception_native.ToJS(__arg_exception); + } } } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/Strings.resx b/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/Strings.resx index 55fbc3b4247ede..7253540e16a0df 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/Strings.resx +++ b/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/Strings.resx @@ -180,8 +180,8 @@ The marshaller entry point type '{0}' for managed type '{1}' must have an arity of one greater than the managed type. - - All marshallers for values that are passed as the unmanaged return value must have the same unmanaged type. + + All marshallers for values that are passed as the unmanaged return value or parameter must have the same unmanaged type. Containing type '{0}' has accessibility '{1}'. diff --git a/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.cs.xlf b/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.cs.xlf index a27704743998bb..9eda94038ab1f8 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.cs.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.cs.xlf @@ -842,9 +842,9 @@ Typ vstupního bodu řadiče „{0}“ pro spravovaný typ „{1}“ musí mít aritu o jednu větší než spravovaný typ. - - All marshallers for values that are passed as the unmanaged return value must have the same unmanaged type. - Všechny zařazovací moduly pro hodnoty, které jsou předány jako nespravovaná návratová hodnota, musí mít stejný nespravovaný typ. + + All marshallers for values that are passed as the unmanaged return value or parameter must have the same unmanaged type. + All marshallers for values that are passed as the unmanaged return value or parameter must have the same unmanaged type. diff --git a/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.de.xlf b/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.de.xlf index 05b494628443e6..9b4f377bf9d986 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.de.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.de.xlf @@ -842,9 +842,9 @@ Der Marshaller-Einstiegspunkttyp "{0}" für den verwalteten Typ "{1}" muss eine Stelligkeit aufweisen, die größer als der verwaltete Typ ist. - - All marshallers for values that are passed as the unmanaged return value must have the same unmanaged type. - Alle Marshaller für Werte, die als nicht verwalteter Rückgabewert übergeben werden, müssen denselben nicht verwalteten Typ aufweisen. + + All marshallers for values that are passed as the unmanaged return value or parameter must have the same unmanaged type. + All marshallers for values that are passed as the unmanaged return value or parameter must have the same unmanaged type. diff --git a/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.es.xlf b/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.es.xlf index 58a124e36da262..d720a61540758c 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.es.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.es.xlf @@ -842,9 +842,9 @@ El tipo de punto de entrada del serializador "{0}" para el tipo administrado "{1}" debe tener una aridad mayor que el tipo administrado. - - All marshallers for values that are passed as the unmanaged return value must have the same unmanaged type. - Todos los serializadores para los valores que se pasan como valor devuelto no administrado deberán tener el mismo tipo no administrado. + + All marshallers for values that are passed as the unmanaged return value or parameter must have the same unmanaged type. + All marshallers for values that are passed as the unmanaged return value or parameter must have the same unmanaged type. diff --git a/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.fr.xlf b/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.fr.xlf index c0bdf3dcb16ad8..29e4ce7970a560 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.fr.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.fr.xlf @@ -842,9 +842,9 @@ Le type de point d’entrée marshaleur '{0}' pour le type managé '{1}' doit avoir une arité supérieure au type managé. - - All marshallers for values that are passed as the unmanaged return value must have the same unmanaged type. - Tous les marshaleurs pour les valeurs passées en tant que valeur de retour non managée doivent avoir le même type non managé. + + All marshallers for values that are passed as the unmanaged return value or parameter must have the same unmanaged type. + All marshallers for values that are passed as the unmanaged return value or parameter must have the same unmanaged type. diff --git a/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.it.xlf b/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.it.xlf index 9c152bcfa03c39..d6b289a74087d2 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.it.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.it.xlf @@ -842,9 +842,9 @@ Il tipo di punto di ingresso del marshalling '{0}' per il tipo gestito '{1}' deve avere un grado maggiore rispetto a quello del tipo gestito. - - All marshallers for values that are passed as the unmanaged return value must have the same unmanaged type. - Tutti i marshalling per i valori passati come valore restituito non gestito devono avere lo stesso tipo non gestito. + + All marshallers for values that are passed as the unmanaged return value or parameter must have the same unmanaged type. + All marshallers for values that are passed as the unmanaged return value or parameter must have the same unmanaged type. diff --git a/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.ja.xlf b/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.ja.xlf index e4e5b7e0bd1ebd..c1637d330ae354 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.ja.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.ja.xlf @@ -842,9 +842,9 @@ マネージド型 '{1}' のマーシャラー エントリ ポイント型 '{0}' には、マネージド型より 1 大きい引数が必要です。 - - All marshallers for values that are passed as the unmanaged return value must have the same unmanaged type. - アンマネージ戻り値として渡される値のすべてのマーシャラーは、同じアンマネージ型を持つ必要があります。 + + All marshallers for values that are passed as the unmanaged return value or parameter must have the same unmanaged type. + All marshallers for values that are passed as the unmanaged return value or parameter must have the same unmanaged type. diff --git a/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.ko.xlf b/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.ko.xlf index b5c19585d13f59..6838c41194c893 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.ko.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.ko.xlf @@ -842,9 +842,9 @@ 관리 유형 '{1}'에 대한 마샬러 진입점 유형 '{0}'에는 관리 유형보다 1이 더 커야 합니다. - - All marshallers for values that are passed as the unmanaged return value must have the same unmanaged type. - 관리되지 않는 반환 값으로 전달되는 값에 대한 모든 마샬러는 관리되지 않는 형식이 동일해야 합니다. + + All marshallers for values that are passed as the unmanaged return value or parameter must have the same unmanaged type. + All marshallers for values that are passed as the unmanaged return value or parameter must have the same unmanaged type. diff --git a/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.pl.xlf b/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.pl.xlf index e2f7643bf88883..f4f4fc2eb19f13 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.pl.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.pl.xlf @@ -842,9 +842,9 @@ The marshaller entry point type '{0}' for managed type '{1}' must have an arity of one greater than the managed type. - - All marshallers for values that are passed as the unmanaged return value must have the same unmanaged type. - All marshallers for values that are passed as the unmanaged return value must have the same unmanaged type. + + All marshallers for values that are passed as the unmanaged return value or parameter must have the same unmanaged type. + All marshallers for values that are passed as the unmanaged return value or parameter must have the same unmanaged type. diff --git a/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.pt-BR.xlf b/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.pt-BR.xlf index e1969dc8b8ab50..2d00f98255fa2a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.pt-BR.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.pt-BR.xlf @@ -842,9 +842,9 @@ O tipo de ponto de entrada para realizar marshaling '{0}' para o tipo gerenciado '{1}' deve ter uma aridade maior do que o tipo gerenciado. - - All marshallers for values that are passed as the unmanaged return value must have the same unmanaged type. - Todos os marshallers de valores passados como o valor retornado não gerenciado devem ter o mesmo tipo não gerenciado. + + All marshallers for values that are passed as the unmanaged return value or parameter must have the same unmanaged type. + All marshallers for values that are passed as the unmanaged return value or parameter must have the same unmanaged type. diff --git a/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.ru.xlf b/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.ru.xlf index d98f485c3e77a7..bffabde1c1834c 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.ru.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.ru.xlf @@ -842,9 +842,9 @@ Тип точки входа маршаллера "{0}" для управляемого типа "{1}" должен иметь более высокую арность, чем управляемый тип. - - All marshallers for values that are passed as the unmanaged return value must have the same unmanaged type. - Все маршалеры для значений, передаваемых в качестве неуправляемого возвращаемого значения, должны использовать одинаковый неуправляемый тип. + + All marshallers for values that are passed as the unmanaged return value or parameter must have the same unmanaged type. + All marshallers for values that are passed as the unmanaged return value or parameter must have the same unmanaged type. diff --git a/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.tr.xlf b/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.tr.xlf index cb79284da8216f..8f38a00cb2e374 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.tr.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.tr.xlf @@ -842,9 +842,9 @@ Yönetilen tür '{1}' için sıralayıcı giriş noktası '{0}', yönetilen türden büyük bir parametre sayısına sahip olmalıdır. - - All marshallers for values that are passed as the unmanaged return value must have the same unmanaged type. - Yönetilmeyen dönüş değeri olarak geçirilen değerler için tüm hazırlayıcılar aynı yönetilmeyen türe sahip olmalıdır. + + All marshallers for values that are passed as the unmanaged return value or parameter must have the same unmanaged type. + All marshallers for values that are passed as the unmanaged return value or parameter must have the same unmanaged type. diff --git a/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.zh-Hans.xlf b/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.zh-Hans.xlf index bfaa9c0b22c78d..1a1d4fea2aceec 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.zh-Hans.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.zh-Hans.xlf @@ -842,9 +842,9 @@ 托管类型“{1}”的封送程序入口点类型“{0}”必须具有大于托管类型的 arity。 - - All marshallers for values that are passed as the unmanaged return value must have the same unmanaged type. - 作为非托管返回值传递的值的所有封送程序必须具有相同的非托管类型。 + + All marshallers for values that are passed as the unmanaged return value or parameter must have the same unmanaged type. + All marshallers for values that are passed as the unmanaged return value or parameter must have the same unmanaged type. diff --git a/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.zh-Hant.xlf b/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.zh-Hant.xlf index c8880476fda354..1a6b5920aad8ab 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.zh-Hant.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.zh-Hant.xlf @@ -842,9 +842,9 @@ 受控類型 '{1}' 的封送處理器進入點類型 '{0}' 必須具有大於受控類型的 arity。 - - All marshallers for values that are passed as the unmanaged return value must have the same unmanaged type. - 以非受控傳回值傳遞之值的所有封送處理常式,都必須具有相同的非受控類型。 + + All marshallers for values that are passed as the unmanaged return value or parameter must have the same unmanaged type. + All marshallers for values that are passed as the unmanaged return value or parameter must have the same unmanaged type. 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 335aca92cab2a9..a96a48eb180612 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 @@ -66,29 +66,60 @@ public static BoundGenerators Create(ImmutableArray elementTyp } } - // Sort the parameter marshallers by index to ensure that we handle them in order when producing signatures. - managedParamMarshallers.Sort(static (m1, m2) => m1.TypeInfo.ManagedIndex.CompareTo(m2.TypeInfo.ManagedIndex)); - nativeParamMarshallers.Sort(static (m1, m2) => m1.TypeInfo.NativeIndex.CompareTo(m2.TypeInfo.NativeIndex)); // Now that we've processed all of the signature marshallers, // we'll handle the special ones that might depend on them, like the exception marshaller. if (managedExceptionInfo is not null) { + // The managed exception marshaller may overlap with another marshaller in the native position. + // In that case, we need to validate some additional invariants. + // Also, some cases may require an overlap, such as when using the "COM" exception marshalling. + IBoundMarshallingGenerator? overlappedMarshaller = null; + if (managedExceptionInfo.IsNativeReturnPosition) + { + overlappedMarshaller = nativeReturnMarshaller; + } + else if (managedExceptionInfo.NativeIndex is not (TypePositionInfo.UnsetIndex or TypePositionInfo.ExceptionIndex)) + { + overlappedMarshaller = nativeParamMarshallers.FirstOrDefault(e => e.TypeInfo.NativeIndex == managedExceptionInfo.NativeIndex); + } + if (managedExceptionInfo.MarshallingAttributeInfo is ComExceptionMarshalling) { - managedExceptionInfo = managedExceptionInfo with + if (overlappedMarshaller is null) + { + generatorDiagnostics.Add(new GeneratorDiagnostic.NotSupported(managedExceptionInfo)); + } + else { - MarshallingAttributeInfo = ComExceptionMarshalling.CreateSpecificMarshallingInfo(nativeReturnMarshaller.NativeType) - }; + managedExceptionInfo = managedExceptionInfo with + { + MarshallingAttributeInfo = ComExceptionMarshalling.CreateSpecificMarshallingInfo(overlappedMarshaller.NativeType) + }; + } } - IMarshallingGeneratorResolver exceptionHandlerFactory = new ExtendedInvariantsValidator(nativeReturnMarshaller.NativeType, generatorResolver); + IMarshallingGeneratorResolver exceptionHandlerFactory = generatorResolver; + + if (overlappedMarshaller is not null) + { + exceptionHandlerFactory = new MatchingNativeTypeValidator(overlappedMarshaller.NativeType, exceptionHandlerFactory); + } - // We explicitly don't include exceptionMarshaller in the signatureMarshallers collection - // as it needs to be specially emitted. managedExceptionMarshaller = CreateGenerator(managedExceptionInfo, generatorResolver); + + if (overlappedMarshaller is null && !TypePositionInfo.IsSpecialIndex(managedExceptionInfo.NativeIndex)) + { + // If the exception marshaller doesn't overlap with another marshaller but has a native index, + // we need to add it to the list of native parameter marshallers. + nativeParamMarshallers.Add(managedExceptionMarshaller); + } } + // Sort the parameter marshallers by index to ensure that we handle them in order when producing signatures. + managedParamMarshallers.Sort(static (m1, m2) => m1.TypeInfo.ManagedIndex.CompareTo(m2.TypeInfo.ManagedIndex)); + nativeParamMarshallers.Sort(static (m1, m2) => m1.TypeInfo.NativeIndex.CompareTo(m2.TypeInfo.NativeIndex)); + generatorBindingDiagnostics = generatorDiagnostics.ToImmutable(); return new BoundGenerators() @@ -190,31 +221,24 @@ IBoundMarshallingGenerator CreateGenerator(TypePositionInfo p, IMarshallingGener public bool HasManagedExceptionMarshaller => !ManagedExceptionMarshaller.IsForwarder(); - private sealed class ExtendedInvariantsValidator : IMarshallingGeneratorResolver + /// + /// Validate that the resolved generator resolves to the same native type. + /// + private sealed class MatchingNativeTypeValidator(ManagedTypeInfo requiredNativeType, IMarshallingGeneratorResolver inner) : IMarshallingGeneratorResolver { - private readonly ManagedTypeInfo _nativeReturnType; - private readonly IMarshallingGeneratorResolver _inner; - - public ExtendedInvariantsValidator(ManagedTypeInfo nativeReturnType, IMarshallingGeneratorResolver inner) - { - _nativeReturnType = nativeReturnType; - _inner = inner; - } - public ResolvedGenerator Create(TypePositionInfo info, StubCodeContext context) { - ResolvedGenerator generator = _inner.Create(info, context); + ResolvedGenerator generator = inner.Create(info, context); if (!generator.IsResolvedWithoutErrors) { return generator; } // Marshallers that share the native return position must have the same native return type. - if (info.IsNativeReturnPosition - && generator.Generator.NativeType != _nativeReturnType) + if (generator.Generator.NativeType != requiredNativeType) { return ResolvedGenerator.NotSupported(info, context, new(info) { - NotSupportedDetails = SR.MarshallerInNativeReturnPositionMustMatchNativeReturnType + NotSupportedDetails = SR.MarshallerInOverlappingNativePositionMustMatchNativeType }); } return generator; diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/UnmanagedToManagedStubGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/UnmanagedToManagedStubGenerator.cs similarity index 98% rename from src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/UnmanagedToManagedStubGenerator.cs rename to src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/UnmanagedToManagedStubGenerator.cs index 04897fb03d7630..bdc27c6555ea19 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/UnmanagedToManagedStubGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/UnmanagedToManagedStubGenerator.cs @@ -11,7 +11,7 @@ namespace Microsoft.Interop { - internal sealed class UnmanagedToManagedStubGenerator + public sealed class UnmanagedToManagedStubGenerator { private const string ReturnIdentifier = "__retVal"; 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 fb10fd2f74aaed..db65df307c5eb2 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 @@ -164,7 +164,9 @@ static void AppendVariableDeclarations(ImmutableArray Date: Thu, 12 Sep 2024 15:44:08 -0700 Subject: [PATCH 03/22] Emit initialization and fix MarshalerType handling for non-generic Task --- .../JSImportGenerator/JSGeneratorFactory.cs | 4 ++-- .../Marshaling/BaseJSGenerator.cs | 22 ++++++++++++++++++- .../Marshaling/FuncJSGenerator.cs | 5 +++++ .../Marshaling/PrimitiveJSGenerator.cs | 5 +++++ .../Marshaling/TaskJSGenerator.cs | 5 +++++ 5 files changed, 38 insertions(+), 3 deletions(-) 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 411a827a4546a5..e5dbb1254ca433 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSGeneratorFactory.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSGeneratorFactory.cs @@ -163,7 +163,7 @@ private static ResolvedGeneratorAndType Create(TypePositionInfo info, StubCodeCo // task - (KnownManagedType.Task, JSTypeFlags.Promise, [], [JSTypeFlags.Void]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Void), MarshalerType.Task), + (KnownManagedType.Task, JSTypeFlags.Promise, [], [JSTypeFlags.Void]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Void), MarshalerType.Task, []), (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Boolean], [JSTypeFlags.Boolean]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Boolean), MarshalerType.Task, [MarshalerType.Boolean]), (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Byte], [JSTypeFlags.Number]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Byte), MarshalerType.Task, [MarshalerType.Byte]), (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Char], [JSTypeFlags.String]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Char), MarshalerType.Task, [MarshalerType.Char]), @@ -182,7 +182,7 @@ private static ResolvedGeneratorAndType Create(TypePositionInfo info, StubCodeCo (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Object], [JSTypeFlags.Any]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Object), MarshalerType.Task, [MarshalerType.Object]), // task missing - (KnownManagedType.Task, JSTypeFlags.Missing, [], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Void), MarshalerType.Task), + (KnownManagedType.Task, JSTypeFlags.Missing, [], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Void), MarshalerType.Task, []), (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Boolean], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Boolean), MarshalerType.Task, [MarshalerType.Boolean]), (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Byte], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Byte), MarshalerType.Task, [MarshalerType.Byte]), (KnownManagedType.Task, JSTypeFlags.Missing, [KnownManagedType.Char], _) => resolved(new TaskJSGenerator(info, context, MarshalerType.Char), MarshalerType.Task, [MarshalerType.Char]), 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 2ec0067b894def..9ba2c3d80eec70 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 @@ -32,7 +32,27 @@ public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarsh return ByValueMarshalKindSupport.NotSupported; } - public abstract IEnumerable Generate(StubIdentifierContext context); + public virtual IEnumerable Generate(StubIdentifierContext context) + { + MarshalDirection marshalDirection = MarshallerHelpers.GetMarshalDirection(TypeInfo, CodeContext); + if (context.CurrentStage == StubIdentifierContext.Stage.Setup + && marshalDirection == MarshalDirection.ManagedToUnmanaged + && !TypeInfo.IsNativeReturnPosition) + { + var (_, js) = context.GetIdentifiers(TypeInfo); + return [ + ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(js), + LiteralExpression(SyntaxKind.DefaultLiteralExpression) + ) + ) + ]; + } + + return []; + } protected static IdentifierNameSyntax GetToManagedMethod(MarshalerType marshalerType) { 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 f4c0da89466c25..f92bc3a4b7691f 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 @@ -15,6 +15,11 @@ internal sealed class FuncJSGenerator(TypePositionInfo info, StubCodeContext con { public override IEnumerable Generate(StubIdentifierContext context) { + foreach (var statement in base.Generate(context)) + { + yield return statement; + } + var (managed, js) = context.GetIdentifiers(TypeInfo); var jsty = (JSFunctionTypeInfo)((JSMarshallingInfo)TypeInfo.MarshallingAttributeInfo).TypeInfo; 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 9a7f548397f4b4..ab7830a642ab71 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 @@ -14,6 +14,11 @@ internal sealed class PrimitiveJSGenerator(TypePositionInfo info, StubCodeContex // TODO order parameters in such way that affinity capturing parameters are emitted first public override IEnumerable Generate(StubIdentifierContext context) { + foreach (var statement in base.Generate(context)) + { + yield return statement; + } + var (managed, js) = context.GetIdentifiers(TypeInfo); MarshalDirection marshalDirection = MarshallerHelpers.GetMarshalDirection(TypeInfo, CodeContext); 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 af22d4707fef37..2a05d2a7dff92f 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,6 +13,11 @@ internal sealed class TaskJSGenerator(TypePositionInfo info, StubCodeContext con { public override IEnumerable Generate(StubIdentifierContext context) { + foreach (var statement in base.Generate(context)) + { + yield return statement; + } + var jsty = (JSTaskTypeInfo)((JSMarshallingInfo)TypeInfo.MarshallingAttributeInfo).TypeInfo; var (managed, js) = context.GetIdentifiers(TypeInfo); From 7e5a1d5e11b91aeebd35cc55ec038aaa7f287cc7 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 12 Sep 2024 15:48:02 -0700 Subject: [PATCH 04/22] Update code snippet --- .../tests/JSImportGenerator.UnitTest/Compiles.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 8a04f1a875051b..73ae589736711d 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 @@ -90,6 +90,22 @@ internal static partial void Annotated(object a1, long a2, long a3, global::Syst global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a13_native; global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a14_native; global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a15_native; + // Setup - Perform required setup. + __a15_native = default; + __a14_native = default; + __a13_native = default; + __a12_native = default; + __a11_native = default; + __a10_native = default; + __a9_native = default; + __a8_native = default; + __a7_native = default; + __a6_native = default; + __a5_native = default; + __a4_native = default; + __a3_native = default; + __a2_native = default; + __a1_native = default; // Marshal - Convert managed data to native data. __a11_native.ToJS(a11); __a10_native.ToJS(a10); From e8b8a6c215ff5a3d0bcfd4f0fc6fb2efe886ed3e Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 17 Oct 2024 16:01:59 -0700 Subject: [PATCH 05/22] Stackalloc the marshaller arguments in the local function. Let's see if that fixes the problems. --- .../JSImportGenerator/JSImportGenerator.cs | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs index 78e821ecd2e505..fa3cd6e20545a0 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs @@ -267,14 +267,20 @@ private static LocalFunctionStatementSyntax GenerateInvokeFunction(string functi IdentifierName(Constants.ArgumentReturn), IdentifierName("Initialize")), Declare(SpanOf(jsMarshalerArgument), Constants.ArgumentsBuffer, - CollectionExpression( - SeparatedList( - (IEnumerable)[ - ExpressionElement(IdentifierName(Constants.ArgumentException)), - ExpressionElement(IdentifierName(Constants.ArgumentReturn)), - ..parameters.Parameters - .Select(p => ExpressionElement(IdentifierName(p.Identifier))) - ]))), + StackAllocArrayCreationExpression( + ArrayType(jsMarshalerArgument)) + .WithRankSpecifiers(SingletonList(ArrayRankSpecifier(SingletonSeparatedList( + LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(parameters.Parameters.Length + 2)))))) + .WithInitializer( + InitializerExpression( + SyntaxKind.ArrayInitializerExpression, + SeparatedList( + (IEnumerable)[ + IdentifierName(Constants.ArgumentException), + IdentifierName(Constants.ArgumentReturn), + ..parameters.Parameters + .Select(p => IdentifierName(p.Identifier)) + ])))), MethodInvocationStatement( IdentifierName(Constants.JSFunctionSignatureGlobal), IdentifierName("InvokeJS"), From d4e42143f3c5470e54f048fbcdbc2530a6aa425c Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 17 Oct 2024 16:34:54 -0700 Subject: [PATCH 06/22] Don't try to calculate the array size, let the compiler do it. --- .../gen/JSImportGenerator/JSImportGenerator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs index fa3cd6e20545a0..35218f2de06645 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs @@ -270,7 +270,7 @@ private static LocalFunctionStatementSyntax GenerateInvokeFunction(string functi StackAllocArrayCreationExpression( ArrayType(jsMarshalerArgument)) .WithRankSpecifiers(SingletonList(ArrayRankSpecifier(SingletonSeparatedList( - LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(parameters.Parameters.Length + 2)))))) + OmittedArraySizeExpression())))) .WithInitializer( InitializerExpression( SyntaxKind.ArrayInitializerExpression, From 3cd828ee01c4ad6250970abac9308776cbacb73b Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 17 Oct 2024 16:53:36 -0700 Subject: [PATCH 07/22] WithRankSpecifiers is on the array type --- .../gen/JSImportGenerator/JSImportGenerator.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs index 35218f2de06645..d1b6c5ef5e6b04 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs @@ -268,9 +268,9 @@ private static LocalFunctionStatementSyntax GenerateInvokeFunction(string functi IdentifierName("Initialize")), Declare(SpanOf(jsMarshalerArgument), Constants.ArgumentsBuffer, StackAllocArrayCreationExpression( - ArrayType(jsMarshalerArgument)) - .WithRankSpecifiers(SingletonList(ArrayRankSpecifier(SingletonSeparatedList( - OmittedArraySizeExpression())))) + ArrayType(jsMarshalerArgument) + .WithRankSpecifiers(SingletonList(ArrayRankSpecifier(SingletonSeparatedList( + OmittedArraySizeExpression()))))) .WithInitializer( InitializerExpression( SyntaxKind.ArrayInitializerExpression, From 456bb732b5a3cf8804a807cc1589d1cf436daad4 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 17 Oct 2024 17:46:43 -0700 Subject: [PATCH 08/22] Fix expected syntax. --- .../JSImportGenerator.UnitTest/Compiles.cs | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) 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 73ae589736711d..c5671a085d8570 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 @@ -153,7 +153,26 @@ internal static partial void Annotated(object a1, long a2, long a3, global::Syst __arg_exception.Initialize(); global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __arg_return = default; __arg_return.Initialize(); - global::System.Span __arguments_buffer = [__arg_exception, __arg_return, __a1_native, __a2_native, __a3_native, __a4_native, __a5_native, __a6_native, __a7_native, __a8_native, __a9_native, __a10_native, __a11_native, __a12_native, __a13_native, __a14_native, __a15_native]; + global::System.Span __arguments_buffer = stackalloc global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument[] + { + __arg_exception, + __arg_return, + __a1_native, + __a2_native, + __a3_native, + __a4_native, + __a5_native, + __a6_native, + __a7_native, + __a8_native, + __a9_native, + __a10_native, + __a11_native, + __a12_native, + __a13_native, + __a14_native, + __a15_native + }; global::System.Runtime.InteropServices.JavaScript.JSFunctionBinding.InvokeJS(__signature_Annotated_564258462, __arguments_buffer); return __arguments_buffer[1]; } @@ -260,7 +279,7 @@ void __Stub(global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgumen } } } - + """.ReplaceLineEndings("\r\n"), Encoding.UTF8)), } }, From fe1e1b60c04765c9f3d971c5cedfa28955380bc3 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 30 Jan 2025 15:04:06 -0800 Subject: [PATCH 09/22] Add another test --- .../JSImportGenerator.UnitTest/Compiles.cs | 127 +++++++++++++++++- 1 file changed, 126 insertions(+), 1 deletion(-) 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 38a66a9d265de2..77d198ecc411b1 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 @@ -51,7 +51,7 @@ public void ValidateSnippets(string source) } [Fact] - public async Task ValidateGeneratedSourceOutput() + public async Task ValidateGeneratedSourceOutput_AllAnnotatedParameters() { var test = new Test() { @@ -288,6 +288,131 @@ void __Stub(global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgumen await test.RunAsync(); } + [Fact] + public async Task ValidateGeneratedSourceOutput_Return() + { + var test = new Test() + { + TestState = + { + Sources = { CodeSnippets.DefaultReturnMarshaler("System.Threading.Tasks.Task") }, + GeneratedSources = + { + (typeof(Microsoft.Interop.JavaScript.JSImportGenerator), + "JSImports.g.cs", + SourceText.From(""" + // + unsafe partial class Basic + { + [global::System.Diagnostics.DebuggerNonUserCode] + public static partial global::System.Threading.Tasks.Task Import1() + { + if (__signature_Import1_622134597 == null) + { + __signature_Import1_622134597 = global::System.Runtime.InteropServices.JavaScript.JSFunctionBinding.BindJSFunction("DoesNotExist", null, [global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Task(global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Int32)]); + } + + { + global::System.Threading.Tasks.Task __retVal; + global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __retVal_native; + { + __retVal_native = __InvokeJSFunction(); + } + + // UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception. + __retVal_native.ToManaged(out __retVal, static (ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __task_result_arg, out int __task_result) => + { + __task_result_arg.ToManaged(out __task_result); + }); + return __retVal; + } + + [global::System.Diagnostics.DebuggerNonUserCode] + global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __InvokeJSFunction() + { + global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __arg_exception = default; + __arg_exception.Initialize(); + global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __arg_return = default; + __arg_return.Initialize(); + global::System.Span __arguments_buffer = stackalloc global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument[] + { + __arg_exception, + __arg_return + }; + global::System.Runtime.InteropServices.JavaScript.JSFunctionBinding.InvokeJS(__signature_Import1_622134597, __arguments_buffer); + return __arguments_buffer[1]; + } + } + + static global::System.Runtime.InteropServices.JavaScript.JSFunctionBinding __signature_Import1_622134597; + } + + """.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_Export1_622134597", "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:Export1", 622134597, [global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Task(global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Int32)]); + } + } + } + unsafe partial class Basic + { + [global::System.Diagnostics.DebuggerNonUserCode] + internal static unsafe void __Wrapper_Export1_622134597(global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument* __arguments_buffer) + { + __arguments_buffer[1] = __Stub(__arguments_buffer); + [global::System.Diagnostics.DebuggerNonUserCode] + global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __Stub(global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument* ____arg_exception_native__param) + { + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument ____arg_exception_native = ref *____arg_exception_native__param; + global::System.Threading.Tasks.Task __retVal = default; + global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __retVal_native = default; + try + { + __retVal = Basic.Export1(); + // Marshal - Convert managed data to native data. + __retVal_native.ToJS(__retVal, static (ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __task_result_arg, int __task_result) => + { + __task_result_arg.ToJS(__task_result); + }); + } + catch (global::System.Exception __arg_exception) + { + ____arg_exception_native.ToJS(__arg_exception); + } + + return __retVal_native; + } + } + } + + """.ReplaceLineEndings("\r\n"), Encoding.UTF8)), + } + }, + }; + + await test.RunAsync(); + } + private sealed class Test : CSharpAnalyzerTest { public Test() From bad0406400924fd9220e345cb497f1e222dc63e6 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 30 Jan 2025 17:22:52 -0800 Subject: [PATCH 10/22] Fall back from sync task resolution to async task resolution if the task has not resolved. --- src/mono/browser/runtime/marshal-to-js.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mono/browser/runtime/marshal-to-js.ts b/src/mono/browser/runtime/marshal-to-js.ts index 29d9f56ff6fb3a..707a123072a667 100644 --- a/src/mono/browser/runtime/marshal-to-js.ts +++ b/src/mono/browser/runtime/marshal-to-js.ts @@ -276,8 +276,9 @@ export function end_marshal_task_to_js (args: JSMarshalerArguments, res_converte // get the synchronous result const promise = try_marshal_sync_task_to_js(res, type, res_converter); - // make sure we got the result - mono_assert(promise !== false, () => `Expected synchronous result, got: ${type}`); + if (promise === false) { + return marshal_task_to_js(res, type, res_converter); + } return promise; } From 672327cbacf34801fe23f645fdb51478e95547ab Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 30 Jan 2025 22:10:14 -0800 Subject: [PATCH 11/22] Treat retval as return-swapped out like we do with PreserveSig --- .../JSImportGenerator/JSExportGenerator.cs | 36 +++++++++++++------ .../JSImportGenerator/JSGeneratorFactory.cs | 2 +- 2 files changed, 26 insertions(+), 12 deletions(-) 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 336153c554057a..607d6ba3bd1a41 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSExportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSExportGenerator.cs @@ -341,6 +341,21 @@ private static (MemberDeclarationSyntax, StatementSyntax, AttributeListSyntax, I RefKind = RefKind.Out, // We'll treat it as a separate out parameter. }); + for (int i = 0; i < allElements.Length; i++) + { + if (allElements[i].IsNativeReturnPosition && allElements[i].ManagedType != SpecialTypeInfo.Void) + { + // The runtime may partially initialize the native return value. + // To preserve this information, we must pass the native return value as an out parameter. + allElements = allElements.SetItem(i, allElements[i] with + { + ManagedIndex = TypePositionInfo.ReturnIndex, + NativeIndex = allElements.Length, // Insert at the end of the argument list + RefKind = RefKind.Out, // We'll treat it as a separate out parameter. + }); + } + } + var stubGenerator = new UnmanagedToManagedStubGenerator( allElements, diagnostics, @@ -352,6 +367,7 @@ private static (MemberDeclarationSyntax, StatementSyntax, AttributeListSyntax, I const string innerWrapperName = "__Stub"; + // TODO: We need to initialize __retVal_native from __arguments_buffer (or fix it up in the caller) as it comes in with some required state BlockSyntax wrapperToInnerStubBlock = Block( CreateWrapperToInnerStubCall(signatureElements, innerWrapperName), GenerateInnerLocalFunction(incrementalContext, innerWrapperName, stubGenerator)); @@ -394,21 +410,19 @@ private static ExpressionStatementSyntax CreateWrapperToInnerStubCall(ImmutableA arguments.Add(Argument(IdentifierName(Constants.ArgumentsBuffer))); - ExpressionSyntax invocation = InvocationExpression(IdentifierName(innerWrapperName)) - .WithArgumentList(ArgumentList(SeparatedList(arguments))); - - if (!hasReturn) + if (hasReturn) { - return ExpressionStatement(invocation); + arguments.Add( + Argument( + BinaryExpression( + SyntaxKind.AddExpression, + IdentifierName(Constants.ArgumentsBuffer), + LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(1))))); } return ExpressionStatement( - AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, - ElementAccessExpression( - IdentifierName(Constants.ArgumentsBuffer), - BracketedArgumentList(SingletonSeparatedList(Argument( - LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(1)))))), - invocation)); + InvocationExpression(IdentifierName(innerWrapperName)) + .WithArgumentList(ArgumentList(SeparatedList(arguments)))); } private static LocalFunctionStatementSyntax GenerateInnerLocalFunction(IncrementalStubGenerationContext context, string innerFunctionName, UnmanagedToManagedStubGenerator stubGenerator) 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 e5dbb1254ca433..7139769da37a8f 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSGeneratorFactory.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSGeneratorFactory.cs @@ -17,7 +17,7 @@ internal sealed class JSGeneratorResolver : IMarshallingGeneratorResolver public ResolvedGenerator Create(TypePositionInfo info, StubCodeContext context) { Debug.Assert(context != null); - if (!info.IsManagedExceptionPosition && (info.IsByRef || info.ByValueContentsMarshalKind != ByValueContentsMarshalKind.Default)) + if (!info.IsManagedExceptionPosition && !info.IsManagedReturnPosition && (info.IsByRef || info.ByValueContentsMarshalKind != ByValueContentsMarshalKind.Default)) { // out of scope for Net7.0 return ResolvedGenerator.NotSupported(info, context, new(info) From e07a6859805ed9db04ac17661a6b477c30d4763f Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 30 Jan 2025 22:30:15 -0800 Subject: [PATCH 12/22] Don't re-initialize the unmanaged return value representation. --- .../Marshaling/BaseJSGenerator.cs | 2 +- .../tests/JSImportGenerator.UnitTest/Compiles.cs | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) 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 9ba2c3d80eec70..163b55ea055884 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 @@ -37,7 +37,7 @@ public virtual IEnumerable Generate(StubIdentifierContext conte MarshalDirection marshalDirection = MarshallerHelpers.GetMarshalDirection(TypeInfo, CodeContext); if (context.CurrentStage == StubIdentifierContext.Stage.Setup && marshalDirection == MarshalDirection.ManagedToUnmanaged - && !TypeInfo.IsNativeReturnPosition) + && !TypeInfo.IsManagedReturnPosition) { var (_, js) = context.GetIdentifiers(TypeInfo); return [ 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 77d198ecc411b1..bf9cc9f7e2d40c 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 @@ -379,18 +379,18 @@ unsafe partial class Basic [global::System.Diagnostics.DebuggerNonUserCode] internal static unsafe void __Wrapper_Export1_622134597(global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument* __arguments_buffer) { - __arguments_buffer[1] = __Stub(__arguments_buffer); + __Stub(__arguments_buffer, __arguments_buffer + 1); [global::System.Diagnostics.DebuggerNonUserCode] - global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __Stub(global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument* ____arg_exception_native__param) + void __Stub(global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument* ____arg_exception_native__param, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument* __invokeRetValUnmanaged__param) { ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument ____arg_exception_native = ref *____arg_exception_native__param; - global::System.Threading.Tasks.Task __retVal = default; - global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __retVal_native = default; + ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __invokeRetValUnmanaged = ref *__invokeRetValUnmanaged__param; + global::System.Threading.Tasks.Task __invokeRetVal = default; try { - __retVal = Basic.Export1(); + __invokeRetVal = Basic.Export1(); // Marshal - Convert managed data to native data. - __retVal_native.ToJS(__retVal, static (ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __task_result_arg, int __task_result) => + __invokeRetValUnmanaged.ToJS(__invokeRetVal, static (ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __task_result_arg, int __task_result) => { __task_result_arg.ToJS(__task_result); }); @@ -399,8 +399,6 @@ internal static unsafe void __Wrapper_Export1_622134597(global::System.Runtime.I { ____arg_exception_native.ToJS(__arg_exception); } - - return __retVal_native; } } } From 337bb67453f9f1ce74faaf8233b041fefbf9433c Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 30 Jan 2025 22:33:31 -0800 Subject: [PATCH 13/22] Update src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSExportGenerator.cs --- .../gen/JSImportGenerator/JSExportGenerator.cs | 1 - 1 file changed, 1 deletion(-) 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 607d6ba3bd1a41..f5dfa0082aa9e9 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSExportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSExportGenerator.cs @@ -367,7 +367,6 @@ private static (MemberDeclarationSyntax, StatementSyntax, AttributeListSyntax, I const string innerWrapperName = "__Stub"; - // TODO: We need to initialize __retVal_native from __arguments_buffer (or fix it up in the caller) as it comes in with some required state BlockSyntax wrapperToInnerStubBlock = Block( CreateWrapperToInnerStubCall(signatureElements, innerWrapperName), GenerateInnerLocalFunction(incrementalContext, innerWrapperName, stubGenerator)); From db6246aabaf93a6024608228549e8cf9054ede65 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 31 Jan 2025 09:14:45 -0800 Subject: [PATCH 14/22] Revert change to JS side --- src/mono/browser/runtime/marshal-to-js.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/mono/browser/runtime/marshal-to-js.ts b/src/mono/browser/runtime/marshal-to-js.ts index 707a123072a667..29d9f56ff6fb3a 100644 --- a/src/mono/browser/runtime/marshal-to-js.ts +++ b/src/mono/browser/runtime/marshal-to-js.ts @@ -276,9 +276,8 @@ export function end_marshal_task_to_js (args: JSMarshalerArguments, res_converte // get the synchronous result const promise = try_marshal_sync_task_to_js(res, type, res_converter); - if (promise === false) { - return marshal_task_to_js(res, type, res_converter); - } + // make sure we got the result + mono_assert(promise !== false, () => `Expected synchronous result, got: ${type}`); return promise; } From 7595b58b7d4690d7a6343580d0b0cf77984e7a89 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 31 Jan 2025 13:20:02 -0800 Subject: [PATCH 15/22] Always call initialize and make sure to initialize the exception and return arguments before we do any marshalling (instead of after). --- .../JSImportGenerator/JSGeneratorFactory.cs | 7 ++ .../JSImportGenerator/JSImportGenerator.cs | 64 ++++++++++++++----- .../Marshaling/BaseJSGenerator.cs | 11 ++-- .../Marshaling/ImplicitArgumentGenerator.cs | 33 ++++++++++ .../JSImportGenerator.UnitTest/Compiles.cs | 63 +++++++++--------- 5 files changed, 126 insertions(+), 52 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/ImplicitArgumentGenerator.cs 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 7139769da37a8f..36f7aca0a33246 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSGeneratorFactory.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSGeneratorFactory.cs @@ -25,6 +25,13 @@ public ResolvedGenerator Create(TypePositionInfo info, StubCodeContext context) NotSupportedDetails = SR.InOutRefNotSupported }); } + + if (MarshallerHelpers.GetMarshalDirection(info, context) != MarshalDirection.UnmanagedToManaged && info.ManagedIndex == TypePositionInfo.UnsetIndex) + { + // Use the InitOnlyJSGenerator for native-only parameters. + return ResolvedGenerator.Resolved(new ImplicitArgumentGenerator(info, context)); + } + return Create(info, info.MarshallingAttributeInfo as JSMarshallingInfo, context).Generator; } diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs index d1b6c5ef5e6b04..9c41af50a1d523 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs @@ -201,9 +201,55 @@ private static (MemberDeclarationSyntax, ImmutableArray) Generat { var diagnostics = new GeneratorDiagnosticsBag(new DescriptorProvider(), incrementalContext.DiagnosticLocation, SR.ResourceManager, typeof(FxResources.Microsoft.Interop.JavaScript.JSImportGenerator.SR)); + // We need to add the implicit exception and return arguments to the signature and ensure they are initialized before we start to do any marshalling. + const int NumImplicitArguments = 2; + + ImmutableArray originalElementInfo = incrementalContext.SignatureContext.SignatureContext.ElementTypeInformation; + + ImmutableArray.Builder typeInfoBuilder = ImmutableArray.CreateBuilder(originalElementInfo.Length + NumImplicitArguments); + + TypePositionInfo nativeOnlyParameterTemplate = new TypePositionInfo( + SpecialTypeInfo.Void, + new JSMarshallingInfo( + NoMarshallingInfo.Instance, + new JSInvalidTypeInfo())) + { + ManagedIndex = TypePositionInfo.UnsetIndex, + }; + + typeInfoBuilder.Add( + // Add the exception argument + nativeOnlyParameterTemplate with + { + InstanceIdentifier = Constants.ArgumentException, + NativeIndex = 0, + }); + + typeInfoBuilder.Add( + // Add the incoming return argument + nativeOnlyParameterTemplate with + { + InstanceIdentifier = Constants.ArgumentReturn, + NativeIndex = 1, + }); + + foreach (var info in originalElementInfo) + { + if (info.IsNativeReturnPosition) + { + typeInfoBuilder.Add(info); + } + else + { + typeInfoBuilder.Add(info with { NativeIndex = info.NativeIndex + NumImplicitArguments }); + } + } + + ImmutableArray finalElementInfo = typeInfoBuilder.ToImmutable(); + // Generate stub code var stubGenerator = new ManagedToNativeStubGenerator( - incrementalContext.SignatureContext.SignatureContext.ElementTypeInformation, + finalElementInfo, setLastError: false, diagnostics, new CompositeMarshallingGeneratorResolver( @@ -258,14 +304,6 @@ private static LocalFunctionStatementSyntax GenerateInvokeFunction(string functi Block( List( [ - Declare(jsMarshalerArgument, Constants.ArgumentException, true), - MethodInvocationStatement( - IdentifierName(Constants.ArgumentException), - IdentifierName("Initialize")), - Declare(jsMarshalerArgument, Constants.ArgumentReturn, true), - MethodInvocationStatement( - IdentifierName(Constants.ArgumentReturn), - IdentifierName("Initialize")), Declare(SpanOf(jsMarshalerArgument), Constants.ArgumentsBuffer, StackAllocArrayCreationExpression( ArrayType(jsMarshalerArgument) @@ -275,12 +313,8 @@ private static LocalFunctionStatementSyntax GenerateInvokeFunction(string functi InitializerExpression( SyntaxKind.ArrayInitializerExpression, SeparatedList( - (IEnumerable)[ - IdentifierName(Constants.ArgumentException), - IdentifierName(Constants.ArgumentReturn), - ..parameters.Parameters - .Select(p => IdentifierName(p.Identifier)) - ])))), + parameters.Parameters + .Select(p => (ExpressionSyntax)IdentifierName(p.Identifier)))))), MethodInvocationStatement( IdentifierName(Constants.JSFunctionSignatureGlobal), IdentifierName("InvokeJS"), 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 163b55ea055884..5d319807d021db 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 @@ -42,12 +42,11 @@ public virtual IEnumerable Generate(StubIdentifierContext conte var (_, js) = context.GetIdentifiers(TypeInfo); return [ ExpressionStatement( - AssignmentExpression( - SyntaxKind.SimpleAssignmentExpression, - IdentifierName(js), - LiteralExpression(SyntaxKind.DefaultLiteralExpression) - ) - ) + InvocationExpression( + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(js), + IdentifierName("Initialize")), + ArgumentList())) ]; } diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/ImplicitArgumentGenerator.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/ImplicitArgumentGenerator.cs new file mode 100644 index 00000000000000..c6f0cce2d176ee --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/ImplicitArgumentGenerator.cs @@ -0,0 +1,33 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; +using System.Text; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; + +namespace Microsoft.Interop.JavaScript +{ + internal sealed class ImplicitArgumentGenerator(TypePositionInfo info, StubCodeContext codeContext) : BaseJSGenerator(info, codeContext) + { + public override IEnumerable Generate(StubIdentifierContext context) + { + if (context.CurrentStage == StubIdentifierContext.Stage.Setup) + { + var (_, js) = context.GetIdentifiers(TypeInfo); + return [ + ExpressionStatement( + InvocationExpression( + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, + IdentifierName(js), + IdentifierName("Initialize")), + ArgumentList())) + ]; + } + + return []; + } + } +} 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 bf9cc9f7e2d40c..916d74dee55bfb 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 @@ -75,6 +75,8 @@ internal static partial void Annotated(object a1, long a2, long a3, global::Syst } { + global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument ____arg_exception_native; + global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument ____arg_return_native; global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a1_native; global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a2_native; global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a3_native; @@ -91,21 +93,23 @@ internal static partial void Annotated(object a1, long a2, long a3, global::Syst global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a14_native; global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a15_native; // Setup - Perform required setup. - __a15_native = default; - __a14_native = default; - __a13_native = default; - __a12_native = default; - __a11_native = default; - __a10_native = default; - __a9_native = default; - __a8_native = default; - __a7_native = default; - __a6_native = default; - __a5_native = default; - __a4_native = default; - __a3_native = default; - __a2_native = default; - __a1_native = default; + __a15_native.Initialize(); + __a14_native.Initialize(); + __a13_native.Initialize(); + __a12_native.Initialize(); + __a11_native.Initialize(); + __a10_native.Initialize(); + __a9_native.Initialize(); + __a8_native.Initialize(); + __a7_native.Initialize(); + __a6_native.Initialize(); + __a5_native.Initialize(); + __a4_native.Initialize(); + __a3_native.Initialize(); + __a2_native.Initialize(); + __a1_native.Initialize(); + ____arg_return_native.Initialize(); + ____arg_exception_native.Initialize(); // Marshal - Convert managed data to native data. __a11_native.ToJS(a11); __a10_native.ToJS(a10); @@ -142,21 +146,17 @@ internal static partial void Annotated(object a1, long a2, long a3, global::Syst __delegate_arg_arg1.ToJS(__delegate_arg1); }); __a4_native.ToJS(a4); - __InvokeJSFunction(__a1_native, __a2_native, __a3_native, __a4_native, __a5_native, __a6_native, __a7_native, __a8_native, __a9_native, __a10_native, __a11_native, __a12_native, __a13_native, __a14_native, __a15_native); + __InvokeJSFunction(____arg_exception_native, ____arg_return_native, __a1_native, __a2_native, __a3_native, __a4_native, __a5_native, __a6_native, __a7_native, __a8_native, __a9_native, __a10_native, __a11_native, __a12_native, __a13_native, __a14_native, __a15_native); } } [global::System.Diagnostics.DebuggerNonUserCode] - global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __InvokeJSFunction(global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a1_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a2_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a3_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a4_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a5_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a6_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a7_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a8_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a9_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a10_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a11_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a12_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a13_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a14_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a15_native) + global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __InvokeJSFunction(global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument ____arg_exception_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument ____arg_return_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a1_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a2_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a3_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a4_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a5_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a6_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a7_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a8_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a9_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a10_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a11_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a12_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a13_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a14_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a15_native) { - global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __arg_exception = default; - __arg_exception.Initialize(); - global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __arg_return = default; - __arg_return.Initialize(); global::System.Span __arguments_buffer = stackalloc global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument[] { - __arg_exception, - __arg_return, + ____arg_exception_native, + ____arg_return_native, __a1_native, __a2_native, __a3_native, @@ -313,10 +313,15 @@ unsafe partial class Basic } { + global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument ____arg_exception_native; + global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument ____arg_return_native; global::System.Threading.Tasks.Task __retVal; global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __retVal_native; + // Setup - Perform required setup. + ____arg_return_native.Initialize(); + ____arg_exception_native.Initialize(); { - __retVal_native = __InvokeJSFunction(); + __retVal_native = __InvokeJSFunction(____arg_exception_native, ____arg_return_native); } // UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception. @@ -328,16 +333,12 @@ unsafe partial class Basic } [global::System.Diagnostics.DebuggerNonUserCode] - global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __InvokeJSFunction() + global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __InvokeJSFunction(global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument ____arg_exception_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument ____arg_return_native) { - global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __arg_exception = default; - __arg_exception.Initialize(); - global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __arg_return = default; - __arg_return.Initialize(); global::System.Span __arguments_buffer = stackalloc global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument[] { - __arg_exception, - __arg_return + ____arg_exception_native, + ____arg_return_native }; global::System.Runtime.InteropServices.JavaScript.JSFunctionBinding.InvokeJS(__signature_Import1_622134597, __arguments_buffer); return __arguments_buffer[1]; From abee68b49404a95817e5c3c0ced65ba80ea9037d Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 31 Jan 2025 14:14:03 -0800 Subject: [PATCH 16/22] We need both initializers to satisfy C# --- .../Marshaling/BaseJSGenerator.cs | 7 +++++++ .../Marshaling/ImplicitArgumentGenerator.cs | 7 +++++++ .../JSImportGenerator.UnitTest/Compiles.cs | 19 +++++++++++++++++++ 3 files changed, 33 insertions(+) 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 5d319807d021db..3b4b06675a0f8d 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 @@ -41,6 +41,13 @@ public virtual IEnumerable Generate(StubIdentifierContext conte { var (_, js) = context.GetIdentifiers(TypeInfo); return [ + ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(js), + LiteralExpression(SyntaxKind.DefaultLiteralExpression) + ) + ), ExpressionStatement( InvocationExpression( MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/ImplicitArgumentGenerator.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/ImplicitArgumentGenerator.cs index c6f0cce2d176ee..5d9a8ab2dfc619 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/ImplicitArgumentGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/ImplicitArgumentGenerator.cs @@ -18,6 +18,13 @@ public override IEnumerable Generate(StubIdentifierContext cont { var (_, js) = context.GetIdentifiers(TypeInfo); return [ + ExpressionStatement( + AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + IdentifierName(js), + LiteralExpression(SyntaxKind.DefaultLiteralExpression) + ) + ), ExpressionStatement( InvocationExpression( MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, 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 916d74dee55bfb..98e03b40825208 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 @@ -93,22 +93,39 @@ internal static partial void Annotated(object a1, long a2, long a3, global::Syst global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a14_native; global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a15_native; // Setup - Perform required setup. + __a15_native = default; __a15_native.Initialize(); + __a14_native = default; __a14_native.Initialize(); + __a13_native = default; __a13_native.Initialize(); + __a12_native = default; __a12_native.Initialize(); + __a11_native = default; __a11_native.Initialize(); + __a10_native = default; __a10_native.Initialize(); + __a9_native = default; __a9_native.Initialize(); + __a8_native = default; __a8_native.Initialize(); + __a7_native = default; __a7_native.Initialize(); + __a6_native = default; __a6_native.Initialize(); + __a5_native = default; __a5_native.Initialize(); + __a4_native = default; __a4_native.Initialize(); + __a3_native = default; __a3_native.Initialize(); + __a2_native = default; __a2_native.Initialize(); + __a1_native = default; __a1_native.Initialize(); + ____arg_return_native = default; ____arg_return_native.Initialize(); + ____arg_exception_native = default; ____arg_exception_native.Initialize(); // Marshal - Convert managed data to native data. __a11_native.ToJS(a11); @@ -318,7 +335,9 @@ unsafe partial class Basic global::System.Threading.Tasks.Task __retVal; global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __retVal_native; // Setup - Perform required setup. + ____arg_return_native = default; ____arg_return_native.Initialize(); + ____arg_exception_native = default; ____arg_exception_native.Initialize(); { __retVal_native = __InvokeJSFunction(____arg_exception_native, ____arg_return_native); From 6c948f7d613227b1147ac41f2818c1990bb4149f Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 31 Jan 2025 16:46:37 -0800 Subject: [PATCH 17/22] Fix DateTimeOffset marshalling --- .../gen/JSImportGenerator/JSGeneratorFactory.cs | 6 +++--- .../tests/JSImportGenerator.UnitTest/Compiles.cs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) 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 36f7aca0a33246..51b6d5764b1b76 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSGeneratorFactory.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSGeneratorFactory.cs @@ -112,7 +112,7 @@ private static ResolvedGeneratorAndType Create(TypePositionInfo info, StubCodeCo (KnownManagedType.Double, JSTypeFlags.Number, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Double), MarshalerType.Double), (KnownManagedType.IntPtr, JSTypeFlags.Number, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.IntPtr), MarshalerType.IntPtr), (KnownManagedType.DateTime, JSTypeFlags.Date, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.DateTime), MarshalerType.DateTime), - (KnownManagedType.DateTimeOffset, JSTypeFlags.Date, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.DateTime), MarshalerType.DateTime), + (KnownManagedType.DateTimeOffset, JSTypeFlags.Date, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.DateTimeOffset), MarshalerType.DateTimeOffset), (KnownManagedType.Exception, JSTypeFlags.Error, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Exception), MarshalerType.Exception), (KnownManagedType.JSObject, JSTypeFlags.Object, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.JSObject), MarshalerType.JSObject), (KnownManagedType.String, JSTypeFlags.String, _, _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.String), MarshalerType.String), @@ -149,7 +149,7 @@ private static ResolvedGeneratorAndType Create(TypePositionInfo info, StubCodeCo (KnownManagedType.Nullable, JSTypeFlags.Number, [KnownManagedType.Double], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Double), MarshalerType.Nullable, [MarshalerType.Double]), (KnownManagedType.Nullable, JSTypeFlags.Number, [KnownManagedType.IntPtr], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.IntPtr), MarshalerType.Nullable, [MarshalerType.IntPtr]), (KnownManagedType.Nullable, JSTypeFlags.Date, [KnownManagedType.DateTime], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.DateTime), MarshalerType.Nullable, [MarshalerType.DateTime]), - (KnownManagedType.Nullable, JSTypeFlags.Date, [KnownManagedType.DateTimeOffset], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.DateTime), MarshalerType.Nullable, [MarshalerType.DateTime]), + (KnownManagedType.Nullable, JSTypeFlags.Date, [KnownManagedType.DateTimeOffset], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.DateTimeOffset), MarshalerType.Nullable, [MarshalerType.DateTimeOffset]), // nullable missing (KnownManagedType.Nullable, JSTypeFlags.Missing, [KnownManagedType.Boolean], _) => resolved(new PrimitiveJSGenerator(info, context, MarshalerType.Boolean), MarshalerType.Nullable, [MarshalerType.Boolean]), @@ -182,7 +182,7 @@ private static ResolvedGeneratorAndType Create(TypePositionInfo info, StubCodeCo (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Double], [JSTypeFlags.Number]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Double), MarshalerType.Task, [MarshalerType.Double]), (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.IntPtr], [JSTypeFlags.Number]) => resolved(new TaskJSGenerator(info, context, MarshalerType.IntPtr), MarshalerType.Task, [MarshalerType.IntPtr]), (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.DateTime], [JSTypeFlags.Date]) => resolved(new TaskJSGenerator(info, context, MarshalerType.DateTime), MarshalerType.Task, [MarshalerType.DateTime]), - (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.DateTimeOffset], [JSTypeFlags.Date]) => resolved(new TaskJSGenerator(info, context, MarshalerType.DateTime), MarshalerType.Task, [MarshalerType.DateTime]), + (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.DateTimeOffset], [JSTypeFlags.Date]) => resolved(new TaskJSGenerator(info, context, MarshalerType.DateTimeOffset), MarshalerType.Task, [MarshalerType.DateTimeOffset]), (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.Exception], [JSTypeFlags.Error]) => resolved(new TaskJSGenerator(info, context, MarshalerType.Exception), MarshalerType.Task, [MarshalerType.Exception]), (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.JSObject], [JSTypeFlags.Object]) => resolved(new TaskJSGenerator(info, context, MarshalerType.JSObject), MarshalerType.Task, [MarshalerType.JSObject]), (KnownManagedType.Task, JSTypeFlags.Promise, [KnownManagedType.String], [JSTypeFlags.String]) => resolved(new TaskJSGenerator(info, context, MarshalerType.String), MarshalerType.Task, [MarshalerType.String]), 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 98e03b40825208..1bf2543c0df22a 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 @@ -71,7 +71,7 @@ internal static partial void Annotated(object a1, long a2, long a3, global::Syst { if (__signature_Annotated_1583225186 == null) { - __signature_Annotated_1583225186 = global::System.Runtime.InteropServices.JavaScript.JSFunctionBinding.BindJSFunction("DoesNotExist", null, [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.DateTime, 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.DateTime), 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)]); + __signature_Annotated_1583225186 = global::System.Runtime.InteropServices.JavaScript.JSFunctionBinding.BindJSFunction("DoesNotExist", null, [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)]); } { @@ -221,7 +221,7 @@ 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", 1583225186, [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.DateTime, 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.DateTime), 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.Runtime.InteropServices.JavaScript.JSFunctionBinding.BindManagedFunction("[TestProject]Basic:AnnotatedExport", 1583225186, [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)]); } } } From 58cb6df683700f1c625c3a082b016cda5a3e5b8a Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 3 Feb 2025 12:00:17 -0800 Subject: [PATCH 18/22] Only initialize when required and make sure we initialize the exception and return marshallers before everything else. --- .../JSImportGenerator/JSImportGenerator.cs | 14 +++- .../JSImportGenerator/JSMarshallingInfo.cs | 10 +++ .../Marshaling/BaseJSGenerator.cs | 17 ++--- .../Marshaling/ImplicitArgumentGenerator.cs | 13 ++-- .../JSImportGenerator.UnitTest/Compiles.cs | 67 +++++++------------ .../BoundGenerators.cs | 2 +- .../Marshalling/MarshallerHelpers.cs | 27 -------- .../MarshallingAttributeInfo.cs | 38 ++++++++++- 8 files changed, 98 insertions(+), 90 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs index 9c41af50a1d523..baee173c9bc18e 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs @@ -235,13 +235,23 @@ nativeOnlyParameterTemplate with foreach (var info in originalElementInfo) { + TypePositionInfo updatedInfo = info with + { + MarshallingAttributeInfo = info.MarshallingAttributeInfo is JSMarshallingInfo jsInfo + ? jsInfo.AddElementDependencies([typeInfoBuilder[0], typeInfoBuilder[1]]) + : info.MarshallingAttributeInfo, + }; + if (info.IsNativeReturnPosition) { - typeInfoBuilder.Add(info); + typeInfoBuilder.Add(updatedInfo); } else { - typeInfoBuilder.Add(info with { NativeIndex = info.NativeIndex + NumImplicitArguments }); + typeInfoBuilder.Add(updatedInfo with + { + NativeIndex = updatedInfo.NativeIndex + NumImplicitArguments + }); } } diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSMarshallingInfo.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSMarshallingInfo.cs index edeb7961aadb1e..8d0ed8384486d9 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSMarshallingInfo.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSMarshallingInfo.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.CodeAnalysis; +using System.Collections.Generic; +using System.Collections.Immutable; using System.Runtime.InteropServices.JavaScript; namespace Microsoft.Interop.JavaScript @@ -16,6 +18,14 @@ protected JSMarshallingInfo() public JSTypeFlags JSType { get; init; } public JSTypeFlags[] JSTypeArguments { get; init; } + + private ImmutableArray _elementDependencies = ImmutableArray.Empty; + public override IEnumerable ElementDependencies => _elementDependencies; + + public JSMarshallingInfo AddElementDependencies(IEnumerable elementDependencies) + { + return this with { _elementDependencies = _elementDependencies.AddRange(elementDependencies) }; + } } internal sealed record JSMissingMarshallingInfo : JSMarshallingInfo 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 3b4b06675a0f8d..ab1cb7c8de5371 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 @@ -7,6 +7,8 @@ using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; +using static Microsoft.Interop.SyntaxFactoryExtensions; + namespace Microsoft.Interop.JavaScript { @@ -42,18 +44,9 @@ public virtual IEnumerable Generate(StubIdentifierContext conte var (_, js) = context.GetIdentifiers(TypeInfo); return [ ExpressionStatement( - AssignmentExpression( - SyntaxKind.SimpleAssignmentExpression, - IdentifierName(js), - LiteralExpression(SyntaxKind.DefaultLiteralExpression) - ) - ), - ExpressionStatement( - InvocationExpression( - MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - IdentifierName(js), - IdentifierName("Initialize")), - ArgumentList())) + MethodInvocation(TypeSyntaxes.System_Runtime_CompilerServices_Unsafe, IdentifierName("SkipInit"), + Argument(IdentifierName(js)) + .WithRefOrOutKeyword(Token(SyntaxKind.OutKeyword)))) ]; } diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/ImplicitArgumentGenerator.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/ImplicitArgumentGenerator.cs index 5d9a8ab2dfc619..346dfb173f1f8c 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/ImplicitArgumentGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/ImplicitArgumentGenerator.cs @@ -7,6 +7,8 @@ using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; +using static Microsoft.Interop.SyntaxFactoryExtensions; + namespace Microsoft.Interop.JavaScript { @@ -19,12 +21,11 @@ public override IEnumerable Generate(StubIdentifierContext cont var (_, js) = context.GetIdentifiers(TypeInfo); return [ ExpressionStatement( - AssignmentExpression( - SyntaxKind.SimpleAssignmentExpression, - IdentifierName(js), - LiteralExpression(SyntaxKind.DefaultLiteralExpression) - ) - ), + MethodInvocation(TypeSyntaxes.System_Runtime_CompilerServices_Unsafe, IdentifierName("SkipInit"), + Argument(IdentifierName(js)) + .WithRefOrOutKeyword(Token(SyntaxKind.OutKeyword)))), + // Unlike the other arguments, we need to initialize the implicit arguments + // as they can set some ambient state necessary for the JSImport logic to function. ExpressionStatement( InvocationExpression( MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, 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 1bf2543c0df22a..1d8295c728bb5c 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 @@ -93,40 +93,25 @@ internal static partial void Annotated(object a1, long a2, long a3, global::Syst global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a14_native; global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a15_native; // Setup - Perform required setup. - __a15_native = default; - __a15_native.Initialize(); - __a14_native = default; - __a14_native.Initialize(); - __a13_native = default; - __a13_native.Initialize(); - __a12_native = default; - __a12_native.Initialize(); - __a11_native = default; - __a11_native.Initialize(); - __a10_native = default; - __a10_native.Initialize(); - __a9_native = default; - __a9_native.Initialize(); - __a8_native = default; - __a8_native.Initialize(); - __a7_native = default; - __a7_native.Initialize(); - __a6_native = default; - __a6_native.Initialize(); - __a5_native = default; - __a5_native.Initialize(); - __a4_native = default; - __a4_native.Initialize(); - __a3_native = default; - __a3_native.Initialize(); - __a2_native = default; - __a2_native.Initialize(); - __a1_native = default; - __a1_native.Initialize(); - ____arg_return_native = default; + global::System.Runtime.CompilerServices.Unsafe.SkipInit(out ____arg_return_native); ____arg_return_native.Initialize(); - ____arg_exception_native = default; + global::System.Runtime.CompilerServices.Unsafe.SkipInit(out ____arg_exception_native); ____arg_exception_native.Initialize(); + global::System.Runtime.CompilerServices.Unsafe.SkipInit(out __a15_native); + global::System.Runtime.CompilerServices.Unsafe.SkipInit(out __a14_native); + global::System.Runtime.CompilerServices.Unsafe.SkipInit(out __a13_native); + global::System.Runtime.CompilerServices.Unsafe.SkipInit(out __a12_native); + global::System.Runtime.CompilerServices.Unsafe.SkipInit(out __a11_native); + global::System.Runtime.CompilerServices.Unsafe.SkipInit(out __a10_native); + global::System.Runtime.CompilerServices.Unsafe.SkipInit(out __a9_native); + global::System.Runtime.CompilerServices.Unsafe.SkipInit(out __a8_native); + global::System.Runtime.CompilerServices.Unsafe.SkipInit(out __a7_native); + global::System.Runtime.CompilerServices.Unsafe.SkipInit(out __a6_native); + global::System.Runtime.CompilerServices.Unsafe.SkipInit(out __a5_native); + global::System.Runtime.CompilerServices.Unsafe.SkipInit(out __a4_native); + global::System.Runtime.CompilerServices.Unsafe.SkipInit(out __a3_native); + global::System.Runtime.CompilerServices.Unsafe.SkipInit(out __a2_native); + global::System.Runtime.CompilerServices.Unsafe.SkipInit(out __a1_native); // Marshal - Convert managed data to native data. __a11_native.ToJS(a11); __a10_native.ToJS(a10); @@ -328,21 +313,21 @@ unsafe partial class Basic { __signature_Import1_622134597 = global::System.Runtime.InteropServices.JavaScript.JSFunctionBinding.BindJSFunction("DoesNotExist", null, [global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Task(global::System.Runtime.InteropServices.JavaScript.JSMarshalerType.Int32)]); } - + { global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument ____arg_exception_native; global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument ____arg_return_native; global::System.Threading.Tasks.Task __retVal; global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __retVal_native; // Setup - Perform required setup. - ____arg_return_native = default; + global::System.Runtime.CompilerServices.Unsafe.SkipInit(out ____arg_return_native); ____arg_return_native.Initialize(); - ____arg_exception_native = default; + global::System.Runtime.CompilerServices.Unsafe.SkipInit(out ____arg_exception_native); ____arg_exception_native.Initialize(); { __retVal_native = __InvokeJSFunction(____arg_exception_native, ____arg_return_native); } - + // UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception. __retVal_native.ToManaged(out __retVal, static (ref global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __task_result_arg, out int __task_result) => { @@ -350,7 +335,7 @@ unsafe partial class Basic }); return __retVal; } - + [global::System.Diagnostics.DebuggerNonUserCode] global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __InvokeJSFunction(global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument ____arg_exception_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument ____arg_return_native) { @@ -363,10 +348,10 @@ unsafe partial class Basic return __arguments_buffer[1]; } } - + static global::System.Runtime.InteropServices.JavaScript.JSFunctionBinding __signature_Import1_622134597; } - + """.ReplaceLineEndings("\r\n"), Encoding.UTF8)), (typeof(Microsoft.Interop.JavaScript.JSExportGenerator), "JSExports.g.cs", @@ -383,7 +368,7 @@ unsafe class __GeneratedInitializer static internal void __TrimmingPreserve_() { } - + [global::System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute("__Wrapper_Export1_622134597", "Basic", "TestProject")] static void __Register_() { @@ -422,7 +407,7 @@ void __Stub(global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgumen } } } - + """.ReplaceLineEndings("\r\n"), Encoding.UTF8)), } }, 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 a96a48eb180612..c517a0c0353999 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 @@ -165,7 +165,7 @@ public static BoundGenerators Create(ImmutableArray elementTyp { return Array.Empty<(bool, int)>(); } - return MarshallerHelpers.GetDependentElementsOfMarshallingInfo(info.MarshallingAttributeInfo) + return info.MarshallingAttributeInfo.ElementDependencies .Select(static info => GetInfoIndex(info)).ToImmutableArray(); } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs index d37849547d1a21..45b1ad734483dd 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs @@ -229,33 +229,6 @@ public bool AnyIncomingEdge(int to) } } - public static IEnumerable GetDependentElementsOfMarshallingInfo( - MarshallingInfo elementMarshallingInfo) - { - if (elementMarshallingInfo is NativeLinearCollectionMarshallingInfo nestedCollection) - { - if (nestedCollection.ElementCountInfo is CountElementCountInfo { ElementInfo: TypePositionInfo nestedCountElement }) - { - // Do not include dependent elements with no managed or native index. - // These values are dummy values that are inserted earlier to avoid emitting extra diagnostics. - if (nestedCountElement.ManagedIndex != TypePositionInfo.UnsetIndex || nestedCountElement.NativeIndex != TypePositionInfo.UnsetIndex) - { - yield return nestedCountElement; - } - } - foreach (KeyValuePair mode in nestedCollection.Marshallers.Modes) - { - foreach (TypePositionInfo nestedElement in GetDependentElementsOfMarshallingInfo(mode.Value.CollectionElementMarshallingInfo)) - { - if (nestedElement.ManagedIndex != TypePositionInfo.UnsetIndex || nestedElement.NativeIndex != TypePositionInfo.UnsetIndex) - { - yield return nestedElement; - } - } - } - } - } - // private static readonly InvocationExpressionSyntax SkipInitInvocation = public static StatementSyntax SkipInitOrDefaultInit(TypePositionInfo info, StubIdentifierContext context) { diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/MarshallingAttributeInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/MarshallingAttributeInfo.cs index 36f56c08bc72c1..6dcc8b97fcedb3 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/MarshallingAttributeInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/MarshallingAttributeInfo.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Collections.Generic; using System.Collections.Immutable; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; @@ -35,6 +36,8 @@ public abstract record MarshallingInfo { protected MarshallingInfo() { } + + public virtual IEnumerable ElementDependencies => []; } /// @@ -117,7 +120,40 @@ public sealed record NativeLinearCollectionMarshallingInfo( CountInfo ElementCountInfo, ManagedTypeInfo PlaceholderTypeParameter) : NativeMarshallingAttributeInfo( EntryPointType, - Marshallers); + Marshallers) + { + public override IEnumerable ElementDependencies + { + get + { + return field ??= GetElementDependencies().ToImmutableArray(); + + IEnumerable GetElementDependencies() + { + if (ElementCountInfo is CountElementCountInfo { ElementInfo: TypePositionInfo nestedCountElement }) + { + // Do not include dependent elements with no managed or native index. + // These values are dummy values that are inserted earlier to avoid emitting extra diagnostics. + if (nestedCountElement.ManagedIndex != TypePositionInfo.UnsetIndex || nestedCountElement.NativeIndex != TypePositionInfo.UnsetIndex) + { + yield return nestedCountElement; + } + } + + foreach (KeyValuePair mode in Marshallers.Modes) + { + foreach (TypePositionInfo nestedElement in mode.Value.CollectionElementMarshallingInfo.ElementDependencies) + { + if (nestedElement.ManagedIndex != TypePositionInfo.UnsetIndex || nestedElement.NativeIndex != TypePositionInfo.UnsetIndex) + { + yield return nestedElement; + } + } + } + } + } + } + } /// /// Marshal an exception based on the same rules as the built-in COM system based on the unmanaged type of the native return marshaller. From 7ebf99adf60eb62dbad9369cd9399c56a9e0f6a0 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Wed, 5 Feb 2025 15:43:58 +0100 Subject: [PATCH 19/22] ActiveIssue https://github.com/dotnet/runtime/issues/99951 --- .../System/Runtime/InteropServices/JavaScript/WebWorkerTest.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/WebWorkerTest.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/WebWorkerTest.cs index c247ef332921f3..278270b470b871 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/WebWorkerTest.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/WebWorkerTest.cs @@ -490,6 +490,7 @@ await executor.Execute(async () => } [Theory, MemberData(nameof(GetTargetThreadsAndBlockingCalls))] + [ActiveIssue("https://github.com/dotnet/runtime/issues/99951")] public async Task WaitInAsyncAssertsOnlyOnJSWebWorker(Executor executor, NamedCall method) { using var cts = CreateTestCaseTimeoutSource(); From efb608fb49a7f293079e6f71a7d4504cd7ecd424 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 5 Feb 2025 18:46:08 +0000 Subject: [PATCH 20/22] Don't return the JSMarshalerArgument from the inner invoke when the function is void. Use that to further cleanup the codegen. --- .../JSImportGenerator/JSImportGenerator.cs | 72 +++++++++++-------- .../JSImportGenerator.UnitTest/Compiles.cs | 31 +------- 2 files changed, 46 insertions(+), 57 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs index baee173c9bc18e..eb157f6ffc210f 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs @@ -233,6 +233,8 @@ nativeOnlyParameterTemplate with NativeIndex = 1, }); + bool hasReturn = false; + foreach (var info in originalElementInfo) { TypePositionInfo updatedInfo = info with @@ -245,6 +247,7 @@ nativeOnlyParameterTemplate with if (info.IsNativeReturnPosition) { typeInfoBuilder.Add(updatedInfo); + hasReturn = true; } else { @@ -276,7 +279,7 @@ nativeOnlyParameterTemplate with incrementalContext.SignatureContext, SignatureBindingHelpers.CreateSignaturesArgument(incrementalContext.SignatureContext.SignatureContext.ElementTypeInformation, StubCodeContext.DefaultManagedToNativeStub)); - LocalFunctionStatementSyntax localFunction = GenerateInvokeFunction(LocalFunctionName, incrementalContext.SignatureContext, stubGenerator); + LocalFunctionStatementSyntax localFunction = GenerateInvokeFunction(LocalFunctionName, incrementalContext.SignatureContext, stubGenerator, hasReturn); return (PrintGeneratedSource(incrementalContext.StubMethodSyntaxTemplate, incrementalContext.SignatureContext, incrementalContext.ContainingSyntaxContext, Block(bindStatement, code, localFunction)), incrementalContext.Diagnostics.Array.AddRange(diagnostics.Diagnostics)); } @@ -302,40 +305,51 @@ private static IfStatementSyntax GenerateBindSyntax(JSImportData jsImportData, J .WithArgumentList(ArgumentList(SeparatedList(bindingParameters)))))))); } - private static LocalFunctionStatementSyntax GenerateInvokeFunction(string functionName, JSSignatureContext signatureContext, ManagedToNativeStubGenerator stubGenerator) + private static LocalFunctionStatementSyntax GenerateInvokeFunction(string functionName, JSSignatureContext signatureContext, ManagedToNativeStubGenerator stubGenerator, bool hasReturn) { var (parameters, returnType, _) = stubGenerator.GenerateTargetMethodSignatureData(); TypeSyntax jsMarshalerArgument = ParseTypeName(Constants.JSMarshalerArgumentGlobal); + LocalDeclarationStatementSyntax argumentsBuffer = CollectionExpression( + SeparatedList( + parameters.Parameters + .Select(p => ExpressionElement(IdentifierName(p.Identifier))))); + + List statements = []; + + if (hasReturn) + { + statements.AddRange([ + Declare( + SpanOf(jsMarshalerArgument), + Constants.ArgumentsBuffer, + CargumentsBuffer), + MethodInvocationStatement( + IdentifierName(Constants.JSFunctionSignatureGlobal), + IdentifierName("InvokeJS"), + Argument(IdentifierName(signatureContext.BindingName)), + Argument(IdentifierName(Constants.ArgumentsBuffer))), + ReturnStatement( + ElementAccessExpression( + IdentifierName(Constants.ArgumentsBuffer), + BracketedArgumentList(SingletonSeparatedList(Argument( + LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(1))))))) + ]); + } + else + { + statements.Add( + MethodInvocationStatement( + IdentifierName(Constants.JSFunctionSignatureGlobal), + IdentifierName("InvokeJS"), + Argument(IdentifierName(signatureContext.BindingName)), + Argument(argumentsBuffer))); + } + return LocalFunctionStatement( - jsMarshalerArgument, + hasReturn ? jsMarshalerArgument : PredefinedType(Token(SyntaxKind.VoidKeyword)), functionName) - .WithBody( - Block( - List( - [ - Declare(SpanOf(jsMarshalerArgument), Constants.ArgumentsBuffer, - StackAllocArrayCreationExpression( - ArrayType(jsMarshalerArgument) - .WithRankSpecifiers(SingletonList(ArrayRankSpecifier(SingletonSeparatedList( - OmittedArraySizeExpression()))))) - .WithInitializer( - InitializerExpression( - SyntaxKind.ArrayInitializerExpression, - SeparatedList( - parameters.Parameters - .Select(p => (ExpressionSyntax)IdentifierName(p.Identifier)))))), - MethodInvocationStatement( - IdentifierName(Constants.JSFunctionSignatureGlobal), - IdentifierName("InvokeJS"), - Argument(IdentifierName(signatureContext.BindingName)), - Argument(IdentifierName(Constants.ArgumentsBuffer))), - ReturnStatement( - ElementAccessExpression( - IdentifierName(Constants.ArgumentsBuffer), - BracketedArgumentList(SingletonSeparatedList(Argument( - LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(1))))))) - ]))) + .WithBody(Block(statements)) .WithParameterList(parameters) .WithAttributeLists(SingletonList(AttributeList(SingletonSeparatedList( Attribute(IdentifierName(Constants.DebuggerNonUserCodeAttribute)))))); 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 1d8295c728bb5c..b376bb096b6fb1 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 @@ -153,30 +153,9 @@ internal static partial void Annotated(object a1, long a2, long a3, global::Syst } [global::System.Diagnostics.DebuggerNonUserCode] - global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __InvokeJSFunction(global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument ____arg_exception_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument ____arg_return_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a1_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a2_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a3_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a4_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a5_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a6_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a7_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a8_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a9_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a10_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a11_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a12_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a13_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a14_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a15_native) + void __InvokeJSFunction(global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument ____arg_exception_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument ____arg_return_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a1_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a2_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a3_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a4_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a5_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a6_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a7_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a8_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a9_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a10_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a11_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a12_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a13_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a14_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __a15_native) { - global::System.Span __arguments_buffer = stackalloc global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument[] - { - ____arg_exception_native, - ____arg_return_native, - __a1_native, - __a2_native, - __a3_native, - __a4_native, - __a5_native, - __a6_native, - __a7_native, - __a8_native, - __a9_native, - __a10_native, - __a11_native, - __a12_native, - __a13_native, - __a14_native, - __a15_native - }; - global::System.Runtime.InteropServices.JavaScript.JSFunctionBinding.InvokeJS(__signature_Annotated_1583225186, __arguments_buffer); - return __arguments_buffer[1]; + global::System.Runtime.InteropServices.JavaScript.JSFunctionBinding.InvokeJS(__signature_Annotated_1583225186, [____arg_exception_native, ____arg_return_native, __a1_native, __a2_native, __a3_native, __a4_native, __a5_native, __a6_native, __a7_native, __a8_native, __a9_native, __a10_native, __a11_native, __a12_native, __a13_native, __a14_native, __a15_native]); } } @@ -339,11 +318,7 @@ unsafe partial class Basic [global::System.Diagnostics.DebuggerNonUserCode] global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument __InvokeJSFunction(global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument ____arg_exception_native, global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument ____arg_return_native) { - global::System.Span __arguments_buffer = stackalloc global::System.Runtime.InteropServices.JavaScript.JSMarshalerArgument[] - { - ____arg_exception_native, - ____arg_return_native - }; + global::System.Span __arguments_buffer = [____arg_exception_native, ____arg_return_native]; global::System.Runtime.InteropServices.JavaScript.JSFunctionBinding.InvokeJS(__signature_Import1_622134597, __arguments_buffer); return __arguments_buffer[1]; } From d91063b264464418deb4c6facb289b358c935d3d Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 5 Feb 2025 19:09:59 +0000 Subject: [PATCH 21/22] Fix a few typos --- .../gen/JSImportGenerator/JSImportGenerator.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs index eb157f6ffc210f..ea7606a0d0b989 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs @@ -310,7 +310,7 @@ private static LocalFunctionStatementSyntax GenerateInvokeFunction(string functi var (parameters, returnType, _) = stubGenerator.GenerateTargetMethodSignatureData(); TypeSyntax jsMarshalerArgument = ParseTypeName(Constants.JSMarshalerArgumentGlobal); - LocalDeclarationStatementSyntax argumentsBuffer = CollectionExpression( + CollectionExpressionSyntax argumentsBuffer = CollectionExpression( SeparatedList( parameters.Parameters .Select(p => ExpressionElement(IdentifierName(p.Identifier))))); @@ -323,7 +323,7 @@ private static LocalFunctionStatementSyntax GenerateInvokeFunction(string functi Declare( SpanOf(jsMarshalerArgument), Constants.ArgumentsBuffer, - CargumentsBuffer), + argumentsBuffer), MethodInvocationStatement( IdentifierName(Constants.JSFunctionSignatureGlobal), IdentifierName("InvokeJS"), From c69d83cf706fda1bc4496dfea6e428e1b6287299 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 5 Feb 2025 22:58:33 +0000 Subject: [PATCH 22/22] Correctly handle void returns --- .../gen/JSImportGenerator/JSImportGenerator.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs index ea7606a0d0b989..a92ed80b5dd732 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs @@ -244,10 +244,14 @@ nativeOnlyParameterTemplate with : info.MarshallingAttributeInfo, }; + if (info.IsManagedReturnPosition) + { + hasReturn = info.ManagedType != SpecialTypeInfo.Void; + } + if (info.IsNativeReturnPosition) { typeInfoBuilder.Add(updatedInfo); - hasReturn = true; } else {