From 94c989db68a702295d4129ec5fe9be9a34419e6c Mon Sep 17 00:00:00 2001 From: Jackson Schuster <36744439+jtschuster@users.noreply.github.com> Date: Wed, 24 May 2023 10:44:05 -0700 Subject: [PATCH] [ComInterfaceGenerator] Warn if StringMarshalling doesn't match base and warn if base interface cannot be generated (#86467) --- .../ComInterfaceContext.cs | 53 +++- .../ComInterfaceGenerator.cs | 37 ++- .../ComInterfaceGenerator/ComInterfaceInfo.cs | 69 ++++- .../ComInterfaceGenerator/ComMethodContext.cs | 1 + .../GeneratedComInterfaceAttributeData.cs | 68 +++++ .../GeneratorDiagnostics.cs | 41 ++- .../gen/ComInterfaceGenerator/LocationInfo.cs | 29 +++ .../Resources/Strings.resx | 73 +++--- .../Resources/xlf/Strings.cs.xlf | 35 ++- .../Resources/xlf/Strings.de.xlf | 35 ++- .../Resources/xlf/Strings.es.xlf | 35 ++- .../Resources/xlf/Strings.fr.xlf | 35 ++- .../Resources/xlf/Strings.it.xlf | 35 ++- .../Resources/xlf/Strings.ja.xlf | 35 ++- .../Resources/xlf/Strings.ko.xlf | 35 ++- .../Resources/xlf/Strings.pl.xlf | 35 ++- .../Resources/xlf/Strings.pt-BR.xlf | 35 ++- .../Resources/xlf/Strings.ru.xlf | 35 ++- .../Resources/xlf/Strings.tr.xlf | 35 ++- .../Resources/xlf/Strings.zh-Hans.xlf | 35 ++- .../Resources/xlf/Strings.zh-Hant.xlf | 35 ++- .../LibraryImportData.cs | 5 +- .../InteropAttributeData.cs | 1 + .../CodeSnippets.cs | 65 +++-- .../CompileFails.cs | 243 +++++++++++++++++- .../GeneratedComInterfaceAttributeProvider.cs | 10 +- .../IComInterfaceAttributeProvider.cs | 2 +- .../IVirtualMethodIndexSignatureProvider.cs | 24 +- .../VirtualMethodIndexAttributeProvider.cs | 8 +- 29 files changed, 1006 insertions(+), 178 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/GeneratedComInterfaceAttributeData.cs create mode 100644 src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/LocationInfo.cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ComInterfaceContext.cs b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ComInterfaceContext.cs index 0eee960740269..94a8fb6285aa1 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ComInterfaceContext.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ComInterfaceContext.cs @@ -1,9 +1,13 @@ // 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.Diagnostics; using System.Threading; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; namespace Microsoft.Interop { @@ -12,15 +16,15 @@ internal sealed record ComInterfaceContext(ComInterfaceInfo Info, ComInterfaceCo /// /// Takes a list of ComInterfaceInfo, and creates a list of ComInterfaceContext. /// - public static ImmutableArray GetContexts(ImmutableArray data, CancellationToken _) + public static ImmutableArray<(ComInterfaceContext? Context, Diagnostic? Diagnostic)> GetContexts(ImmutableArray data, CancellationToken _) { - Dictionary symbolToInterfaceInfoMap = new(); - var accumulator = ImmutableArray.CreateBuilder(data.Length); + Dictionary nameToInterfaceInfoMap = new(); + var accumulator = ImmutableArray.CreateBuilder<(ComInterfaceContext? Context, Diagnostic? Diagnostic)>(data.Length); foreach (var iface in data) { - symbolToInterfaceInfoMap.Add(iface.ThisInterfaceKey, iface); + nameToInterfaceInfoMap.Add(iface.ThisInterfaceKey, iface); } - Dictionary symbolToContextMap = new(); + Dictionary nameToContextCache = new(); foreach (var iface in data) { @@ -28,9 +32,9 @@ public static ImmutableArray GetContexts(ImmutableArray data.Diagnostic is null) - .Select((data, ct) => - (data.InterfaceInfo, data.Symbol)); + .Select((data, ct) => (data.InterfaceInfo, data.Symbol)); - var interfaceContexts = interfaceSymbolsWithoutDiagnostics + var interfaceContextsAndDiagnostics = interfaceSymbolsWithoutDiagnostics .Select((data, ct) => data.InterfaceInfo!) .Collect() .SelectMany(ComInterfaceContext.GetContexts); + context.RegisterDiagnostics(interfaceContextsAndDiagnostics.Select((data, ct) => data.Diagnostic)); + var interfaceContexts = interfaceContextsAndDiagnostics + .Where(data => data.Context is not null) + .Select((data, ct) => data.Context!); + // Filter down interface symbols to remove those with diagnostics from GetContexts + interfaceSymbolsWithoutDiagnostics = interfaceSymbolsWithoutDiagnostics + .Zip(interfaceContextsAndDiagnostics) + .Where(data => data.Right.Diagnostic is null) + .Select((data, ct) => data.Left); var comMethodsAndSymbolsAndDiagnostics = interfaceSymbolsWithoutDiagnostics.Select(ComMethodInfo.GetMethodsFromInterface); context.RegisterDiagnostics(comMethodsAndSymbolsAndDiagnostics.SelectMany(static (methodList, ct) => methodList.Select(m => m.Diagnostic))); @@ -77,6 +86,10 @@ public void Initialize(IncrementalGeneratorInitializationContext context) .Zip(methodInfosGroupedByInterface) .Collect() .SelectMany(static (data, ct) => + { + return data.GroupBy(data => data.Left.GetTopLevelBase()); + }) + .SelectMany(static (data, ct) => { return ComMethodContext.CalculateAllMethods(data, ct); }); @@ -239,16 +252,6 @@ private static IncrementalMethodStubGenerationContext CalculateStubInformation(M } } - AttributeData? generatedComAttribute = null; - foreach (var attr in symbol.ContainingType.GetAttributes()) - { - if (generatedComAttribute is null - && attr.AttributeClass?.ToDisplayString() == TypeNames.GeneratedComInterfaceAttribute) - { - generatedComAttribute = attr; - } - } - var generatorDiagnostics = new GeneratorDiagnostics(); if (lcidConversionAttr is not null) @@ -257,12 +260,8 @@ private static IncrementalMethodStubGenerationContext CalculateStubInformation(M generatorDiagnostics.ReportConfigurationNotSupported(lcidConversionAttr, nameof(TypeNames.LCIDConversionAttribute)); } - var generatedComInterfaceAttributeData = new InteropAttributeCompilationData(); - if (generatedComAttribute is not null) - { - var args = generatedComAttribute.NamedArguments.ToImmutableDictionary(); - generatedComInterfaceAttributeData = generatedComInterfaceAttributeData.WithValuesFromNamedArguments(args); - } + GeneratedComInterfaceCompilationData.TryGetGeneratedComInterfaceAttributeFromInterface(symbol.ContainingType, out var generatedComAttribute); + var generatedComInterfaceAttributeData = GeneratedComInterfaceCompilationData.GetDataFromAttribute(generatedComAttribute); // Create the stub. var signatureContext = SignatureContext.Create( symbol, diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ComInterfaceInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ComInterfaceInfo.cs index 23d56f750b458..533eb8c54bb8e 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ComInterfaceInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ComInterfaceInfo.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Linq; using Microsoft.CodeAnalysis; @@ -20,7 +21,8 @@ internal sealed record ComInterfaceInfo( InterfaceDeclarationSyntax Declaration, ContainingSyntaxContext TypeDefinitionContext, ContainingSyntax ContainingSyntax, - Guid InterfaceId) + Guid InterfaceId, + LocationInfo DiagnosticLocation) { public static (ComInterfaceInfo? Info, Diagnostic? Diagnostic) From(INamedTypeSymbol symbol, InterfaceDeclarationSyntax syntax) { @@ -58,14 +60,63 @@ public static (ComInterfaceInfo? Info, Diagnostic? Diagnostic) From(INamedTypeSy if (!TryGetBaseComInterface(symbol, syntax, out INamedTypeSymbol? baseSymbol, out Diagnostic? baseDiagnostic)) return (null, baseDiagnostic); - return (new ComInterfaceInfo( - ManagedTypeInfo.CreateTypeInfoForTypeSymbol(symbol), - symbol.ToDisplayString(), - baseSymbol?.ToDisplayString(), - syntax, - new ContainingSyntaxContext(syntax), - new ContainingSyntax(syntax.Modifiers, syntax.Kind(), syntax.Identifier, syntax.TypeParameterList), - guid ?? Guid.Empty), null); + if (!StringMarshallingIsValid(symbol, syntax, baseSymbol, out Diagnostic? stringMarshallingDiagnostic)) + return (null, stringMarshallingDiagnostic); + + return ( + new ComInterfaceInfo( + ManagedTypeInfo.CreateTypeInfoForTypeSymbol(symbol), + symbol.ToDisplayString(), + baseSymbol?.ToDisplayString(), + syntax, + new ContainingSyntaxContext(syntax), + new ContainingSyntax(syntax.Modifiers, syntax.Kind(), syntax.Identifier, syntax.TypeParameterList), + guid ?? Guid.Empty, + LocationInfo.From(symbol)), + null); + } + + private static bool StringMarshallingIsValid(INamedTypeSymbol symbol, InterfaceDeclarationSyntax syntax, INamedTypeSymbol? baseSymbol, [NotNullWhen(false)] out Diagnostic? stringMarshallingDiagnostic) + { + var attrInfo = GeneratedComInterfaceData.From(GeneratedComInterfaceCompilationData.GetAttributeDataFromInterfaceSymbol(symbol)); + if (attrInfo.IsUserDefined.HasFlag(InteropAttributeMember.StringMarshalling) || attrInfo.IsUserDefined.HasFlag(InteropAttributeMember.StringMarshallingCustomType)) + { + if (attrInfo.StringMarshalling is StringMarshalling.Custom && attrInfo.StringMarshallingCustomType is null) + { + stringMarshallingDiagnostic = Diagnostic.Create( + GeneratorDiagnostics.InvalidStringMarshallingConfigurationOnInterface, + syntax.Identifier.GetLocation(), + symbol.ToDisplayString(), + SR.InvalidStringMarshallingConfigurationMissingCustomType); + return false; + } + if (attrInfo.StringMarshalling is not StringMarshalling.Custom && attrInfo.StringMarshallingCustomType is not null) + { + stringMarshallingDiagnostic = Diagnostic.Create( + GeneratorDiagnostics.InvalidStringMarshallingConfigurationOnInterface, + syntax.Identifier.GetLocation(), + symbol.ToDisplayString(), + SR.InvalidStringMarshallingConfigurationNotCustom); + return false; + } + } + if (baseSymbol is not null) + { + var baseAttrInfo = GeneratedComInterfaceData.From(GeneratedComInterfaceCompilationData.GetAttributeDataFromInterfaceSymbol(baseSymbol)); + // The base can be undefined string marshalling + if ((baseAttrInfo.IsUserDefined.HasFlag(InteropAttributeMember.StringMarshalling) || baseAttrInfo.IsUserDefined.HasFlag(InteropAttributeMember.StringMarshallingCustomType)) + && baseAttrInfo != attrInfo) + { + stringMarshallingDiagnostic = Diagnostic.Create( + GeneratorDiagnostics.InvalidStringMarshallingMismatchBetweenBaseAndDerived, + syntax.Identifier.GetLocation(), + symbol.ToDisplayString(), + SR.GeneratedComInterfaceStringMarshallingMustMatchBase); + return false; + } + } + stringMarshallingDiagnostic = null; + return true; } /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ComMethodContext.cs b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ComMethodContext.cs index daf7c149adf92..f4aa8979a5a1f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ComMethodContext.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ComMethodContext.cs @@ -109,6 +109,7 @@ private MethodDeclarationSyntax CreateUnreachableExceptionStub() .WithAttributeLists(List()) .WithExplicitInterfaceSpecifier(ExplicitInterfaceSpecifier( ParseName(OriginalDeclaringInterface.Info.Type.FullTypeName))) + .WithParameterList(ParameterList(SeparatedList(GenerationContext.SignatureContext.StubParameters))) .WithExpressionBody(ArrowExpressionClause( ThrowExpression( ObjectCreationExpression( diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/GeneratedComInterfaceAttributeData.cs b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/GeneratedComInterfaceAttributeData.cs new file mode 100644 index 0000000000000..f8c42b2c97852 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/GeneratedComInterfaceAttributeData.cs @@ -0,0 +1,68 @@ +// 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.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Text; +using Microsoft.CodeAnalysis; + +namespace Microsoft.Interop +{ + /// + /// Contains the data related to a GeneratedComInterfaceAttribute, without references to Roslyn symbols. + /// See for a type with a reference to the StringMarshallingCustomType + /// + internal sealed record GeneratedComInterfaceData : InteropAttributeData + { + public static GeneratedComInterfaceData From(GeneratedComInterfaceCompilationData generatedComInterfaceAttr) + => new GeneratedComInterfaceData() with + { + IsUserDefined = generatedComInterfaceAttr.IsUserDefined, + SetLastError = generatedComInterfaceAttr.SetLastError, + StringMarshalling = generatedComInterfaceAttr.StringMarshalling, + StringMarshallingCustomType = generatedComInterfaceAttr.StringMarshallingCustomType is not null + ? ManagedTypeInfo.CreateTypeInfoForTypeSymbol(generatedComInterfaceAttr.StringMarshallingCustomType) + : null + }; + } + + /// + /// Contains the data related to a GeneratedComInterfaceAttribute, with references to Roslyn symbols. + /// Use instead when using for incremental compilation state to avoid keeping a compilation alive + /// + internal sealed record GeneratedComInterfaceCompilationData : InteropAttributeCompilationData + { + public static bool TryGetGeneratedComInterfaceAttributeFromInterface(INamedTypeSymbol interfaceSymbol, [NotNullWhen(true)] out AttributeData? generatedComInterfaceAttribute) + { + generatedComInterfaceAttribute = null; + foreach (var attr in interfaceSymbol.GetAttributes()) + { + if (generatedComInterfaceAttribute is null + && attr.AttributeClass?.ToDisplayString() == TypeNames.GeneratedComInterfaceAttribute) + { + generatedComInterfaceAttribute = attr; + } + } + return generatedComInterfaceAttribute is not null; + } + + public static GeneratedComInterfaceCompilationData GetAttributeDataFromInterfaceSymbol(INamedTypeSymbol interfaceSymbol) + { + bool found = TryGetGeneratedComInterfaceAttributeFromInterface(interfaceSymbol, out var attr); + Debug.Assert(found); + return GetDataFromAttribute(attr); + } + + public static GeneratedComInterfaceCompilationData GetDataFromAttribute(AttributeData attr) + { + Debug.Assert(attr.AttributeClass.ToDisplayString() == TypeNames.GeneratedComInterfaceAttribute); + var generatedComInterfaceAttributeData = new GeneratedComInterfaceCompilationData(); + var args = attr.NamedArguments.ToImmutableDictionary(); + generatedComInterfaceAttributeData = generatedComInterfaceAttributeData.WithValuesFromNamedArguments(args); + return generatedComInterfaceAttributeData; + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/GeneratorDiagnostics.cs b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/GeneratorDiagnostics.cs index 69e6d9187ab2e..2c47e3f5daacf 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/GeneratorDiagnostics.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/GeneratorDiagnostics.cs @@ -24,6 +24,7 @@ public class Ids public const string InvalidGeneratedComInterfaceAttributeUsage = Prefix + "1092"; public const string MultipleComInterfaceBaseTypes = Prefix + "1093"; public const string AnalysisFailed = Prefix + "1094"; + public const string BaseInterfaceFailedGeneration = Prefix + "1095"; } private const string Category = "ComInterfaceGenerator"; @@ -58,11 +59,31 @@ public class Ids isEnabledByDefault: true, description: GetResourceString(nameof(SR.InvalidAttributedMethodDescription))); - public static readonly DiagnosticDescriptor InvalidStringMarshallingConfiguration = + public static readonly DiagnosticDescriptor InvalidStringMarshallingMismatchBetweenBaseAndDerived = + new DiagnosticDescriptor( + Ids.InvalidGeneratedComInterfaceAttributeUsage, + GetResourceString(nameof(SR.InvalidGeneratedComInterfaceAttributeUsageTitle)), + GetResourceString(nameof(SR.InvalidStringMarshallingConfigurationOnInterfaceMessage)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: GetResourceString(nameof(SR.GeneratedComInterfaceStringMarshallingMustMatchBase))); + + public static readonly DiagnosticDescriptor InvalidStringMarshallingConfigurationOnMethod = new DiagnosticDescriptor( Ids.InvalidLibraryImportAttributeUsage, GetResourceString(nameof(SR.InvalidVirtualMethodIndexAttributeUsage)), - GetResourceString(nameof(SR.InvalidStringMarshallingConfigurationMessage)), + GetResourceString(nameof(SR.InvalidStringMarshallingConfigurationOnMethodMessage)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: GetResourceString(nameof(SR.InvalidStringMarshallingConfigurationDescription))); + + public static readonly DiagnosticDescriptor InvalidStringMarshallingConfigurationOnInterface = + new DiagnosticDescriptor( + Ids.InvalidGeneratedComInterfaceAttributeUsage, + GetResourceString(nameof(SR.InvalidGeneratedComInterfaceAttributeUsageTitle)), + GetResourceString(nameof(SR.InvalidStringMarshallingConfigurationOnInterfaceMessage)), Category, DiagnosticSeverity.Error, isEnabledByDefault: true, @@ -214,7 +235,7 @@ public class Ids GetResourceString(nameof(SR.AnalysisFailedTitle)), GetResourceString(nameof(SR.AnalysisFailedMethodMessage)), Category, - DiagnosticSeverity.Warning, + DiagnosticSeverity.Error, isEnabledByDefault: true, description: GetResourceString(nameof(SR.AnalysisFailedDescription))); @@ -224,10 +245,20 @@ public class Ids GetResourceString(nameof(SR.AnalysisFailedTitle)), GetResourceString(nameof(SR.AnalysisFailedInterfaceMessage)), Category, - DiagnosticSeverity.Warning, + DiagnosticSeverity.Error, isEnabledByDefault: true, description: GetResourceString(nameof(SR.AnalysisFailedDescription))); + public static readonly DiagnosticDescriptor BaseInterfaceIsNotGenerated = + new DiagnosticDescriptor( + Ids.BaseInterfaceFailedGeneration, + GetResourceString(nameof(SR.BaseInterfaceCannotBeGeneratedTitle)), + GetResourceString(nameof(SR.BaseInterfaceCannotBeGeneratedMessage)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: GetResourceString(nameof(SR.BaseInterfaceCannotBeGeneratedDescription))); + private readonly List _diagnostics = new List(); public IEnumerable Diagnostics => _diagnostics; @@ -246,7 +277,7 @@ public void ReportInvalidStringMarshallingConfiguration( { _diagnostics.Add( attributeData.CreateDiagnostic( - GeneratorDiagnostics.InvalidStringMarshallingConfiguration, + GeneratorDiagnostics.InvalidStringMarshallingConfigurationOnMethod, methodName, detailsMessage)); } diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/LocationInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/LocationInfo.cs new file mode 100644 index 0000000000000..982e1ca75bc6a --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/LocationInfo.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Text; + +namespace Microsoft.Interop +{ + /// + /// Contains data required to reconstruct a without keeping any symbols or references to a + /// + internal sealed record LocationInfo( + LinePositionSpan LinePositionSpan, + string FilePath, + TextSpan TextSpan) + { + public Location AsLocation() => Location.Create(FilePath, TextSpan, LinePositionSpan); + + public static LocationInfo From(ISymbol symbol) + { + var location = symbol.Locations[0]; + var lineSpan = location.GetLineSpan().Span; + var filePath = location.SourceTree.FilePath; + var textSpan = location.SourceSpan; + + return new LocationInfo(lineSpan, filePath, textSpan); + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/Strings.resx b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/Strings.resx index ad3eaf5ec2bec..f797fced9f31a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/Strings.resx +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/Strings.resx @@ -1,17 +1,17 @@  - @@ -141,7 +141,7 @@ The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' is invalid. - + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} {1} is a message containing additional details about what is not valid @@ -252,4 +252,19 @@ Analysis for generation has failed. - + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface. + + + COM interface source generation requires all base COM interfaces to be valid interfaces. Fix any issues on the base interface to resolve this diagnostic. + + + COM interface {0} inherits from {1}, which has errors. ComInterfaceGenerator will not generate source for {0}. + + + The base COM interface failed to generate source. ComInterfaceGenerator will not generate source for this interface. + + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on interface '{0}' is invalid. {1} + + \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.cs.xlf b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.cs.xlf index 04074dec8feb6..1c0d66c7781aa 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.cs.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.cs.xlf @@ -22,6 +22,21 @@ Analýza pro generování se nezdařila + + COM interface source generation requires all base COM interfaces to be valid interfaces. Fix any issues on the base interface to resolve this diagnostic. + COM interface source generation requires all base COM interfaces to be valid interfaces. Fix any issues on the base interface to resolve this diagnostic. + + + + COM interface {0} inherits from {1}, which has errors. ComInterfaceGenerator will not generate source for {0}. + COM interface {0} inherits from {1}, which has errors. ComInterfaceGenerator will not generate source for {0}. + + + + The base COM interface failed to generate source. ComInterfaceGenerator will not generate source for this interface. + The base COM interface failed to generate source. ComInterfaceGenerator will not generate source for this interface. + + Source-generated COM will ignore any configuration that is not supported. Zdrojem generovaná volání P/Invokes budou ignorovat všechny nepodporované konfigurace. @@ -57,6 +72,11 @@ Určenou konfiguraci nepodporují zdrojem generovaná volání P/Invokes. + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface. + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface. + + Using 'GeneratedComInterfaceAttribute' and 'InterfaceTypeAttribute' is not supported with 'ComInterfaceType' value '{0}'. Použití GeneratedComInterfaceAttribute a InterfaceTypeAttribute se nepodporuje s hodnotou ComInterfaceType {0}. @@ -137,11 +157,6 @@ Konfigurace StringMarshalling a StringMarshallingCustomType je neplatná. - - The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} - Konfigurace StringMarshalling a StringMarshallingCustomType u metody {0} je neplatná. {1} - {1} is a message containing additional details about what is not valid - 'StringMarshallingCustomType' must be specified when 'StringMarshalling' is set to 'StringMarshalling.Custom'. StringMarshallingCustomType musí být určený, pokud je StringMarshalling nastavený na StringMarshalling.Custom. @@ -152,6 +167,16 @@ StringMarshalling by měl být nastavený na StringMarshalling.Custom, když je pokud je určený StringMarshallingCustomType. + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on interface '{0}' is invalid. {1} + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on interface '{0}' is invalid. {1} + + + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} + {1} is a message containing additional details about what is not valid + Invalid 'VirtualMethodIndexAttribute' usage Neplatné použití VirtualMethodIndexAttribute diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.de.xlf b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.de.xlf index f87f9a59d34f1..1f498be82346a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.de.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.de.xlf @@ -22,6 +22,21 @@ Fehler bei der Analyse für die Generierung. + + COM interface source generation requires all base COM interfaces to be valid interfaces. Fix any issues on the base interface to resolve this diagnostic. + COM interface source generation requires all base COM interfaces to be valid interfaces. Fix any issues on the base interface to resolve this diagnostic. + + + + COM interface {0} inherits from {1}, which has errors. ComInterfaceGenerator will not generate source for {0}. + COM interface {0} inherits from {1}, which has errors. ComInterfaceGenerator will not generate source for {0}. + + + + The base COM interface failed to generate source. ComInterfaceGenerator will not generate source for this interface. + The base COM interface failed to generate source. ComInterfaceGenerator will not generate source for this interface. + + Source-generated COM will ignore any configuration that is not supported. Quellgenerierte P/Invokes ignorieren alle Konfigurationen, die nicht unterstützt werden. @@ -57,6 +72,11 @@ Die angegebene Konfiguration wird von quellgenerierten P/Invokes nicht unterstützt. + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface. + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface. + + Using 'GeneratedComInterfaceAttribute' and 'InterfaceTypeAttribute' is not supported with 'ComInterfaceType' value '{0}'. Die Verwendung von „GeneratedComInterfaceAttribute“ und „InterfaceTypeAttribute“ wird mit dem ComInterfaceType-Wert „{0}“ nicht unterstützt. @@ -137,11 +157,6 @@ Die Konfiguration von \"StringMarshalling\" und \"StringMarshallingCustomType\" ist ungültig. - - The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} - Die Konfiguration von \"StringMarshalling\" und \"StringMarshallingCustomType\" für die Methode \"{0}\" ist ungültig. {1} - {1} is a message containing additional details about what is not valid - 'StringMarshallingCustomType' must be specified when 'StringMarshalling' is set to 'StringMarshalling.Custom'. \"StringMarshallingCustomType\" muss angegeben werden, wenn \"StringMarshalling\" auf \"StringMarshalling.Custom\" festgelegt ist. @@ -152,6 +167,16 @@ \"StringMarshalling\" muss auf \"StringMarshalling.Custom\" festgelegt werden, wenn \"StringMarshallingCustomType\" angegeben ist. + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on interface '{0}' is invalid. {1} + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on interface '{0}' is invalid. {1} + + + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} + {1} is a message containing additional details about what is not valid + Invalid 'VirtualMethodIndexAttribute' usage Ungültige Verwendung von „VirtualMethodIndexAttribute“ diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.es.xlf b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.es.xlf index ab9392104f356..47607c08be7c5 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.es.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.es.xlf @@ -22,6 +22,21 @@ Error en el análisis de generación. + + COM interface source generation requires all base COM interfaces to be valid interfaces. Fix any issues on the base interface to resolve this diagnostic. + COM interface source generation requires all base COM interfaces to be valid interfaces. Fix any issues on the base interface to resolve this diagnostic. + + + + COM interface {0} inherits from {1}, which has errors. ComInterfaceGenerator will not generate source for {0}. + COM interface {0} inherits from {1}, which has errors. ComInterfaceGenerator will not generate source for {0}. + + + + The base COM interface failed to generate source. ComInterfaceGenerator will not generate source for this interface. + The base COM interface failed to generate source. ComInterfaceGenerator will not generate source for this interface. + + Source-generated COM will ignore any configuration that is not supported. Los P/Invoke de un generador de código fuente omitirán cualquier configuración que no esté admitida. @@ -57,6 +72,11 @@ La configuración especificada no está admitida por P/Invokes de un generador de código fuente. + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface. + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface. + + Using 'GeneratedComInterfaceAttribute' and 'InterfaceTypeAttribute' is not supported with 'ComInterfaceType' value '{0}'. No se admite el uso de "GeneratedComInterfaceAttribute" e "InterfaceTypeAttribute" con el valor "ComInterfaceType" '{0}'. @@ -137,11 +157,6 @@ La configuración de “StringMarshalling” y “StringMarshallingCustomType” no es válida. - - The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} - La configuración de “StringMarshalling” y “StringMarshallingCustomType” en el método “{0}” no es válida. {1} - {1} is a message containing additional details about what is not valid - 'StringMarshallingCustomType' must be specified when 'StringMarshalling' is set to 'StringMarshalling.Custom'. Se debe especificar “StringMarshallingCustomType” cuando “StringMarshalling” esté establecido en “StringMarshalling.Custom”. @@ -152,6 +167,16 @@ “StringMarshalling” debe establecerse en “StringMarshalling.Custom” cuando “StringMarshallingCustomType” esté especificado. + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on interface '{0}' is invalid. {1} + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on interface '{0}' is invalid. {1} + + + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} + {1} is a message containing additional details about what is not valid + Invalid 'VirtualMethodIndexAttribute' usage Uso de ”VirtualMethodIndexAttribute” no válido diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.fr.xlf b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.fr.xlf index fa3d3b320ecd8..6d23021f51585 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.fr.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.fr.xlf @@ -22,6 +22,21 @@ Échec de l’analyse de la génération. + + COM interface source generation requires all base COM interfaces to be valid interfaces. Fix any issues on the base interface to resolve this diagnostic. + COM interface source generation requires all base COM interfaces to be valid interfaces. Fix any issues on the base interface to resolve this diagnostic. + + + + COM interface {0} inherits from {1}, which has errors. ComInterfaceGenerator will not generate source for {0}. + COM interface {0} inherits from {1}, which has errors. ComInterfaceGenerator will not generate source for {0}. + + + + The base COM interface failed to generate source. ComInterfaceGenerator will not generate source for this interface. + The base COM interface failed to generate source. ComInterfaceGenerator will not generate source for this interface. + + Source-generated COM will ignore any configuration that is not supported. Les P/Invokes générés par la source ignorent toute configuration qui n’est pas prise en charge. @@ -57,6 +72,11 @@ La configuration spécifiée n’est pas prise en charge par les P/Invokes générés par la source. + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface. + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface. + + Using 'GeneratedComInterfaceAttribute' and 'InterfaceTypeAttribute' is not supported with 'ComInterfaceType' value '{0}'. L’utilisation de 'GeneratedComInterfaceAttribute' et 'InterfaceTypeAttribute' n’est pas prise en charge avec la valeur 'ComInterfaceType' '{0}'. @@ -137,11 +157,6 @@ La configuration de « StringMarshalling » et de « StringMarshallingCustomType » n’est pas valide. - - The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} - La configuration de « StringMarshalling » et de « StringMarshallingCustomType » n’est sur la méthode « {0} » pas valide. {1} - {1} is a message containing additional details about what is not valid - 'StringMarshallingCustomType' must be specified when 'StringMarshalling' is set to 'StringMarshalling.Custom'. « StringMarshallingCustomType » doit être spécifié quand « StringMarshalling » a la valeur « StringMarshalling.Custom ». @@ -152,6 +167,16 @@ « StringMarshalling » doit être défini sur « StringMarshalling.Custom » quand « StringMarshallingCustomType » est spécifié. + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on interface '{0}' is invalid. {1} + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on interface '{0}' is invalid. {1} + + + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} + {1} is a message containing additional details about what is not valid + Invalid 'VirtualMethodIndexAttribute' usage Utilisation de « VirtualMethodIndexAttribute » non valide diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.it.xlf b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.it.xlf index 54ebc3bd110c7..67fb4de171841 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.it.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.it.xlf @@ -22,6 +22,21 @@ L'analisi per la generazione non è riuscita. + + COM interface source generation requires all base COM interfaces to be valid interfaces. Fix any issues on the base interface to resolve this diagnostic. + COM interface source generation requires all base COM interfaces to be valid interfaces. Fix any issues on the base interface to resolve this diagnostic. + + + + COM interface {0} inherits from {1}, which has errors. ComInterfaceGenerator will not generate source for {0}. + COM interface {0} inherits from {1}, which has errors. ComInterfaceGenerator will not generate source for {0}. + + + + The base COM interface failed to generate source. ComInterfaceGenerator will not generate source for this interface. + The base COM interface failed to generate source. ComInterfaceGenerator will not generate source for this interface. + + Source-generated COM will ignore any configuration that is not supported. I P/Invoke generati dall'origine ignoreranno qualsiasi configurazione non supportata. @@ -57,6 +72,11 @@ La configurazione specificata non è supportata dai P/Invoke generati dall'origine. + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface. + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface. + + Using 'GeneratedComInterfaceAttribute' and 'InterfaceTypeAttribute' is not supported with 'ComInterfaceType' value '{0}'. L'uso di 'GeneratedComInterfaceAttribute' e 'InterfaceTypeAttribute' non è supportato con il valore '{0}' di 'ComInterfaceType'. @@ -137,11 +157,6 @@ La configurazione di 'StringMarshalling' e 'StringMarshallingCustomType' non è valida. - - The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} - La configurazione di 'StringMarshalling' e 'StringMarshallingCustomType' nel metodo '{0}' non è valida. {1} - {1} is a message containing additional details about what is not valid - 'StringMarshallingCustomType' must be specified when 'StringMarshalling' is set to 'StringMarshalling.Custom'. È necessario specificare 'StringMarshallingCustomType' quando 'StringMarshalling' è impostato su 'StringMarshalling.Custom'. @@ -152,6 +167,16 @@ 'StringMarshalling' deve essere impostato su 'StringMarshalling.Custom' quando è specificato 'StringMarshallingCustomType'. + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on interface '{0}' is invalid. {1} + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on interface '{0}' is invalid. {1} + + + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} + {1} is a message containing additional details about what is not valid + Invalid 'VirtualMethodIndexAttribute' usage Utilizzo di 'VirtualMethodIndexAttribute' non valido diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.ja.xlf b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.ja.xlf index ee0c05e76107b..49f864b2d70f3 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.ja.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.ja.xlf @@ -22,6 +22,21 @@ 生成の分析に失敗しました。 + + COM interface source generation requires all base COM interfaces to be valid interfaces. Fix any issues on the base interface to resolve this diagnostic. + COM interface source generation requires all base COM interfaces to be valid interfaces. Fix any issues on the base interface to resolve this diagnostic. + + + + COM interface {0} inherits from {1}, which has errors. ComInterfaceGenerator will not generate source for {0}. + COM interface {0} inherits from {1}, which has errors. ComInterfaceGenerator will not generate source for {0}. + + + + The base COM interface failed to generate source. ComInterfaceGenerator will not generate source for this interface. + The base COM interface failed to generate source. ComInterfaceGenerator will not generate source for this interface. + + Source-generated COM will ignore any configuration that is not supported. ソース生成済みの P/Invoke は、サポートされていない構成を無視します。 @@ -57,6 +72,11 @@ 指定された構成は、ソースで生成された P/Invoke ではサポートされていません。 + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface. + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface. + + Using 'GeneratedComInterfaceAttribute' and 'InterfaceTypeAttribute' is not supported with 'ComInterfaceType' value '{0}'. 'GeneratedComInterfaceAttribute' および 'InterfaceTypeAttribute' は、'ComInterfaceType' の値 '{0}' ではサポートされていません。 @@ -137,11 +157,6 @@ 'StringMarshalling' と 'StringMarshallingCustomType' の構成が無効です。 - - The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} - メソッド '{0}' の 'StringMarshalling' と 'StringMarshallingCustomType' の構成が無効です。{1} - {1} is a message containing additional details about what is not valid - 'StringMarshallingCustomType' must be specified when 'StringMarshalling' is set to 'StringMarshalling.Custom'. 'StringMarshalling' が 'StringMarshalling.Custom' に設定されている場合は、'StringMarshallingCustomType' を指定する必要があります。 @@ -152,6 +167,16 @@ 'StringMarshallingCustomType' が指定されている場合、'StringMarshalling' を 'StringMarshalling.Custom' に設定する必要があります。 + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on interface '{0}' is invalid. {1} + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on interface '{0}' is invalid. {1} + + + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} + {1} is a message containing additional details about what is not valid + Invalid 'VirtualMethodIndexAttribute' usage 'VirtualMethodIndexAttribute' の使用法が無効です diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.ko.xlf b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.ko.xlf index 36208a9df18ee..cc35991644b7d 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.ko.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.ko.xlf @@ -22,6 +22,21 @@ 생성에 필요한 분석이 실패했습니다. + + COM interface source generation requires all base COM interfaces to be valid interfaces. Fix any issues on the base interface to resolve this diagnostic. + COM interface source generation requires all base COM interfaces to be valid interfaces. Fix any issues on the base interface to resolve this diagnostic. + + + + COM interface {0} inherits from {1}, which has errors. ComInterfaceGenerator will not generate source for {0}. + COM interface {0} inherits from {1}, which has errors. ComInterfaceGenerator will not generate source for {0}. + + + + The base COM interface failed to generate source. ComInterfaceGenerator will not generate source for this interface. + The base COM interface failed to generate source. ComInterfaceGenerator will not generate source for this interface. + + Source-generated COM will ignore any configuration that is not supported. 소스 생성 P/Invoke는 지원되지 않는 구성을 무시합니다. @@ -57,6 +72,11 @@ 지정된 구성은 소스 생성 P/Invoke에서 지원되지 않습니다. + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface. + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface. + + Using 'GeneratedComInterfaceAttribute' and 'InterfaceTypeAttribute' is not supported with 'ComInterfaceType' value '{0}'. 'GeneratedComInterfaceAttribute' 및 'InterfaceTypeAttribute'는 'ComInterfaceType' 값 '{0}'에서 지원되지 않습니다. @@ -137,11 +157,6 @@ 'StringMarshalling' 및 'StringMarshallingCustomType'의 구성이 잘못되었습니다. - - The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} - '{0}' 메서드의 'StringMarshalling' 및 'StringMarshallingCustomType' 구성이 잘못되었습니다. {1} - {1} is a message containing additional details about what is not valid - 'StringMarshallingCustomType' must be specified when 'StringMarshalling' is set to 'StringMarshalling.Custom'. 'StringMarshalling'이 'StringMarshalling.Custom'으로 설정된 경우 'StringMarshallingCustomType'을 지정해야 합니다. @@ -152,6 +167,16 @@ 'StringMarshallingCustomType'이 지정된 경우 'StringMarshalling'은 'StringMarshalling.Custom'으로 설정되어야 합니다. + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on interface '{0}' is invalid. {1} + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on interface '{0}' is invalid. {1} + + + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} + {1} is a message containing additional details about what is not valid + Invalid 'VirtualMethodIndexAttribute' usage 잘못된 'VirtualMethodIndexAttribute' 사용 diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.pl.xlf b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.pl.xlf index 09d52e535401b..c9b2075eaa77a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.pl.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.pl.xlf @@ -22,6 +22,21 @@ Analiza generowania nie powiodła się. + + COM interface source generation requires all base COM interfaces to be valid interfaces. Fix any issues on the base interface to resolve this diagnostic. + COM interface source generation requires all base COM interfaces to be valid interfaces. Fix any issues on the base interface to resolve this diagnostic. + + + + COM interface {0} inherits from {1}, which has errors. ComInterfaceGenerator will not generate source for {0}. + COM interface {0} inherits from {1}, which has errors. ComInterfaceGenerator will not generate source for {0}. + + + + The base COM interface failed to generate source. ComInterfaceGenerator will not generate source for this interface. + The base COM interface failed to generate source. ComInterfaceGenerator will not generate source for this interface. + + Source-generated COM will ignore any configuration that is not supported. Funkcja P/Invokes generowana przez źródło zignoruje każdą nieobsługiwaną konfigurację. @@ -57,6 +72,11 @@ Określona konfiguracja nie jest obsługiwana przez funkcję P/Invokes generowaną przez źródło. + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface. + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface. + + Using 'GeneratedComInterfaceAttribute' and 'InterfaceTypeAttribute' is not supported with 'ComInterfaceType' value '{0}'. Użycie atrybutów „GeneratedComInterfaceAttribute” i „InterfaceTypeAttribute” nie jest obsługiwane w przypadku wartości „ComInterfaceType” „{0}”. @@ -137,11 +157,6 @@ Konfiguracja elementów „StringMarshalling” i „StringMarshallingCustomType” jest nieprawidłowa. - - The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} - Konfiguracja elementów „StringMarshalling” i „StringMarshallingCustomType” w metodzie „{0}” jest nieprawidłowa. {1} - {1} is a message containing additional details about what is not valid - 'StringMarshallingCustomType' must be specified when 'StringMarshalling' is set to 'StringMarshalling.Custom'. Element „StringMarshallingCustomType” należy określić, gdy element „StringMarshalling” ma wartość „StringMarshalling.Custom”. @@ -152,6 +167,16 @@ Element „StringMarshalling” należy ustawić na wartość „StringMarshalling.Custom”, gdy określono element „StringMarshallingCustomType”. + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on interface '{0}' is invalid. {1} + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on interface '{0}' is invalid. {1} + + + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} + {1} is a message containing additional details about what is not valid + Invalid 'VirtualMethodIndexAttribute' usage Nieprawidłowe użycie elementu "VirtualMethodIndexAttribute" diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.pt-BR.xlf b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.pt-BR.xlf index 1cc64435e9ef7..94df2644a5661 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.pt-BR.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.pt-BR.xlf @@ -22,6 +22,21 @@ Falha na análise de geração. + + COM interface source generation requires all base COM interfaces to be valid interfaces. Fix any issues on the base interface to resolve this diagnostic. + COM interface source generation requires all base COM interfaces to be valid interfaces. Fix any issues on the base interface to resolve this diagnostic. + + + + COM interface {0} inherits from {1}, which has errors. ComInterfaceGenerator will not generate source for {0}. + COM interface {0} inherits from {1}, which has errors. ComInterfaceGenerator will not generate source for {0}. + + + + The base COM interface failed to generate source. ComInterfaceGenerator will not generate source for this interface. + The base COM interface failed to generate source. ComInterfaceGenerator will not generate source for this interface. + + Source-generated COM will ignore any configuration that is not supported. P/Invokes gerados pela origem ignorarão qualquer configuração sem suporte. @@ -57,6 +72,11 @@ A configuração especificada não tem suporte de P/Invokes gerados pela origem. + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface. + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface. + + Using 'GeneratedComInterfaceAttribute' and 'InterfaceTypeAttribute' is not supported with 'ComInterfaceType' value '{0}'. Não há suporte para o uso de 'GeneratedComInterfaceAttribute' e 'InterfaceTypeAttribute' com o valor 'ComInterfaceType' '{0}'. @@ -137,11 +157,6 @@ A configuração de 'StringMarshalling' e 'StringMarshallingCustomType' é inválida. - - The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} - A configuração de 'StringMarshalling' e 'StringMarshallingCustomType' no método '{0}' é inválida. {1} - {1} is a message containing additional details about what is not valid - 'StringMarshallingCustomType' must be specified when 'StringMarshalling' is set to 'StringMarshalling.Custom'. 'StringMarshallingCustomType' deve ser especificado quando 'StringMarshalling' está definido como 'StringMarshalling.Custom'. @@ -152,6 +167,16 @@ 'StringMarshalling' deve ser definido como 'StringMarshalling.Custom' quando 'StringMarshallingCustomType' for especificado. + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on interface '{0}' is invalid. {1} + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on interface '{0}' is invalid. {1} + + + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} + {1} is a message containing additional details about what is not valid + Invalid 'VirtualMethodIndexAttribute' usage Uso inválido de 'VirtualMethodIndexAttribute' diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.ru.xlf b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.ru.xlf index 453512de37dcc..f6cb2cb3fb049 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.ru.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.ru.xlf @@ -22,6 +22,21 @@ Сбой анализа для создания. + + COM interface source generation requires all base COM interfaces to be valid interfaces. Fix any issues on the base interface to resolve this diagnostic. + COM interface source generation requires all base COM interfaces to be valid interfaces. Fix any issues on the base interface to resolve this diagnostic. + + + + COM interface {0} inherits from {1}, which has errors. ComInterfaceGenerator will not generate source for {0}. + COM interface {0} inherits from {1}, which has errors. ComInterfaceGenerator will not generate source for {0}. + + + + The base COM interface failed to generate source. ComInterfaceGenerator will not generate source for this interface. + The base COM interface failed to generate source. ComInterfaceGenerator will not generate source for this interface. + + Source-generated COM will ignore any configuration that is not supported. P/Invoke с созданием источника будут игнорировать все неподдерживаемые конфигурации. @@ -57,6 +72,11 @@ Указанная конфигурация не поддерживается в P/Invoke с созданием источника. + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface. + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface. + + Using 'GeneratedComInterfaceAttribute' and 'InterfaceTypeAttribute' is not supported with 'ComInterfaceType' value '{0}'. Использование GeneratedComInterfaceAttribute и InterfaceTypeAttribute не поддерживается со значением ComInterfaceType "{0}". @@ -137,11 +157,6 @@ Конфигурация \"StringMarshalling\" и \"StringMarshallingCustomType\" недопустима. - - The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} - Конфигурация \"StringMarshalling\" и \"StringMarshallingCustomType\" в методе \"{0}\" недопустима. {1} - {1} is a message containing additional details about what is not valid - 'StringMarshallingCustomType' must be specified when 'StringMarshalling' is set to 'StringMarshalling.Custom'. Если для \"StringMarshalling\" задано значение \"StringMarshalling.Custom\", необходимо указать \"StringMarshallingCustomType\". @@ -152,6 +167,16 @@ Если указано \"StringMarshallingCustomType\", для \"StringMarshalling\" следует задать значение \"StringMarshalling.Custom\". + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on interface '{0}' is invalid. {1} + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on interface '{0}' is invalid. {1} + + + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} + {1} is a message containing additional details about what is not valid + Invalid 'VirtualMethodIndexAttribute' usage Недопустимое использование VirtualMethodIndexAttribute diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.tr.xlf b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.tr.xlf index 437082116ea83..e9bf892c3a6aa 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.tr.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.tr.xlf @@ -22,6 +22,21 @@ Oluşturma analizi başarısız oldu. + + COM interface source generation requires all base COM interfaces to be valid interfaces. Fix any issues on the base interface to resolve this diagnostic. + COM interface source generation requires all base COM interfaces to be valid interfaces. Fix any issues on the base interface to resolve this diagnostic. + + + + COM interface {0} inherits from {1}, which has errors. ComInterfaceGenerator will not generate source for {0}. + COM interface {0} inherits from {1}, which has errors. ComInterfaceGenerator will not generate source for {0}. + + + + The base COM interface failed to generate source. ComInterfaceGenerator will not generate source for this interface. + The base COM interface failed to generate source. ComInterfaceGenerator will not generate source for this interface. + + Source-generated COM will ignore any configuration that is not supported. Kaynak tarafından oluşturulan P/Invokes desteklenmeyen yapılandırmaları yok sayar. @@ -57,6 +72,11 @@ Belirtilen yapılandırma, kaynak tarafından oluşturulan P/Invokes tarafından desteklenmiyor. + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface. + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface. + + Using 'GeneratedComInterfaceAttribute' and 'InterfaceTypeAttribute' is not supported with 'ComInterfaceType' value '{0}'. 'GeneratedComInterfaceAttribute' ve 'InterfaceTypeAttribute' kullanımı, 'ComInterfaceType' değeri '{0}' ile desteklenmiyor. @@ -137,11 +157,6 @@ 'StringMarshalling' ve 'StringMarshallingCustomType' yapılandırması geçersiz. - - The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} - '{0}' metodundaki 'StringMarshalling' ve 'StringMarshallingCustomType' yapılandırması geçersiz. {1} - {1} is a message containing additional details about what is not valid - 'StringMarshallingCustomType' must be specified when 'StringMarshalling' is set to 'StringMarshalling.Custom'. 'StringMarshalling' 'StringMarshalling.Custom' olarak ayarlandığında 'StringMarshallingCustomType' belirtilmelidir. @@ -152,6 +167,16 @@ 'StringMarshallingCustomType' belirtilirken 'StringMarshalling', 'StringMarshalling.Custom' olarak ayarlanmalıdır. + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on interface '{0}' is invalid. {1} + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on interface '{0}' is invalid. {1} + + + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} + {1} is a message containing additional details about what is not valid + Invalid 'VirtualMethodIndexAttribute' usage Geçersiz 'VirtualMethodIndexAttribute' kullanımı diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.zh-Hans.xlf b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.zh-Hans.xlf index 466366bee4ce8..8fae13efb4960 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.zh-Hans.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.zh-Hans.xlf @@ -22,6 +22,21 @@ 生成分析失败。 + + COM interface source generation requires all base COM interfaces to be valid interfaces. Fix any issues on the base interface to resolve this diagnostic. + COM interface source generation requires all base COM interfaces to be valid interfaces. Fix any issues on the base interface to resolve this diagnostic. + + + + COM interface {0} inherits from {1}, which has errors. ComInterfaceGenerator will not generate source for {0}. + COM interface {0} inherits from {1}, which has errors. ComInterfaceGenerator will not generate source for {0}. + + + + The base COM interface failed to generate source. ComInterfaceGenerator will not generate source for this interface. + The base COM interface failed to generate source. ComInterfaceGenerator will not generate source for this interface. + + Source-generated COM will ignore any configuration that is not supported. 源生成的 P/Invoke 将忽略任何不受支持的配置。 @@ -57,6 +72,11 @@ 源生成的 P/Invoke 不支持指定的配置。 + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface. + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface. + + Using 'GeneratedComInterfaceAttribute' and 'InterfaceTypeAttribute' is not supported with 'ComInterfaceType' value '{0}'. “ComInterfaceType”值“{0}”不支持使用“GeneratedComInterfaceAttribute”和“InterfaceTypeAttribute”。 @@ -137,11 +157,6 @@ “StringMarshalling” 和 “StringMarshallingCustomType” 的配置无效。 - - The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} - 方法“{0}”上的 “StringMarshalling” 和 “StringMarshallingCustomType” 的配置无效。{1} - {1} is a message containing additional details about what is not valid - 'StringMarshallingCustomType' must be specified when 'StringMarshalling' is set to 'StringMarshalling.Custom'. 在 “StringMarshalling” 设置为 “StringMarshalling.Custom” 时,必须指定 “StringMarshallingCustomType”。 @@ -152,6 +167,16 @@ 在指定 “StringMarshallingCustomType” 时,应将 “StringMarshalling” 设置为 “StringMarshalling.Custom”。 + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on interface '{0}' is invalid. {1} + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on interface '{0}' is invalid. {1} + + + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} + {1} is a message containing additional details about what is not valid + Invalid 'VirtualMethodIndexAttribute' usage “VirtualMethodIndexAttribute” 使用情况无效 diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.zh-Hant.xlf b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.zh-Hant.xlf index 5accdc6466637..1bc4bef29f222 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.zh-Hant.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.zh-Hant.xlf @@ -22,6 +22,21 @@ 產生分析失敗。 + + COM interface source generation requires all base COM interfaces to be valid interfaces. Fix any issues on the base interface to resolve this diagnostic. + COM interface source generation requires all base COM interfaces to be valid interfaces. Fix any issues on the base interface to resolve this diagnostic. + + + + COM interface {0} inherits from {1}, which has errors. ComInterfaceGenerator will not generate source for {0}. + COM interface {0} inherits from {1}, which has errors. ComInterfaceGenerator will not generate source for {0}. + + + + The base COM interface failed to generate source. ComInterfaceGenerator will not generate source for this interface. + The base COM interface failed to generate source. ComInterfaceGenerator will not generate source for this interface. + + Source-generated COM will ignore any configuration that is not supported. 来源產生的 P/Invokes 將會忽略任何不支援的設定。 @@ -57,6 +72,11 @@ 来源產生的 P/Invokes 不支援指定的設定。 + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface. + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface. + + Using 'GeneratedComInterfaceAttribute' and 'InterfaceTypeAttribute' is not supported with 'ComInterfaceType' value '{0}'. 'ComInterfaceType' 值 '{0}' 不支援使用 'GeneratedComInterfaceAttribute' 和 'InterfaceTypeAttribute'。 @@ -137,11 +157,6 @@ 'StringMarshalling' 和 'StringMarshallingCustomType' 的設定無效。 - - The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} - 方法 '{0}' 上的 'StringMarshalling' 和 'StringMarshallingCustomType' 設定無效。{1} - {1} is a message containing additional details about what is not valid - 'StringMarshallingCustomType' must be specified when 'StringMarshalling' is set to 'StringMarshalling.Custom'. 當 'StringMarshalling' 設定為 'StringMarshalling.Custom' 時,必須指定 'StringMarshallingCustomType'。 @@ -152,6 +167,16 @@ 指定 'StringMarshallingCustomType' 時,'StringMarshalling' 應設定為 'StringMarshalling.Custom'。 + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on interface '{0}' is invalid. {1} + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on interface '{0}' is invalid. {1} + + + + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} + The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' on method '{0}' is invalid. {1} + {1} is a message containing additional details about what is not valid + Invalid 'VirtualMethodIndexAttribute' usage 'VirtualMethodIndexAttribute' 使用方式無效 diff --git a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/LibraryImportData.cs b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/LibraryImportData.cs index 65691faf8beb3..16a3b0687fe5d 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/LibraryImportData.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/LibraryImportData.cs @@ -17,7 +17,10 @@ public static LibraryImportData From(LibraryImportCompilationData libraryImport) EntryPoint = libraryImport.EntryPoint, IsUserDefined = libraryImport.IsUserDefined, SetLastError = libraryImport.SetLastError, - StringMarshalling = libraryImport.StringMarshalling + StringMarshalling = libraryImport.StringMarshalling, + StringMarshallingCustomType = libraryImport.StringMarshallingCustomType is not null + ? ManagedTypeInfo.CreateTypeInfoForTypeSymbol(libraryImport.StringMarshallingCustomType) + : null, }; } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/InteropAttributeData.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/InteropAttributeData.cs index ecbb18426791f..53ac617954074 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/InteropAttributeData.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/InteropAttributeData.cs @@ -32,6 +32,7 @@ public record InteropAttributeData public InteropAttributeMember IsUserDefined { get; init; } public bool SetLastError { get; init; } public StringMarshalling StringMarshalling { get; init; } + public ManagedTypeInfo? StringMarshallingCustomType { get; init; } } /// diff --git a/src/libraries/System.Runtime.InteropServices/tests/ComInterfaceGenerator.Unit.Tests/CodeSnippets.cs b/src/libraries/System.Runtime.InteropServices/tests/ComInterfaceGenerator.Unit.Tests/CodeSnippets.cs index 38f9f9f8e262d..f6f54511e22d4 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/ComInterfaceGenerator.Unit.Tests/CodeSnippets.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/ComInterfaceGenerator.Unit.Tests/CodeSnippets.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Collections.Generic; using System.Linq; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -38,7 +39,8 @@ private string VirtualMethodIndex( private string UnmanagedObjectUnwrapper(Type t) => _attributeProvider.UnmanagedObjectUnwrapper(t); - private string GeneratedComInterface => _attributeProvider.GeneratedComInterface; + private string GeneratedComInterface(StringMarshalling? stringMarshalling = null, Type? stringMarshallingCustomType = null) + => _attributeProvider.GeneratedComInterface(stringMarshalling, stringMarshallingCustomType); private string UnmanagedCallConv(Type[]? CallConvs = null) { @@ -55,7 +57,7 @@ private string UnmanagedCallConv(Type[]? CallConvs = null) using System.Runtime.InteropServices.Marshalling; {{UnmanagedObjectUnwrapper(typeof(UnmanagedObjectUnwrapper.TestUnwrapper))}} - {{GeneratedComInterface}} + {{GeneratedComInterface()}} partial interface INativeAPI { {{VirtualMethodIndex(0)}} @@ -70,7 +72,7 @@ partial interface INativeAPI using System.Runtime.InteropServices.Marshalling; {{UnmanagedObjectUnwrapper(typeof(UnmanagedObjectUnwrapper.TestUnwrapper))}} - {{GeneratedComInterface}} + {{GeneratedComInterface()}} partial interface INativeAPI { {{VirtualMethodIndex(0, ImplicitThisParameter: false)}} @@ -86,7 +88,7 @@ partial interface INativeAPI using System.Runtime.InteropServices.Marshalling; {{UnmanagedObjectUnwrapper(typeof(UnmanagedObjectUnwrapper.TestUnwrapper))}} - {{GeneratedComInterface}} + {{GeneratedComInterface()}} partial interface INativeAPI { @@ -122,7 +124,7 @@ public string BasicParametersAndModifiers(string typeName, string methodModifier [assembly:DisableRuntimeMarshalling] {{UnmanagedObjectUnwrapper(typeof(UnmanagedObjectUnwrapper.TestUnwrapper))}} - {{GeneratedComInterface}} + {{GeneratedComInterface()}} partial interface INativeAPI { {{VirtualMethodIndex(0)}} @@ -140,7 +142,7 @@ public string BasicParametersAndModifiersManagedToUnmanaged(string typeName, str [assembly:DisableRuntimeMarshalling] {{UnmanagedObjectUnwrapper(typeof(UnmanagedObjectUnwrapper.TestUnwrapper))}} - {{GeneratedComInterface}} + {{GeneratedComInterface()}} partial interface INativeAPI { {{VirtualMethodIndex(0, Direction: MarshalDirection.ManagedToUnmanaged)}} @@ -159,7 +161,7 @@ public string BasicParametersAndModifiersNoRef(string typeName, string preDeclar [assembly:DisableRuntimeMarshalling] {{UnmanagedObjectUnwrapper(typeof(UnmanagedObjectUnwrapper.TestUnwrapper))}} - {{GeneratedComInterface}} + {{GeneratedComInterface()}} partial interface INativeAPI { {{VirtualMethodIndex(0)}} @@ -175,7 +177,7 @@ public string BasicParametersAndModifiersNoImplicitThis(string typeName) => $$"" using System.Runtime.InteropServices.Marshalling; {{UnmanagedObjectUnwrapper(typeof(UnmanagedObjectUnwrapper.TestUnwrapper))}} - {{GeneratedComInterface}} + {{GeneratedComInterface()}} partial interface INativeAPI { {{VirtualMethodIndex(0, ImplicitThisParameter: false)}} @@ -193,7 +195,7 @@ public string MarshalUsingCollectionCountInfoParametersAndModifiers(string colle [assembly:DisableRuntimeMarshalling] {{UnmanagedObjectUnwrapper(typeof(UnmanagedObjectUnwrapper.TestUnwrapper))}} - {{GeneratedComInterface}} + {{GeneratedComInterface()}} partial interface INativeAPI { {{VirtualMethodIndex(0)}} @@ -219,7 +221,7 @@ public string BasicReturnTypeComExceptionHandling(string typeName, string preDec {{preDeclaration}} {{UnmanagedObjectUnwrapper(typeof(UnmanagedObjectUnwrapper.TestUnwrapper))}} - {{GeneratedComInterface}} + {{GeneratedComInterface()}} partial interface INativeAPI { {{VirtualMethodIndex(0, ExceptionMarshalling: ExceptionMarshalling.Com)}} @@ -236,7 +238,7 @@ public string BasicReturnTypeCustomExceptionHandling(string typeName, string cus {{preDeclaration}} {{UnmanagedObjectUnwrapper(typeof(UnmanagedObjectUnwrapper.TestUnwrapper))}} - {{GeneratedComInterface}} + {{GeneratedComInterface()}} partial interface INativeAPI { {{VirtualMethodIndex(0, ExceptionMarshallingType: Type.GetType(customExceptionType))}} @@ -250,12 +252,12 @@ partial interface INativeAPI using System.Runtime.InteropServices; using System.Runtime.InteropServices.Marshalling; - {{GeneratedComInterface}} + {{GeneratedComInterface()}} partial interface IComInterface { void Method(); } - {{GeneratedComInterface}} + {{GeneratedComInterface()}} partial interface IComInterface2 : IComInterface { void Method2(); @@ -266,25 +268,54 @@ partial interface IComInterface2 : IComInterface using System.Runtime.InteropServices; using System.Runtime.InteropServices.Marshalling; - {{GeneratedComInterface}} + {{GeneratedComInterface()}} partial interface IComInterface { void Method(); } - {{GeneratedComInterface}} + {{GeneratedComInterface()}} partial interface IOtherComInterface { void MethodA(); } - {{GeneratedComInterface}} + {{GeneratedComInterface()}} partial interface {|#0:IComInterface2|} : IComInterface, IOtherComInterface { void Method2(); } """; + public string DerivedWithStringMarshalling(params + (StringMarshalling StringMarshalling, Type? StringMarshallingCustomType)[] attributeArguments) + { + List declarations = new(); + int i = 0; + foreach (var args in attributeArguments) + { + declarations.Add($$""" + {{GeneratedComInterface(args.StringMarshalling, args.StringMarshallingCustomType)}} + internal partial interface {|#{{i}}:IStringMarshalling{{i}}|} {{(i > 0 ? $": IStringMarshalling{i - 1}" : "")}} + { + public string GetString{{i}}(); + public void SetString{{i}}(string value); + } + """); + i++; + } + return $$""" + using System; + using System.Runtime.InteropServices; + using System.Runtime.InteropServices.Marshalling; + + namespace Test + { + {{string.Join("\n\n", declarations)}} + } + """; + } + public string ComInterfaceParameters => BasicParametersAndModifiers("IComInterface2") + $$""" - {{GeneratedComInterface}} + {{GeneratedComInterface()}} partial interface IComInterface2 { void Method2(); diff --git a/src/libraries/System.Runtime.InteropServices/tests/ComInterfaceGenerator.Unit.Tests/CompileFails.cs b/src/libraries/System.Runtime.InteropServices/tests/ComInterfaceGenerator.Unit.Tests/CompileFails.cs index acc11f6139c9c..ee1c28017c555 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/ComInterfaceGenerator.Unit.Tests/CompileFails.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/ComInterfaceGenerator.Unit.Tests/CompileFails.cs @@ -17,8 +17,8 @@ using System.Diagnostics; using VerifyComInterfaceGenerator = Microsoft.Interop.UnitTests.Verifiers.CSharpSourceGeneratorVerifier; -using Newtonsoft.Json.Bson; -using System.Diagnostics.CodeAnalysis; +using StringMarshalling = System.Runtime.InteropServices.StringMarshalling; +using System.Runtime.InteropServices.Marshalling; namespace ComInterfaceGenerator.Unit.Tests { @@ -95,6 +95,237 @@ public static IEnumerable InvalidUnmanagedToManagedCodeSnippetsToCompi yield return new object[] { ID(), customStructMarshallingCodeSnippets.Stateful.ByValueInParameter, new[] { invalidUnmanagedToManagedParameterDiagnostic } }; } + public static IEnumerable StringMarshallingCodeSnippets(GeneratorKind generator) + { + const string CustomStringMarshallingWithNoCustomTypeMessage = @"'StringMarshallingCustomType' must be specified when 'StringMarshalling' is set to 'StringMarshalling.Custom'."; + const string CustomTypeSpecifiedWithNoStringMarshallingCustom = @"'StringMarshalling' should be set to 'StringMarshalling.Custom' when 'StringMarshallingCustomType' is specified."; + const string StringMarshallingMustMatchBase = "The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface."; + + CodeSnippets codeSnippets = new(GetAttributeProvider(generator)); + (StringMarshalling, Type?) utf8Marshalling = (StringMarshalling.Utf8, null); + (StringMarshalling, Type?) utf16Marshalling = (StringMarshalling.Utf16, null); + (StringMarshalling, Type?) customUtf16Marshalling = (StringMarshalling.Custom, typeof(Utf16StringMarshaller)); + (StringMarshalling, Type?) customWithNoType = (StringMarshalling.Custom, null); + (StringMarshalling, Type?) utf8WithType = (StringMarshalling.Utf8, typeof(Utf16StringMarshaller)); + DiagnosticResult[] emptyDiagnostics = new DiagnosticResult[] { }; + + // StringMarshalling.Custom / StringMarshallingCustomType invalid + yield return new object[] + { + ID(), + codeSnippets.DerivedWithStringMarshalling(customWithNoType), + new DiagnosticResult[] + { + VerifyComInterfaceGenerator.Diagnostic(GeneratorDiagnostics.InvalidStringMarshallingConfigurationOnInterface) + .WithLocation(0) + .WithArguments("Test.IStringMarshalling0", CustomStringMarshallingWithNoCustomTypeMessage) + } + }; + yield return new object[] + { + ID(), + codeSnippets.DerivedWithStringMarshalling(utf8WithType), + new DiagnosticResult[] + { + VerifyComInterfaceGenerator.Diagnostic(GeneratorDiagnostics.InvalidStringMarshallingConfigurationOnInterface) + .WithLocation(0) + .WithArguments("Test.IStringMarshalling0", CustomTypeSpecifiedWithNoStringMarshallingCustom) + } + }; + + // Inheritance no diagnostic + yield return new object[] + { + ID(), + codeSnippets.DerivedWithStringMarshalling(utf16Marshalling, utf16Marshalling), + emptyDiagnostics + }; + yield return new object[] + { + ID(), + codeSnippets.DerivedWithStringMarshalling(utf8Marshalling, utf8Marshalling), + emptyDiagnostics + }; + yield return new object[] + { + ID(), + codeSnippets.DerivedWithStringMarshalling(customUtf16Marshalling, customUtf16Marshalling), + emptyDiagnostics + }; + + // mismatches + DiagnosticResult[] mismatchAt1 = MismatchesWithLocations(1); + yield return new object[] + { + ID(), + codeSnippets.DerivedWithStringMarshalling(utf8Marshalling, utf16Marshalling), + mismatchAt1 + }; + yield return new object[] + { + ID(), + codeSnippets.DerivedWithStringMarshalling(utf16Marshalling, utf8Marshalling), + mismatchAt1 + }; + yield return new object[] + { + ID(), + codeSnippets.DerivedWithStringMarshalling(utf16Marshalling, customUtf16Marshalling), + mismatchAt1 + }; + yield return new object[] + { + ID(), + codeSnippets.DerivedWithStringMarshalling(customUtf16Marshalling, utf16Marshalling), + mismatchAt1 + }; + yield return new object[] + { + ID(), + codeSnippets.DerivedWithStringMarshalling(utf8Marshalling, customUtf16Marshalling), + mismatchAt1 + }; + yield return new object[] + { + ID(), + codeSnippets.DerivedWithStringMarshalling(customUtf16Marshalling, utf8Marshalling), + mismatchAt1 + }; + + // Three levels inheritance + // Matching + yield return new object[] + { + ID(), + codeSnippets.DerivedWithStringMarshalling(utf8Marshalling, utf8Marshalling, utf8Marshalling), + emptyDiagnostics + }; + yield return new object[] + { + ID(), + codeSnippets.DerivedWithStringMarshalling(utf16Marshalling, utf16Marshalling, utf16Marshalling), + emptyDiagnostics + }; + yield return new object[] + { + ID(), + codeSnippets.DerivedWithStringMarshalling(customUtf16Marshalling, customUtf16Marshalling, customUtf16Marshalling), + emptyDiagnostics + }; + + //Mismatches + yield return new object[] + { + ID(), + codeSnippets.DerivedWithStringMarshalling(utf8Marshalling, utf8Marshalling, utf16Marshalling), + MismatchesWithLocations(2) + }; + yield return new object[] + { + ID(), + codeSnippets.DerivedWithStringMarshalling(utf8Marshalling, utf16Marshalling, utf16Marshalling), + MismatchesWithLocations(1).Concat(BaseCannotBeGeneratedWithLocations(2)).ToArray() + }; + yield return new object[] + { + ID(), + codeSnippets.DerivedWithStringMarshalling(utf8Marshalling, utf16Marshalling, utf8Marshalling), + MismatchesWithLocations(1, 2) + }; + yield return new object[] + { + ID(), + codeSnippets.DerivedWithStringMarshalling(utf8Marshalling, utf16Marshalling, customUtf16Marshalling), + MismatchesWithLocations(1, 2) + }; + + // Base has no StringMarshalling and Derived does is okay + string source = $$""" + using System; + using System.Runtime.InteropServices; + using System.Runtime.InteropServices.Marshalling; + namespace Test + { + [GeneratedComInterface] + [Guid("0E7204B5-4B61-4E06-B872-82BA652F2ECA")] + internal partial interface INoStringMarshalling + { + public int GetInt(); + public void SetInt(int value); + } + [GeneratedComInterface(StringMarshalling = StringMarshalling.Utf8)] + [Guid("0E7204B5-4B61-5E06-B872-82BA652F2ECA")] + internal partial interface IStringMarshalling : INoStringMarshalling + { + public string GetString(); + public void SetString(string value); + } + } + """; + yield return new object[] { ID(), source, emptyDiagnostics }; + + source = $$""" + using System; + using System.Runtime.InteropServices; + using System.Runtime.InteropServices.Marshalling; + namespace Test + { + [GeneratedComInterface] + [Guid("0E7204B5-4B61-4E06-B872-82BA652F2ECA")] + internal partial interface INoStringMarshalling + { + [return: MarshalUsing(typeof(Utf8StringMarshaller))] + public string GetString(); + public void SetString([MarshalUsing(typeof(Utf8StringMarshaller))] string value); + } + [GeneratedComInterface(StringMarshalling = StringMarshalling.Utf16)] + [Guid("0E7204B5-4B61-5E06-B872-82BA652F2ECA")] + internal partial interface IStringMarshalling : INoStringMarshalling + { + public string GetString2(); + public void SetString2(string value); + } + } + """; + yield return new object[] { ID(), source, emptyDiagnostics }; + + // Base many levels up fails, all inheriting fail + yield return new object[] + { + ID(), + codeSnippets.DerivedWithStringMarshalling(customWithNoType, customUtf16Marshalling, customUtf16Marshalling, customUtf16Marshalling, customUtf16Marshalling, customUtf16Marshalling), + new DiagnosticResult[] + { + VerifyComInterfaceGenerator.Diagnostic(GeneratorDiagnostics.InvalidStringMarshallingConfigurationOnInterface) + .WithLocation(0) + .WithArguments("Test.IStringMarshalling0", CustomStringMarshallingWithNoCustomTypeMessage) + } + .Concat(MismatchesWithLocations(1)) + .Concat(BaseCannotBeGeneratedWithLocations(2, 3, 4, 5)) + .ToArray() + }; + + DiagnosticResult[] MismatchesWithLocations(params int[] locations) + { + return locations + .Select(i => + new DiagnosticResult(GeneratorDiagnostics.InvalidStringMarshallingMismatchBetweenBaseAndDerived) + .WithLocation(i) + .WithArguments($"Test.IStringMarshalling{i}", StringMarshallingMustMatchBase)) + .ToArray(); + } + + DiagnosticResult[] BaseCannotBeGeneratedWithLocations(params int[] locations) + { + return locations + .Select(i => + new DiagnosticResult(GeneratorDiagnostics.BaseInterfaceIsNotGenerated) + .WithLocation(i) + .WithArguments($"Test.IStringMarshalling{i}", $"Test.IStringMarshalling{i - 1}")) + .ToArray(); + } + } + public static IEnumerable InvalidManagedToUnmanagedCodeSnippetsToCompile(GeneratorKind generator) { // Marshallers with only support for their expected places in the signatures in @@ -135,6 +366,14 @@ public async Task ValidateInvalidManagedToUnmanagedCodeSnippets(string id, strin await VerifyComInterfaceGenerator.VerifySourceGeneratorAsync(source, expectedDiagnostic); } + [Theory] + [MemberData(nameof(StringMarshallingCodeSnippets), GeneratorKind.ComInterfaceGenerator)] + public async Task ValidateStringMarshallingDiagnostics(string id, string source, DiagnosticResult[] expectedDiagnostics) + { + _ = id; + await VerifyComInterfaceGenerator.VerifySourceGeneratorAsync(source, expectedDiagnostics); + } + [Fact] public async Task ValidateInterfaceWithoutGuidWarns() { diff --git a/src/libraries/System.Runtime.InteropServices/tests/ComInterfaceGenerator.Unit.Tests/GeneratedComInterfaceAttributeProvider.cs b/src/libraries/System.Runtime.InteropServices/tests/ComInterfaceGenerator.Unit.Tests/GeneratedComInterfaceAttributeProvider.cs index 83bac9f792146..b1bcef7a77d58 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/ComInterfaceGenerator.Unit.Tests/GeneratedComInterfaceAttributeProvider.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/ComInterfaceGenerator.Unit.Tests/GeneratedComInterfaceAttributeProvider.cs @@ -22,7 +22,15 @@ public string VirtualMethodIndex( public string UnmanagedObjectUnwrapper(Type t) => ""; - public string GeneratedComInterface => @$"[global::System.Runtime.InteropServices.Marshalling.GeneratedComInterface, global::System.Runtime.InteropServices.Guid(""0A52B77C-E08B-4274-A1F4-1A2BF2C07E60"")]"; + public string GeneratedComInterface(StringMarshalling? stringMarshalling = null, Type? stringMarshallingCustomType = null) + { + string comma = stringMarshalling is not null && stringMarshallingCustomType is not null ? ", " : ""; + return @$"[global::System.Runtime.InteropServices.Marshalling.GeneratedComInterface(" + + (stringMarshalling is not null ? $"StringMarshalling = {typeof(StringMarshalling).FullName}.{stringMarshalling!.Value}" : "") + + comma + + (stringMarshallingCustomType is not null ? $"StringMarshallingCustomType = typeof({stringMarshallingCustomType!.FullName})" : "") + + @$"), global::System.Runtime.InteropServices.Guid(""0A52B77C-E08B-4274-A1F4-1A2BF2C07E60"")]"; + } public string AdditionalUserRequiredInterfaces(string userDefinedInterfaceName) => ""; } diff --git a/src/libraries/System.Runtime.InteropServices/tests/ComInterfaceGenerator.Unit.Tests/IComInterfaceAttributeProvider.cs b/src/libraries/System.Runtime.InteropServices/tests/ComInterfaceGenerator.Unit.Tests/IComInterfaceAttributeProvider.cs index f2df492921301..84a0c09701469 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/ComInterfaceGenerator.Unit.Tests/IComInterfaceAttributeProvider.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/ComInterfaceGenerator.Unit.Tests/IComInterfaceAttributeProvider.cs @@ -33,7 +33,7 @@ string VirtualMethodIndex( /// /// Returns the [GeneratedComInterface] to be put into a snippet, if desired. Otherwise, returns . /// - string GeneratedComInterface { get; } + string GeneratedComInterface(StringMarshalling? stringMarshalling = null, Type? stringMarshallingCustomType = null); /// /// Returns any additional code to be appended to the snippet that provides any additional interfaces the user must implement diff --git a/src/libraries/System.Runtime.InteropServices/tests/ComInterfaceGenerator.Unit.Tests/IVirtualMethodIndexSignatureProvider.cs b/src/libraries/System.Runtime.InteropServices/tests/ComInterfaceGenerator.Unit.Tests/IVirtualMethodIndexSignatureProvider.cs index 04746077763d2..fde57878da80d 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/ComInterfaceGenerator.Unit.Tests/IVirtualMethodIndexSignatureProvider.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/ComInterfaceGenerator.Unit.Tests/IVirtualMethodIndexSignatureProvider.cs @@ -30,7 +30,7 @@ string ICustomMarshallingSignatureTestProvider.BasicParametersAndModifiers(strin [assembly:DisableRuntimeMarshalling] {{AttributeProvider.UnmanagedObjectUnwrapper(typeof(UnmanagedObjectUnwrapper.TestUnwrapper))}} - {{AttributeProvider.GeneratedComInterface}} + {{AttributeProvider.GeneratedComInterface()}} partial interface INativeAPI { {{AttributeProvider.VirtualMethodIndex(0, ImplicitThisParameter: ImplicitThisParameter, Direction: Direction)}} @@ -47,7 +47,7 @@ string ICustomMarshallingSignatureTestProvider.BasicParametersAndModifiersNoRef( [assembly:DisableRuntimeMarshalling] {{AttributeProvider.UnmanagedObjectUnwrapper(typeof(UnmanagedObjectUnwrapper.TestUnwrapper))}} - {{AttributeProvider.GeneratedComInterface}} + {{AttributeProvider.GeneratedComInterface()}} partial interface INativeAPI { {{AttributeProvider.VirtualMethodIndex(0, ImplicitThisParameter: ImplicitThisParameter, Direction: Direction)}} @@ -63,7 +63,7 @@ string ICustomMarshallingSignatureTestProvider.BasicParameterByValue(string type {{preDeclaration}} {{AttributeProvider.UnmanagedObjectUnwrapper(typeof(UnmanagedObjectUnwrapper.TestUnwrapper))}} - {{AttributeProvider.GeneratedComInterface}} + {{AttributeProvider.GeneratedComInterface()}} partial interface INativeAPI { {{AttributeProvider.VirtualMethodIndex(0, ImplicitThisParameter: ImplicitThisParameter, Direction: Direction)}} @@ -81,7 +81,7 @@ string ICustomMarshallingSignatureTestProvider.BasicParameterWithByRefModifier(s [assembly:DisableRuntimeMarshalling] {{AttributeProvider.UnmanagedObjectUnwrapper(typeof(UnmanagedObjectUnwrapper.TestUnwrapper))}} - {{AttributeProvider.GeneratedComInterface}} + {{AttributeProvider.GeneratedComInterface()}} partial interface INativeAPI { {{AttributeProvider.VirtualMethodIndex(0, ImplicitThisParameter: ImplicitThisParameter, Direction: Direction)}} @@ -96,7 +96,7 @@ string ICustomMarshallingSignatureTestProvider.BasicReturnType(string typeName, {{preDeclaration}} {{AttributeProvider.UnmanagedObjectUnwrapper(typeof(UnmanagedObjectUnwrapper.TestUnwrapper))}} - {{AttributeProvider.GeneratedComInterface}} + {{AttributeProvider.GeneratedComInterface()}} partial interface INativeAPI { {{AttributeProvider.VirtualMethodIndex(0, ImplicitThisParameter: ImplicitThisParameter, Direction: Direction)}} @@ -111,7 +111,7 @@ string ICustomMarshallingSignatureTestProvider.MarshalUsingParametersAndModifier {{preDeclaration}} {{AttributeProvider.UnmanagedObjectUnwrapper(typeof(UnmanagedObjectUnwrapper.TestUnwrapper))}} - {{AttributeProvider.GeneratedComInterface}} + {{AttributeProvider.GeneratedComInterface()}} partial interface INativeAPI { {{AttributeProvider.VirtualMethodIndex(0, ImplicitThisParameter: ImplicitThisParameter, Direction: Direction)}} @@ -131,7 +131,7 @@ string ICustomMarshallingSignatureTestProvider.MarshalUsingCollectionCountInfoPa [assembly:DisableRuntimeMarshalling] {{AttributeProvider.UnmanagedObjectUnwrapper(typeof(UnmanagedObjectUnwrapper.TestUnwrapper))}} - {{AttributeProvider.GeneratedComInterface}} + {{AttributeProvider.GeneratedComInterface()}} partial interface INativeAPI { {{AttributeProvider.VirtualMethodIndex(0, ImplicitThisParameter: ImplicitThisParameter, Direction: Direction)}} @@ -156,7 +156,7 @@ string ICustomMarshallingSignatureTestProvider.MarshalUsingCollectionParametersA [assembly:DisableRuntimeMarshalling] {{AttributeProvider.UnmanagedObjectUnwrapper(typeof(UnmanagedObjectUnwrapper.TestUnwrapper))}} - {{AttributeProvider.GeneratedComInterface}} + {{AttributeProvider.GeneratedComInterface()}} partial interface INativeAPI { {{AttributeProvider.VirtualMethodIndex(0, ImplicitThisParameter: ImplicitThisParameter, Direction: Direction)}} @@ -182,7 +182,7 @@ string ICustomMarshallingSignatureTestProvider.MarshalUsingCollectionReturnValue [assembly:DisableRuntimeMarshalling] {{AttributeProvider.UnmanagedObjectUnwrapper(typeof(UnmanagedObjectUnwrapper.TestUnwrapper))}} - {{AttributeProvider.GeneratedComInterface}} + {{AttributeProvider.GeneratedComInterface()}} partial interface INativeAPI { {{AttributeProvider.VirtualMethodIndex(0, ImplicitThisParameter: ImplicitThisParameter, Direction: Direction)}} @@ -202,7 +202,7 @@ string ICustomMarshallingSignatureTestProvider.MarshalUsingCollectionOutConstant [assembly:DisableRuntimeMarshalling] {{AttributeProvider.UnmanagedObjectUnwrapper(typeof(UnmanagedObjectUnwrapper.TestUnwrapper))}} - {{AttributeProvider.GeneratedComInterface}} + {{AttributeProvider.GeneratedComInterface()}} partial interface INativeAPI { {{AttributeProvider.VirtualMethodIndex(0, ImplicitThisParameter: ImplicitThisParameter, Direction: Direction)}} @@ -221,7 +221,7 @@ string ICustomMarshallingSignatureTestProvider.MarshalUsingCollectionReturnConst [assembly:DisableRuntimeMarshalling] {{AttributeProvider.UnmanagedObjectUnwrapper(typeof(UnmanagedObjectUnwrapper.TestUnwrapper))}} - {{AttributeProvider.GeneratedComInterface}} + {{AttributeProvider.GeneratedComInterface()}} partial interface INativeAPI { {{AttributeProvider.VirtualMethodIndex(0, ImplicitThisParameter: ImplicitThisParameter, Direction: Direction)}} @@ -239,7 +239,7 @@ string ICustomMarshallingSignatureTestProvider.CustomElementMarshalling(string c [assembly:DisableRuntimeMarshalling] {{AttributeProvider.UnmanagedObjectUnwrapper(typeof(UnmanagedObjectUnwrapper.TestUnwrapper))}} - {{AttributeProvider.GeneratedComInterface}} + {{AttributeProvider.GeneratedComInterface()}} partial interface INativeAPI { {{AttributeProvider.VirtualMethodIndex(0, ImplicitThisParameter: ImplicitThisParameter, Direction: Direction)}} diff --git a/src/libraries/System.Runtime.InteropServices/tests/ComInterfaceGenerator.Unit.Tests/VirtualMethodIndexAttributeProvider.cs b/src/libraries/System.Runtime.InteropServices/tests/ComInterfaceGenerator.Unit.Tests/VirtualMethodIndexAttributeProvider.cs index 0c31f2d61ffd2..94553726a92ff 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/ComInterfaceGenerator.Unit.Tests/VirtualMethodIndexAttributeProvider.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/ComInterfaceGenerator.Unit.Tests/VirtualMethodIndexAttributeProvider.cs @@ -23,15 +23,15 @@ public string VirtualMethodIndex( + (ImplicitThisParameter.HasValue ? $", ImplicitThisParameter = {ImplicitThisParameter.Value.ToString().ToLower()}" : "") + (Direction is not null ? $", Direction = {typeof(MarshalDirection).FullName}.{Direction.Value}" : "") + (StringMarshalling is not null ? $", StringMarshalling = {typeof(StringMarshalling).FullName}.{StringMarshalling!.Value}" : "") - + (StringMarshallingCustomType is not null ? $", StringMarshallingCustomType = {StringMarshallingCustomType!.FullName}" : "") + + (StringMarshallingCustomType is not null ? $", StringMarshallingCustomType = typeof({StringMarshallingCustomType!.FullName})" : "") + (SetLastError is not null ? $", SetLastError = {SetLastError.Value.ToString().ToLower()}" : "") + (ExceptionMarshalling is not null ? $", ExceptionMarshalling = {typeof(ExceptionMarshalling).FullName}.{ExceptionMarshalling.Value}" : "") - + (ExceptionMarshallingType is not null ? $", ExceptionMarshallingCustomType = {ExceptionMarshallingType!.FullName}" : "") + + (ExceptionMarshallingType is not null ? $", ExceptionMarshallingCustomType = typeof({ExceptionMarshallingType!.FullName})" : "") + ")]"; public string UnmanagedObjectUnwrapper(Type t) => $"[global::System.Runtime.InteropServices.Marshalling.UnmanagedObjectUnwrapperAttribute<{t.FullName!.Replace('+', '.')}>]"; - public string GeneratedComInterface => ""; + public string GeneratedComInterface(StringMarshalling? stringMarshalling = null, Type? stringMarshallingCustomType = null) => ""; public string AdditionalUserRequiredInterfaces(string userDefinedInterfaceName) => """ partial interface INativeAPI : IUnmanagedInterfaceType @@ -40,4 +40,4 @@ partial interface INativeAPI : IUnmanagedInterfaceType } """; } -} \ No newline at end of file +}