internal sealed record IncrementalStubGenerationContext( StubEnvironment Environment, JSSignatureContext SignatureContext, ContainingSyntaxContext ContainingSyntaxContext, ContainingSyntax StubMethodSyntaxTemplate, MethodSignatureDiagnosticLocations DiagnosticLocation, JSExportData JSExportData, MarshallingGeneratorFactoryKey <(TargetFramework, Version, JSGeneratorOptions)> GeneratorFactoryKey,
public JSImportCodeGenerator( StubEnvironment environment, ImmutableArray <TypePositionInfo> argTypes, JSImportData attributeData, JSSignatureContext signatureContext, Action <TypePositionInfo, MarshallingNotSupportedException> marshallingNotSupportedCallback, IMarshallingGeneratorFactory generatorFactory) { _signatureContext = signatureContext; ManagedToNativeStubCodeContext innerContext = new ManagedToNativeStubCodeContext(environment, ReturnIdentifier, ReturnIdentifier); _context = new JSImportCodeContext(attributeData, innerContext); _marshallers = new BoundGenerators(argTypes, CreateGenerator); if (_marshallers.ManagedReturnMarshaller.Generator.UsesNativeIdentifier(_marshallers.ManagedReturnMarshaller.TypeInfo, null)) { // If we need a different native return identifier, then recreate the context with the correct identifier before we generate any code. innerContext = new ManagedToNativeStubCodeContext(environment, ReturnIdentifier, ReturnNativeIdentifier); _context = new JSImportCodeContext(attributeData, innerContext); _marshallers = new BoundGenerators(argTypes, CreateGenerator); } // validate task + span mix if (_marshallers.ManagedReturnMarshaller.TypeInfo.ManagedType is JSTaskTypeInfo) { BoundGenerator spanArg = _marshallers.AllMarshallers.FirstOrDefault(m => m.TypeInfo.ManagedType is JSSpanTypeInfo); if (spanArg != default) { marshallingNotSupportedCallback(spanArg.TypeInfo, new MarshallingNotSupportedException(spanArg.TypeInfo, _context) { NotSupportedDetails = SR.SpanAndTaskNotSupported }); } } IMarshallingGenerator CreateGenerator(TypePositionInfo p) { try { return(generatorFactory.Create(p, _context)); } catch (MarshallingNotSupportedException e) { marshallingNotSupportedCallback(p, e); return(new EmptyJSGenerator()); } } }