diff --git a/eng/generators.targets b/eng/generators.targets index a83febbe2c8bea..92909989d30426 100644 --- a/eng/generators.targets +++ b/eng/generators.targets @@ -13,7 +13,7 @@ @@ -22,7 +22,7 @@ '$(IsSourceProject)' == 'true' and '$(MSBuildProjectExtension)' == '.csproj' and ( - '$(TargetFrameworkMoniker)' != '$(NetCoreAppCurrentTargetFrameworkMoniker)' or + !$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0')) or ( '$(DisableImplicitFrameworkReferences)' == 'true' and ( @@ -33,17 +33,13 @@ )" /> diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/BaseJSGenerator.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/BaseJSGenerator.cs index 2b8b4e12ad58a2..4d4a9f20dc2c43 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/BaseJSGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/BaseJSGenerator.cs @@ -26,7 +26,7 @@ protected BaseJSGenerator(MarshalerType marshalerType, IMarshallingGenerator inn 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 GenerateBind(TypePositionInfo info, StubCodeContext context) { diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/EmptyJSGenerator.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/EmptyJSGenerator.cs index 1a50568a1fc444..37204d1f7464d1 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/EmptyJSGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/EmptyJSGenerator.cs @@ -15,7 +15,7 @@ internal sealed class EmptyJSGenerator : IJSMarshallingGenerator 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; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/DiagnosticDescriptorProvider.cs b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/DiagnosticDescriptorProvider.cs index 9864fbed576ec5..c676f27cb9f401 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/DiagnosticDescriptorProvider.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/DiagnosticDescriptorProvider.cs @@ -24,6 +24,8 @@ internal sealed class DiagnosticDescriptorProvider : IDiagnosticDescriptorProvid 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, diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/GeneratorDiagnostics.cs b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/GeneratorDiagnostics.cs index 9aaf3a59d0a4a7..fb941b73d08141 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/GeneratorDiagnostics.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/GeneratorDiagnostics.cs @@ -21,6 +21,7 @@ public class Ids 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"; @@ -415,6 +416,34 @@ public class Ids 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 + }); + /// /// Report diagnostic for invalid configuration for string marshalling. /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ComInterfaceDispatchMarshallerFactory.cs b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ComInterfaceDispatchMarshallerFactory.cs index be71ae535f1c94..9373dd7eaa4b9a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ComInterfaceDispatchMarshallerFactory.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ComInterfaceDispatchMarshallerFactory.cs @@ -61,7 +61,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont 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; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ManagedHResultExceptionMarshallerFactory.cs b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ManagedHResultExceptionMarshallerFactory.cs index 4c012042a05791..13d82b4a332197 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ManagedHResultExceptionMarshallerFactory.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ManagedHResultExceptionMarshallerFactory.cs @@ -71,7 +71,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont 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; } @@ -108,7 +108,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont 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; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ObjectUnwrapperMarshallerFactory.cs b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ObjectUnwrapperMarshallerFactory.cs index b5a2d998890e8a..ba55a49c1a7c94 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ObjectUnwrapperMarshallerFactory.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ObjectUnwrapperMarshallerFactory.cs @@ -61,7 +61,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont 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; } } 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 420d0a0616b003..2d66fc739503bf 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/Strings.resx +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/Strings.resx @@ -395,4 +395,16 @@ 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. + + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + + + Unnecessary marshalling info was provided and can be removed. + + + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + + + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + 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 fe85bbe4a1f12d..aeb5da741e491a 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 @@ -454,6 +454,26 @@ Zadaný typ není podporován modelem COM generovaným zdrojem. + + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + + + + Unnecessary marshalling info was provided and can be removed. + Unnecessary marshalling info was provided and can be removed. + + + + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + + + + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + + \ No newline at end of file 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 ce6d5f8e8a5180..b5b75a48e6d15d 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 @@ -454,6 +454,26 @@ Der angegebene Typ wird vom quellgenerierten COM nicht unterstützt. + + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + + + + Unnecessary marshalling info was provided and can be removed. + Unnecessary marshalling info was provided and can be removed. + + + + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + + + + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + + \ No newline at end of file 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 40ca99b0ba434d..a03de7a674b1a1 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 @@ -454,6 +454,26 @@ El tipo especificado no es compatible con COM generado por el origen + + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + + + + Unnecessary marshalling info was provided and can be removed. + Unnecessary marshalling info was provided and can be removed. + + + + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + + + + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + + \ No newline at end of file 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 f16485ea6284e4..9388fee2c5e006 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 @@ -454,6 +454,26 @@ Le type spécifié n’est pas pris en charge par com généré par la source + + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + + + + Unnecessary marshalling info was provided and can be removed. + Unnecessary marshalling info was provided and can be removed. + + + + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + + + + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + + \ No newline at end of file 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 c6a5ed91f97deb..07ddb4c0b44808 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 @@ -454,6 +454,26 @@ Il tipo specificato non è supportato da COM generati dall'origine + + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + + + + Unnecessary marshalling info was provided and can be removed. + Unnecessary marshalling info was provided and can be removed. + + + + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + + + + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + + \ No newline at end of file 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 5451abb3e9eb1e..a3871e3f1a3589 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 @@ -454,6 +454,26 @@ 指定された型は、ソース生成済みの COM ではサポートされていません + + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + + + + Unnecessary marshalling info was provided and can be removed. + Unnecessary marshalling info was provided and can be removed. + + + + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + + + + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + + \ No newline at end of file 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 084b3060932943..a4d363410b6cd7 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 @@ -454,6 +454,26 @@ 지정된 형식은 원본 생성 COM에서 지원되지 않습니다. + + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + + + + Unnecessary marshalling info was provided and can be removed. + Unnecessary marshalling info was provided and can be removed. + + + + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + + + + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + + \ No newline at end of file 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 1f160566ff82bc..36d381ef07a088 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 @@ -454,6 +454,26 @@ Określony typ nie jest obsługiwany przez źródłowy COM + + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + + + + Unnecessary marshalling info was provided and can be removed. + Unnecessary marshalling info was provided and can be removed. + + + + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + + + + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + + \ No newline at end of file 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 895b43091b7a8c..49e717f7dc5ac8 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 @@ -454,6 +454,26 @@ Um COM gerado pela origem não dá suporte ao tipo especificado. + + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + + + + Unnecessary marshalling info was provided and can be removed. + Unnecessary marshalling info was provided and can be removed. + + + + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + + + + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + + \ No newline at end of file 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 2a80ec68a7905c..b36f526a4da9f3 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 @@ -454,6 +454,26 @@ Указанный тип не поддерживается моделью COM генератора исходного кода. + + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + + + + Unnecessary marshalling info was provided and can be removed. + Unnecessary marshalling info was provided and can be removed. + + + + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + + + + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + + \ No newline at end of file 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 2e463078195081..d28012ac2f92f2 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 @@ -454,6 +454,26 @@ Belirtilen tür, kaynak tarafından oluşturulan COM tarafından desteklenmiyor + + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + + + + Unnecessary marshalling info was provided and can be removed. + Unnecessary marshalling info was provided and can be removed. + + + + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + + + + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + + \ No newline at end of file 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 b1d5ffe2b7ad9b..6c41ecaebbcd9b 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 @@ -454,6 +454,26 @@ 源生成的 COM 不支持指定的类型 + + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + + + + Unnecessary marshalling info was provided and can be removed. + Unnecessary marshalling info was provided and can be removed. + + + + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + + + + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + + \ No newline at end of file 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 4fd66401f744a8..85e47d659f0331 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 @@ -454,6 +454,26 @@ 来源產生的 COM 不支援指定的類型。 + + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + + + + Unnecessary marshalling info was provided and can be removed. + Unnecessary marshalling info was provided and can be removed. + + + + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + + + + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + + \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/DiagnosticDescriptorProvider.cs b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/DiagnosticDescriptorProvider.cs index bca67a7fdefc97..2bef64490f9a4e 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/DiagnosticDescriptorProvider.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/DiagnosticDescriptorProvider.cs @@ -22,6 +22,8 @@ internal sealed class DiagnosticDescriptorProvider : IDiagnosticDescriptorProvid 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, diff --git a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/GeneratorDiagnostics.cs b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/GeneratorDiagnostics.cs index 953f02c338ce54..c3de7263618a11 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/GeneratorDiagnostics.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/GeneratorDiagnostics.cs @@ -24,6 +24,7 @@ public class Ids public const string CannotForwardToDllImport = Prefix + "1053"; public const string RequiresAllowUnsafeBlocks = Prefix + "1062"; + public const string UnnecessaryMarshallingInfo = Prefix + "1063"; } private const string Category = "LibraryImportGenerator"; @@ -188,6 +189,33 @@ public class Ids 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 + }); + /// /// Report diagnostic for invalid configuration for string marshalling. /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/Strings.resx b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/Strings.resx index 2d1d9fe9f69451..2e528def1c88ff 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/Strings.resx +++ b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/Strings.resx @@ -509,4 +509,16 @@ 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. + + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + + + Unnecessary marshalling info was provided and can be removed. + + + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + + + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.cs.xlf b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.cs.xlf index af1c864dfbc713..862030ac7fe22c 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.cs.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.cs.xlf @@ -629,6 +629,26 @@ Určený typ nepodporují zdrojem generovaná volání P/Invokes. + + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + + + + Unnecessary marshalling info was provided and can be removed. + Unnecessary marshalling info was provided and can be removed. + + + + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + + + + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + + 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 Nativní typ druhu Value, který podporuje funkci CallerAllocatedBuffer, musí poskytovat dvouparametrový konstruktor přebírající spravovaný prvek a hodnotu Span jako parametry. diff --git a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.de.xlf b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.de.xlf index 7aebebb5ac2078..dbd4a181636086 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.de.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.de.xlf @@ -629,6 +629,26 @@ Der angegebene Typ wird von quellgenerierten P/Invokes nicht unterstützt. + + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + + + + Unnecessary marshalling info was provided and can be removed. + Unnecessary marshalling info was provided and can be removed. + + + + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + + + + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + + 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 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. diff --git a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.es.xlf b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.es.xlf index 3163cf9f2cc264..e2040a730d7b25 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.es.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.es.xlf @@ -629,6 +629,26 @@ El tipo especificado no está admitido por P/Invokes de un generador de código fuente + + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + + + + Unnecessary marshalling info was provided and can be removed. + Unnecessary marshalling info was provided and can be removed. + + + + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + + + + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + + 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 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 diff --git a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.fr.xlf b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.fr.xlf index 001d5bf7ddec2a..0c6e31b5555c88 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.fr.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.fr.xlf @@ -629,6 +629,26 @@ Le type spécifié n’est pas prise en charge par les P/Invokes générés par la source. + + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + + + + Unnecessary marshalling info was provided and can be removed. + Unnecessary marshalling info was provided and can be removed. + + + + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + + + + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + + 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 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 diff --git a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.it.xlf b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.it.xlf index b4ba463171b9a9..b6000a081ca6ec 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.it.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.it.xlf @@ -629,6 +629,26 @@ Il tipo specificato non è supportato dai P/Invoke generati dall'origine + + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + + + + Unnecessary marshalling info was provided and can be removed. + Unnecessary marshalling info was provided and can be removed. + + + + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + + + + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + + 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 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 diff --git a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.ja.xlf b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.ja.xlf index aec417742e285b..c3a10832ddca1b 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.ja.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.ja.xlf @@ -630,6 +630,26 @@ 指定された型は、ソースで生成された P/Invoke ではサポートされていません + + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + + + + Unnecessary marshalling info was provided and can be removed. + Unnecessary marshalling info was provided and can be removed. + + + + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + + + + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + + 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 'CallerAllocatedBuffer' 機能をサポートする 'Value' のネイティブ型では、マネージド型と 'アンマネージド' 型の 'Span' をパラメーターとして受け取る 2 つのパラメーター コンストラクターを指定する必要があります diff --git a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.ko.xlf b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.ko.xlf index 5045fc7f0857dd..6839022f0e3c38 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.ko.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.ko.xlf @@ -629,6 +629,26 @@ 지정된 형식은 소스 생성 P/Invoke에서 지원되지 않습니다. + + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + + + + Unnecessary marshalling info was provided and can be removed. + Unnecessary marshalling info was provided and can be removed. + + + + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + + + + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + + 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 'CallerAllocatedBuffer' 기능을 지원하는 '값' 종류의 네이티브 형식은 관리되는 형식과 '관리되지 않는' 형식의 'Span'을 매개 변수로 사용하는 두 개의 매개 변수 생성자를 제공해야 합니다. diff --git a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.pl.xlf b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.pl.xlf index e4551eb36fd91e..973db6ef00e82e 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.pl.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.pl.xlf @@ -629,6 +629,26 @@ Określony typ nie jest obsługiwany przez funkcję P/Invokes generowaną przez źródło + + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + + + + Unnecessary marshalling info was provided and can be removed. + Unnecessary marshalling info was provided and can be removed. + + + + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + + + + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + + 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 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 diff --git a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.pt-BR.xlf b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.pt-BR.xlf index a4a9e3438c53df..dde0f798e16097 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.pt-BR.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.pt-BR.xlf @@ -629,6 +629,26 @@ O tipo especificado não tem suporte de P/Invokes gerados pela origem. + + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + + + + Unnecessary marshalling info was provided and can be removed. + Unnecessary marshalling info was provided and can be removed. + + + + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + + + + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + + 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 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 diff --git a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.ru.xlf b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.ru.xlf index 7d6327da6e3dd3..0edff93bc1a4ec 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.ru.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.ru.xlf @@ -629,6 +629,26 @@ Указанный тип не поддерживается в P/Invoke с созданием источника. + + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + + + + Unnecessary marshalling info was provided and can be removed. + Unnecessary marshalling info was provided and can be removed. + + + + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + + + + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + + 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 Собственный тип вида \"Value\", который поддерживает функцию \"CallerAllocatedBuffer\", должен предоставлять конструктор с двумя параметрами: управляемый тип и \"Span неуправляемого типа\" diff --git a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.tr.xlf b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.tr.xlf index 6a3419791a6b9f..e516681f84c59e 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.tr.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.tr.xlf @@ -629,6 +629,26 @@ Belirtilen tür, kaynak tarafından oluşturulan P/Invokes tarafından desteklenmiyor + + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + + + + Unnecessary marshalling info was provided and can be removed. + Unnecessary marshalling info was provided and can be removed. + + + + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + + + + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + + 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 '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 diff --git a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.zh-Hans.xlf b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.zh-Hans.xlf index 170f205bffce7f..ad82d7c31cc732 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.zh-Hans.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.zh-Hans.xlf @@ -629,6 +629,26 @@ 源生成的 P/Invoke 不支持指定的类型 + + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + + + + Unnecessary marshalling info was provided and can be removed. + Unnecessary marshalling info was provided and can be removed. + + + + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + + + + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + + 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 支持 \"CallerAllocatedBuffer\" 功能的 \"Value\" 种类本机类型必须提供以托管类型和“非管理”类型的 \"Span\" 作为参数的双参数构造函数 diff --git a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.zh-Hant.xlf b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.zh-Hant.xlf index 90289abc2a74e0..32024ab500d068 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.zh-Hant.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/xlf/Strings.zh-Hant.xlf @@ -629,6 +629,26 @@ 来源產生的 P/Invokes 不支援指定的類型。 + + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application. + + + + Unnecessary marshalling info was provided and can be removed. + Unnecessary marshalling info was provided and can be removed. + + + + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + Unnecessary marshalling info '{0}' was provided for parameter '{1}' + + + + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + Unnecessary marshalling info '{0}' was provided for the return type of method '{1}' + + 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 支援 'CallerAllocatedBuffer' 功能的 'Value'-kind 原生類型必須提供接受受管理類型的雙參數建構函示,以及以 'unmanaged' 類型的 'Span' 作為參數 diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/MarshalAsAttributeParser.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/MarshalAsAttributeParser.cs index 885ac8153759eb..bc49ed4d3b0f05 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/MarshalAsAttributeParser.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/MarshalAsAttributeParser.cs @@ -161,7 +161,9 @@ private MarshallingInfo CreateStringMarshallingInfo( }; if (marshallerName is null) + { return new MarshalAsInfo(unmanagedType, _defaultInfo.CharEncoding); + } return StringMarshallingInfoProvider.CreateStringMarshallingInfo(_compilation, type, marshallerName); } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/AttributedMarshallingModelGeneratorFactory.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/AttributedMarshallingModelGeneratorFactory.cs index f55008fef06e7e..88e73b555796e4 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/AttributedMarshallingModelGeneratorFactory.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/AttributedMarshallingModelGeneratorFactory.cs @@ -64,9 +64,9 @@ public ResolvedGenerator Create(TypePositionInfo info, StubCodeContext context) return ResolvedGenerator.NotSupported( new GeneratorDiagnostic.NotSupported(info, context) - { - NotSupportedDetails = SR.RuntimeMarshallingMustBeDisabled, - DiagnosticProperties = AddDisableRuntimeMarshallingAttributeProperties + { + NotSupportedDetails = SR.RuntimeMarshallingMustBeDisabled, + DiagnosticProperties = AddDisableRuntimeMarshallingAttributeProperties }); } @@ -99,34 +99,34 @@ private ExpressionOrNotSupported GetNumElementsExpressionFromMarshallingInfo(Typ 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) { @@ -294,7 +294,7 @@ private ResolvedGenerator CreateCustomNativeTypeMarshaller(TypePositionInfo info } } - IMarshallingGenerator marshallingGenerator = new CustomTypeMarshallingGenerator(marshallingStrategy, enableByValueContentsMarshalling: false); + IMarshallingGenerator marshallingGenerator = new CustomTypeMarshallingGenerator(marshallingStrategy, ByValueMarshalKindSupport.NotSupported); if (marshallerData.Shape.HasFlag(MarshallerShape.StatelessPinnableReference)) { @@ -334,7 +334,7 @@ private ResolvedGenerator CreateNativeCollectionMarshaller( if (numElementsExpressionResult is (_, GeneratorDiagnostic.NotSupported notSupportedDiagnostic)) { return ResolvedGenerator.NotSupported(notSupportedDiagnostic); - } + } numElementsExpression = numElementsExpressionResult.Expression; } @@ -426,9 +426,28 @@ private ResolvedGenerator CreateNativeCollectionMarshaller( } } + 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) diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BlittableMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BlittableMarshaller.cs index bb3b35b389f502..5173be0796ce3a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BlittableMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BlittableMarshaller.cs @@ -103,7 +103,7 @@ public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) 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; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BoolMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BoolMarshaller.cs index 9d971718751e06..aee1d16404fc9c 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BoolMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/BoolMarshaller.cs @@ -100,7 +100,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont 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; } /// diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ByValueContentsMarshalKindValidator.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ByValueContentsMarshalKindValidator.cs index 3eb7fdad7d1e07..66559ad90de194 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ByValueContentsMarshalKindValidator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ByValueContentsMarshalKindValidator.cs @@ -2,8 +2,8 @@ // 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 { @@ -49,13 +49,36 @@ private static ResolvedGenerator ValidateByValueMarshalKind(TypePositionInfo inf 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.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; } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs index 970a11cc49bef8..b432ea88d7c942 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CharMarshaller.cs @@ -128,7 +128,7 @@ public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) 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) { diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CustomTypeMarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CustomTypeMarshallingGenerator.cs index ee5eef21254dfa..3c492cb16ac0b1 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CustomTypeMarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/CustomTypeMarshallingGenerator.cs @@ -15,12 +15,12 @@ namespace Microsoft.Interop 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) @@ -108,12 +108,12 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont 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) diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/DelegateMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/DelegateMarshaller.cs index f1205c3ffcecab..2d2461e9b160f6 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/DelegateMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/DelegateMarshaller.cs @@ -102,6 +102,6 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont 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; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/Forwarder.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/Forwarder.cs index eb3a4bada79e0f..0b75eb030f88e7 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/Forwarder.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/Forwarder.cs @@ -3,11 +3,7 @@ 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 { @@ -37,6 +33,6 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont 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; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/GeneratorDiagnostic.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/GeneratorDiagnostic.cs index c82819d0ae46fd..8abcaf363fd5d5 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/GeneratorDiagnostic.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/GeneratorDiagnostic.cs @@ -19,7 +19,7 @@ private GeneratorDiagnostic(TypePositionInfo typePositionInfo, StubCodeContext s /// /// [Optional] Properties to attach to any diagnostic emitted due to this exception. /// - public ImmutableDictionary? DiagnosticProperties { get; init; } + public ImmutableDictionary DiagnosticProperties { get; init; } = ImmutableDictionary.Empty; public TypePositionInfo TypePositionInfo { get; } public StubCodeContext StubCodeContext { get; } public bool IsFatal { get; } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshalAsMarshallingGeneratorFactory.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshalAsMarshallingGeneratorFactory.cs index ceb13bf94c57dc..4fc077035fa994 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshalAsMarshallingGeneratorFactory.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshalAsMarshallingGeneratorFactory.cs @@ -53,6 +53,7 @@ public ResolvedGenerator Create( 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 diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGenerator.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGenerator.cs index 7a5a4ecc3d72cd..d1c26134145ebc 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGenerator.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallingGenerator.cs @@ -68,6 +68,25 @@ public enum ValueBoundaryBehavior CastNativeIdentifier } + /// + /// An enumeration describing if the provided is supported and changes behavior from the default behavior. + /// + public enum ByValueMarshalKindSupport + { + /// + /// The provided is supported and changes behavior from the default behavior. + /// + Supported, + /// + /// The provided is not supported. + /// + NotSupported, + /// + /// The provided is supported but does not change behavior from the default in this scenario. + /// + Unnecessary, + } + /// /// Interface for generation of marshalling code for P/Invoke stubs /// @@ -135,7 +154,7 @@ public interface IMarshallingGenerator /// /// The marshal kind. /// The marshalling context. - /// - bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context); + /// If the provided is supported and if it is required to specify the requested behavior. + ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context); } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/SafeHandleMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/SafeHandleMarshaller.cs index b24774cd53c8c4..42129ce4a16a6a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/SafeHandleMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/SafeHandleMarshaller.cs @@ -234,6 +234,6 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont 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; } } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StaticPinnableManagedValueMarshaller.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StaticPinnableManagedValueMarshaller.cs index 3708fd917330ed..a4256b204d5679 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StaticPinnableManagedValueMarshaller.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StaticPinnableManagedValueMarshaller.cs @@ -62,7 +62,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont return _innerMarshallingGenerator.Generate(info, context); } - public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) + public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) { return _innerMarshallingGenerator.SupportsByValueMarshalKind(marshalKind, context); } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/UnmanagedToManagedOwnershipTrackingStrategy.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/UnmanagedToManagedOwnershipTrackingStrategy.cs index a5ec887a5e64f9..00f54099c90aa3 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/UnmanagedToManagedOwnershipTrackingStrategy.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/UnmanagedToManagedOwnershipTrackingStrategy.cs @@ -164,7 +164,7 @@ IEnumerable GenerateStatementsFromInner(StubCodeContext 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); } diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/Strings.resx b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/Strings.resx index 8b3acf75b0189b..71140a99ff445f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/Strings.resx +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/Strings.resx @@ -192,4 +192,7 @@ '{0}' has accessibility '{1}'. + + [In] and [Out] attributes + \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.cs.xlf b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.cs.xlf index ea18fe04b64ef7..c53a275e8b34fd 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.cs.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.cs.xlf @@ -67,6 +67,11 @@ Poskytnuté atributy „[In]“ a „[Out]“ u tohoto parametru se na tomto parametru nepodporují. + + [In] and [Out] attributes + [In] and [Out] attributes + + The specified parameter needs to be marshalled from managed to unmanaged, but the marshaller type '{0}' does not support it. Určený parametr musí být zařazený ze spravovaného do nespravovaného, ale zařazovací typ {0} to nepodporuje. diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.de.xlf b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.de.xlf index 172c13790821b4..0c08a2dd85d423 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.de.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.de.xlf @@ -67,6 +67,11 @@ Die angegebenen Attribute \"[In]\" und \"[Out]\" für diesen Parameter werden für diesen Parameter nicht unterstützt. + + [In] and [Out] attributes + [In] and [Out] attributes + + The specified parameter needs to be marshalled from managed to unmanaged, but the marshaller type '{0}' does not support it. Der angegebene Parameter muss von verwaltet zu nicht verwaltet gemarshallt werden, aber der Marshaller-Typ ‚{0}‘ unterstützt dies nicht. diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.es.xlf b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.es.xlf index 64def4b53f9a83..81ed3249c4a829 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.es.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.es.xlf @@ -67,6 +67,11 @@ En este parámetro, los atributos “[In]” y “[Out]” proporcionados no se admiten. + + [In] and [Out] attributes + [In] and [Out] attributes + + The specified parameter needs to be marshalled from managed to unmanaged, but the marshaller type '{0}' does not support it. El parámetro especificado debe serializarse de administrado a no administrado, pero el tipo no administrado “{0}” no lo admite. diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.fr.xlf b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.fr.xlf index 1aa3d47900e8ad..fd674a3b223f98 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.fr.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.fr.xlf @@ -67,6 +67,11 @@ Les attributs « [In] » et « [Out] » fournis sur ce paramètre ne sont pas pris en charge sur ce paramètre. + + [In] and [Out] attributes + [In] and [Out] attributes + + The specified parameter needs to be marshalled from managed to unmanaged, but the marshaller type '{0}' does not support it. Le paramètre spécifié doit être marshalé de managé à non managé, mais le type marshaleur « {0} » ne le prend pas en charge. diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.it.xlf b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.it.xlf index 4c2ecd67252b24..8c33aa8b550e2d 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.it.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.it.xlf @@ -67,6 +67,11 @@ Gli attributi '[In]' e '[Out]' specificati per questo parametro non sono supportati in questo parametro. + + [In] and [Out] attributes + [In] and [Out] attributes + + The specified parameter needs to be marshalled from managed to unmanaged, but the marshaller type '{0}' does not support it. È necessario effettuare il marshalling del parametro specificato da gestito a non gestito, ma il tipo di gestore del marshalling '{0}' non lo supporta. diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.ja.xlf b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.ja.xlf index 27cc99b001bcf1..699215ea83dda7 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.ja.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.ja.xlf @@ -67,6 +67,11 @@ このパラメーターに指定された '[In]' 属性と '[Out]' 属性は、このパラメーターではサポートされていません。 + + [In] and [Out] attributes + [In] and [Out] attributes + + The specified parameter needs to be marshalled from managed to unmanaged, but the marshaller type '{0}' does not support it. 指定されたパラメーターはマネージドからアンマネージドにマーシャリングする必要がありますが、マーシャラー型 '{0}' ではそれはサポートされていません。 diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.ko.xlf b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.ko.xlf index c1091feae70da5..7b06d3369b2e45 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.ko.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.ko.xlf @@ -67,6 +67,11 @@ 이 매개 변수에 제공된 '[In]' 및 '[Out]' 특성은 이 매개 변수에서 지원되지 않습니다. + + [In] and [Out] attributes + [In] and [Out] attributes + + The specified parameter needs to be marshalled from managed to unmanaged, but the marshaller type '{0}' does not support it. 지정된 매개 변수를 관리형에서 비관리형으로 마샬링해야 하지만 마샬러 유형 '{0}'은(는) 지원하지 않습니다. diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.pl.xlf b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.pl.xlf index 8be8cdf02e9545..0a8a553f5c8adb 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.pl.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.pl.xlf @@ -67,6 +67,11 @@ Podane atrybuty „[In]” i „[Out]” w tym parametrze nie są obsługiwane w tym parametrze. + + [In] and [Out] attributes + [In] and [Out] attributes + + The specified parameter needs to be marshalled from managed to unmanaged, but the marshaller type '{0}' does not support it. Określony parametr musi być kierowany z zarządzanego do niezarządzanego, ale typ marszałka „{0}” go nie obsługuje. diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.pt-BR.xlf b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.pt-BR.xlf index 376ed1bea6540f..b3122750cb9e60 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.pt-BR.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.pt-BR.xlf @@ -67,6 +67,11 @@ Os atributos '[In]' e '[Out]' neste parâmetro não têm suporte neste parâmetro. + + [In] and [Out] attributes + [In] and [Out] attributes + + The specified parameter needs to be marshalled from managed to unmanaged, but the marshaller type '{0}' does not support it. 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. diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.ru.xlf b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.ru.xlf index 30b3a23f5cc657..7e9349298e4405 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.ru.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.ru.xlf @@ -67,6 +67,11 @@ Указанные атрибуты \"[In]\" и \"[Out]\" для этого параметра не поддерживаются. + + [In] and [Out] attributes + [In] and [Out] attributes + + The specified parameter needs to be marshalled from managed to unmanaged, but the marshaller type '{0}' does not support it. Указанный параметр необходимо маршалировать из управляемого в неуправляемый, но тип маршаллера "{0}" не поддерживает это. diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.tr.xlf b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.tr.xlf index f98b8630033fc9..c84a8adfb0eacb 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.tr.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.tr.xlf @@ -67,6 +67,11 @@ Bu parametrede sağlanan '[In]' ve '[Out]' öznitelikleri bu parametrede desteklenmiyor. + + [In] and [Out] attributes + [In] and [Out] attributes + + The specified parameter needs to be marshalled from managed to unmanaged, but the marshaller type '{0}' does not support it. Belirtilen parametrenin yönetilenden yönetilmeyene doğru hazırlanması gerekiyor, ancak '{0}' hazırlayıcı türü bunu desteklemiyor. diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.zh-Hans.xlf b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.zh-Hans.xlf index 606fcf26d2b943..ad906a0b467066 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.zh-Hans.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.zh-Hans.xlf @@ -67,6 +67,11 @@ 此参数上提供的 “[In]” 和 “[Out]” 属性在此参数上不受支持。 + + [In] and [Out] attributes + [In] and [Out] attributes + + The specified parameter needs to be marshalled from managed to unmanaged, but the marshaller type '{0}' does not support it. 需要将指定的参数从托管封送到非托管,但封送程序类型“{0}”不支持它。 diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.zh-Hant.xlf b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.zh-Hant.xlf index bfa8dec1e245f6..b0a23a900017e4 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.zh-Hant.xlf +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Resources/xlf/Strings.zh-Hant.xlf @@ -67,6 +67,11 @@ 此參數不支援在此參數上提供的 '[In]' 和 '[Out]' 屬性。 + + [In] and [Out] attributes + [In] and [Out] attributes + + The specified parameter needs to be marshalled from managed to unmanaged, but the marshaller type '{0}' does not support it. 指定的參數必須從受控封送處理到非受控,但封送處理程式類型 '{0}' 不支援。 diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypePositionInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypePositionInfo.cs index 2fd278f8b97c40..bb401167313626 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypePositionInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypePositionInfo.cs @@ -70,6 +70,8 @@ public static int IncrementIndex(int index) 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; } @@ -79,38 +81,45 @@ public static int IncrementIndex(int index) 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 attributes, Compilation compilation) + private static (ByValueContentsMarshalKind, Location? inAttribute, Location? outAttribute) GetByValueContentsMarshalKind(IEnumerable 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) diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CompileFails.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CompileFails.cs index ca5c587da7442d..5ceb8316e1f7eb 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CompileFails.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CompileFails.cs @@ -354,20 +354,6 @@ public static IEnumerable CodeSnippetsToCompile() }}; // Unsupported [In, Out] attributes usage - // Blittable array - yield return new object[] { ID(), CodeSnippets.ByValueParameterWithModifier("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("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[] diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/Compiles.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/Compiles.cs index 7265720c1d162f..1c3bae10f095a2 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/Compiles.cs @@ -20,6 +20,7 @@ using System.Threading; using Microsoft.CodeAnalysis.Text; using System.Text; +using GeneratorDiagnostics = Microsoft.Interop.GeneratorDiagnostics; namespace LibraryImportGenerator.UnitTests { @@ -739,5 +740,34 @@ public NoChangeTest(TestTargetFramework framework) return (newCompilation, diagnostics); } } + + public static IEnumerable ByValueMarshalKindSnippets() + { + // Blittable array + yield return new object[] { ID(), CodeSnippets.ByValueParameterWithModifier("{|#10:Out|}"), new[] + { + VerifyCS.Diagnostic(GeneratorDiagnostics.UnnecessaryParameterMarshallingInfo) + .WithLocation(0) + .WithLocation(10) + .WithArguments("[In] and [Out] attributes", "p") + } }; + + yield return new object[] { ID(), CodeSnippets.ByValueParameterWithModifier("{|#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); + } } }