internal sealed record IncrementalStubGenerationContext( StubEnvironment Environment, JSSignatureContext SignatureContext, ContainingSyntaxContext ContainingSyntaxContext, ContainingSyntax StubMethodSyntaxTemplate, MethodSignatureDiagnosticLocations DiagnosticLocation, JSExportData JSExportData, MarshallingGeneratorFactoryKey <(TargetFramework, Version, JSGeneratorOptions)> GeneratorFactoryKey,
/// <summary> /// Report diagnostic for configuration that cannot be forwarded to <see cref="DllImportAttribute" /> /// </summary> /// <param name="method">Method with the configuration that cannot be forwarded</param> /// <param name="name">Configuration name</param> /// <param name="value">Configuration value</param> public void ReportCannotForwardToDllImport(MethodSignatureDiagnosticLocations method, string name, string?value = null) { _diagnostics.Add( Diagnostic.Create( CannotForwardToDllImport, method.FallbackLocation, value is null ? name : $"{name}={value}")); }
internal sealed record IncrementalStubGenerationContext( StubEnvironment Environment, SignatureContext SignatureContext, ContainingSyntaxContext ContainingSyntaxContext, ContainingSyntax StubMethodSyntaxTemplate, MethodSignatureDiagnosticLocations DiagnosticLocation, ImmutableArray <AttributeSyntax> ForwardedAttributes, LibraryImportData LibraryImportData, MarshallingGeneratorFactoryKey <(TargetFramework, Version, LibraryImportGeneratorOptions)> GeneratorFactoryKey,
/// <summary> /// Report diagnostic for marshalling of a parameter/return that is not supported /// </summary> /// <param name="diagnosticLocations">Method with the parameter/return</param> /// <param name="info">Type info for the parameter/return</param> /// <param name="notSupportedDetails">[Optional] Specific reason for lack of support</param> public void ReportMarshallingNotSupported( MethodSignatureDiagnosticLocations diagnosticLocations, TypePositionInfo info, string?notSupportedDetails, ImmutableDictionary <string, string> diagnosticProperties) { Location diagnosticLocation = Location.None; string elementName = string.Empty; if (info.IsManagedReturnPosition) { diagnosticLocation = diagnosticLocations.FallbackLocation; elementName = diagnosticLocations.MethodIdentifier; } else { Debug.Assert(info.ManagedIndex <= diagnosticLocations.ManagedParameterLocations.Length); diagnosticLocation = diagnosticLocations.ManagedParameterLocations[info.ManagedIndex]; elementName = info.InstanceIdentifier; } if (!string.IsNullOrEmpty(notSupportedDetails)) { // Report the specific not-supported reason. if (info.IsManagedReturnPosition) { _diagnostics.Add( diagnosticLocation.CreateDiagnostic( GeneratorDiagnostics.ReturnTypeNotSupportedWithDetails, diagnosticProperties, notSupportedDetails !, elementName)); } else { _diagnostics.Add( diagnosticLocation.CreateDiagnostic( GeneratorDiagnostics.ParameterTypeNotSupportedWithDetails, diagnosticProperties, notSupportedDetails !, elementName)); } } else if (info.MarshallingAttributeInfo is MarshalAsInfo) { // Report that the specified marshalling configuration is not supported. // We don't forward marshalling attributes, so this is reported differently // than when there is no attribute and the type itself is not supported. if (info.IsManagedReturnPosition) { _diagnostics.Add( diagnosticLocation.CreateDiagnostic( GeneratorDiagnostics.ReturnConfigurationNotSupported, diagnosticProperties, nameof(System.Runtime.InteropServices.MarshalAsAttribute), elementName)); } else { _diagnostics.Add( diagnosticLocation.CreateDiagnostic( GeneratorDiagnostics.ParameterConfigurationNotSupported, diagnosticProperties, nameof(System.Runtime.InteropServices.MarshalAsAttribute), elementName)); } } else { // Report that the type is not supported if (info.IsManagedReturnPosition) { _diagnostics.Add( diagnosticLocation.CreateDiagnostic( GeneratorDiagnostics.ReturnTypeNotSupported, diagnosticProperties, info.ManagedType.DiagnosticFormattedName, elementName)); } else { _diagnostics.Add( diagnosticLocation.CreateDiagnostic( GeneratorDiagnostics.ParameterTypeNotSupported, diagnosticProperties, info.ManagedType.DiagnosticFormattedName, elementName)); } } }