From: Jackson Schuster <36744439+jtschuster@users.noreply.github.com>
Date: Wed, 24 May 2023 17:44:05 +0000 (-0700)
Subject: [ComInterfaceGenerator] Warn if StringMarshalling doesn't match base and warn if...
X-Git-Tag: accepted/tizen/unified/riscv/20231226.055536~1997
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=94c989db68a702295d4129ec5fe9be9a34419e6c;p=platform%2Fupstream%2Fdotnet%2Fruntime.git
[ComInterfaceGenerator] Warn if StringMarshalling doesn't match base and warn if base interface cannot be generated (#86467)
---
diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ComInterfaceContext.cs b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ComInterfaceContext.cs
index 0eee960..94a8fb6 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 @@ namespace Microsoft.Interop
///
/// 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 @@ namespace Microsoft.Interop
}
return accumulator.MoveToImmutable();
- ComInterfaceContext AddContext(ComInterfaceInfo iface)
+ (ComInterfaceContext? Context, Diagnostic? Diagnostic) AddContext(ComInterfaceInfo iface)
{
- if (symbolToContextMap.TryGetValue(iface.ThisInterfaceKey, out var cachedValue))
+ if (nameToContextCache.TryGetValue(iface.ThisInterfaceKey, out var cachedValue))
{
return cachedValue;
}
@@ -38,18 +42,41 @@ namespace Microsoft.Interop
if (iface.BaseInterfaceKey is null)
{
var baselessCtx = new ComInterfaceContext(iface, null);
- symbolToContextMap[iface.ThisInterfaceKey] = baselessCtx;
- return baselessCtx;
+ nameToContextCache[iface.ThisInterfaceKey] = (baselessCtx, null);
+ return (baselessCtx, null);
}
- if (!symbolToContextMap.TryGetValue(iface.BaseInterfaceKey, out var baseContext))
+ if (
+ // Cached base info has a diagnostic - failure
+ (nameToContextCache.TryGetValue(iface.BaseInterfaceKey, out var basePair) && basePair.Diagnostic is not null)
+ // Cannot find base ComInterfaceInfo - failure (failed ComInterfaceInfo creation)
+ || !nameToInterfaceInfoMap.TryGetValue(iface.BaseInterfaceKey, out var baseInfo)
+ // Newly calculated base context pair has a diagnostic - failure
+ || (AddContext(baseInfo) is { } baseReturnPair && baseReturnPair.Diagnostic is not null))
{
- baseContext = AddContext(symbolToInterfaceInfoMap[iface.BaseInterfaceKey]);
+ // The base has failed generation at some point, so this interface cannot be generated
+ (ComInterfaceContext, Diagnostic?) diagnosticPair = (null,
+ Diagnostic.Create(
+ GeneratorDiagnostics.BaseInterfaceIsNotGenerated,
+ iface.DiagnosticLocation.AsLocation(), iface.ThisInterfaceKey, iface.BaseInterfaceKey));
+ nameToContextCache[iface.ThisInterfaceKey] = diagnosticPair;
+ return diagnosticPair;
}
+ var baseContext = basePair.Context ?? baseReturnPair.Context;
+ Debug.Assert(baseContext != null);
var ctx = new ComInterfaceContext(iface, baseContext);
- symbolToContextMap[iface.ThisInterfaceKey] = ctx;
- return ctx;
+ (ComInterfaceContext, Diagnostic?) contextPair = (ctx, null);
+ nameToContextCache[iface.ThisInterfaceKey] = contextPair;
+ return contextPair;
}
}
+
+ internal ComInterfaceContext GetTopLevelBase()
+ {
+ var currBase = Base;
+ while (currBase is not null)
+ currBase = currBase.Base;
+ return currBase;
+ }
}
}
diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ComInterfaceGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ComInterfaceGenerator.cs
index 4165e7a..5497794 100644
--- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ComInterfaceGenerator.cs
+++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ComInterfaceGenerator.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.Collections.Immutable;
using System.IO;
using System.Linq;
@@ -52,13 +53,21 @@ namespace Microsoft.Interop
var interfaceSymbolsWithoutDiagnostics = interfaceSymbolAndDiagnostics
.Where(data => 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)));
@@ -78,6 +87,10 @@ namespace Microsoft.Interop
.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 @@ namespace Microsoft.Interop
}
}
- 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 @@ namespace Microsoft.Interop
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 23d56f7..533eb8c 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 @@ namespace Microsoft.Interop
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 @@ namespace Microsoft.Interop
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 daf7c14..f4aa897 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 @@ namespace Microsoft.Interop
.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 0000000..f8c42b2
--- /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 69e6d91..2c47e3f 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 @@ namespace Microsoft.Interop
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 @@ namespace Microsoft.Interop
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 @@ namespace Microsoft.Interop
GetResourceString(nameof(SR.AnalysisFailedTitle)),
GetResourceString(nameof(SR.AnalysisFailedMethodMessage)),
Category,
- DiagnosticSeverity.Warning,
+ DiagnosticSeverity.Error,
isEnabledByDefault: true,
description: GetResourceString(nameof(SR.AnalysisFailedDescription)));
@@ -224,10 +245,20 @@ namespace Microsoft.Interop
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 @@ namespace Microsoft.Interop
{
_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 0000000..982e1ca
--- /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 ad3eaf5..f797fce 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 04074de..1c0d66c 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 {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.
+
+
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.
+
+
Použità GeneratedComInterfaceAttribute a InterfaceTypeAttribute se nepodporuje s hodnotou ComInterfaceType {0}.
@@ -137,11 +157,6 @@
Konfigurace StringMarshalling a StringMarshallingCustomType je neplatná.
-
-
- Konfigurace StringMarshalling a StringMarshallingCustomType u metody {0} je neplatná. {1}
- {1} is a message containing additional details about what is not valid
-
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 method '{0}' is invalid. {1}
+ {1} is a message containing additional details about what is not valid
+
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 f87f9a5..1f498be 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 {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.
+
+
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.
+
+
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.
-
-
- 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\" 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 method '{0}' is invalid. {1}
+ {1} is a message containing additional details about what is not valid
+
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 ab93921..47607c0 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 {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.
+
+
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.
+
+
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.
-
-
- 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
-
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 method '{0}' is invalid. {1}
+ {1} is a message containing additional details about what is not valid
+
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 fa3d3b32..6d23021 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 {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.
+
+
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.
+
+
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.
-
-
- 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 » 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 method '{0}' is invalid. {1}
+ {1} is a message containing additional details about what is not valid
+
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 54ebc3b..67fb4de 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 {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.
+
+
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.
+
+
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.
-
-
- La configurazione di 'StringMarshalling' e 'StringMarshallingCustomType' nel metodo '{0}' non è valida. {1}
- {1} is a message containing additional details about what is not valid
-
à 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 method '{0}' is invalid. {1}
+ {1} is a message containing additional details about what is not valid
+
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 ee0c05e..49f864b 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 {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.
+
+
ã½ã¼ã¹çææ¸ã¿ã® P/Invoke ã¯ããµãã¼ãããã¦ããªãæ§æãç¡è¦ãã¾ãã
@@ -57,6 +72,11 @@
æå®ãããæ§æã¯ãã½ã¼ã¹ã§çæããã P/Invoke ã§ã¯ãµãã¼ãããã¦ãã¾ããã
+
+
+ The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface.
+
+
'GeneratedComInterfaceAttribute' ããã³ 'InterfaceTypeAttribute' ã¯ã'ComInterfaceType' ã®å¤ '{0}' ã§ã¯ãµãã¼ãããã¦ãã¾ããã
@@ -137,11 +157,6 @@
'StringMarshalling' 㨠'StringMarshallingCustomType' ã®æ§æãç¡å¹ã§ãã
-
-
- ã¡ã½ãã '{0}' ã® 'StringMarshalling' 㨠'StringMarshallingCustomType' ã®æ§æãç¡å¹ã§ãã{1}
- {1} is a message containing additional details about what is not valid
-
'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 method '{0}' is invalid. {1}
+ {1} is a message containing additional details about what is not valid
+
'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 36208a9..cc35991 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 {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.
+
+
ìì¤ ìì± P/Invokeë ì§ìëì§ ìë 구ì±ì 무ìí©ëë¤.
@@ -57,6 +72,11 @@
ì§ì ë 구ì±ì ìì¤ ìì± P/Invokeìì ì§ìëì§ ììµëë¤.
+
+
+ The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface.
+
+
'GeneratedComInterfaceAttribute' ë° 'InterfaceTypeAttribute'ë 'ComInterfaceType' ê° '{0}'ìì ì§ìëì§ ììµëë¤.
@@ -137,11 +157,6 @@
'StringMarshalling' ë° 'StringMarshallingCustomType'ì 구ì±ì´ ì못ëììµëë¤.
-
-
- '{0}' ë©ìëì 'StringMarshalling' ë° 'StringMarshallingCustomType' 구ì±ì´ ì못ëììµëë¤. {1}
- {1} is a message containing additional details about what is not valid
-
'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 method '{0}' is invalid. {1}
+ {1} is a message containing additional details about what is not valid
+
ì못ë '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 09d52e5..c9b2075 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 {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.
+
+
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.
+
+
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.
-
-
- 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
-
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 method '{0}' is invalid. {1}
+ {1} is a message containing additional details about what is not valid
+
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 1cc6443..94df264 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 {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.
+
+
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.
+
+
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.
-
-
- 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' 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 method '{0}' is invalid. {1}
+ {1} is a message containing additional details about what is not valid
+
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 453512d..f6cb2cb 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 {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.
+
+
P/Invoke Ñ Ñозданием иÑÑоÑника бÑдÑÑ Ð¸Ð³Ð½Ð¾ÑиÑоваÑÑ Ð²Ñе неподдеÑживаемÑе конÑигÑÑаÑии.
@@ -57,6 +72,11 @@
Ð£ÐºÐ°Ð·Ð°Ð½Ð½Ð°Ñ ÐºÐ¾Ð½ÑигÑÑаÑÐ¸Ñ Ð½Ðµ поддеÑживаеÑÑÑ Ð² P/Invoke Ñ Ñозданием иÑÑоÑника.
+
+
+ The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface.
+
+
ÐÑполÑзование GeneratedComInterfaceAttribute и InterfaceTypeAttribute не поддеÑживаеÑÑÑ Ñо знаÑением ComInterfaceType "{0}".
@@ -137,11 +157,6 @@
ÐонÑигÑÑаÑÐ¸Ñ \"StringMarshalling\" и \"StringMarshallingCustomType\" недопÑÑÑима.
-
-
- ÐонÑигÑÑаÑÐ¸Ñ \"StringMarshalling\" и \"StringMarshallingCustomType\" в меÑоде \"{0}\" недопÑÑÑима. {1}
- {1} is a message containing additional details about what is not valid
-
ÐÑли Ð´Ð»Ñ \"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 method '{0}' is invalid. {1}
+ {1} is a message containing additional details about what is not valid
+
ÐедопÑÑÑимое иÑполÑзование 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 4370821..e9bf892 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 {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.
+
+
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.
+
+
'GeneratedComInterfaceAttribute' ve 'InterfaceTypeAttribute' kullanımı, 'ComInterfaceType' deÄeri '{0}' ile desteklenmiyor.
@@ -137,11 +157,6 @@
'StringMarshalling' ve 'StringMarshallingCustomType' yapılandırması geçersiz.
-
-
- '{0}' metodundaki 'StringMarshalling' ve 'StringMarshallingCustomType' yapılandırması geçersiz. {1}
- {1} is a message containing additional details about what is not valid
-
'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 method '{0}' is invalid. {1}
+ {1} is a message containing additional details about what is not valid
+
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 466366b..8fae13e 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 {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.
+
+
æºçæç P/Invoke å°å¿½ç¥ä»»ä½ä¸åæ¯æçé
ç½®ã
@@ -57,6 +72,11 @@
æºçæç P/Invoke ä¸æ¯ææå®çé
ç½®ã
+
+
+ The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface.
+
+
âComInterfaceTypeâå¼â{0}âä¸æ¯æ使ç¨âGeneratedComInterfaceAttributeâåâInterfaceTypeAttributeâã
@@ -137,11 +157,6 @@
âStringMarshallingâ å âStringMarshallingCustomTypeâ çé
ç½®æ æã
-
-
- æ¹æ³â{0}âä¸ç âStringMarshallingâ å âStringMarshallingCustomTypeâ çé
ç½®æ æã{1}
- {1} is a message containing additional details about what is not valid
-
å¨ â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 method '{0}' is invalid. {1}
+ {1} is a message containing additional details about what is not valid
+
â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 5accdc6..1bc4bef 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 {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.
+
+
æ¥æºç¢çç P/Invokes å°æ忽ç¥ä»»ä½ä¸æ¯æ´çè¨å®ã
@@ -57,6 +72,11 @@
æ¥æºç¢çç P/Invokes ä¸æ¯æ´æå®çè¨å®ã
+
+
+ The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' must match the base COM interface.
+
+
'ComInterfaceType' å¼ '{0}' ä¸æ¯æ´ä½¿ç¨ 'GeneratedComInterfaceAttribute' å 'InterfaceTypeAttribute'ã
@@ -137,11 +157,6 @@
'StringMarshalling' å 'StringMarshallingCustomType' çè¨å®ç¡æã
-
-
- æ¹æ³ '{0}' ä¸ç 'StringMarshalling' å 'StringMarshallingCustomType' è¨å®ç¡æã{1}
- {1} is a message containing additional details about what is not valid
-
ç¶ '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 method '{0}' is invalid. {1}
+ {1} is a message containing additional details about what is not valid
+
'VirtualMethodIndexAttribute' 使ç¨æ¹å¼ç¡æ
diff --git a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/LibraryImportData.cs b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/LibraryImportData.cs
index 65691fa..16a3b06 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 @@ namespace Microsoft.Interop
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 ecbb184..53ac617 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 @@ namespace Microsoft.Interop
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 38f9f9f..f6f5451 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 @@ namespace ComInterfaceGenerator.Unit.Tests
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 @@ namespace ComInterfaceGenerator.Unit.Tests
using System.Runtime.InteropServices.Marshalling;
{{UnmanagedObjectUnwrapper(typeof(UnmanagedObjectUnwrapper.TestUnwrapper))}}
- {{GeneratedComInterface}}
+ {{GeneratedComInterface()}}
partial interface INativeAPI
{
{{VirtualMethodIndex(0)}}
@@ -70,7 +72,7 @@ namespace ComInterfaceGenerator.Unit.Tests
using System.Runtime.InteropServices.Marshalling;
{{UnmanagedObjectUnwrapper(typeof(UnmanagedObjectUnwrapper.TestUnwrapper))}}
- {{GeneratedComInterface}}
+ {{GeneratedComInterface()}}
partial interface INativeAPI
{
{{VirtualMethodIndex(0, ImplicitThisParameter: false)}}
@@ -86,7 +88,7 @@ namespace ComInterfaceGenerator.Unit.Tests
using System.Runtime.InteropServices.Marshalling;
{{UnmanagedObjectUnwrapper(typeof(UnmanagedObjectUnwrapper.TestUnwrapper))}}
- {{GeneratedComInterface}}
+ {{GeneratedComInterface()}}
partial interface INativeAPI
{
@@ -122,7 +124,7 @@ namespace ComInterfaceGenerator.Unit.Tests
[assembly:DisableRuntimeMarshalling]
{{UnmanagedObjectUnwrapper(typeof(UnmanagedObjectUnwrapper.TestUnwrapper))}}
- {{GeneratedComInterface}}
+ {{GeneratedComInterface()}}
partial interface INativeAPI
{
{{VirtualMethodIndex(0)}}
@@ -140,7 +142,7 @@ namespace ComInterfaceGenerator.Unit.Tests
[assembly:DisableRuntimeMarshalling]
{{UnmanagedObjectUnwrapper(typeof(UnmanagedObjectUnwrapper.TestUnwrapper))}}
- {{GeneratedComInterface}}
+ {{GeneratedComInterface()}}
partial interface INativeAPI
{
{{VirtualMethodIndex(0, Direction: MarshalDirection.ManagedToUnmanaged)}}
@@ -159,7 +161,7 @@ namespace ComInterfaceGenerator.Unit.Tests
[assembly:DisableRuntimeMarshalling]
{{UnmanagedObjectUnwrapper(typeof(UnmanagedObjectUnwrapper.TestUnwrapper))}}
- {{GeneratedComInterface}}
+ {{GeneratedComInterface()}}
partial interface INativeAPI
{
{{VirtualMethodIndex(0)}}
@@ -175,7 +177,7 @@ namespace ComInterfaceGenerator.Unit.Tests
using System.Runtime.InteropServices.Marshalling;
{{UnmanagedObjectUnwrapper(typeof(UnmanagedObjectUnwrapper.TestUnwrapper))}}
- {{GeneratedComInterface}}
+ {{GeneratedComInterface()}}
partial interface INativeAPI
{
{{VirtualMethodIndex(0, ImplicitThisParameter: false)}}
@@ -193,7 +195,7 @@ namespace ComInterfaceGenerator.Unit.Tests
[assembly:DisableRuntimeMarshalling]
{{UnmanagedObjectUnwrapper(typeof(UnmanagedObjectUnwrapper.TestUnwrapper))}}
- {{GeneratedComInterface}}
+ {{GeneratedComInterface()}}
partial interface INativeAPI
{
{{VirtualMethodIndex(0)}}
@@ -219,7 +221,7 @@ namespace ComInterfaceGenerator.Unit.Tests
{{preDeclaration}}
{{UnmanagedObjectUnwrapper(typeof(UnmanagedObjectUnwrapper.TestUnwrapper))}}
- {{GeneratedComInterface}}
+ {{GeneratedComInterface()}}
partial interface INativeAPI
{
{{VirtualMethodIndex(0, ExceptionMarshalling: ExceptionMarshalling.Com)}}
@@ -236,7 +238,7 @@ namespace ComInterfaceGenerator.Unit.Tests
{{preDeclaration}}
{{UnmanagedObjectUnwrapper(typeof(UnmanagedObjectUnwrapper.TestUnwrapper))}}
- {{GeneratedComInterface}}
+ {{GeneratedComInterface()}}
partial interface INativeAPI
{
{{VirtualMethodIndex(0, ExceptionMarshallingType: Type.GetType(customExceptionType))}}
@@ -250,12 +252,12 @@ namespace ComInterfaceGenerator.Unit.Tests
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 @@ namespace ComInterfaceGenerator.Unit.Tests
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 acc11f6..ee1c280 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 Xunit;
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 @@ namespace ComInterfaceGenerator.Unit.Tests
yield return new object[] { ID(), customStructMarshallingCodeSnippets.Stateful.ByValueInParameter, new[] { invalidUnmanagedToManagedParameterDiagnostic } };
}
+ public static IEnumerable