* Change our '[In, Out]' attribute handling to have a concept of 'unnecessary but not invalid' to enable us in the future to report a non-fatal diagnostic.
* WIP enable unnecessary diagnostic in LibraryImportGenerator'
* Hook up diagnostics and add tests for LibraryImportGenerator
* Hook up diagnostics for ComInterfaceGenerator as well
* Update XLF
* Don't reference the live LibraryImportGenerator when building .NET 7 assets. Use the inbox instead.
* PR feedback
* Fix merge
<EnabledGenerators Include="LibraryImportGenerator" Condition="'$(EnableLibraryImportGenerator)' == 'true'" />
<!-- If the current project is not System.Private.CoreLib, we enable the LibraryImportGenerator source generator
when the project is a C# source project that:
- - doesn't target the latest TFM or
+ - doesn't target the a TFM that includes LibraryImportGenerator or
- doesn't reference the live targeting pack (i.e. when inbox) and
- references System.Private.CoreLib, or
- references System.Runtime.InteropServices -->
'$(IsSourceProject)' == 'true' and
'$(MSBuildProjectExtension)' == '.csproj' and
(
- '$(TargetFrameworkMoniker)' != '$(NetCoreAppCurrentTargetFrameworkMoniker)' or
+ !$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0')) or
(
'$(DisableImplicitFrameworkReferences)' == 'true' and
(
)" />
<!-- We enable the ComInterfaceGenerator source generator
when the project is a C# source project that:
- - doesn't target the latest TFM or
- references System.Runtime.InteropServices directly and not through the live targeting pack (i.e. when inbox) -->
<EnabledGenerators Include="ComInterfaceGenerator"
Condition="'$(IsSourceProject)' == 'true' and
'$(MSBuildProjectExtension)' == '.csproj' and
(
- '$(TargetFrameworkMoniker)' != '$(NetCoreAppCurrentTargetFrameworkMoniker)' or
- (
'$(DisableImplicitFrameworkReferences)' == 'true' and
'@(Reference->AnyHaveMetadataValue('Identity', 'System.Runtime.InteropServices'))' == 'true'
- )
)" />
</ItemGroup>
public virtual bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => _inner.UsesNativeIdentifier(info, context);
public SignatureBehavior GetNativeSignatureBehavior(TypePositionInfo info) => _inner.GetNativeSignatureBehavior(info);
public ValueBoundaryBehavior GetValueBoundaryBehavior(TypePositionInfo info, StubCodeContext context) => _inner.GetValueBoundaryBehavior(info, context);
- public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => _inner.SupportsByValueMarshalKind(marshalKind, context);
+ public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => _inner.SupportsByValueMarshalKind(marshalKind, context);
public virtual IEnumerable<ExpressionSyntax> GenerateBind(TypePositionInfo info, StubCodeContext context)
{
public SignatureBehavior GetNativeSignatureBehavior(TypePositionInfo info) => SignatureBehavior.ManagedTypeAndAttributes;
public ValueBoundaryBehavior GetValueBoundaryBehavior(TypePositionInfo info, StubCodeContext context) => ValueBoundaryBehavior.ManagedIdentifier;
public bool IsSupported(TargetFramework target, Version version) => false;
- public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false;
+ public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => ByValueMarshalKindSupport.NotSupported;
public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => false;
}
}
GeneratorDiagnostic.NotSupported { NotSupportedDetails: null, TypePositionInfo: { IsManagedReturnPosition: false, MarshallingAttributeInfo: MarshalAsInfo } } => GeneratorDiagnostics.MarshalAsParameterConfigurationNotSupported,
GeneratorDiagnostic.NotSupported { NotSupportedDetails: not null, TypePositionInfo.IsManagedReturnPosition: true } => GeneratorDiagnostics.ReturnTypeNotSupportedWithDetails,
GeneratorDiagnostic.NotSupported { NotSupportedDetails: not null, TypePositionInfo.IsManagedReturnPosition: false } => GeneratorDiagnostics.ParameterTypeNotSupportedWithDetails,
+ GeneratorDiagnostic.UnnecessaryData { TypePositionInfo.IsManagedReturnPosition: false } => GeneratorDiagnostics.UnnecessaryParameterMarshallingInfo,
+ GeneratorDiagnostic.UnnecessaryData { TypePositionInfo.IsManagedReturnPosition: true } => GeneratorDiagnostics.UnnecessaryReturnMarshallingInfo,
{ IsFatal: false } => null,
{ TypePositionInfo.IsManagedReturnPosition: true } => GeneratorDiagnostics.ReturnTypeNotSupported,
{ TypePositionInfo.IsManagedReturnPosition: false } => GeneratorDiagnostics.ParameterTypeNotSupported,
public const string TypeNotSupported = Prefix + "1051";
public const string ConfigurationNotSupported = Prefix + "1052";
public const string RequiresAllowUnsafeBlocks = Prefix + "1062";
+ public const string UnnecessaryMarshallingInfo = Prefix + "1063";
public const string InvalidGeneratedComInterfaceAttributeUsage = Prefix + "1090";
public const string MemberWillNotBeSourceGenerated = Prefix + "1091";
public const string MultipleComInterfaceBaseTypes = Prefix + "1092";
isEnabledByDefault: true,
description: GetResourceString(nameof(SR.ClassDoesNotImplementAnyGeneratedComInterfacesDescription)));
+ public static readonly DiagnosticDescriptor UnnecessaryParameterMarshallingInfo =
+ new DiagnosticDescriptor(
+ Ids.UnnecessaryMarshallingInfo,
+ GetResourceString(nameof(SR.UnnecessaryMarshallingInfoTitle)),
+ GetResourceString(nameof(SR.UnnecessaryParameterMarshallingInfoMessage)),
+ Category,
+ DiagnosticSeverity.Info,
+ isEnabledByDefault: true,
+ description: GetResourceString(nameof(SR.UnnecessaryMarshallingInfoDescription)),
+ customTags: new[]
+ {
+ WellKnownDiagnosticTags.Unnecessary
+ });
+
+ public static readonly DiagnosticDescriptor UnnecessaryReturnMarshallingInfo =
+ new DiagnosticDescriptor(
+ Ids.UnnecessaryMarshallingInfo,
+ GetResourceString(nameof(SR.UnnecessaryMarshallingInfoTitle)),
+ GetResourceString(nameof(SR.UnnecessaryReturnMarshallingInfoMessage)),
+ Category,
+ DiagnosticSeverity.Info,
+ isEnabledByDefault: true,
+ description: GetResourceString(nameof(SR.UnnecessaryMarshallingInfoDescription)),
+ customTags: new[]
+ {
+ WellKnownDiagnosticTags.Unnecessary
+ });
+
/// <summary>
/// Report diagnostic for invalid configuration for string marshalling.
/// </summary>
public ValueBoundaryBehavior GetValueBoundaryBehavior(TypePositionInfo info, StubCodeContext context) => ValueBoundaryBehavior.NativeIdentifier;
public bool IsSupported(TargetFramework target, Version version)
=> target == TargetFramework.Net && version >= new Version(5, 0);
- public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false;
+ public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => ByValueMarshalKindSupport.NotSupported;
public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true;
}
}
public SignatureBehavior GetNativeSignatureBehavior(TypePositionInfo info) => SignatureBehavior.NativeType;
public ValueBoundaryBehavior GetValueBoundaryBehavior(TypePositionInfo info, StubCodeContext context) => ValueBoundaryBehavior.ManagedIdentifier;
public bool IsSupported(TargetFramework target, Version version) => true;
- public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false;
+ public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => ByValueMarshalKindSupport.NotSupported;
public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => false;
}
public SignatureBehavior GetNativeSignatureBehavior(TypePositionInfo info) => SignatureBehavior.NativeType;
public ValueBoundaryBehavior GetValueBoundaryBehavior(TypePositionInfo info, StubCodeContext context) => ValueBoundaryBehavior.ManagedIdentifier;
public bool IsSupported(TargetFramework target, Version version) => true;
- public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false;
+ public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => ByValueMarshalKindSupport.NotSupported;
public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => false;
}
}
public SignatureBehavior GetNativeSignatureBehavior(TypePositionInfo info) => SignatureBehavior.NativeType;
public ValueBoundaryBehavior GetValueBoundaryBehavior(TypePositionInfo info, StubCodeContext context) => ValueBoundaryBehavior.NativeIdentifier;
public bool IsSupported(TargetFramework target, Version version) => true;
- public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false;
+ public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => ByValueMarshalKindSupport.NotSupported;
public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true;
}
}
<data name="MarshalAsConfigurationNotSupportedMessageReturn" xml:space="preserve">
<value>The specified 'MarshalAsAttribute' configuration for the return value of method '{1}' is not supported by source-generated COM. If the specified configuration is required, use `ComImport` instead.</value>
</data>
+ <data name="UnnecessaryMarshallingInfoDescription" xml:space="preserve">
+ <value>Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</value>
+ </data>
+ <data name="UnnecessaryMarshallingInfoTitle" xml:space="preserve">
+ <value>Unnecessary marshalling info was provided and can be removed.</value>
+ </data>
+ <data name="UnnecessaryParameterMarshallingInfoMessage" xml:space="preserve">
+ <value>Unnecessary marshalling info '{0}' was provided for parameter '{1}'</value>
+ </data>
+ <data name="UnnecessaryReturnMarshallingInfoMessage" xml:space="preserve">
+ <value>Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</value>
+ </data>
</root>
<target state="translated">Zadaný typ není podporován modelem COM generovaným zdrojem.</target>
<note />
</trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoDescription">
+ <source>Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</source>
+ <target state="new">Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoTitle">
+ <source>Unnecessary marshalling info was provided and can be removed.</source>
+ <target state="new">Unnecessary marshalling info was provided and can be removed.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryParameterMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for parameter '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for parameter '{1}'</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryReturnMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</target>
+ <note />
+ </trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
<target state="translated">Der angegebene Typ wird vom quellgenerierten COM nicht unterstützt.</target>
<note />
</trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoDescription">
+ <source>Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</source>
+ <target state="new">Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoTitle">
+ <source>Unnecessary marshalling info was provided and can be removed.</source>
+ <target state="new">Unnecessary marshalling info was provided and can be removed.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryParameterMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for parameter '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for parameter '{1}'</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryReturnMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</target>
+ <note />
+ </trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
<target state="translated">El tipo especificado no es compatible con COM generado por el origen</target>
<note />
</trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoDescription">
+ <source>Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</source>
+ <target state="new">Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoTitle">
+ <source>Unnecessary marshalling info was provided and can be removed.</source>
+ <target state="new">Unnecessary marshalling info was provided and can be removed.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryParameterMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for parameter '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for parameter '{1}'</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryReturnMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</target>
+ <note />
+ </trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
<target state="translated">Le type spécifié n’est pas pris en charge par com généré par la source</target>
<note />
</trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoDescription">
+ <source>Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</source>
+ <target state="new">Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoTitle">
+ <source>Unnecessary marshalling info was provided and can be removed.</source>
+ <target state="new">Unnecessary marshalling info was provided and can be removed.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryParameterMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for parameter '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for parameter '{1}'</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryReturnMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</target>
+ <note />
+ </trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
<target state="translated">Il tipo specificato non è supportato da COM generati dall'origine</target>
<note />
</trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoDescription">
+ <source>Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</source>
+ <target state="new">Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoTitle">
+ <source>Unnecessary marshalling info was provided and can be removed.</source>
+ <target state="new">Unnecessary marshalling info was provided and can be removed.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryParameterMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for parameter '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for parameter '{1}'</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryReturnMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</target>
+ <note />
+ </trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
<target state="translated">指定された型は、ソース生成済みの COM ではサポートされていません</target>
<note />
</trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoDescription">
+ <source>Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</source>
+ <target state="new">Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoTitle">
+ <source>Unnecessary marshalling info was provided and can be removed.</source>
+ <target state="new">Unnecessary marshalling info was provided and can be removed.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryParameterMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for parameter '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for parameter '{1}'</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryReturnMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</target>
+ <note />
+ </trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
<target state="translated">지정된 형식은 원본 생성 COM에서 지원되지 않습니다.</target>
<note />
</trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoDescription">
+ <source>Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</source>
+ <target state="new">Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoTitle">
+ <source>Unnecessary marshalling info was provided and can be removed.</source>
+ <target state="new">Unnecessary marshalling info was provided and can be removed.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryParameterMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for parameter '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for parameter '{1}'</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryReturnMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</target>
+ <note />
+ </trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
<target state="translated">Określony typ nie jest obsługiwany przez źródłowy COM</target>
<note />
</trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoDescription">
+ <source>Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</source>
+ <target state="new">Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoTitle">
+ <source>Unnecessary marshalling info was provided and can be removed.</source>
+ <target state="new">Unnecessary marshalling info was provided and can be removed.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryParameterMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for parameter '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for parameter '{1}'</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryReturnMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</target>
+ <note />
+ </trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
<target state="translated">Um COM gerado pela origem não dá suporte ao tipo especificado.</target>
<note />
</trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoDescription">
+ <source>Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</source>
+ <target state="new">Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoTitle">
+ <source>Unnecessary marshalling info was provided and can be removed.</source>
+ <target state="new">Unnecessary marshalling info was provided and can be removed.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryParameterMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for parameter '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for parameter '{1}'</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryReturnMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</target>
+ <note />
+ </trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
<target state="translated">Указанный тип не поддерживается моделью COM генератора исходного кода.</target>
<note />
</trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoDescription">
+ <source>Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</source>
+ <target state="new">Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoTitle">
+ <source>Unnecessary marshalling info was provided and can be removed.</source>
+ <target state="new">Unnecessary marshalling info was provided and can be removed.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryParameterMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for parameter '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for parameter '{1}'</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryReturnMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</target>
+ <note />
+ </trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
<target state="translated">Belirtilen tür, kaynak tarafından oluşturulan COM tarafından desteklenmiyor</target>
<note />
</trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoDescription">
+ <source>Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</source>
+ <target state="new">Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoTitle">
+ <source>Unnecessary marshalling info was provided and can be removed.</source>
+ <target state="new">Unnecessary marshalling info was provided and can be removed.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryParameterMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for parameter '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for parameter '{1}'</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryReturnMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</target>
+ <note />
+ </trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
<target state="translated">源生成的 COM 不支持指定的类型</target>
<note />
</trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoDescription">
+ <source>Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</source>
+ <target state="new">Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoTitle">
+ <source>Unnecessary marshalling info was provided and can be removed.</source>
+ <target state="new">Unnecessary marshalling info was provided and can be removed.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryParameterMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for parameter '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for parameter '{1}'</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryReturnMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</target>
+ <note />
+ </trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
<target state="translated">来源產生的 COM 不支援指定的類型。</target>
<note />
</trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoDescription">
+ <source>Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</source>
+ <target state="new">Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoTitle">
+ <source>Unnecessary marshalling info was provided and can be removed.</source>
+ <target state="new">Unnecessary marshalling info was provided and can be removed.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryParameterMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for parameter '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for parameter '{1}'</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryReturnMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</target>
+ <note />
+ </trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
GeneratorDiagnostic.NotSupported { NotSupportedDetails: null, TypePositionInfo: { IsManagedReturnPosition: false, MarshallingAttributeInfo: MarshalAsInfo } } => GeneratorDiagnostics.MarshalAsParameterConfigurationNotSupported,
GeneratorDiagnostic.NotSupported { NotSupportedDetails: not null, TypePositionInfo.IsManagedReturnPosition: true } => GeneratorDiagnostics.ReturnTypeNotSupportedWithDetails,
GeneratorDiagnostic.NotSupported { NotSupportedDetails: not null, TypePositionInfo.IsManagedReturnPosition: false } => GeneratorDiagnostics.ParameterTypeNotSupportedWithDetails,
+ GeneratorDiagnostic.UnnecessaryData { TypePositionInfo.IsManagedReturnPosition: false } => GeneratorDiagnostics.UnnecessaryParameterMarshallingInfo,
+ GeneratorDiagnostic.UnnecessaryData { TypePositionInfo.IsManagedReturnPosition: true } => GeneratorDiagnostics.UnnecessaryReturnMarshallingInfo,
{ IsFatal: false } => null,
{ TypePositionInfo.IsManagedReturnPosition: true } => GeneratorDiagnostics.ReturnTypeNotSupported,
{ TypePositionInfo.IsManagedReturnPosition: false } => GeneratorDiagnostics.ParameterTypeNotSupported,
public const string CannotForwardToDllImport = Prefix + "1053";
public const string RequiresAllowUnsafeBlocks = Prefix + "1062";
+ public const string UnnecessaryMarshallingInfo = Prefix + "1063";
}
private const string Category = "LibraryImportGenerator";
isEnabledByDefault: true,
description: GetResourceString(nameof(SR.RequiresAllowUnsafeBlocksDescription)));
+ public static readonly DiagnosticDescriptor UnnecessaryParameterMarshallingInfo =
+ new DiagnosticDescriptor(
+ Ids.UnnecessaryMarshallingInfo,
+ GetResourceString(nameof(SR.UnnecessaryMarshallingInfoTitle)),
+ GetResourceString(nameof(SR.UnnecessaryParameterMarshallingInfoMessage)),
+ Category,
+ DiagnosticSeverity.Info,
+ isEnabledByDefault: true,
+ description: GetResourceString(nameof(SR.UnnecessaryMarshallingInfoDescription)),
+ customTags: new[]
+ {
+ WellKnownDiagnosticTags.Unnecessary
+ });
+ public static readonly DiagnosticDescriptor UnnecessaryReturnMarshallingInfo =
+ new DiagnosticDescriptor(
+ Ids.UnnecessaryMarshallingInfo,
+ GetResourceString(nameof(SR.UnnecessaryMarshallingInfoTitle)),
+ GetResourceString(nameof(SR.UnnecessaryReturnMarshallingInfoMessage)),
+ Category,
+ DiagnosticSeverity.Info,
+ isEnabledByDefault: true,
+ description: GetResourceString(nameof(SR.UnnecessaryMarshallingInfoDescription)),
+ customTags: new[]
+ {
+ WellKnownDiagnosticTags.Unnecessary
+ });
+
/// <summary>
/// Report diagnostic for invalid configuration for string marshalling.
/// </summary>
<data name="MarshalAsConfigurationNotSupportedMessageReturn" xml:space="preserve">
<value>The specified 'MarshalAsAttribute' configuration for the return value of method '{1}' is not supported by source-generated P/Invokes. If the specified configuration is required, use a regular 'DllImport' instead.</value>
</data>
+ <data name="UnnecessaryMarshallingInfoDescription" xml:space="preserve">
+ <value>Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</value>
+ </data>
+ <data name="UnnecessaryMarshallingInfoTitle" xml:space="preserve">
+ <value>Unnecessary marshalling info was provided and can be removed.</value>
+ </data>
+ <data name="UnnecessaryParameterMarshallingInfoMessage" xml:space="preserve">
+ <value>Unnecessary marshalling info '{0}' was provided for parameter '{1}'</value>
+ </data>
+ <data name="UnnecessaryReturnMarshallingInfoMessage" xml:space="preserve">
+ <value>Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</value>
+ </data>
</root>
\ No newline at end of file
<target state="translated">Určený typ nepodporují zdrojem generovaná volání P/Invokes.</target>
<note />
</trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoDescription">
+ <source>Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</source>
+ <target state="new">Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoTitle">
+ <source>Unnecessary marshalling info was provided and can be removed.</source>
+ <target state="new">Unnecessary marshalling info was provided and can be removed.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryParameterMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for parameter '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for parameter '{1}'</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryReturnMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</target>
+ <note />
+ </trans-unit>
<trans-unit id="ValueInCallerAllocatedBufferRequiresSpanConstructorDescription">
<source>A 'Value'-kind native type that supports the 'CallerAllocatedBuffer' feature must provide a two-parameter constructor taking the managed type and a 'Span' of an 'unmanaged' type as parameters</source>
<target state="translated">Nativní typ druhu Value, který podporuje funkci CallerAllocatedBuffer, musí poskytovat dvouparametrový konstruktor přebírající spravovaný prvek a hodnotu Span jako parametry.</target>
<target state="translated">Der angegebene Typ wird von quellgenerierten P/Invokes nicht unterstützt.</target>
<note />
</trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoDescription">
+ <source>Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</source>
+ <target state="new">Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoTitle">
+ <source>Unnecessary marshalling info was provided and can be removed.</source>
+ <target state="new">Unnecessary marshalling info was provided and can be removed.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryParameterMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for parameter '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for parameter '{1}'</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryReturnMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</target>
+ <note />
+ </trans-unit>
<trans-unit id="ValueInCallerAllocatedBufferRequiresSpanConstructorDescription">
<source>A 'Value'-kind native type that supports the 'CallerAllocatedBuffer' feature must provide a two-parameter constructor taking the managed type and a 'Span' of an 'unmanaged' type as parameters</source>
<target state="translated">Ein nativer Typ „Value“, der das Feature „CallerAllocatedBuffer“ unterstützt, muss einen Konstruktor mit zwei Parametern bereitstellen, der den verwalteten Typ und „Span“ eines „Unmanaged“-Typs als Parameter verwendet.</target>
<target state="translated">El tipo especificado no está admitido por P/Invokes de un generador de código fuente</target>
<note />
</trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoDescription">
+ <source>Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</source>
+ <target state="new">Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoTitle">
+ <source>Unnecessary marshalling info was provided and can be removed.</source>
+ <target state="new">Unnecessary marshalling info was provided and can be removed.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryParameterMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for parameter '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for parameter '{1}'</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryReturnMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</target>
+ <note />
+ </trans-unit>
<trans-unit id="ValueInCallerAllocatedBufferRequiresSpanConstructorDescription">
<source>A 'Value'-kind native type that supports the 'CallerAllocatedBuffer' feature must provide a two-parameter constructor taking the managed type and a 'Span' of an 'unmanaged' type as parameters</source>
<target state="translated">Un tipo nativo de tipo \"Value\" que admita la característica \"CallerAllocatedBuffer\" debe proporcionar un constructor de dos parámetros que tome el tipo administrado y un \"Span\" de un tipo \"no administrado\" como parámetros</target>
<target state="translated">Le type spécifié n’est pas prise en charge par les P/Invokes générés par la source.</target>
<note />
</trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoDescription">
+ <source>Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</source>
+ <target state="new">Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoTitle">
+ <source>Unnecessary marshalling info was provided and can be removed.</source>
+ <target state="new">Unnecessary marshalling info was provided and can be removed.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryParameterMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for parameter '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for parameter '{1}'</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryReturnMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</target>
+ <note />
+ </trans-unit>
<trans-unit id="ValueInCallerAllocatedBufferRequiresSpanConstructorDescription">
<source>A 'Value'-kind native type that supports the 'CallerAllocatedBuffer' feature must provide a two-parameter constructor taking the managed type and a 'Span' of an 'unmanaged' type as parameters</source>
<target state="translated">Un type natif de type «Value» qui prend en charge la fonctionnalité «CallerAllocatedBuffer» doit fournir un constructeur à deux paramètres prenant le type managé et un « Span » d’un type « non géré » comme paramètres</target>
<target state="translated">Il tipo specificato non è supportato dai P/Invoke generati dall'origine</target>
<note />
</trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoDescription">
+ <source>Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</source>
+ <target state="new">Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoTitle">
+ <source>Unnecessary marshalling info was provided and can be removed.</source>
+ <target state="new">Unnecessary marshalling info was provided and can be removed.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryParameterMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for parameter '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for parameter '{1}'</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryReturnMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</target>
+ <note />
+ </trans-unit>
<trans-unit id="ValueInCallerAllocatedBufferRequiresSpanConstructorDescription">
<source>A 'Value'-kind native type that supports the 'CallerAllocatedBuffer' feature must provide a two-parameter constructor taking the managed type and a 'Span' of an 'unmanaged' type as parameters</source>
<target state="translated">Un tipo nativo di tipo 'Value' che supporta la funzionalità 'CallerAllocatedBuffer' deve fornire un costruttore a due parametri che accetta il tipo gestito e un 'Span' di un tipo 'non gestito' come parametri</target>
<target state="translated">指定された型は、ソースで生成された P/Invoke ではサポートされていません</target>
<note />
</trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoDescription">
+ <source>Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</source>
+ <target state="new">Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoTitle">
+ <source>Unnecessary marshalling info was provided and can be removed.</source>
+ <target state="new">Unnecessary marshalling info was provided and can be removed.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryParameterMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for parameter '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for parameter '{1}'</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryReturnMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</target>
+ <note />
+ </trans-unit>
<trans-unit id="ValueInCallerAllocatedBufferRequiresSpanConstructorDescription">
<source>A 'Value'-kind native type that supports the 'CallerAllocatedBuffer' feature must provide a two-parameter constructor taking the managed type and a 'Span' of an 'unmanaged' type as parameters</source>
<target state="translated">'CallerAllocatedBuffer' 機能をサポートする 'Value' のネイティブ型では、マネージド型と 'アンマネージド' 型の 'Span' をパラメーターとして受け取る 2 つのパラメーター コンストラクターを指定する必要があります</target>
<target state="translated">지정된 형식은 소스 생성 P/Invoke에서 지원되지 않습니다.</target>
<note />
</trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoDescription">
+ <source>Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</source>
+ <target state="new">Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoTitle">
+ <source>Unnecessary marshalling info was provided and can be removed.</source>
+ <target state="new">Unnecessary marshalling info was provided and can be removed.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryParameterMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for parameter '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for parameter '{1}'</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryReturnMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</target>
+ <note />
+ </trans-unit>
<trans-unit id="ValueInCallerAllocatedBufferRequiresSpanConstructorDescription">
<source>A 'Value'-kind native type that supports the 'CallerAllocatedBuffer' feature must provide a two-parameter constructor taking the managed type and a 'Span' of an 'unmanaged' type as parameters</source>
<target state="translated">'CallerAllocatedBuffer' 기능을 지원하는 '값' 종류의 네이티브 형식은 관리되는 형식과 '관리되지 않는' 형식의 'Span'을 매개 변수로 사용하는 두 개의 매개 변수 생성자를 제공해야 합니다.</target>
<target state="translated">Określony typ nie jest obsługiwany przez funkcję P/Invokes generowaną przez źródło</target>
<note />
</trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoDescription">
+ <source>Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</source>
+ <target state="new">Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoTitle">
+ <source>Unnecessary marshalling info was provided and can be removed.</source>
+ <target state="new">Unnecessary marshalling info was provided and can be removed.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryParameterMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for parameter '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for parameter '{1}'</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryReturnMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</target>
+ <note />
+ </trans-unit>
<trans-unit id="ValueInCallerAllocatedBufferRequiresSpanConstructorDescription">
<source>A 'Value'-kind native type that supports the 'CallerAllocatedBuffer' feature must provide a two-parameter constructor taking the managed type and a 'Span' of an 'unmanaged' type as parameters</source>
<target state="translated">Typ natywny rodzaju „Value”, który obsługuje funkcję „CallerAllocatedBuffer” musi zapewniać konstruktora z dwoma parametrami przyjmującego typ zarządzany i wartość „Span” typu „unmanaged” jako parametry</target>
<target state="translated">O tipo especificado não tem suporte de P/Invokes gerados pela origem.</target>
<note />
</trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoDescription">
+ <source>Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</source>
+ <target state="new">Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoTitle">
+ <source>Unnecessary marshalling info was provided and can be removed.</source>
+ <target state="new">Unnecessary marshalling info was provided and can be removed.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryParameterMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for parameter '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for parameter '{1}'</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryReturnMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</target>
+ <note />
+ </trans-unit>
<trans-unit id="ValueInCallerAllocatedBufferRequiresSpanConstructorDescription">
<source>A 'Value'-kind native type that supports the 'CallerAllocatedBuffer' feature must provide a two-parameter constructor taking the managed type and a 'Span' of an 'unmanaged' type as parameters</source>
<target state="translated">Um tipo nativo do tipo 'Value' que dá suporte ao recurso 'CallerAllocatedBuffer' deve fornecer um construtor de dois parâmetros usando o tipo gerenciado e um 'Span' de um tipo 'não gerenciado' como parâmetros</target>
<target state="translated">Указанный тип не поддерживается в P/Invoke с созданием источника.</target>
<note />
</trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoDescription">
+ <source>Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</source>
+ <target state="new">Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoTitle">
+ <source>Unnecessary marshalling info was provided and can be removed.</source>
+ <target state="new">Unnecessary marshalling info was provided and can be removed.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryParameterMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for parameter '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for parameter '{1}'</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryReturnMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</target>
+ <note />
+ </trans-unit>
<trans-unit id="ValueInCallerAllocatedBufferRequiresSpanConstructorDescription">
<source>A 'Value'-kind native type that supports the 'CallerAllocatedBuffer' feature must provide a two-parameter constructor taking the managed type and a 'Span' of an 'unmanaged' type as parameters</source>
<target state="translated">Собственный тип вида \"Value\", который поддерживает функцию \"CallerAllocatedBuffer\", должен предоставлять конструктор с двумя параметрами: управляемый тип и \"Span неуправляемого типа\"</target>
<target state="translated">Belirtilen tür, kaynak tarafından oluşturulan P/Invokes tarafından desteklenmiyor</target>
<note />
</trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoDescription">
+ <source>Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</source>
+ <target state="new">Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoTitle">
+ <source>Unnecessary marshalling info was provided and can be removed.</source>
+ <target state="new">Unnecessary marshalling info was provided and can be removed.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryParameterMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for parameter '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for parameter '{1}'</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryReturnMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</target>
+ <note />
+ </trans-unit>
<trans-unit id="ValueInCallerAllocatedBufferRequiresSpanConstructorDescription">
<source>A 'Value'-kind native type that supports the 'CallerAllocatedBuffer' feature must provide a two-parameter constructor taking the managed type and a 'Span' of an 'unmanaged' type as parameters</source>
<target state="translated">'CallerAllocatedBuffer' özelliğini destekleyen bir 'Value' tipi yerel türün, yönetilen türü ve 'unmanaged' türünün 'Span' değerini parametre olarak alan iki parametreli bir oluşturucu sağlaması gerekir</target>
<target state="translated">源生成的 P/Invoke 不支持指定的类型</target>
<note />
</trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoDescription">
+ <source>Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</source>
+ <target state="new">Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoTitle">
+ <source>Unnecessary marshalling info was provided and can be removed.</source>
+ <target state="new">Unnecessary marshalling info was provided and can be removed.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryParameterMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for parameter '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for parameter '{1}'</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryReturnMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</target>
+ <note />
+ </trans-unit>
<trans-unit id="ValueInCallerAllocatedBufferRequiresSpanConstructorDescription">
<source>A 'Value'-kind native type that supports the 'CallerAllocatedBuffer' feature must provide a two-parameter constructor taking the managed type and a 'Span' of an 'unmanaged' type as parameters</source>
<target state="translated">支持 \"CallerAllocatedBuffer\" 功能的 \"Value\" 种类本机类型必须提供以托管类型和“非管理”类型的 \"Span\" 作为参数的双参数构造函数</target>
<target state="translated">来源產生的 P/Invokes 不支援指定的類型。</target>
<note />
</trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoDescription">
+ <source>Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</source>
+ <target state="new">Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryMarshallingInfoTitle">
+ <source>Unnecessary marshalling info was provided and can be removed.</source>
+ <target state="new">Unnecessary marshalling info was provided and can be removed.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryParameterMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for parameter '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for parameter '{1}'</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="UnnecessaryReturnMarshallingInfoMessage">
+ <source>Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</source>
+ <target state="new">Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'</target>
+ <note />
+ </trans-unit>
<trans-unit id="ValueInCallerAllocatedBufferRequiresSpanConstructorDescription">
<source>A 'Value'-kind native type that supports the 'CallerAllocatedBuffer' feature must provide a two-parameter constructor taking the managed type and a 'Span' of an 'unmanaged' type as parameters</source>
<target state="translated">支援 'CallerAllocatedBuffer' 功能的 'Value'-kind 原生類型必須提供接受受管理類型的雙參數建構函示,以及以 'unmanaged' 類型的 'Span' 作為參數</target>
};
if (marshallerName is null)
+ {
return new MarshalAsInfo(unmanagedType, _defaultInfo.CharEncoding);
+ }
return StringMarshallingInfoProvider.CreateStringMarshallingInfo(_compilation, type, marshallerName);
}
return ResolvedGenerator.NotSupported(
new GeneratorDiagnostic.NotSupported(info, context)
- {
- NotSupportedDetails = SR.RuntimeMarshallingMustBeDisabled,
- DiagnosticProperties = AddDisableRuntimeMarshallingAttributeProperties
+ {
+ NotSupportedDetails = SR.RuntimeMarshallingMustBeDisabled,
+ DiagnosticProperties = AddDisableRuntimeMarshallingAttributeProperties
});
}
case ConstSizeCountInfo(int size):
return new(GetConstSizeExpression(size));
case SizeAndParamIndexInfo(SizeAndParamIndexInfo.UnspecifiedConstSize, TypePositionInfo param):
- {
+ {
return GetExpressionForParam(param, out bool isIntType) switch
{
(ExpressionSyntax expr, null) => new(isIntType ? expr : CheckedExpression(SyntaxKind.CheckedExpression, expr)),
(null, GeneratorDiagnostic.NotSupported notSupported) => new(notSupported),
(not null, not null) => throw new UnreachableException()
};
- }
+ }
case SizeAndParamIndexInfo(int size, TypePositionInfo param):
return GetExpressionForParam(param, out bool _) switch
{
(ExpressionSyntax expr, null) => new(
CheckedExpression(SyntaxKind.CheckedExpression,
- BinaryExpression(SyntaxKind.AddExpression,
- GetConstSizeExpression(size),
+ BinaryExpression(SyntaxKind.AddExpression,
+ GetConstSizeExpression(size),
expr))),
(null, GeneratorDiagnostic.NotSupported notSupported) => new(notSupported),
(not null, not null) => throw new UnreachableException()
};
case CountElementCountInfo(TypePositionInfo elementInfo):
- {
+ {
return GetExpressionForParam(elementInfo, out bool isIntType) switch
{
(ExpressionSyntax expr, null) => new(isIntType ? expr : CheckedExpression(SyntaxKind.CheckedExpression, expr)),
(null, GeneratorDiagnostic.NotSupported notSupported) => new(notSupported),
(not null, not null) => throw new UnreachableException()
};
- }
+ }
default:
return new(new GeneratorDiagnostic.NotSupported(info, context)
{
}
}
- IMarshallingGenerator marshallingGenerator = new CustomTypeMarshallingGenerator(marshallingStrategy, enableByValueContentsMarshalling: false);
+ IMarshallingGenerator marshallingGenerator = new CustomTypeMarshallingGenerator(marshallingStrategy, ByValueMarshalKindSupport.NotSupported);
if (marshallerData.Shape.HasFlag(MarshallerShape.StatelessPinnableReference))
{
if (numElementsExpressionResult is (_, GeneratorDiagnostic.NotSupported notSupportedDiagnostic))
{
return ResolvedGenerator.NotSupported(notSupportedDiagnostic);
- }
+ }
numElementsExpression = numElementsExpressionResult.Expression;
}
}
}
+ ByValueMarshalKindSupport byValueMarshalKindSupport;
+ if (info.ManagedType is not SzArrayType)
+ {
+ // We only support the [In] and [Out] attributes on array types.
+ byValueMarshalKindSupport = ByValueMarshalKindSupport.NotSupported;
+ }
+ else if (!elementIsBlittable || ElementTypeIsSometimesNonBlittable(elementInfo))
+ {
+ // If the type is not blittable or is sometimes not blittable, we will generate different code when the attributes are provided.
+ byValueMarshalKindSupport = ByValueMarshalKindSupport.Supported;
+ }
+ else
+ {
+ // If the type is always blittable, we'll generate the same code regardless of the attributes,
+ // but we'll allow them to make it easier to transition to source-generated code and allow users to be clear about expectations
+ // for values in pre-allocated buffers.
+ byValueMarshalKindSupport = ByValueMarshalKindSupport.Unnecessary;
+ }
+
IMarshallingGenerator marshallingGenerator = new CustomTypeMarshallingGenerator(
marshallingStrategy,
- enableByValueContentsMarshalling: info.ManagedType is SzArrayType && (!elementIsBlittable || ElementTypeIsSometimesNonBlittable(elementInfo)));
+ byValueMarshalKindSupport);
// Elements in the collection must be blittable to use the pinnable marshaller.
if (marshallerData.Shape.HasFlag(MarshallerShape.StatelessPinnableReference) && elementIsBlittable)
return info.IsByRef && !context.IsInStubReturnPosition(info) && !context.SingleFrameSpansNativeContext;
}
- public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false;
+ public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => ByValueMarshalKindSupport.NotSupported;
}
}
public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true;
- public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false;
+ public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => ByValueMarshalKindSupport.NotSupported;
}
/// <summary>
// The .NET Foundation licenses this file to you under the MIT license.
using System;
-using System.Collections.Generic;
-using System.Text;
+using System.Collections.Immutable;
+using Microsoft.CodeAnalysis;
namespace Microsoft.Interop
{
NotSupportedDetails = SR.InAttributeNotSupportedWithoutOut
}));
}
- else if (info.ByValueContentsMarshalKind != ByValueContentsMarshalKind.Default
- && !generator.Generator.SupportsByValueMarshalKind(info.ByValueContentsMarshalKind, context))
+ else if (info.ByValueContentsMarshalKind != ByValueContentsMarshalKind.Default)
{
- return ResolvedGenerator.ResolvedWithDiagnostics(s_forwarder, generator.Diagnostics.Add(new GeneratorDiagnostic.NotSupported(info, context)
+ ByValueMarshalKindSupport support = generator.Generator.SupportsByValueMarshalKind(info.ByValueContentsMarshalKind, context);
+ if (support == ByValueMarshalKindSupport.NotSupported)
{
- NotSupportedDetails = SR.InOutAttributeMarshalerNotSupported
- }));
+ return ResolvedGenerator.ResolvedWithDiagnostics(s_forwarder, generator.Diagnostics.Add(new GeneratorDiagnostic.NotSupported(info, context)
+ {
+ NotSupportedDetails = SR.InOutAttributeMarshalerNotSupported
+ }));
+ }
+ else if (support == ByValueMarshalKindSupport.Unnecessary)
+ {
+ var locations = ImmutableArray<Location>.Empty;
+ if (info.ByValueMarshalAttributeLocations.InLocation is not null)
+ {
+ locations = locations.Add(info.ByValueMarshalAttributeLocations.InLocation);
+ }
+ if (info.ByValueMarshalAttributeLocations.OutLocation is not null)
+ {
+ locations = locations.Add(info.ByValueMarshalAttributeLocations.OutLocation);
+ }
+
+ return generator with
+ {
+ Diagnostics = generator.Diagnostics.Add(new GeneratorDiagnostic.UnnecessaryData(info, context, locations)
+ {
+ UnnecessaryDataDetails = SR.InOutAttributes
+ })
+ };
+ }
}
return generator;
}
return context.IsInStubReturnPosition(info) || (info.IsByRef && !context.SingleFrameSpansNativeContext);
}
- public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false;
+ public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => ByValueMarshalKindSupport.NotSupported;
private static bool IsPinningPathSupported(TypePositionInfo info, StubCodeContext context)
{
internal sealed class CustomTypeMarshallingGenerator : IMarshallingGenerator
{
private readonly ICustomTypeMarshallingStrategy _nativeTypeMarshaller;
- private readonly bool _enableByValueContentsMarshalling;
+ private readonly ByValueMarshalKindSupport _byValueContentsMarshallingSupport;
- public CustomTypeMarshallingGenerator(ICustomTypeMarshallingStrategy nativeTypeMarshaller, bool enableByValueContentsMarshalling)
+ public CustomTypeMarshallingGenerator(ICustomTypeMarshallingStrategy nativeTypeMarshaller, ByValueMarshalKindSupport byValueContentsMarshallingSupport)
{
_nativeTypeMarshaller = nativeTypeMarshaller;
- _enableByValueContentsMarshalling = enableByValueContentsMarshalling;
+ _byValueContentsMarshallingSupport = byValueContentsMarshallingSupport;
}
public bool IsSupported(TargetFramework target, Version version)
private bool ShouldGenerateByValueOutMarshalling(TypePositionInfo info)
{
- return _enableByValueContentsMarshalling && !info.IsByRef && info.ByValueContentsMarshalKind.HasFlag(ByValueContentsMarshalKind.Out);
+ return _byValueContentsMarshallingSupport == ByValueMarshalKindSupport.Supported && !info.IsByRef && info.ByValueContentsMarshalKind.HasFlag(ByValueContentsMarshalKind.Out);
}
- public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context)
+ public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context)
{
- return _enableByValueContentsMarshalling;
+ return _byValueContentsMarshallingSupport;
}
public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context)
public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true;
- public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false;
+ public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => ByValueMarshalKindSupport.NotSupported;
}
}
using System;
using System.Collections.Generic;
-using System.Runtime.InteropServices;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
-using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
namespace Microsoft.Interop
{
public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => false;
- public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => true;
+ public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => ByValueMarshalKindSupport.Supported;
}
}
/// <summary>
/// [Optional] Properties to attach to any diagnostic emitted due to this exception.
/// </summary>
- public ImmutableDictionary<string, string>? DiagnosticProperties { get; init; }
+ public ImmutableDictionary<string, string> DiagnosticProperties { get; init; } = ImmutableDictionary<string, string>.Empty;
public TypePositionInfo TypePositionInfo { get; }
public StubCodeContext StubCodeContext { get; }
public bool IsFatal { get; }
or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_UIntPtr }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.SysUInt, _) }
or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Single }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.R4, _) }
or { ManagedType: SpecialTypeInfo { SpecialType: SpecialType.System_Double }, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.R8, _) }:
+ // TODO: Report the MarshalAs attribute as unnecessary
return ResolvedGenerator.Resolved(s_blittable);
// Enum with no marshalling info
}
/// <summary>
+ /// An enumeration describing if the provided <see cref="ByValueContentsMarshalKind" /> is supported and changes behavior from the default behavior.
+ /// </summary>
+ public enum ByValueMarshalKindSupport
+ {
+ /// <summary>
+ /// The provided <see cref="ByValueContentsMarshalKind" /> is supported and changes behavior from the default behavior.
+ /// </summary>
+ Supported,
+ /// <summary>
+ /// The provided <see cref="ByValueContentsMarshalKind" /> is not supported.
+ /// </summary>
+ NotSupported,
+ /// <summary>
+ /// The provided <see cref="ByValueContentsMarshalKind" /> is supported but does not change behavior from the default in this scenario.
+ /// </summary>
+ Unnecessary,
+ }
+
+ /// <summary>
/// Interface for generation of marshalling code for P/Invoke stubs
/// </summary>
public interface IMarshallingGenerator
/// </summary>
/// <param name="marshalKind">The marshal kind.</param>
/// <param name="context">The marshalling context.</param>
- /// <returns></returns>
- bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context);
+ /// <returns>If the provided <paramref name="marshalKind"/> is supported and if it is required to specify the requested behavior.</returns>
+ ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context);
}
}
public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true;
- public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false;
+ public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => ByValueMarshalKindSupport.NotSupported;
}
}
return _innerMarshallingGenerator.Generate(info, context);
}
- public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context)
+ public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context)
{
return _innerMarshallingGenerator.SupportsByValueMarshalKind(marshalKind, context);
}
public SignatureBehavior GetNativeSignatureBehavior(TypePositionInfo info) => _inner.GetNativeSignatureBehavior(info);
public ValueBoundaryBehavior GetValueBoundaryBehavior(TypePositionInfo info, StubCodeContext context) => _inner.GetValueBoundaryBehavior(info, context);
public bool IsSupported(TargetFramework target, Version version) => _inner.IsSupported(target, version);
- public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => _inner.SupportsByValueMarshalKind(marshalKind, context);
+ public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => _inner.SupportsByValueMarshalKind(marshalKind, context);
public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => _inner.UsesNativeIdentifier(info, context);
}
<data name="TypeAccessibilityDetails" xml:space="preserve">
<value>'{0}' has accessibility '{1}'.</value>
</data>
+ <data name="InOutAttributes" xml:space="preserve">
+ <value>[In] and [Out] attributes</value>
+ </data>
</root>
\ No newline at end of file
<target state="translated">Poskytnuté atributy „[In]“ a „[Out]“ u tohoto parametru se na tomto parametru nepodporují.</target>
<note />
</trans-unit>
+ <trans-unit id="InOutAttributes">
+ <source>[In] and [Out] attributes</source>
+ <target state="new">[In] and [Out] attributes</target>
+ <note />
+ </trans-unit>
<trans-unit id="ManagedToUnmanagedMissingRequiredMarshaller">
<source>The specified parameter needs to be marshalled from managed to unmanaged, but the marshaller type '{0}' does not support it.</source>
<target state="translated">Určený parametr musí být zařazený ze spravovaného do nespravovaného, ale zařazovací typ {0} to nepodporuje.</target>
<target state="translated">Die angegebenen Attribute \"[In]\" und \"[Out]\" für diesen Parameter werden für diesen Parameter nicht unterstützt.</target>
<note />
</trans-unit>
+ <trans-unit id="InOutAttributes">
+ <source>[In] and [Out] attributes</source>
+ <target state="new">[In] and [Out] attributes</target>
+ <note />
+ </trans-unit>
<trans-unit id="ManagedToUnmanagedMissingRequiredMarshaller">
<source>The specified parameter needs to be marshalled from managed to unmanaged, but the marshaller type '{0}' does not support it.</source>
<target state="translated">Der angegebene Parameter muss von verwaltet zu nicht verwaltet gemarshallt werden, aber der Marshaller-Typ ‚{0}‘ unterstützt dies nicht.</target>
<target state="translated">En este parámetro, los atributos “[In]” y “[Out]” proporcionados no se admiten.</target>
<note />
</trans-unit>
+ <trans-unit id="InOutAttributes">
+ <source>[In] and [Out] attributes</source>
+ <target state="new">[In] and [Out] attributes</target>
+ <note />
+ </trans-unit>
<trans-unit id="ManagedToUnmanagedMissingRequiredMarshaller">
<source>The specified parameter needs to be marshalled from managed to unmanaged, but the marshaller type '{0}' does not support it.</source>
<target state="translated">El parámetro especificado debe serializarse de administrado a no administrado, pero el tipo no administrado “{0}” no lo admite.</target>
<target state="translated">Les attributs « [In] » et « [Out] » fournis sur ce paramètre ne sont pas pris en charge sur ce paramètre.</target>
<note />
</trans-unit>
+ <trans-unit id="InOutAttributes">
+ <source>[In] and [Out] attributes</source>
+ <target state="new">[In] and [Out] attributes</target>
+ <note />
+ </trans-unit>
<trans-unit id="ManagedToUnmanagedMissingRequiredMarshaller">
<source>The specified parameter needs to be marshalled from managed to unmanaged, but the marshaller type '{0}' does not support it.</source>
<target state="translated">Le paramètre spécifié doit être marshalé de managé à non managé, mais le type marshaleur « {0} » ne le prend pas en charge.</target>
<target state="translated">Gli attributi '[In]' e '[Out]' specificati per questo parametro non sono supportati in questo parametro.</target>
<note />
</trans-unit>
+ <trans-unit id="InOutAttributes">
+ <source>[In] and [Out] attributes</source>
+ <target state="new">[In] and [Out] attributes</target>
+ <note />
+ </trans-unit>
<trans-unit id="ManagedToUnmanagedMissingRequiredMarshaller">
<source>The specified parameter needs to be marshalled from managed to unmanaged, but the marshaller type '{0}' does not support it.</source>
<target state="translated">È necessario effettuare il marshalling del parametro specificato da gestito a non gestito, ma il tipo di gestore del marshalling '{0}' non lo supporta.</target>
<target state="translated">このパラメーターに指定された '[In]' 属性と '[Out]' 属性は、このパラメーターではサポートされていません。</target>
<note />
</trans-unit>
+ <trans-unit id="InOutAttributes">
+ <source>[In] and [Out] attributes</source>
+ <target state="new">[In] and [Out] attributes</target>
+ <note />
+ </trans-unit>
<trans-unit id="ManagedToUnmanagedMissingRequiredMarshaller">
<source>The specified parameter needs to be marshalled from managed to unmanaged, but the marshaller type '{0}' does not support it.</source>
<target state="translated">指定されたパラメーターはマネージドからアンマネージドにマーシャリングする必要がありますが、マーシャラー型 '{0}' ではそれはサポートされていません。</target>
<target state="translated">이 매개 변수에 제공된 '[In]' 및 '[Out]' 특성은 이 매개 변수에서 지원되지 않습니다.</target>
<note />
</trans-unit>
+ <trans-unit id="InOutAttributes">
+ <source>[In] and [Out] attributes</source>
+ <target state="new">[In] and [Out] attributes</target>
+ <note />
+ </trans-unit>
<trans-unit id="ManagedToUnmanagedMissingRequiredMarshaller">
<source>The specified parameter needs to be marshalled from managed to unmanaged, but the marshaller type '{0}' does not support it.</source>
<target state="translated">지정된 매개 변수를 관리형에서 비관리형으로 마샬링해야 하지만 마샬러 유형 '{0}'은(는) 지원하지 않습니다.</target>
<target state="translated">Podane atrybuty „[In]” i „[Out]” w tym parametrze nie są obsługiwane w tym parametrze.</target>
<note />
</trans-unit>
+ <trans-unit id="InOutAttributes">
+ <source>[In] and [Out] attributes</source>
+ <target state="new">[In] and [Out] attributes</target>
+ <note />
+ </trans-unit>
<trans-unit id="ManagedToUnmanagedMissingRequiredMarshaller">
<source>The specified parameter needs to be marshalled from managed to unmanaged, but the marshaller type '{0}' does not support it.</source>
<target state="translated">Określony parametr musi być kierowany z zarządzanego do niezarządzanego, ale typ marszałka „{0}” go nie obsługuje.</target>
<target state="translated">Os atributos '[In]' e '[Out]' neste parâmetro não têm suporte neste parâmetro.</target>
<note />
</trans-unit>
+ <trans-unit id="InOutAttributes">
+ <source>[In] and [Out] attributes</source>
+ <target state="new">[In] and [Out] attributes</target>
+ <note />
+ </trans-unit>
<trans-unit id="ManagedToUnmanagedMissingRequiredMarshaller">
<source>The specified parameter needs to be marshalled from managed to unmanaged, but the marshaller type '{0}' does not support it.</source>
<target state="translated">O parâmetro especificado precisa ser marshalled de gerenciado para não gerenciado, mas o tipo de marshaller '{0}' não dá suporte a ele.</target>
<target state="translated">Указанные атрибуты \"[In]\" и \"[Out]\" для этого параметра не поддерживаются.</target>
<note />
</trans-unit>
+ <trans-unit id="InOutAttributes">
+ <source>[In] and [Out] attributes</source>
+ <target state="new">[In] and [Out] attributes</target>
+ <note />
+ </trans-unit>
<trans-unit id="ManagedToUnmanagedMissingRequiredMarshaller">
<source>The specified parameter needs to be marshalled from managed to unmanaged, but the marshaller type '{0}' does not support it.</source>
<target state="translated">Указанный параметр необходимо маршалировать из управляемого в неуправляемый, но тип маршаллера "{0}" не поддерживает это.</target>
<target state="translated">Bu parametrede sağlanan '[In]' ve '[Out]' öznitelikleri bu parametrede desteklenmiyor.</target>
<note />
</trans-unit>
+ <trans-unit id="InOutAttributes">
+ <source>[In] and [Out] attributes</source>
+ <target state="new">[In] and [Out] attributes</target>
+ <note />
+ </trans-unit>
<trans-unit id="ManagedToUnmanagedMissingRequiredMarshaller">
<source>The specified parameter needs to be marshalled from managed to unmanaged, but the marshaller type '{0}' does not support it.</source>
<target state="translated">Belirtilen parametrenin yönetilenden yönetilmeyene doğru hazırlanması gerekiyor, ancak '{0}' hazırlayıcı türü bunu desteklemiyor.</target>
<target state="translated">此参数上提供的 “[In]” 和 “[Out]” 属性在此参数上不受支持。</target>
<note />
</trans-unit>
+ <trans-unit id="InOutAttributes">
+ <source>[In] and [Out] attributes</source>
+ <target state="new">[In] and [Out] attributes</target>
+ <note />
+ </trans-unit>
<trans-unit id="ManagedToUnmanagedMissingRequiredMarshaller">
<source>The specified parameter needs to be marshalled from managed to unmanaged, but the marshaller type '{0}' does not support it.</source>
<target state="translated">需要将指定的参数从托管封送到非托管,但封送程序类型“{0}”不支持它。</target>
<target state="translated">此參數不支援在此參數上提供的 '[In]' 和 '[Out]' 屬性。</target>
<note />
</trans-unit>
+ <trans-unit id="InOutAttributes">
+ <source>[In] and [Out] attributes</source>
+ <target state="new">[In] and [Out] attributes</target>
+ <note />
+ </trans-unit>
<trans-unit id="ManagedToUnmanagedMissingRequiredMarshaller">
<source>The specified parameter needs to be marshalled from managed to unmanaged, but the marshaller type '{0}' does not support it.</source>
<target state="translated">指定的參數必須從受控封送處理到非受控,但封送處理程式類型 '{0}' 不支援。</target>
public ByValueContentsMarshalKind ByValueContentsMarshalKind { get; init; }
+ public (Location? InLocation, Location? OutLocation) ByValueMarshalAttributeLocations { get; init; }
+
public bool IsManagedReturnPosition { get => ManagedIndex == ReturnIndex; }
public bool IsNativeReturnPosition { get => NativeIndex == ReturnIndex; }
public bool IsManagedExceptionPosition { get => ManagedIndex == ExceptionIndex; }
public static TypePositionInfo CreateForParameter(IParameterSymbol paramSymbol, MarshallingInfo marshallingInfo, Compilation compilation)
{
+ var (byValueContentsMarshalKind, inLocation, outLocation) = GetByValueContentsMarshalKind(paramSymbol.GetAttributes(), compilation);
+
var typeInfo = new TypePositionInfo(ManagedTypeInfo.CreateTypeInfoForTypeSymbol(paramSymbol.Type), marshallingInfo)
{
InstanceIdentifier = ParseToken(paramSymbol.Name).IsReservedKeyword() ? $"@{paramSymbol.Name}" : paramSymbol.Name,
RefKind = paramSymbol.RefKind,
RefKindSyntax = RefKindToSyntax(paramSymbol.RefKind),
- ByValueContentsMarshalKind = GetByValueContentsMarshalKind(paramSymbol.GetAttributes(), compilation),
+ ByValueContentsMarshalKind = byValueContentsMarshalKind,
+ ByValueMarshalAttributeLocations = (inLocation, outLocation),
ScopedKind = paramSymbol.ScopedKind
};
return typeInfo;
}
- private static ByValueContentsMarshalKind GetByValueContentsMarshalKind(IEnumerable<AttributeData> attributes, Compilation compilation)
+ private static (ByValueContentsMarshalKind, Location? inAttribute, Location? outAttribute) GetByValueContentsMarshalKind(IEnumerable<AttributeData> attributes, Compilation compilation)
{
INamedTypeSymbol outAttributeType = compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_OutAttribute)!;
INamedTypeSymbol inAttributeType = compilation.GetTypeByMetadataName(TypeNames.System_Runtime_InteropServices_InAttribute)!;
ByValueContentsMarshalKind marshalKind = ByValueContentsMarshalKind.Default;
+ Location? inAttributeLocation = null;
+ Location? outAttributeLocation = null;
foreach (AttributeData attr in attributes)
{
if (SymbolEqualityComparer.Default.Equals(attr.AttributeClass, outAttributeType))
{
marshalKind |= ByValueContentsMarshalKind.Out;
+ outAttributeLocation = attr.ApplicationSyntaxReference.SyntaxTree.GetLocation(attr.ApplicationSyntaxReference.Span);
}
else if (SymbolEqualityComparer.Default.Equals(attr.AttributeClass, inAttributeType))
{
marshalKind |= ByValueContentsMarshalKind.In;
+ inAttributeLocation = attr.ApplicationSyntaxReference.SyntaxTree.GetLocation(attr.ApplicationSyntaxReference.Span);
}
}
- return marshalKind;
+ return (marshalKind, inAttributeLocation, outAttributeLocation);
}
private static SyntaxKind RefKindToSyntax(RefKind refKind)
}};
// Unsupported [In, Out] attributes usage
- // Blittable array
- yield return new object[] { ID(), CodeSnippets.ByValueParameterWithModifier<int[]>("Out"), new[]
- {
- VerifyCS.Diagnostic(GeneratorDiagnostics.ParameterTypeNotSupportedWithDetails)
- .WithLocation(0)
- .WithArguments("The provided '[In]' and '[Out]' attributes on this parameter are unsupported on this parameter.", "p")
- } };
-
- yield return new object[] { ID(), CodeSnippets.ByValueParameterWithModifier<int[]>("In, Out"), new[]
- {
- VerifyCS.Diagnostic(GeneratorDiagnostics.ParameterTypeNotSupportedWithDetails)
- .WithLocation(0)
- .WithArguments("The provided '[In]' and '[Out]' attributes on this parameter are unsupported on this parameter.", "p")
- } };
// By ref with [In, Out] attributes
yield return new object[] { ID(), CodeSnippets.ByValueParameterWithModifier("in int", "In"), new[]
using System.Threading;
using Microsoft.CodeAnalysis.Text;
using System.Text;
+using GeneratorDiagnostics = Microsoft.Interop.GeneratorDiagnostics;
namespace LibraryImportGenerator.UnitTests
{
return (newCompilation, diagnostics);
}
}
+
+ public static IEnumerable<object[]> ByValueMarshalKindSnippets()
+ {
+ // Blittable array
+ yield return new object[] { ID(), CodeSnippets.ByValueParameterWithModifier<int[]>("{|#10:Out|}"), new[]
+ {
+ VerifyCS.Diagnostic(GeneratorDiagnostics.UnnecessaryParameterMarshallingInfo)
+ .WithLocation(0)
+ .WithLocation(10)
+ .WithArguments("[In] and [Out] attributes", "p")
+ } };
+
+ yield return new object[] { ID(), CodeSnippets.ByValueParameterWithModifier<int[]>("{|#10:In|}, {|#11:Out|}"), new[]
+ {
+ VerifyCS.Diagnostic(GeneratorDiagnostics.UnnecessaryParameterMarshallingInfo)
+ .WithLocation(0)
+ .WithLocation(10)
+ .WithLocation(11)
+ .WithArguments("[In] and [Out] attributes", "p")
+ } };
+ }
+
+ [MemberData(nameof(ByValueMarshalKindSnippets))]
+ [Theory]
+ public async Task ValidateDiagnosticsForUnnecessaryByValueMarshalKindAttributes(string id, string source, DiagnosticResult[] diagnostics)
+ {
+ _ = id;
+ await VerifyCS.VerifySourceGeneratorAsync(source, diagnostics);
+ }
}
}