From 251802e110f634a98b4a1be4056933f980c4b664 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 26 Jul 2022 15:09:09 -0700 Subject: [PATCH 1/3] Add stateful marshaller support to the CustomMarshallerAttributeAnalyzer Add support and tests for analyzing the required shapes for stateful marshallers. --- .../CustomMarshallerAttributeAnalyzer.cs | 419 +++++++++++++++- .../Resources/Strings.resx | 48 +- .../Resources/xlf/Strings.cs.xlf | 72 ++- .../Resources/xlf/Strings.de.xlf | 72 ++- .../Resources/xlf/Strings.es.xlf | 72 ++- .../Resources/xlf/Strings.fr.xlf | 72 ++- .../Resources/xlf/Strings.it.xlf | 72 ++- .../Resources/xlf/Strings.ja.xlf | 72 ++- .../Resources/xlf/Strings.ko.xlf | 72 ++- .../Resources/xlf/Strings.pl.xlf | 72 ++- .../Resources/xlf/Strings.pt-BR.xlf | 72 ++- .../Resources/xlf/Strings.ru.xlf | 72 ++- .../Resources/xlf/Strings.tr.xlf | 72 ++- .../Resources/xlf/Strings.zh-Hans.xlf | 72 ++- .../Resources/xlf/Strings.zh-Hant.xlf | 72 ++- ...StatefulLinearCollectionShapeValidation.cs | 457 ++++++++++++++++++ ...FixerTests_StatefulValueShapeValidation.cs | 249 ++++++++++ ...tatelessLinearCollectionShapeValidation.cs | 2 +- ...ixerTests_StatelessValueShapeValidation.cs | 2 +- 19 files changed, 2009 insertions(+), 104 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CustomMarshallerAttributeFixerTests_StatefulLinearCollectionShapeValidation.cs create mode 100644 src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CustomMarshallerAttributeFixerTests_StatefulValueShapeValidation.cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Analyzers/CustomMarshallerAttributeAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Analyzers/CustomMarshallerAttributeAnalyzer.cs index 15772ebaccb9a..1916103748b03 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Analyzers/CustomMarshallerAttributeAnalyzer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Analyzers/CustomMarshallerAttributeAnalyzer.cs @@ -64,6 +64,17 @@ public static ImmutableDictionary CreateDiagnosticPropertiesForM isEnabledByDefault: true, description: GetResourceString(nameof(SR.MarshallerTypeMustBeStaticClassOrStructDescription))); + /// + public static readonly DiagnosticDescriptor ElementMarshallerCannotBeStatefulRule = + new DiagnosticDescriptor( + Ids.InvalidMarshallerType, + GetResourceString(nameof(SR.InvalidMarshallerTypeTitle)), + GetResourceString(nameof(SR.ElementMarshallerCannotBeStatefulMessage)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: GetResourceString(nameof(SR.ElementMarshallerCannotBeStatefulDescription))); + /// public static readonly DiagnosticDescriptor UnmanagedTypeMustBeUnmanagedRule = new DiagnosticDescriptor( @@ -196,27 +207,93 @@ public static ImmutableDictionary CreateDiagnosticPropertiesForM isEnabledByDefault: true, description: GetResourceString(nameof(SR.StatelessLinearCollectionRequiresTwoParameterAllocateContainerForManagedElementsDescription))); - /// - public static readonly DiagnosticDescriptor CallerAllocConstructorMustHaveBufferSizeRule = + /// + public static readonly DiagnosticDescriptor CallerAllocFromManagedMustHaveBufferSizeRule = + new DiagnosticDescriptor( + Ids.CustomMarshallerTypeMustHaveRequiredShape, + GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)), + GetResourceString(nameof(SR.CallerAllocFromManagedMustHaveBufferSizeMessage)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: GetResourceString(nameof(SR.CallerAllocFromManagedMustHaveBufferSizeDescription))); + + /// + public static readonly DiagnosticDescriptor StatelessLinearCollectionCallerAllocFromManagedMustHaveBufferSizeRule = + new DiagnosticDescriptor( + Ids.CustomMarshallerTypeMustHaveRequiredShape, + GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)), + GetResourceString(nameof(SR.StatelessLinearCollectionCallerAllocFromManagedMustHaveBufferSizeMessage)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: GetResourceString(nameof(SR.StatelessLinearCollectionCallerAllocFromManagedMustHaveBufferSizeDescription))); + + /// + public static readonly DiagnosticDescriptor StatefulMarshallerRequiresFromManagedRule = + new DiagnosticDescriptor( + Ids.CustomMarshallerTypeMustHaveRequiredShape, + GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)), + GetResourceString(nameof(SR.StatefulMarshallerRequiresFromManagedMessage)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: GetResourceString(nameof(SR.StatefulMarshallerRequiresFromManagedDescription))); + + /// + public static readonly DiagnosticDescriptor StatefulMarshallerRequiresToUnmanagedRule = new DiagnosticDescriptor( Ids.CustomMarshallerTypeMustHaveRequiredShape, GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)), - GetResourceString(nameof(SR.CallerAllocConstructorMustHaveBufferSizeMessage)), + GetResourceString(nameof(SR.StatefulMarshallerRequiresToUnmanagedMessage)), Category, DiagnosticSeverity.Error, isEnabledByDefault: true, - description: GetResourceString(nameof(SR.CallerAllocConstructorMustHaveBufferSizeDescription))); + description: GetResourceString(nameof(SR.StatefulMarshallerRequiresToUnmanagedDescription))); - /// - public static readonly DiagnosticDescriptor StatelessLinearCollectionCallerAllocConstructorMustHaveBufferSizeRule = + /// + public static readonly DiagnosticDescriptor StatefulMarshallerRequiresToManagedRule = new DiagnosticDescriptor( Ids.CustomMarshallerTypeMustHaveRequiredShape, GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)), - GetResourceString(nameof(SR.StatelessLinearCollectionCallerAllocConstructorMustHaveBufferSizeMessage)), + GetResourceString(nameof(SR.StatefulMarshallerRequiresToManagedMessage)), Category, DiagnosticSeverity.Error, isEnabledByDefault: true, - description: GetResourceString(nameof(SR.StatelessLinearCollectionCallerAllocConstructorMustHaveBufferSizeDescription))); + description: GetResourceString(nameof(SR.StatefulMarshallerRequiresToManagedDescription))); + + /// + public static readonly DiagnosticDescriptor StatefulMarshallerRequiresFromUnmanagedRule = + new DiagnosticDescriptor( + Ids.CustomMarshallerTypeMustHaveRequiredShape, + GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)), + GetResourceString(nameof(SR.StatefulMarshallerRequiresFromUnmanagedMessage)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: GetResourceString(nameof(SR.StatefulMarshallerRequiresFromUnmanagedDescription))); + + /// + public static readonly DiagnosticDescriptor StatefulMarshallerRequiresFreeRule = + new DiagnosticDescriptor( + Ids.CustomMarshallerTypeMustHaveRequiredShape, + GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)), + GetResourceString(nameof(SR.StatefulMarshallerRequiresFreeMessage)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: GetResourceString(nameof(SR.StatefulMarshallerRequiresFreeDescription))); + + /// + public static readonly DiagnosticDescriptor FromUnmanagedOverloadsNotSupportedRule = + new DiagnosticDescriptor( + Ids.CustomMarshallerTypeMustHaveRequiredShape, + GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)), + GetResourceString(nameof(SR.FromUnmanagedOverloadsNotSupportedMessage)), + Category, + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: GetResourceString(nameof(SR.FromUnmanagedOverloadsNotSupportedDescription))); /// public static readonly DiagnosticDescriptor MarshallerTypeMustBeClosedOrMatchArityRule = @@ -390,6 +467,50 @@ public static class DefaultMarshalModeDiagnostics isEnabledByDefault: true, description: GetResourceString(nameof(SR.StatelessLinearCollectionRequiresTwoParameterAllocateContainerForManagedElementsDescription))); + /// + public static readonly DiagnosticDescriptor StatefulMarshallerRequiresFromManagedRule = + new DiagnosticDescriptor( + Ids.CustomMarshallerTypeMustHaveRequiredShape, + GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)), + GetResourceString(nameof(SR.StatefulMarshallerRequiresFromManagedMessage)), + Category, + DiagnosticSeverity.Info, + isEnabledByDefault: true, + description: GetResourceString(nameof(SR.StatefulMarshallerRequiresFromManagedDescription))); + + /// + public static readonly DiagnosticDescriptor StatefulMarshallerRequiresToUnmanagedRule = + new DiagnosticDescriptor( + Ids.CustomMarshallerTypeMustHaveRequiredShape, + GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)), + GetResourceString(nameof(SR.StatefulMarshallerRequiresToUnmanagedMessage)), + Category, + DiagnosticSeverity.Info, + isEnabledByDefault: true, + description: GetResourceString(nameof(SR.StatefulMarshallerRequiresToUnmanagedDescription))); + + /// + public static readonly DiagnosticDescriptor StatefulMarshallerRequiresToManagedRule = + new DiagnosticDescriptor( + Ids.CustomMarshallerTypeMustHaveRequiredShape, + GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)), + GetResourceString(nameof(SR.StatefulMarshallerRequiresToManagedMessage)), + Category, + DiagnosticSeverity.Info, + isEnabledByDefault: true, + description: GetResourceString(nameof(SR.StatefulMarshallerRequiresToManagedDescription))); + + /// + public static readonly DiagnosticDescriptor StatefulMarshallerRequiresFromUnmanagedRule = + new DiagnosticDescriptor( + Ids.CustomMarshallerTypeMustHaveRequiredShape, + GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)), + GetResourceString(nameof(SR.StatefulMarshallerRequiresFromUnmanagedMessage)), + Category, + DiagnosticSeverity.Info, + isEnabledByDefault: true, + description: GetResourceString(nameof(SR.StatefulMarshallerRequiresFromUnmanagedDescription))); + internal static DiagnosticDescriptor GetDefaultMarshalModeDiagnostic(DiagnosticDescriptor errorDescriptor) { if (ReferenceEquals(errorDescriptor, CustomMarshallerAttributeAnalyzer.StatelessValueInRequiresConvertToUnmanagedRule)) @@ -416,6 +537,22 @@ internal static DiagnosticDescriptor GetDefaultMarshalModeDiagnostic(DiagnosticD { return StatelessLinearCollectionRequiresTwoParameterAllocateContainerForManagedElementsRule; } + if (ReferenceEquals(errorDescriptor, CustomMarshallerAttributeAnalyzer.StatefulMarshallerRequiresFromManagedRule)) + { + return StatefulMarshallerRequiresFromManagedRule; + } + if (ReferenceEquals(errorDescriptor, CustomMarshallerAttributeAnalyzer.StatefulMarshallerRequiresToUnmanagedRule)) + { + return StatefulMarshallerRequiresToUnmanagedRule; + } + if (ReferenceEquals(errorDescriptor, CustomMarshallerAttributeAnalyzer.StatefulMarshallerRequiresToManagedRule)) + { + return StatefulMarshallerRequiresToManagedRule; + } + if (ReferenceEquals(errorDescriptor, CustomMarshallerAttributeAnalyzer.StatefulMarshallerRequiresFromUnmanagedRule)) + { + return StatefulMarshallerRequiresFromUnmanagedRule; + } return errorDescriptor; } } @@ -436,7 +573,21 @@ internal static DiagnosticDescriptor GetDefaultMarshalModeDiagnostic(DiagnosticD LinearCollectionOutRequiresCollectionMethodsRule, StatelessLinearCollectionOutRequiresCollectionMethodsRule, StatelessLinearCollectionRequiresTwoParameterAllocateContainerForManagedElementsRule, - CallerAllocConstructorMustHaveBufferSizeRule, + StatefulMarshallerRequiresFromManagedRule, + StatefulMarshallerRequiresToUnmanagedRule, + StatefulMarshallerRequiresToManagedRule, + StatefulMarshallerRequiresFromUnmanagedRule, + DefaultMarshalModeDiagnostics.GetDefaultMarshalModeDiagnostic(StatelessValueInRequiresConvertToUnmanagedRule), + DefaultMarshalModeDiagnostics.GetDefaultMarshalModeDiagnostic(StatelessLinearCollectionRequiresTwoParameterAllocateContainerForUnmanagedElementsRule), + DefaultMarshalModeDiagnostics.GetDefaultMarshalModeDiagnostic(StatelessRequiresConvertToManagedRule), + DefaultMarshalModeDiagnostics.GetDefaultMarshalModeDiagnostic(StatelessLinearCollectionInRequiresCollectionMethodsRule), + DefaultMarshalModeDiagnostics.GetDefaultMarshalModeDiagnostic(StatelessLinearCollectionOutRequiresCollectionMethodsRule), + DefaultMarshalModeDiagnostics.GetDefaultMarshalModeDiagnostic(StatelessLinearCollectionRequiresTwoParameterAllocateContainerForManagedElementsRule), + DefaultMarshalModeDiagnostics.GetDefaultMarshalModeDiagnostic(StatefulMarshallerRequiresFromManagedRule), + DefaultMarshalModeDiagnostics.GetDefaultMarshalModeDiagnostic(StatefulMarshallerRequiresToUnmanagedRule), + DefaultMarshalModeDiagnostics.GetDefaultMarshalModeDiagnostic(StatefulMarshallerRequiresToManagedRule), + DefaultMarshalModeDiagnostics.GetDefaultMarshalModeDiagnostic(StatefulMarshallerRequiresFromUnmanagedRule), + CallerAllocFromManagedMustHaveBufferSizeRule, MarshallerTypeMustBeClosedOrMatchArityRule, FirstParameterMustMatchReturnTypeRule, ReturnTypesMustMatchRule, @@ -444,12 +595,9 @@ internal static DiagnosticDescriptor GetDefaultMarshalModeDiagnostic(DiagnosticD ElementTypesOfReturnTypesMustMatchRule, ManagedTypeMustBeClosedOrMatchArityRule, ManagedTypeMustBeNonNullRule, - DefaultMarshalModeDiagnostics.GetDefaultMarshalModeDiagnostic(StatelessValueInRequiresConvertToUnmanagedRule), - DefaultMarshalModeDiagnostics.GetDefaultMarshalModeDiagnostic(StatelessLinearCollectionRequiresTwoParameterAllocateContainerForUnmanagedElementsRule), - DefaultMarshalModeDiagnostics.GetDefaultMarshalModeDiagnostic(StatelessRequiresConvertToManagedRule), - DefaultMarshalModeDiagnostics.GetDefaultMarshalModeDiagnostic(StatelessLinearCollectionInRequiresCollectionMethodsRule), - DefaultMarshalModeDiagnostics.GetDefaultMarshalModeDiagnostic(StatelessLinearCollectionOutRequiresCollectionMethodsRule), - DefaultMarshalModeDiagnostics.GetDefaultMarshalModeDiagnostic(StatelessLinearCollectionRequiresTwoParameterAllocateContainerForManagedElementsRule)); + ElementMarshallerCannotBeStatefulRule, + StatefulMarshallerRequiresFreeRule, + FromUnmanagedOverloadsNotSupportedRule); public override void Initialize(AnalysisContext context) { @@ -579,7 +727,7 @@ void ReportDiagnosticsForMissingMembers(DiagnosticReporter diagnosticReporter) { CheckForBufferSizeMember( diagnosticReporter, - isLinearCollectionMarshaller ? StatelessLinearCollectionCallerAllocConstructorMustHaveBufferSizeRule : CallerAllocConstructorMustHaveBufferSizeRule, + isLinearCollectionMarshaller ? StatelessLinearCollectionCallerAllocFromManagedMustHaveBufferSizeRule : CallerAllocFromManagedMustHaveBufferSizeRule, marshallerType, methods.ToUnmanagedWithBuffer!); } @@ -835,10 +983,245 @@ private bool TryGetElementTypeFromSpanType(ITypeSymbol spanTypeMaybe, [NotNullWh return false; } -#pragma warning disable CA1822 // Mark members as static private void AnalyzeStatefulMarshallerType(DiagnosticReporter diagnosticReporter, ITypeSymbol managedType, MarshalMode mode, INamedTypeSymbol marshallerType, bool isLinearCollectionMarshaller) -#pragma warning restore CA1822 // Mark members as static { + if (mode is MarshalMode.ElementIn + or MarshalMode.ElementRef + or MarshalMode.ElementOut) + { + diagnosticReporter.CreateAndReportDiagnostic(ElementMarshallerCannotBeStatefulRule, marshallerType.ToDisplayString(), mode); + return; + } + + var (shape, methods) = StatefulMarshallerShapeHelper.GetShapeForType(marshallerType, managedType, isLinearCollectionMarshaller, _compilation); + var fromUnmanagedCandidates = StatefulMarshallerShapeHelper.GetFromUnmanagedMethodCandidates(marshallerType); + + bool reportedDiagnostics = false; + DiagnosticReporter trackingReporter = new DiagnosticReporter((descriptor, properties, args) => + { + reportedDiagnostics = true; + diagnosticReporter.CreateAndReportDiagnostic(descriptor, properties, args); + }); + trackingReporter = AdaptReporterForMarshalMode(trackingReporter, mode); + + ReportDiagnosticsForMissingMembers(trackingReporter); + + // If we encountered any missing-member diagnostics, then we'll stop checking for additional errors here. + if (reportedDiagnostics) + return; + + ReportDiagnosticsForMismatchedMemberSignatures(trackingReporter); + + void ReportDiagnosticsForMissingMembers(DiagnosticReporter diagnosticReporter) + { + // If a caller-allocated-buffer convert method exists, verify that the BufferSize property exists + if (shape.HasFlag(MarshallerShape.CallerAllocatedBuffer) && mode == MarshalMode.ManagedToUnmanagedIn) + { + CheckForBufferSizeMember( + diagnosticReporter, + CallerAllocFromManagedMustHaveBufferSizeRule, + marshallerType, + methods.FromManagedWithBuffer!); + } + + if (ManualTypeMarshallingHelper.ModeUsesManagedToUnmanagedShape(mode)) + { + // If the marshaller mode uses the managed->unmanaged shapes, + // verify that we have either a full managed-to-unmanaged shape + // or that our scenario supports the caller-allocated buffer managed-to-unmanaged shape + // and that the caller-allocated-buffer shape is present. + if (!(shape.HasFlag(MarshallerShape.ToUnmanaged) || (mode == MarshalMode.ManagedToUnmanagedIn && shape.HasFlag(MarshallerShape.CallerAllocatedBuffer)))) + { + // Verify that all of the following methods are present with valid shapes: + // - FromManaged + // - ToUnmanaged + if (methods.FromManaged is null && methods.FromManagedWithBuffer is null) + { + diagnosticReporter.CreateAndReportDiagnostic( + StatefulMarshallerRequiresFromManagedRule, + MissingMemberNames.CreateDiagnosticPropertiesForMissingMembersDiagnostic( + mode, + ShapeMemberNames.Value.Stateful.FromManaged), + marshallerType.ToDisplayString(), + mode, + managedType.ToDisplayString()); + } + if (methods.ToUnmanaged is null) + { + diagnosticReporter.CreateAndReportDiagnostic( + StatefulMarshallerRequiresToUnmanagedRule, + MissingMemberNames.CreateDiagnosticPropertiesForMissingMembersDiagnostic( + mode, + ShapeMemberNames.Value.Stateful.ToUnmanaged), + marshallerType.ToDisplayString(), + mode, + managedType.ToDisplayString()); + } + + if (isLinearCollectionMarshaller) + { + // Verify that all of the following methods are present with valid shapes: + // - GetManagedValuesSource + // - GetUnmanagedValuesDestination + List missingCollectionMethods = new(); + if (methods.ManagedValuesSource is null) + { + missingCollectionMethods.Add(ShapeMemberNames.LinearCollection.Stateful.GetManagedValuesSource); + } + if (methods.UnmanagedValuesDestination is null) + { + missingCollectionMethods.Add(ShapeMemberNames.LinearCollection.Stateful.GetUnmanagedValuesDestination); + } + if (missingCollectionMethods.Count > 0) + { + diagnosticReporter.CreateAndReportDiagnostic( + LinearCollectionInRequiresCollectionMethodsRule, + MissingMemberNames.CreateDiagnosticPropertiesForMissingMembersDiagnostic( + mode, + missingCollectionMethods), + marshallerType.ToDisplayString(), + mode, + managedType.ToDisplayString()); + } + } + } + } + + if (ManualTypeMarshallingHelper.ModeUsesUnmanagedToManagedShape(mode)) + { + // If the marshaller mode uses the unmanaged->managed shapes, + // verify that we have a full unmanaged-to-managed shape + if ((shape & (MarshallerShape.ToManaged | MarshallerShape.GuaranteedUnmarshal)) == 0) + { + // Verify that all of the following methods are present with valid shapes: + // - ToManaged or ToManagedFinally + // - FromUnmanaged + if (methods.ToManaged is null && methods.ToManagedGuaranteed is null) + { + diagnosticReporter.CreateAndReportDiagnostic( + StatefulMarshallerRequiresToManagedRule, + MissingMemberNames.CreateDiagnosticPropertiesForMissingMembersDiagnostic( + mode, + ShapeMemberNames.Value.Stateful.ToManaged), + marshallerType.ToDisplayString(), + mode, + managedType.ToDisplayString()); + } + + if (fromUnmanagedCandidates.Length == 0) + { + diagnosticReporter.CreateAndReportDiagnostic( + StatefulMarshallerRequiresFromUnmanagedRule, + MissingMemberNames.CreateDiagnosticPropertiesForMissingMembersDiagnostic( + mode, + ShapeMemberNames.Value.Stateful.FromUnmanaged), + marshallerType.ToDisplayString(), + mode, + managedType.ToDisplayString()); + } + + if (fromUnmanagedCandidates.Length > 1) + { + diagnosticReporter.CreateAndReportDiagnostic( + FromUnmanagedOverloadsNotSupportedRule, + marshallerType.ToDisplayString()); + } + + if (isLinearCollectionMarshaller) + { + // Verify that all of the following methods are present with valid shapes: + // - GetUnmanagedValuesSource + // - GetManagedValuesDestination + List missingCollectionMethods = new(); + if (methods.UnmanagedValuesSource is null) + { + missingCollectionMethods.Add(ShapeMemberNames.LinearCollection.Stateful.GetUnmanagedValuesSource); + } + if (methods.ManagedValuesDestination is null) + { + missingCollectionMethods.Add(ShapeMemberNames.LinearCollection.Stateful.GetManagedValuesDestination); + } + if (missingCollectionMethods.Count > 0) + { + diagnosticReporter.CreateAndReportDiagnostic( + LinearCollectionOutRequiresCollectionMethodsRule, + MissingMemberNames.CreateDiagnosticPropertiesForMissingMembersDiagnostic( + mode, + missingCollectionMethods), + marshallerType.ToDisplayString(), + mode, + managedType.ToDisplayString()); + } + } + } + } + + if (methods.Free is null) + { + diagnosticReporter.CreateAndReportDiagnostic( + StatefulMarshallerRequiresFreeRule, + MissingMemberNames.CreateDiagnosticPropertiesForMissingMembersDiagnostic( + mode, + ShapeMemberNames.Free), + marshallerType.ToDisplayString()); + } + } + + void ReportDiagnosticsForMismatchedMemberSignatures(DiagnosticReporter diagnosticReporter) + { + // Verify that the unmanaged type used by the marshaller is consistently + // the same in all of the methods that use the unmanaged type. + // Also, verify that the collection element types are consistent. + ITypeSymbol? unmanagedType = null; + if (ManualTypeMarshallingHelper.ModeUsesManagedToUnmanagedShape(mode)) + { + // First verify all usages in the managed->unmanaged shape. + unmanagedType = methods.ToUnmanaged.ReturnType; + if (!unmanagedType.IsUnmanagedType && !unmanagedType.IsStrictlyBlittable()) + { + diagnosticReporter.CreateAndReportDiagnostic(UnmanagedTypeMustBeUnmanagedRule, methods.ToUnmanaged.ToDisplayString()); + } + } + + if (ManualTypeMarshallingHelper.ModeUsesUnmanagedToManagedShape(mode)) + { + // Verify the unmanaged types match unmanaged->managed shape + if (unmanagedType is not null && !SymbolEqualityComparer.Default.Equals(unmanagedType, fromUnmanagedCandidates[0].Parameters[0].Type)) + { + // If both shapes are present, verify that the unmanaged types match + diagnosticReporter.CreateAndReportDiagnostic(FirstParameterMustMatchReturnTypeRule, fromUnmanagedCandidates[0].ToDisplayString(), methods.ToUnmanaged.ToDisplayString()); + } + else + { + unmanagedType = fromUnmanagedCandidates[0].Parameters[0].Type; + + if (!unmanagedType.IsUnmanagedType && !unmanagedType.IsStrictlyBlittable()) + { + diagnosticReporter.CreateAndReportDiagnostic(UnmanagedTypeMustBeUnmanagedRule, fromUnmanagedCandidates[0].ToDisplayString()); + } + } + } + + // Verify that the managed collection element types match. + // Verify that the unmanaged collection types have the expected element types. + if (isLinearCollectionMarshaller) + { + if (methods.ManagedValuesSource is not null && methods.ManagedValuesDestination is not null) + { + if (TryGetElementTypeFromSpanType(methods.ManagedValuesSource.ReturnType, out ITypeSymbol sourceElementType) + && TryGetElementTypeFromSpanType(methods.ManagedValuesDestination.ReturnType, out ITypeSymbol destinationElementType) + && !SymbolEqualityComparer.Default.Equals(sourceElementType, destinationElementType)) + { + diagnosticReporter.CreateAndReportDiagnostic(ElementTypesOfReturnTypesMustMatchRule, methods.ManagedValuesSource.ToDisplayString(), methods.ManagedValuesDestination.ToDisplayString()); + } + } + + var (typeArguments, _) = marshallerType.GetAllTypeArgumentsIncludingInContainingTypes(); + ITypeSymbol expectedUnmanagedCollectionElementType = typeArguments[typeArguments.Length - 1]; + VerifyUnmanagedCollectionElementType(diagnosticReporter, methods.UnmanagedValuesSource, expectedUnmanagedCollectionElementType, _readOnlySpanOfT); + VerifyUnmanagedCollectionElementType(diagnosticReporter, methods.UnmanagedValuesDestination, expectedUnmanagedCollectionElementType, _spanOfT); + } + } } } } 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 8ffbfe9aaa35c..52f8231668374 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/Strings.resx +++ b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/Strings.resx @@ -117,16 +117,16 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing a 'FromManaged' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. - + The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has a FromManaged method that takes a caller-allocated 'Span<{1}>' - + When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing an 'AllocateContainerForUnmanagedElements' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. - + The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has an 'AllocateContainerForUnmanagedElements' method that takes a caller-allocated 'Span<{1}>' @@ -379,7 +379,7 @@ Overloading the 'FromUnmanaged' method is unuspported as some shapes are unable to distinguish between overloads. - Overloading the 'FromUnmanaged' method is not supported in custom marshallers + The type '{0}' overloads the 'FromUnmanaged' method, which is not supported in custom marshallers The return type of 'ConvertToUnmanaged' and the parameter type of 'ConvertToManaged' must be the same. @@ -447,6 +447,12 @@ The element type of the span returned by '{0}' must be the same type as the element type of the span returned by '{1}'. + + A marshaller for an element scenario cannot be stateful. + + + The specified marshaller type '{0}' is a stateful marshaller, but stateful marshallers are not allowed in the provided marshal mode '{1}' + LibraryImportAttribute requires unsafe code. Project must be updated with '<AllowUnsafeBlocks>true</AllowUnsafeBlocks>'. @@ -456,4 +462,34 @@ LibraryImportAttribute requires unsafe code. - \ No newline at end of file + + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromManaged' that takes a '{2}' as a parameter and returns 'void' + + + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + + + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromUnmanaged' that takes the 'unmanaged' value as a parameter and returns 'void' + + + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + + + A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'. + + + The type '{0}' is a stateful marshaller and does not have a zero-parameter void-returning instance method named 'Free' + + 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 ef3111ac3e769..d29eed9d161a8 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 @@ -7,12 +7,12 @@ Přidat chybějící vlastní typu zařazovacích členů - + When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing a 'FromManaged' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing a 'FromManaged' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. - + The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has a FromManaged method that takes a caller-allocated 'Span<{1}>' The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has a FromManaged method that takes a caller-allocated 'Span<{1}>' @@ -107,6 +107,16 @@ Zařazovací typ nemá požadovaný tvar + + A marshaller for an element scenario cannot be stateful. + A marshaller for an element scenario cannot be stateful. + + + + The specified marshaller type '{0}' is a stateful marshaller, but stateful marshallers are not allowed in the provided marshal mode '{1}' + The specified marshaller type '{0}' is a stateful marshaller, but stateful marshallers are not allowed in the provided marshal mode '{1}' + + The element type of the span returned by the first method must be the same type as the element type of the span returned by the second method. The element type of the span returned by the first method must be the same type as the element type of the span returned by the second method. @@ -153,8 +163,8 @@ - Overloading the 'FromUnmanaged' method is not supported in custom marshallers - Overloading the 'FromUnmanaged' method is not supported in custom marshallers + The type '{0}' overloads the 'FromUnmanaged' method, which is not supported in custom marshallers + The type '{0}' overloads the 'FromUnmanaged' method, which is not supported in custom marshallers @@ -377,12 +387,62 @@ The return type of '{0}' must be the same type as the return type of '{1}' - + + A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'. + A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'. + + + + The type '{0}' is a stateful marshaller and does not have a zero-parameter void-returning instance method named 'Free' + The type '{0}' is a stateful marshaller and does not have a zero-parameter void-returning instance method named 'Free' + + + + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromManaged' that takes a '{2}' as a parameter and returns 'void' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromManaged' that takes a '{2}' as a parameter and returns 'void' + + + + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromUnmanaged' that takes the 'unmanaged' value as a parameter and returns 'void' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromUnmanaged' that takes the 'unmanaged' value as a parameter and returns 'void' + + + + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + + + + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + + + When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing an 'AllocateContainerForUnmanagedElements' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing an 'AllocateContainerForUnmanagedElements' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. - + The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has an 'AllocateContainerForUnmanagedElements' method that takes a caller-allocated 'Span<{1}>' The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has an 'AllocateContainerForUnmanagedElements' method that takes a caller-allocated 'Span<{1}>' 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 b4e1fcff8a04e..5b662d16f54e2 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 @@ -7,12 +7,12 @@ Hinzufügen fehlender benutzerdefinierter Marshallermember - + When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing a 'FromManaged' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing a 'FromManaged' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. - + The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has a FromManaged method that takes a caller-allocated 'Span<{1}>' The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has a FromManaged method that takes a caller-allocated 'Span<{1}>' @@ -107,6 +107,16 @@ Der Marshaller-Typ weist nicht die erforderliche Form auf + + A marshaller for an element scenario cannot be stateful. + A marshaller for an element scenario cannot be stateful. + + + + The specified marshaller type '{0}' is a stateful marshaller, but stateful marshallers are not allowed in the provided marshal mode '{1}' + The specified marshaller type '{0}' is a stateful marshaller, but stateful marshallers are not allowed in the provided marshal mode '{1}' + + The element type of the span returned by the first method must be the same type as the element type of the span returned by the second method. The element type of the span returned by the first method must be the same type as the element type of the span returned by the second method. @@ -153,8 +163,8 @@ - Overloading the 'FromUnmanaged' method is not supported in custom marshallers - Overloading the 'FromUnmanaged' method is not supported in custom marshallers + The type '{0}' overloads the 'FromUnmanaged' method, which is not supported in custom marshallers + The type '{0}' overloads the 'FromUnmanaged' method, which is not supported in custom marshallers @@ -377,12 +387,62 @@ The return type of '{0}' must be the same type as the return type of '{1}' - + + A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'. + A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'. + + + + The type '{0}' is a stateful marshaller and does not have a zero-parameter void-returning instance method named 'Free' + The type '{0}' is a stateful marshaller and does not have a zero-parameter void-returning instance method named 'Free' + + + + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromManaged' that takes a '{2}' as a parameter and returns 'void' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromManaged' that takes a '{2}' as a parameter and returns 'void' + + + + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromUnmanaged' that takes the 'unmanaged' value as a parameter and returns 'void' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromUnmanaged' that takes the 'unmanaged' value as a parameter and returns 'void' + + + + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + + + + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + + + When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing an 'AllocateContainerForUnmanagedElements' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing an 'AllocateContainerForUnmanagedElements' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. - + The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has an 'AllocateContainerForUnmanagedElements' method that takes a caller-allocated 'Span<{1}>' The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has an 'AllocateContainerForUnmanagedElements' method that takes a caller-allocated 'Span<{1}>' 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 ce3c6b8a918bf..c7130822d2888 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 @@ -7,12 +7,12 @@ Agregue los miembros de serializador de tipo personalizado que faltan - + When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing a 'FromManaged' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing a 'FromManaged' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. - + The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has a FromManaged method that takes a caller-allocated 'Span<{1}>' The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has a FromManaged method that takes a caller-allocated 'Span<{1}>' @@ -107,6 +107,16 @@ El tipo de serializador no tiene la forma necesaria + + A marshaller for an element scenario cannot be stateful. + A marshaller for an element scenario cannot be stateful. + + + + The specified marshaller type '{0}' is a stateful marshaller, but stateful marshallers are not allowed in the provided marshal mode '{1}' + The specified marshaller type '{0}' is a stateful marshaller, but stateful marshallers are not allowed in the provided marshal mode '{1}' + + The element type of the span returned by the first method must be the same type as the element type of the span returned by the second method. The element type of the span returned by the first method must be the same type as the element type of the span returned by the second method. @@ -153,8 +163,8 @@ - Overloading the 'FromUnmanaged' method is not supported in custom marshallers - Overloading the 'FromUnmanaged' method is not supported in custom marshallers + The type '{0}' overloads the 'FromUnmanaged' method, which is not supported in custom marshallers + The type '{0}' overloads the 'FromUnmanaged' method, which is not supported in custom marshallers @@ -377,12 +387,62 @@ The return type of '{0}' must be the same type as the return type of '{1}' - + + A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'. + A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'. + + + + The type '{0}' is a stateful marshaller and does not have a zero-parameter void-returning instance method named 'Free' + The type '{0}' is a stateful marshaller and does not have a zero-parameter void-returning instance method named 'Free' + + + + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromManaged' that takes a '{2}' as a parameter and returns 'void' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromManaged' that takes a '{2}' as a parameter and returns 'void' + + + + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromUnmanaged' that takes the 'unmanaged' value as a parameter and returns 'void' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromUnmanaged' that takes the 'unmanaged' value as a parameter and returns 'void' + + + + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + + + + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + + + When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing an 'AllocateContainerForUnmanagedElements' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing an 'AllocateContainerForUnmanagedElements' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. - + The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has an 'AllocateContainerForUnmanagedElements' method that takes a caller-allocated 'Span<{1}>' The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has an 'AllocateContainerForUnmanagedElements' method that takes a caller-allocated 'Span<{1}>' 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 783d138dc5734..ad5075ea73073 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 @@ -7,12 +7,12 @@ Ajouter les membres du marshaleur de type personnalisé manquants - + When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing a 'FromManaged' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing a 'FromManaged' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. - + The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has a FromManaged method that takes a caller-allocated 'Span<{1}>' The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has a FromManaged method that takes a caller-allocated 'Span<{1}>' @@ -107,6 +107,16 @@ Le type Marshaller n’a pas la forme requise + + A marshaller for an element scenario cannot be stateful. + A marshaller for an element scenario cannot be stateful. + + + + The specified marshaller type '{0}' is a stateful marshaller, but stateful marshallers are not allowed in the provided marshal mode '{1}' + The specified marshaller type '{0}' is a stateful marshaller, but stateful marshallers are not allowed in the provided marshal mode '{1}' + + The element type of the span returned by the first method must be the same type as the element type of the span returned by the second method. The element type of the span returned by the first method must be the same type as the element type of the span returned by the second method. @@ -153,8 +163,8 @@ - Overloading the 'FromUnmanaged' method is not supported in custom marshallers - Overloading the 'FromUnmanaged' method is not supported in custom marshallers + The type '{0}' overloads the 'FromUnmanaged' method, which is not supported in custom marshallers + The type '{0}' overloads the 'FromUnmanaged' method, which is not supported in custom marshallers @@ -377,12 +387,62 @@ The return type of '{0}' must be the same type as the return type of '{1}' - + + A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'. + A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'. + + + + The type '{0}' is a stateful marshaller and does not have a zero-parameter void-returning instance method named 'Free' + The type '{0}' is a stateful marshaller and does not have a zero-parameter void-returning instance method named 'Free' + + + + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromManaged' that takes a '{2}' as a parameter and returns 'void' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromManaged' that takes a '{2}' as a parameter and returns 'void' + + + + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromUnmanaged' that takes the 'unmanaged' value as a parameter and returns 'void' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromUnmanaged' that takes the 'unmanaged' value as a parameter and returns 'void' + + + + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + + + + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + + + When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing an 'AllocateContainerForUnmanagedElements' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing an 'AllocateContainerForUnmanagedElements' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. - + The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has an 'AllocateContainerForUnmanagedElements' method that takes a caller-allocated 'Span<{1}>' The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has an 'AllocateContainerForUnmanagedElements' method that takes a caller-allocated 'Span<{1}>' 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 e52047f551535..d063774a00872 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 @@ -7,12 +7,12 @@ Aggiungi membri mancanti del gestore del marshalling di tipi personalizzato mancanti - + When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing a 'FromManaged' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing a 'FromManaged' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. - + The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has a FromManaged method that takes a caller-allocated 'Span<{1}>' The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has a FromManaged method that takes a caller-allocated 'Span<{1}>' @@ -107,6 +107,16 @@ Il tipo di marshaller non ha la forma richiesta + + A marshaller for an element scenario cannot be stateful. + A marshaller for an element scenario cannot be stateful. + + + + The specified marshaller type '{0}' is a stateful marshaller, but stateful marshallers are not allowed in the provided marshal mode '{1}' + The specified marshaller type '{0}' is a stateful marshaller, but stateful marshallers are not allowed in the provided marshal mode '{1}' + + The element type of the span returned by the first method must be the same type as the element type of the span returned by the second method. The element type of the span returned by the first method must be the same type as the element type of the span returned by the second method. @@ -153,8 +163,8 @@ - Overloading the 'FromUnmanaged' method is not supported in custom marshallers - Overloading the 'FromUnmanaged' method is not supported in custom marshallers + The type '{0}' overloads the 'FromUnmanaged' method, which is not supported in custom marshallers + The type '{0}' overloads the 'FromUnmanaged' method, which is not supported in custom marshallers @@ -377,12 +387,62 @@ The return type of '{0}' must be the same type as the return type of '{1}' - + + A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'. + A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'. + + + + The type '{0}' is a stateful marshaller and does not have a zero-parameter void-returning instance method named 'Free' + The type '{0}' is a stateful marshaller and does not have a zero-parameter void-returning instance method named 'Free' + + + + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromManaged' that takes a '{2}' as a parameter and returns 'void' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromManaged' that takes a '{2}' as a parameter and returns 'void' + + + + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromUnmanaged' that takes the 'unmanaged' value as a parameter and returns 'void' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromUnmanaged' that takes the 'unmanaged' value as a parameter and returns 'void' + + + + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + + + + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + + + When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing an 'AllocateContainerForUnmanagedElements' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing an 'AllocateContainerForUnmanagedElements' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. - + The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has an 'AllocateContainerForUnmanagedElements' method that takes a caller-allocated 'Span<{1}>' The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has an 'AllocateContainerForUnmanagedElements' method that takes a caller-allocated 'Span<{1}>' 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 fb66485c94471..d57b1ac7c3b10 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 @@ -7,12 +7,12 @@ 不足しているカスタム型マーシャラー メンバーの追加 - + When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing a 'FromManaged' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing a 'FromManaged' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. - + The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has a FromManaged method that takes a caller-allocated 'Span<{1}>' The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has a FromManaged method that takes a caller-allocated 'Span<{1}>' @@ -107,6 +107,16 @@ マーシャラー型に必要な図形がありません + + A marshaller for an element scenario cannot be stateful. + A marshaller for an element scenario cannot be stateful. + + + + The specified marshaller type '{0}' is a stateful marshaller, but stateful marshallers are not allowed in the provided marshal mode '{1}' + The specified marshaller type '{0}' is a stateful marshaller, but stateful marshallers are not allowed in the provided marshal mode '{1}' + + The element type of the span returned by the first method must be the same type as the element type of the span returned by the second method. The element type of the span returned by the first method must be the same type as the element type of the span returned by the second method. @@ -153,8 +163,8 @@ - Overloading the 'FromUnmanaged' method is not supported in custom marshallers - Overloading the 'FromUnmanaged' method is not supported in custom marshallers + The type '{0}' overloads the 'FromUnmanaged' method, which is not supported in custom marshallers + The type '{0}' overloads the 'FromUnmanaged' method, which is not supported in custom marshallers @@ -377,12 +387,62 @@ The return type of '{0}' must be the same type as the return type of '{1}' - + + A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'. + A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'. + + + + The type '{0}' is a stateful marshaller and does not have a zero-parameter void-returning instance method named 'Free' + The type '{0}' is a stateful marshaller and does not have a zero-parameter void-returning instance method named 'Free' + + + + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromManaged' that takes a '{2}' as a parameter and returns 'void' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromManaged' that takes a '{2}' as a parameter and returns 'void' + + + + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromUnmanaged' that takes the 'unmanaged' value as a parameter and returns 'void' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromUnmanaged' that takes the 'unmanaged' value as a parameter and returns 'void' + + + + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + + + + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + + + When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing an 'AllocateContainerForUnmanagedElements' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing an 'AllocateContainerForUnmanagedElements' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. - + The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has an 'AllocateContainerForUnmanagedElements' method that takes a caller-allocated 'Span<{1}>' The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has an 'AllocateContainerForUnmanagedElements' method that takes a caller-allocated 'Span<{1}>' 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 0f846fd62c73f..4db25633e65c3 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 @@ -7,12 +7,12 @@ 누락된 사용자 지정 형식 마샬러 구성원 추가 - + When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing a 'FromManaged' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing a 'FromManaged' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. - + The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has a FromManaged method that takes a caller-allocated 'Span<{1}>' The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has a FromManaged method that takes a caller-allocated 'Span<{1}>' @@ -107,6 +107,16 @@ 마샬러 형식에 필요한 셰이프가 없습니다. + + A marshaller for an element scenario cannot be stateful. + A marshaller for an element scenario cannot be stateful. + + + + The specified marshaller type '{0}' is a stateful marshaller, but stateful marshallers are not allowed in the provided marshal mode '{1}' + The specified marshaller type '{0}' is a stateful marshaller, but stateful marshallers are not allowed in the provided marshal mode '{1}' + + The element type of the span returned by the first method must be the same type as the element type of the span returned by the second method. The element type of the span returned by the first method must be the same type as the element type of the span returned by the second method. @@ -153,8 +163,8 @@ - Overloading the 'FromUnmanaged' method is not supported in custom marshallers - Overloading the 'FromUnmanaged' method is not supported in custom marshallers + The type '{0}' overloads the 'FromUnmanaged' method, which is not supported in custom marshallers + The type '{0}' overloads the 'FromUnmanaged' method, which is not supported in custom marshallers @@ -377,12 +387,62 @@ The return type of '{0}' must be the same type as the return type of '{1}' - + + A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'. + A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'. + + + + The type '{0}' is a stateful marshaller and does not have a zero-parameter void-returning instance method named 'Free' + The type '{0}' is a stateful marshaller and does not have a zero-parameter void-returning instance method named 'Free' + + + + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromManaged' that takes a '{2}' as a parameter and returns 'void' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromManaged' that takes a '{2}' as a parameter and returns 'void' + + + + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromUnmanaged' that takes the 'unmanaged' value as a parameter and returns 'void' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromUnmanaged' that takes the 'unmanaged' value as a parameter and returns 'void' + + + + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + + + + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + + + When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing an 'AllocateContainerForUnmanagedElements' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing an 'AllocateContainerForUnmanagedElements' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. - + The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has an 'AllocateContainerForUnmanagedElements' method that takes a caller-allocated 'Span<{1}>' The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has an 'AllocateContainerForUnmanagedElements' method that takes a caller-allocated 'Span<{1}>' 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 bcc51f44ad2e3..a5227e11b534e 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 @@ -7,12 +7,12 @@ Dodaj brakujące składowe elementu przeprowadzającego marshalling typu niestandardowego - + When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing a 'FromManaged' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing a 'FromManaged' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. - + The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has a FromManaged method that takes a caller-allocated 'Span<{1}>' The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has a FromManaged method that takes a caller-allocated 'Span<{1}>' @@ -107,6 +107,16 @@ Typ marshallera nie ma wymaganego kształtu + + A marshaller for an element scenario cannot be stateful. + A marshaller for an element scenario cannot be stateful. + + + + The specified marshaller type '{0}' is a stateful marshaller, but stateful marshallers are not allowed in the provided marshal mode '{1}' + The specified marshaller type '{0}' is a stateful marshaller, but stateful marshallers are not allowed in the provided marshal mode '{1}' + + The element type of the span returned by the first method must be the same type as the element type of the span returned by the second method. The element type of the span returned by the first method must be the same type as the element type of the span returned by the second method. @@ -153,8 +163,8 @@ - Overloading the 'FromUnmanaged' method is not supported in custom marshallers - Overloading the 'FromUnmanaged' method is not supported in custom marshallers + The type '{0}' overloads the 'FromUnmanaged' method, which is not supported in custom marshallers + The type '{0}' overloads the 'FromUnmanaged' method, which is not supported in custom marshallers @@ -377,12 +387,62 @@ The return type of '{0}' must be the same type as the return type of '{1}' - + + A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'. + A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'. + + + + The type '{0}' is a stateful marshaller and does not have a zero-parameter void-returning instance method named 'Free' + The type '{0}' is a stateful marshaller and does not have a zero-parameter void-returning instance method named 'Free' + + + + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromManaged' that takes a '{2}' as a parameter and returns 'void' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromManaged' that takes a '{2}' as a parameter and returns 'void' + + + + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromUnmanaged' that takes the 'unmanaged' value as a parameter and returns 'void' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromUnmanaged' that takes the 'unmanaged' value as a parameter and returns 'void' + + + + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + + + + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + + + When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing an 'AllocateContainerForUnmanagedElements' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing an 'AllocateContainerForUnmanagedElements' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. - + The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has an 'AllocateContainerForUnmanagedElements' method that takes a caller-allocated 'Span<{1}>' The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has an 'AllocateContainerForUnmanagedElements' method that takes a caller-allocated 'Span<{1}>' 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 4bb950282a16b..9e22028ca4326 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 @@ -7,12 +7,12 @@ Adicionar membros marshaller de tipo personalizado ausentes - + When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing a 'FromManaged' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing a 'FromManaged' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. - + The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has a FromManaged method that takes a caller-allocated 'Span<{1}>' The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has a FromManaged method that takes a caller-allocated 'Span<{1}>' @@ -107,6 +107,16 @@ O tipo de marshaller não tem a forma necessária + + A marshaller for an element scenario cannot be stateful. + A marshaller for an element scenario cannot be stateful. + + + + The specified marshaller type '{0}' is a stateful marshaller, but stateful marshallers are not allowed in the provided marshal mode '{1}' + The specified marshaller type '{0}' is a stateful marshaller, but stateful marshallers are not allowed in the provided marshal mode '{1}' + + The element type of the span returned by the first method must be the same type as the element type of the span returned by the second method. The element type of the span returned by the first method must be the same type as the element type of the span returned by the second method. @@ -153,8 +163,8 @@ - Overloading the 'FromUnmanaged' method is not supported in custom marshallers - Overloading the 'FromUnmanaged' method is not supported in custom marshallers + The type '{0}' overloads the 'FromUnmanaged' method, which is not supported in custom marshallers + The type '{0}' overloads the 'FromUnmanaged' method, which is not supported in custom marshallers @@ -377,12 +387,62 @@ The return type of '{0}' must be the same type as the return type of '{1}' - + + A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'. + A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'. + + + + The type '{0}' is a stateful marshaller and does not have a zero-parameter void-returning instance method named 'Free' + The type '{0}' is a stateful marshaller and does not have a zero-parameter void-returning instance method named 'Free' + + + + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromManaged' that takes a '{2}' as a parameter and returns 'void' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromManaged' that takes a '{2}' as a parameter and returns 'void' + + + + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromUnmanaged' that takes the 'unmanaged' value as a parameter and returns 'void' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromUnmanaged' that takes the 'unmanaged' value as a parameter and returns 'void' + + + + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + + + + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + + + When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing an 'AllocateContainerForUnmanagedElements' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing an 'AllocateContainerForUnmanagedElements' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. - + The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has an 'AllocateContainerForUnmanagedElements' method that takes a caller-allocated 'Span<{1}>' The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has an 'AllocateContainerForUnmanagedElements' method that takes a caller-allocated 'Span<{1}>' 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 88140fc58a109..7dfc725b49d52 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 @@ -7,12 +7,12 @@ Добавить отсутствующие элементы маршалатора настраиваемого типа - + When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing a 'FromManaged' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing a 'FromManaged' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. - + The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has a FromManaged method that takes a caller-allocated 'Span<{1}>' The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has a FromManaged method that takes a caller-allocated 'Span<{1}>' @@ -107,6 +107,16 @@ Тип маршалера не имеет требуемой фигуры + + A marshaller for an element scenario cannot be stateful. + A marshaller for an element scenario cannot be stateful. + + + + The specified marshaller type '{0}' is a stateful marshaller, but stateful marshallers are not allowed in the provided marshal mode '{1}' + The specified marshaller type '{0}' is a stateful marshaller, but stateful marshallers are not allowed in the provided marshal mode '{1}' + + The element type of the span returned by the first method must be the same type as the element type of the span returned by the second method. The element type of the span returned by the first method must be the same type as the element type of the span returned by the second method. @@ -153,8 +163,8 @@ - Overloading the 'FromUnmanaged' method is not supported in custom marshallers - Overloading the 'FromUnmanaged' method is not supported in custom marshallers + The type '{0}' overloads the 'FromUnmanaged' method, which is not supported in custom marshallers + The type '{0}' overloads the 'FromUnmanaged' method, which is not supported in custom marshallers @@ -377,12 +387,62 @@ The return type of '{0}' must be the same type as the return type of '{1}' - + + A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'. + A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'. + + + + The type '{0}' is a stateful marshaller and does not have a zero-parameter void-returning instance method named 'Free' + The type '{0}' is a stateful marshaller and does not have a zero-parameter void-returning instance method named 'Free' + + + + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromManaged' that takes a '{2}' as a parameter and returns 'void' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromManaged' that takes a '{2}' as a parameter and returns 'void' + + + + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromUnmanaged' that takes the 'unmanaged' value as a parameter and returns 'void' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromUnmanaged' that takes the 'unmanaged' value as a parameter and returns 'void' + + + + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + + + + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + + + When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing an 'AllocateContainerForUnmanagedElements' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing an 'AllocateContainerForUnmanagedElements' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. - + The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has an 'AllocateContainerForUnmanagedElements' method that takes a caller-allocated 'Span<{1}>' The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has an 'AllocateContainerForUnmanagedElements' method that takes a caller-allocated 'Span<{1}>' 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 b8635272321d6..42eccea1f7a9e 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 @@ -7,12 +7,12 @@ Eksik olan özel tür sıralayıcı üyelerini ekleyin - + When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing a 'FromManaged' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing a 'FromManaged' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. - + The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has a FromManaged method that takes a caller-allocated 'Span<{1}>' The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has a FromManaged method that takes a caller-allocated 'Span<{1}>' @@ -107,6 +107,16 @@ Sıralayıcı türü gerekli şekle sahip değil + + A marshaller for an element scenario cannot be stateful. + A marshaller for an element scenario cannot be stateful. + + + + The specified marshaller type '{0}' is a stateful marshaller, but stateful marshallers are not allowed in the provided marshal mode '{1}' + The specified marshaller type '{0}' is a stateful marshaller, but stateful marshallers are not allowed in the provided marshal mode '{1}' + + The element type of the span returned by the first method must be the same type as the element type of the span returned by the second method. The element type of the span returned by the first method must be the same type as the element type of the span returned by the second method. @@ -153,8 +163,8 @@ - Overloading the 'FromUnmanaged' method is not supported in custom marshallers - Overloading the 'FromUnmanaged' method is not supported in custom marshallers + The type '{0}' overloads the 'FromUnmanaged' method, which is not supported in custom marshallers + The type '{0}' overloads the 'FromUnmanaged' method, which is not supported in custom marshallers @@ -377,12 +387,62 @@ The return type of '{0}' must be the same type as the return type of '{1}' - + + A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'. + A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'. + + + + The type '{0}' is a stateful marshaller and does not have a zero-parameter void-returning instance method named 'Free' + The type '{0}' is a stateful marshaller and does not have a zero-parameter void-returning instance method named 'Free' + + + + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromManaged' that takes a '{2}' as a parameter and returns 'void' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromManaged' that takes a '{2}' as a parameter and returns 'void' + + + + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromUnmanaged' that takes the 'unmanaged' value as a parameter and returns 'void' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromUnmanaged' that takes the 'unmanaged' value as a parameter and returns 'void' + + + + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + + + + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + + + When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing an 'AllocateContainerForUnmanagedElements' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing an 'AllocateContainerForUnmanagedElements' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. - + The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has an 'AllocateContainerForUnmanagedElements' method that takes a caller-allocated 'Span<{1}>' The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has an 'AllocateContainerForUnmanagedElements' method that takes a caller-allocated 'Span<{1}>' 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 4b489fc32be0f..cb5cde89b2a8e 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 @@ -7,12 +7,12 @@ 添加缺少的自定义类型封送程序成员 - + When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing a 'FromManaged' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing a 'FromManaged' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. - + The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has a FromManaged method that takes a caller-allocated 'Span<{1}>' The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has a FromManaged method that takes a caller-allocated 'Span<{1}>' @@ -107,6 +107,16 @@ 封送程序类型没有必需的形状 + + A marshaller for an element scenario cannot be stateful. + A marshaller for an element scenario cannot be stateful. + + + + The specified marshaller type '{0}' is a stateful marshaller, but stateful marshallers are not allowed in the provided marshal mode '{1}' + The specified marshaller type '{0}' is a stateful marshaller, but stateful marshallers are not allowed in the provided marshal mode '{1}' + + The element type of the span returned by the first method must be the same type as the element type of the span returned by the second method. The element type of the span returned by the first method must be the same type as the element type of the span returned by the second method. @@ -153,8 +163,8 @@ - Overloading the 'FromUnmanaged' method is not supported in custom marshallers - Overloading the 'FromUnmanaged' method is not supported in custom marshallers + The type '{0}' overloads the 'FromUnmanaged' method, which is not supported in custom marshallers + The type '{0}' overloads the 'FromUnmanaged' method, which is not supported in custom marshallers @@ -377,12 +387,62 @@ The return type of '{0}' must be the same type as the return type of '{1}' - + + A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'. + A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'. + + + + The type '{0}' is a stateful marshaller and does not have a zero-parameter void-returning instance method named 'Free' + The type '{0}' is a stateful marshaller and does not have a zero-parameter void-returning instance method named 'Free' + + + + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromManaged' that takes a '{2}' as a parameter and returns 'void' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromManaged' that takes a '{2}' as a parameter and returns 'void' + + + + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromUnmanaged' that takes the 'unmanaged' value as a parameter and returns 'void' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromUnmanaged' that takes the 'unmanaged' value as a parameter and returns 'void' + + + + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + + + + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + + + When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing an 'AllocateContainerForUnmanagedElements' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing an 'AllocateContainerForUnmanagedElements' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. - + The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has an 'AllocateContainerForUnmanagedElements' method that takes a caller-allocated 'Span<{1}>' The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has an 'AllocateContainerForUnmanagedElements' method that takes a caller-allocated 'Span<{1}>' 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 437627b481da9..4ab7887126eda 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 @@ -7,12 +7,12 @@ 新增遺漏的自訂類型排列器成員 - + When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing a 'FromManaged' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing a 'FromManaged' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. - + The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has a FromManaged method that takes a caller-allocated 'Span<{1}>' The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has a FromManaged method that takes a caller-allocated 'Span<{1}>' @@ -107,6 +107,16 @@ 封送處理器類型沒有必要的圖形 + + A marshaller for an element scenario cannot be stateful. + A marshaller for an element scenario cannot be stateful. + + + + The specified marshaller type '{0}' is a stateful marshaller, but stateful marshallers are not allowed in the provided marshal mode '{1}' + The specified marshaller type '{0}' is a stateful marshaller, but stateful marshallers are not allowed in the provided marshal mode '{1}' + + The element type of the span returned by the first method must be the same type as the element type of the span returned by the second method. The element type of the span returned by the first method must be the same type as the element type of the span returned by the second method. @@ -153,8 +163,8 @@ - Overloading the 'FromUnmanaged' method is not supported in custom marshallers - Overloading the 'FromUnmanaged' method is not supported in custom marshallers + The type '{0}' overloads the 'FromUnmanaged' method, which is not supported in custom marshallers + The type '{0}' overloads the 'FromUnmanaged' method, which is not supported in custom marshallers @@ -377,12 +387,62 @@ The return type of '{0}' must be the same type as the return type of '{1}' - + + A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'. + A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'. + + + + The type '{0}' is a stateful marshaller and does not have a zero-parameter void-returning instance method named 'Free' + The type '{0}' is a stateful marshaller and does not have a zero-parameter void-returning instance method named 'Free' + + + + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromManaged' that takes a '{2}' as a parameter and returns 'void' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromManaged' that takes a '{2}' as a parameter and returns 'void' + + + + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromUnmanaged' that takes the 'unmanaged' value as a parameter and returns 'void' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromUnmanaged' that takes the 'unmanaged' value as a parameter and returns 'void' + + + + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + + + + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + + + + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + + + When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing an 'AllocateContainerForUnmanagedElements' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing an 'AllocateContainerForUnmanagedElements' method that takes a 'Span<T>' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer. - + The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has an 'AllocateContainerForUnmanagedElements' method that takes a caller-allocated 'Span<{1}>' The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has an 'AllocateContainerForUnmanagedElements' method that takes a caller-allocated 'Span<{1}>' diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CustomMarshallerAttributeFixerTests_StatefulLinearCollectionShapeValidation.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CustomMarshallerAttributeFixerTests_StatefulLinearCollectionShapeValidation.cs new file mode 100644 index 0000000000000..0ad27bb6b2f8e --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CustomMarshallerAttributeFixerTests_StatefulLinearCollectionShapeValidation.cs @@ -0,0 +1,457 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Testing; +using Microsoft.Interop; +using System.Collections.Generic; +using System.Threading.Tasks; +using Xunit; +using static Microsoft.Interop.Analyzers.CustomMarshallerAttributeAnalyzer; + +using VerifyCS = LibraryImportGenerator.UnitTests.Verifiers.CSharpCodeFixVerifier< + Microsoft.Interop.Analyzers.CustomMarshallerAttributeAnalyzer, + Microsoft.Interop.Analyzers.CustomMarshallerAttributeFixer>; + +namespace LibraryImportGenerator.UnitTests +{ + [ActiveIssue("https://github.com/dotnet/runtime/issues/60650", TestRuntimes.Mono)] + public class CustomMarshallerAttributeAnalyzerTests_StatefulLinearCollectionShapeValidation + { + [Fact] + public async Task ModeThatUsesManagedToUnmanagedShape_Missing_AllMethods_ReportsDiagnostic() + { + string source = """ + using System.Runtime.InteropServices.Marshalling; + + class ManagedType {} + + [CustomMarshaller(typeof(ManagedType), MarshalMode.ManagedToUnmanagedIn, typeof({|#0:MarshallerType<>|}))] + [CustomMarshaller(typeof(ManagedType), MarshalMode.UnmanagedToManagedOut, typeof({|#1:MarshallerType<>|}))] + [ContiguousCollectionMarshaller] + struct MarshallerType + { + } + """; + + await VerifyCS.VerifyAnalyzerAsync( + source, + VerifyCS.Diagnostic(StatefulMarshallerRequiresFreeRule).WithLocation(0).WithArguments("MarshallerType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresFromManagedRule).WithLocation(0).WithArguments("MarshallerType", MarshalMode.ManagedToUnmanagedIn, "ManagedType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresFromManagedRule).WithLocation(1).WithArguments("MarshallerType", MarshalMode.UnmanagedToManagedOut, "ManagedType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresToUnmanagedRule).WithLocation(0).WithArguments("MarshallerType", MarshalMode.ManagedToUnmanagedIn, "ManagedType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresToUnmanagedRule).WithLocation(1).WithArguments("MarshallerType", MarshalMode.UnmanagedToManagedOut, "ManagedType"), + VerifyCS.Diagnostic(LinearCollectionInRequiresCollectionMethodsRule).WithLocation(0).WithArguments("MarshallerType", MarshalMode.ManagedToUnmanagedIn, "ManagedType"), + VerifyCS.Diagnostic(LinearCollectionInRequiresCollectionMethodsRule).WithLocation(1).WithArguments("MarshallerType", MarshalMode.UnmanagedToManagedOut, "ManagedType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresFreeRule).WithLocation(1).WithArguments("MarshallerType")); + } + + [Fact] + public async Task ModeThatUsesManagedToUnmanagedShape_Missing_ContainerMethods_ReportsDiagnostic() + { + string source = """ + using System.Runtime.InteropServices.Marshalling; + + class ManagedType {} + + [CustomMarshaller(typeof(ManagedType), MarshalMode.ManagedToUnmanagedIn, typeof({|#0:MarshallerType<>|}))] + [CustomMarshaller(typeof(ManagedType), MarshalMode.UnmanagedToManagedOut, typeof({|#1:MarshallerType<>|}))] + [ContiguousCollectionMarshaller] + struct MarshallerType + { + public void FromManaged(ManagedType m) {} + public nint ToUnmanaged() => default; + public void Free() {} + } + """; + + await VerifyCS.VerifyAnalyzerAsync( + source, + VerifyCS.Diagnostic(LinearCollectionInRequiresCollectionMethodsRule).WithLocation(0).WithArguments("MarshallerType", MarshalMode.ManagedToUnmanagedIn, "ManagedType"), + VerifyCS.Diagnostic(LinearCollectionInRequiresCollectionMethodsRule).WithLocation(1).WithArguments("MarshallerType", MarshalMode.UnmanagedToManagedOut, "ManagedType")); + } + + [Fact] + public async Task ModeThatUsesManagedToUnmanagedShape_Missing_GetManagedValuesSource_ReportsDiagnostic() + { + string source = """ + using System; + using System.Runtime.InteropServices.Marshalling; + + class ManagedType {} + + [CustomMarshaller(typeof(ManagedType), MarshalMode.ManagedToUnmanagedIn, typeof({|#0:MarshallerType<>|}))] + [CustomMarshaller(typeof(ManagedType), MarshalMode.UnmanagedToManagedOut, typeof({|#1:MarshallerType<>|}))] + [ContiguousCollectionMarshaller] + struct MarshallerType + { + public void FromManaged(ManagedType m) {} + public nint ToUnmanaged() => default; + public void Free() {} + public Span GetUnmanagedValuesDestination() => default; + } + """; + + await VerifyCS.VerifyAnalyzerAsync( + source, + VerifyCS.Diagnostic(LinearCollectionInRequiresCollectionMethodsRule).WithLocation(0).WithArguments("MarshallerType", MarshalMode.ManagedToUnmanagedIn, "ManagedType"), + VerifyCS.Diagnostic(LinearCollectionInRequiresCollectionMethodsRule).WithLocation(1).WithArguments("MarshallerType", MarshalMode.UnmanagedToManagedOut, "ManagedType")); + } + + [Fact] + public async Task ModeThatUsesManagedToUnmanagedShape_Missing_GetUnmanagedValuesDestination_ReportsDiagnostic() + { + string source = """ + using System; + using System.Runtime.InteropServices.Marshalling; + + class ManagedType {} + + [CustomMarshaller(typeof(ManagedType), MarshalMode.ManagedToUnmanagedIn, typeof({|#0:MarshallerType<>|}))] + [CustomMarshaller(typeof(ManagedType), MarshalMode.UnmanagedToManagedOut, typeof({|#1:MarshallerType<>|}))] + [ContiguousCollectionMarshaller] + struct MarshallerType + { + public void FromManaged(ManagedType m) {} + public nint ToUnmanaged() => default; + public void Free() {} + public ReadOnlySpan GetManagedValuesSource() => default; + } + """; + + await VerifyCS.VerifyAnalyzerAsync( + source, + VerifyCS.Diagnostic(LinearCollectionInRequiresCollectionMethodsRule).WithLocation(1).WithArguments("MarshallerType", MarshalMode.UnmanagedToManagedOut, "ManagedType"), + VerifyCS.Diagnostic(LinearCollectionInRequiresCollectionMethodsRule).WithLocation(0).WithArguments("MarshallerType", MarshalMode.ManagedToUnmanagedIn, "ManagedType")); + } + + [Fact] + public async Task ModeThatUsesManagedToUnmanagedShape_DoesNotReportDiagnostic() + { + string source = """ + using System; + using System.Runtime.InteropServices.Marshalling; + + class ManagedType {} + + [CustomMarshaller(typeof(ManagedType), MarshalMode.ManagedToUnmanagedIn, typeof(MarshallerType<>))] + [CustomMarshaller(typeof(ManagedType), MarshalMode.UnmanagedToManagedOut, typeof(MarshallerType<>))] + [ContiguousCollectionMarshaller] + struct MarshallerType + { + public void FromManaged(ManagedType m) {} + public nint ToUnmanaged() => default; + public void Free() {} + public ReadOnlySpan GetManagedValuesSource() => default; + public Span GetUnmanagedValuesDestination() => default; + } + """; + + await VerifyCS.VerifyAnalyzerAsync( + source); + } + + + [Fact] + public async Task ModeThatUsesManagedToUnmanagedShape_InvalidCollectionElementType_DoesNotReportDiagnostic() + { + string source = """ + using System; + using System.Runtime.InteropServices.Marshalling; + + class ManagedType {} + + [CustomMarshaller(typeof(ManagedType), MarshalMode.ManagedToUnmanagedIn, typeof({|#0:MarshallerType<>|}))] + [CustomMarshaller(typeof(ManagedType), MarshalMode.UnmanagedToManagedOut, typeof({|#1:MarshallerType<>|}))] + [ContiguousCollectionMarshaller] + struct MarshallerType + { + public void FromManaged(ManagedType m) {} + public nint ToUnmanaged() => default; + public void Free() {} + public ReadOnlySpan GetManagedValuesSource() => default; + public Span GetUnmanagedValuesDestination() => default; + } + """; + + await VerifyCS.VerifyAnalyzerAsync( + source, + VerifyCS.Diagnostic(ReturnTypeMustBeExpectedTypeRule).WithLocation(0).WithArguments("MarshallerType.GetUnmanagedValuesDestination()", "System.Span"), + VerifyCS.Diagnostic(ReturnTypeMustBeExpectedTypeRule).WithLocation(1).WithArguments("MarshallerType.GetUnmanagedValuesDestination()", "System.Span")); + } + + [Fact] + public async Task ModeThatUsesUnmanagedToManagedShape_Missing_AllMethods_ReportsDiagnostic() + { + string source = """ + using System.Runtime.InteropServices.Marshalling; + + class ManagedType {} + + [CustomMarshaller(typeof(ManagedType), MarshalMode.ManagedToUnmanagedOut, typeof({|#0:MarshallerType<>|}))] + [CustomMarshaller(typeof(ManagedType), MarshalMode.UnmanagedToManagedIn, typeof({|#1:MarshallerType<>|}))] + [ContiguousCollectionMarshaller] + struct MarshallerType + { + } + """; + + await VerifyCS.VerifyAnalyzerAsync( + source, + VerifyCS.Diagnostic(StatefulMarshallerRequiresFreeRule).WithLocation(0).WithArguments("MarshallerType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresToManagedRule).WithLocation(0).WithArguments("MarshallerType", MarshalMode.ManagedToUnmanagedOut, "ManagedType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresToManagedRule).WithLocation(1).WithArguments("MarshallerType", MarshalMode.UnmanagedToManagedIn, "ManagedType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresFromUnmanagedRule).WithLocation(0).WithArguments("MarshallerType", MarshalMode.ManagedToUnmanagedOut, "ManagedType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresFromUnmanagedRule).WithLocation(1).WithArguments("MarshallerType", MarshalMode.UnmanagedToManagedIn, "ManagedType"), + VerifyCS.Diagnostic(LinearCollectionOutRequiresCollectionMethodsRule).WithLocation(0).WithArguments("MarshallerType", MarshalMode.ManagedToUnmanagedOut, "ManagedType"), + VerifyCS.Diagnostic(LinearCollectionOutRequiresCollectionMethodsRule).WithLocation(1).WithArguments("MarshallerType", MarshalMode.UnmanagedToManagedIn, "ManagedType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresFreeRule).WithLocation(1).WithArguments("MarshallerType")); + } + + [Fact] + public async Task ModeThatUsesUnmanagedToManagedShape_Missing_ContainerMethods_ReportsDiagnostic() + { + string source = """ + using System.Runtime.InteropServices.Marshalling; + + class ManagedType {} + + [CustomMarshaller(typeof(ManagedType), MarshalMode.ManagedToUnmanagedOut, typeof({|#0:MarshallerType<>|}))] + [CustomMarshaller(typeof(ManagedType), MarshalMode.UnmanagedToManagedIn, typeof({|#1:MarshallerType<>|}))] + [ContiguousCollectionMarshaller] + struct MarshallerType + { + public void FromUnmanaged(int f) {} + public ManagedType ToManaged() => default; + public void Free() {} + } + """; + + await VerifyCS.VerifyAnalyzerAsync( + source, + VerifyCS.Diagnostic(LinearCollectionOutRequiresCollectionMethodsRule).WithLocation(0).WithArguments("MarshallerType", MarshalMode.ManagedToUnmanagedOut, "ManagedType"), + VerifyCS.Diagnostic(LinearCollectionOutRequiresCollectionMethodsRule).WithLocation(1).WithArguments("MarshallerType", MarshalMode.UnmanagedToManagedIn, "ManagedType")); + } + + [Fact] + public async Task ModeThatUsesUnmanagedToManagedShape_Missing_GetUnmanagedValuesSource_ReportsDiagnostic() + { + string source = """ + using System; + using System.Runtime.InteropServices.Marshalling; + + class ManagedType {} + + [CustomMarshaller(typeof(ManagedType), MarshalMode.ManagedToUnmanagedOut, typeof({|#0:MarshallerType<>|}))] + [CustomMarshaller(typeof(ManagedType), MarshalMode.UnmanagedToManagedIn, typeof({|#1:MarshallerType<>|}))] + [ContiguousCollectionMarshaller] + struct MarshallerType + { + public void FromUnmanaged(int f) {} + public ManagedType ToManaged() => default; + public void Free() {} + public Span GetManagedValuesDestination(int numElements) => default; + } + """; + + await VerifyCS.VerifyAnalyzerAsync( + source, + VerifyCS.Diagnostic(LinearCollectionOutRequiresCollectionMethodsRule).WithLocation(0).WithArguments("MarshallerType", MarshalMode.ManagedToUnmanagedOut, "ManagedType"), + VerifyCS.Diagnostic(LinearCollectionOutRequiresCollectionMethodsRule).WithLocation(1).WithArguments("MarshallerType", MarshalMode.UnmanagedToManagedIn, "ManagedType")); + } + + [Fact] + public async Task ModeThatUsesUnmanagedToManagedShape_Missing_GetManagedValuesDestination_ReportsDiagnostic() + { + string source = """ + using System; + using System.Runtime.InteropServices.Marshalling; + + class ManagedType {} + + [CustomMarshaller(typeof(ManagedType), MarshalMode.ManagedToUnmanagedOut, typeof({|#0:MarshallerType<>|}))] + [CustomMarshaller(typeof(ManagedType), MarshalMode.UnmanagedToManagedIn, typeof({|#1:MarshallerType<>|}))] + [ContiguousCollectionMarshaller] + struct MarshallerType + { + public void FromUnmanaged(int f) {} + public ManagedType ToManaged() => default; + public void Free() {} + public ReadOnlySpan GetUnmanagedValuesSource(int numElements) => default; + } + """; + + await VerifyCS.VerifyAnalyzerAsync( + source, + VerifyCS.Diagnostic(LinearCollectionOutRequiresCollectionMethodsRule).WithLocation(1).WithArguments("MarshallerType", MarshalMode.UnmanagedToManagedIn, "ManagedType"), + VerifyCS.Diagnostic(LinearCollectionOutRequiresCollectionMethodsRule).WithLocation(0).WithArguments("MarshallerType", MarshalMode.ManagedToUnmanagedOut, "ManagedType")); + } + + [Fact] + public async Task ModeThatUsesUnmanagedToManagedShape_DoesNotReportDiagnostic() + { + string source = """ + using System; + using System.Runtime.InteropServices.Marshalling; + + class ManagedType {} + + [CustomMarshaller(typeof(ManagedType), MarshalMode.ManagedToUnmanagedOut, typeof(MarshallerType<>))] + [CustomMarshaller(typeof(ManagedType), MarshalMode.UnmanagedToManagedIn, typeof(MarshallerType<>))] + [ContiguousCollectionMarshaller] + struct MarshallerType + { + public void FromUnmanaged(int f) {} + public ManagedType ToManaged() => default; + public void Free() {} + public Span GetManagedValuesDestination(int numElements) => default; + public ReadOnlySpan GetUnmanagedValuesSource(int numElements) => default; + } + """; + + await VerifyCS.VerifyAnalyzerAsync( + source); + } + + [Fact] + public async Task ModeThatUsesUnmanagedToManagedShape_InvalidCollectionElementType_ReportsDiagnostic() + { + string source = """ + using System; + using System.Runtime.InteropServices.Marshalling; + + class ManagedType {} + + [CustomMarshaller(typeof(ManagedType), MarshalMode.ManagedToUnmanagedOut, typeof({|#0:MarshallerType<>|}))] + [CustomMarshaller(typeof(ManagedType), MarshalMode.UnmanagedToManagedIn, typeof({|#1:MarshallerType<>|}))] + [ContiguousCollectionMarshaller] + struct MarshallerType + { + public void FromUnmanaged(int f) {} + public ManagedType ToManaged() => default; + public void Free() {} + public Span GetManagedValuesDestination(int numElements) => default; + public ReadOnlySpan GetUnmanagedValuesSource(int numElements) => default; + } + """; + + await VerifyCS.VerifyAnalyzerAsync( + source, + VerifyCS.Diagnostic(ReturnTypeMustBeExpectedTypeRule).WithLocation(0).WithArguments("MarshallerType.GetUnmanagedValuesSource(int)", "System.ReadOnlySpan"), + VerifyCS.Diagnostic(ReturnTypeMustBeExpectedTypeRule).WithLocation(1).WithArguments("MarshallerType.GetUnmanagedValuesSource(int)", "System.ReadOnlySpan")); + } + + [Fact] + public async Task CallerAllocatedBuffer_NoBufferSize_ReportsDiagnostic() + { + string source = """ + using System; + using System.Runtime.InteropServices.Marshalling; + + class ManagedType {} + + [CustomMarshaller(typeof(ManagedType), MarshalMode.ManagedToUnmanagedIn, typeof({|#0:MarshallerType<>|}))] + [ContiguousCollectionMarshaller] + struct MarshallerType + { + public void FromManaged(ManagedType m, Span buffer) {} + public nint ToUnmanaged() => default; + public void Free() {} + public ReadOnlySpan GetManagedValuesSource() => default; + public Span GetUnmanagedValuesDestination() => default; + } + """; + + await VerifyCS.VerifyAnalyzerAsync( + source, + VerifyCS.Diagnostic(CallerAllocFromManagedMustHaveBufferSizeRule).WithLocation(0).WithArguments("MarshallerType", "byte")); + } + + [Fact] + public async Task ModeThatUsesBidirectionalShape_DoesNotReportDiagnostic() + { + string source = """ + using System; + using System.Runtime.InteropServices.Marshalling; + + class ManagedType {} + + [CustomMarshaller(typeof(ManagedType), MarshalMode.ManagedToUnmanagedRef, typeof({|#0:MarshallerType<>|}))] + [CustomMarshaller(typeof(ManagedType), MarshalMode.UnmanagedToManagedRef, typeof({|#1:MarshallerType<>|}))] + [ContiguousCollectionMarshaller] + struct MarshallerType + { + public void FromManaged(ManagedType m) {} + public nint ToUnmanaged() => default; + public ReadOnlySpan GetManagedValuesSource() => default; + public Span GetUnmanagedValuesDestination() => default; + public void FromUnmanaged(nint i) {} + public ManagedType ToManaged() => default; + public Span GetManagedValuesDestination(int numElements) => default; + public ReadOnlySpan GetUnmanagedValuesSource(int numElements) => default; + public void Free() {} + } + """; + + await VerifyCS.VerifyAnalyzerAsync(source); + } + + [Fact] + public async Task ModeThatUsesBidirectionalShape_MismatchedManagedElementTypes_ReportsDiagnostic() + { + string source = """ + using System; + using System.Runtime.InteropServices.Marshalling; + + class ManagedType {} + + [CustomMarshaller(typeof(ManagedType), MarshalMode.ManagedToUnmanagedRef, typeof({|#0:MarshallerType<>|}))] + [CustomMarshaller(typeof(ManagedType), MarshalMode.UnmanagedToManagedRef, typeof({|#1:MarshallerType<>|}))] + [ContiguousCollectionMarshaller] + struct MarshallerType + { + public void FromManaged(ManagedType m) {} + public nint ToUnmanaged() => default; + public ReadOnlySpan GetManagedValuesSource() => default; + public Span GetUnmanagedValuesDestination() => default; + public void FromUnmanaged(nint i) {} + public ManagedType ToManaged() => default; + public Span GetManagedValuesDestination(int numElements) => default; + public ReadOnlySpan GetUnmanagedValuesSource(int numElements) => default; + public void Free() {} + } + """; + + await VerifyCS.VerifyAnalyzerAsync(source, + VerifyCS.Diagnostic(ElementTypesOfReturnTypesMustMatchRule).WithLocation(0).WithArguments("MarshallerType.GetManagedValuesSource()", "MarshallerType.GetManagedValuesDestination(int)"), + VerifyCS.Diagnostic(ElementTypesOfReturnTypesMustMatchRule).WithLocation(1).WithArguments("MarshallerType.GetManagedValuesSource()", "MarshallerType.GetManagedValuesDestination(int)")); + } + + [Fact] + public async Task ModeThatUsesBidirectionalShape_ArrayTarget_DoesNotReportDiagnostic() + { + string source = """ + using System; + using System.Runtime.InteropServices.Marshalling; + + [CustomMarshaller(typeof(CustomMarshallerAttribute.GenericPlaceholder[]), MarshalMode.ManagedToUnmanagedRef, typeof({|#0:MarshallerType<,>|}))] + [CustomMarshaller(typeof(CustomMarshallerAttribute.GenericPlaceholder[]), MarshalMode.UnmanagedToManagedRef, typeof({|#1:MarshallerType<,>|}))] + [ContiguousCollectionMarshaller] + struct MarshallerType + { + public void FromManaged(T[] m) {} + public nint ToUnmanaged() => default; + public ReadOnlySpan GetManagedValuesSource() => default; + public Span GetUnmanagedValuesDestination() => default; + public void FromUnmanaged(nint i) {} + public T[] ToManaged() => default; + public Span GetManagedValuesDestination(int numElements) => default; + public ReadOnlySpan GetUnmanagedValuesSource(int numElements) => default; + public void Free() {} + } + """; + + await VerifyCS.VerifyAnalyzerAsync(source); + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CustomMarshallerAttributeFixerTests_StatefulValueShapeValidation.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CustomMarshallerAttributeFixerTests_StatefulValueShapeValidation.cs new file mode 100644 index 0000000000000..f3e6710d8bf8c --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CustomMarshallerAttributeFixerTests_StatefulValueShapeValidation.cs @@ -0,0 +1,249 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Testing; +using Microsoft.Interop; +using System.Collections.Generic; +using System.Threading.Tasks; +using Xunit; +using static Microsoft.Interop.Analyzers.CustomMarshallerAttributeAnalyzer; + +using VerifyCS = LibraryImportGenerator.UnitTests.Verifiers.CSharpCodeFixVerifier< + Microsoft.Interop.Analyzers.CustomMarshallerAttributeAnalyzer, + Microsoft.Interop.Analyzers.CustomMarshallerAttributeFixer>; + +namespace LibraryImportGenerator.UnitTests +{ + [ActiveIssue("https://github.com/dotnet/runtime/issues/60650", TestRuntimes.Mono)] + public class CustomMarshallerAttributeAnalyzerTests_StatefulValueShapeValidation + { + [Fact] + public async Task ModeThatUsesManagedToUnmanagedShape_Missing_AllMethods_ReportsDiagnostic() + { + string source = """ + using System.Runtime.InteropServices.Marshalling; + + class ManagedType {} + + [CustomMarshaller(typeof(ManagedType), MarshalMode.ManagedToUnmanagedIn, typeof({|#0:MarshallerType|}))] + [CustomMarshaller(typeof(ManagedType), MarshalMode.UnmanagedToManagedOut, typeof({|#1:MarshallerType|}))] + struct MarshallerType + { + } + """; + + await VerifyCS.VerifyAnalyzerAsync( + source, + VerifyCS.Diagnostic(StatefulMarshallerRequiresFromManagedRule).WithLocation(0).WithArguments("MarshallerType", MarshalMode.ManagedToUnmanagedIn, "ManagedType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresFromManagedRule).WithLocation(1).WithArguments("MarshallerType", MarshalMode.UnmanagedToManagedOut, "ManagedType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresToUnmanagedRule).WithLocation(0).WithArguments("MarshallerType", MarshalMode.ManagedToUnmanagedIn, "ManagedType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresToUnmanagedRule).WithLocation(1).WithArguments("MarshallerType", MarshalMode.UnmanagedToManagedOut, "ManagedType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresFreeRule).WithLocation(0).WithArguments("MarshallerType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresFreeRule).WithLocation(1).WithArguments("MarshallerType")); + } + + [Fact] + public async Task ModeThatUsesUnmanagedToManagedShape_Missing_AllMethods_ReportsDiagnostic() + { + string source = """ + using System.Runtime.InteropServices.Marshalling; + + class ManagedType {} + + [CustomMarshaller(typeof(ManagedType), MarshalMode.ManagedToUnmanagedOut, typeof({|#0:MarshallerType|}))] + [CustomMarshaller(typeof(ManagedType), MarshalMode.UnmanagedToManagedIn, typeof({|#1:MarshallerType|}))] + struct MarshallerType + { + } + """; + + await VerifyCS.VerifyAnalyzerAsync( + source, + VerifyCS.Diagnostic(StatefulMarshallerRequiresFromUnmanagedRule).WithLocation(0).WithArguments("MarshallerType", MarshalMode.ManagedToUnmanagedOut, "ManagedType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresFromUnmanagedRule).WithLocation(1).WithArguments("MarshallerType", MarshalMode.UnmanagedToManagedIn, "ManagedType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresToManagedRule).WithLocation(0).WithArguments("MarshallerType", MarshalMode.ManagedToUnmanagedOut, "ManagedType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresToManagedRule).WithLocation(1).WithArguments("MarshallerType", MarshalMode.UnmanagedToManagedIn, "ManagedType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresFreeRule).WithLocation(0).WithArguments("MarshallerType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresFreeRule).WithLocation(1).WithArguments("MarshallerType")); + } + + [Fact] + public async Task Overloaded_FromUnmanaged_ReportsDiagnostic() + { + string source = """ + using System.Runtime.InteropServices.Marshalling; + + class ManagedType {} + + [CustomMarshaller(typeof(ManagedType), MarshalMode.ManagedToUnmanagedOut, typeof({|#0:MarshallerType|}))] + struct MarshallerType + { + public ManagedType ToManaged() => default; + public void FromUnmanaged(int i) {} + public void FromUnmanaged(float f) {} + public void Free() {} + } + """; + + await VerifyCS.VerifyAnalyzerAsync( + source, + VerifyCS.Diagnostic(FromUnmanagedOverloadsNotSupportedRule).WithLocation(0).WithArguments("MarshallerType")); + } + + [Fact] + public async Task ModeThatUsesBidirectionalShape_Missing_AllMethods_ReportsDiagnostic() + { + string source = """ + using System.Runtime.InteropServices.Marshalling; + + class ManagedType {} + + [CustomMarshaller(typeof(ManagedType), MarshalMode.ManagedToUnmanagedRef, typeof({|#0:MarshallerType|}))] + [CustomMarshaller(typeof(ManagedType), MarshalMode.UnmanagedToManagedRef, typeof({|#1:MarshallerType|}))] + struct MarshallerType + { + } + """; + + await VerifyCS.VerifyAnalyzerAsync( + source, + VerifyCS.Diagnostic(StatefulMarshallerRequiresFreeRule).WithLocation(0).WithArguments("MarshallerType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresFromManagedRule).WithLocation(0).WithArguments("MarshallerType", MarshalMode.ManagedToUnmanagedRef, "ManagedType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresFromManagedRule).WithLocation(1).WithArguments("MarshallerType", MarshalMode.UnmanagedToManagedRef, "ManagedType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresToUnmanagedRule).WithLocation(0).WithArguments("MarshallerType", MarshalMode.ManagedToUnmanagedRef, "ManagedType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresToUnmanagedRule).WithLocation(1).WithArguments("MarshallerType", MarshalMode.UnmanagedToManagedRef, "ManagedType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresFromUnmanagedRule).WithLocation(0).WithArguments("MarshallerType", MarshalMode.ManagedToUnmanagedRef, "ManagedType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresFromUnmanagedRule).WithLocation(1).WithArguments("MarshallerType", MarshalMode.UnmanagedToManagedRef, "ManagedType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresToManagedRule).WithLocation(0).WithArguments("MarshallerType", MarshalMode.ManagedToUnmanagedRef, "ManagedType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresToManagedRule).WithLocation(1).WithArguments("MarshallerType", MarshalMode.UnmanagedToManagedRef, "ManagedType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresFreeRule).WithLocation(1).WithArguments("MarshallerType")); + } + + [Fact] + public async Task ModeThatUsesBidirectionalShape_MismatchedUnmanagedTypes_ReportsDiagnostic() + { + string source = """ + using System.Runtime.InteropServices.Marshalling; + + class ManagedType {} + + [CustomMarshaller(typeof(ManagedType), MarshalMode.ManagedToUnmanagedRef, typeof({|#0:MarshallerType|}))] + [CustomMarshaller(typeof(ManagedType), MarshalMode.UnmanagedToManagedRef, typeof({|#1:MarshallerType|}))] + struct MarshallerType + { + public void FromManaged(ManagedType t) {} + public int ToUnmanaged() => default; + public void FromUnmanaged(float f) {} + public ManagedType ToManaged() => default; + public void Free() {} + } + """; + + await VerifyCS.VerifyAnalyzerAsync( + source, + VerifyCS.Diagnostic(FirstParameterMustMatchReturnTypeRule).WithLocation(0).WithArguments("MarshallerType.FromUnmanaged(float)", "MarshallerType.ToUnmanaged()"), + VerifyCS.Diagnostic(FirstParameterMustMatchReturnTypeRule).WithLocation(1).WithArguments("MarshallerType.FromUnmanaged(float)", "MarshallerType.ToUnmanaged()")); + } + + [Fact] + public async Task ModeThatUsesBidirectionalShape_DoesNotReportDiagnostic() + { + string source = """ + using System.Runtime.InteropServices.Marshalling; + + class ManagedType {} + + [CustomMarshaller(typeof(ManagedType), MarshalMode.ManagedToUnmanagedRef, typeof(MarshallerType))] + [CustomMarshaller(typeof(ManagedType), MarshalMode.UnmanagedToManagedRef, typeof(MarshallerType))] + struct MarshallerType + { + public void FromManaged(ManagedType t) {} + public int ToUnmanaged() => default; + public void FromUnmanaged(int f) {} + public ManagedType ToManaged() => default; + public void Free() {} + } + """; + + await VerifyCS.VerifyAnalyzerAsync( + source); + } + + [Fact] + public async Task ModeThatUsesElementMode_ReportsDiagnostic() + { + string source = """ + using System.Runtime.InteropServices.Marshalling; + + class ManagedType {} + + [CustomMarshaller(typeof(ManagedType), MarshalMode.ElementIn, typeof({|#0:MarshallerType|}))] + [CustomMarshaller(typeof(ManagedType), MarshalMode.ElementRef, typeof({|#1:MarshallerType|}))] + [CustomMarshaller(typeof(ManagedType), MarshalMode.ElementOut, typeof({|#2:MarshallerType|}))] + struct MarshallerType + { + public void FromManaged(ManagedType t) {} + public int ToUnmanaged() => default; + public void FromUnmanaged(int f) {} + public ManagedType ToManaged() => default; + public void Free() {} + } + """; + + await VerifyCS.VerifyAnalyzerAsync( + source, + VerifyCS.Diagnostic(ElementMarshallerCannotBeStatefulRule).WithLocation(0).WithArguments("MarshallerType", MarshalMode.ElementIn), + VerifyCS.Diagnostic(ElementMarshallerCannotBeStatefulRule).WithLocation(1).WithArguments("MarshallerType", MarshalMode.ElementRef), + VerifyCS.Diagnostic(ElementMarshallerCannotBeStatefulRule).WithLocation(2).WithArguments("MarshallerType", MarshalMode.ElementOut)); + } + + [Fact] + public async Task DefaultMode_Missing_AllMethods_ReportsDiagnostic() + { + string source = """ + using System.Runtime.InteropServices.Marshalling; + + class ManagedType {} + + [CustomMarshaller(typeof(ManagedType), MarshalMode.Default, typeof({|#0:MarshallerType|}))] + struct MarshallerType + { + } + """; + + await VerifyCS.VerifyAnalyzerAsync( + source, + VerifyCS.Diagnostic(StatefulMarshallerRequiresFreeRule).WithLocation(0).WithArguments("MarshallerType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresFromManagedRule).WithSeverity(DiagnosticSeverity.Info).WithLocation(0).WithArguments("MarshallerType", MarshalMode.Default, "ManagedType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresToUnmanagedRule).WithSeverity(DiagnosticSeverity.Info).WithLocation(0).WithArguments("MarshallerType", MarshalMode.Default, "ManagedType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresFromUnmanagedRule).WithSeverity(DiagnosticSeverity.Info).WithLocation(0).WithArguments("MarshallerType", MarshalMode.Default, "ManagedType"), + VerifyCS.Diagnostic(StatefulMarshallerRequiresToManagedRule).WithSeverity(DiagnosticSeverity.Info).WithLocation(0).WithArguments("MarshallerType", MarshalMode.Default, "ManagedType")); + } + + [Fact] + public async Task CallerAllocatedBuffer_NoBufferSize_ReportsDiagnostic() + { + string source = """ + using System; + using System.Runtime.InteropServices.Marshalling; + + class ManagedType {} + + [CustomMarshaller(typeof(ManagedType), MarshalMode.ManagedToUnmanagedIn, typeof({|#0:MarshallerType|}))] + struct MarshallerType + { + public void FromManaged(ManagedType m, Span b) {} + + public int ToUnmanaged() => default; + + public void Free() {} + } + """; + + await VerifyCS.VerifyAnalyzerAsync( + source, + VerifyCS.Diagnostic(CallerAllocFromManagedMustHaveBufferSizeRule).WithLocation(0).WithArguments("MarshallerType", "byte")); + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CustomMarshallerAttributeFixerTests_StatelessLinearCollectionShapeValidation.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CustomMarshallerAttributeFixerTests_StatelessLinearCollectionShapeValidation.cs index 1442074e660f8..502a9781d982c 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CustomMarshallerAttributeFixerTests_StatelessLinearCollectionShapeValidation.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CustomMarshallerAttributeFixerTests_StatelessLinearCollectionShapeValidation.cs @@ -432,7 +432,7 @@ static class MarshallerType await VerifyCS.VerifyAnalyzerAsync( source, - VerifyCS.Diagnostic(StatelessLinearCollectionCallerAllocConstructorMustHaveBufferSizeRule).WithLocation(0).WithArguments("MarshallerType", "byte")); + VerifyCS.Diagnostic(StatelessLinearCollectionCallerAllocFromManagedMustHaveBufferSizeRule).WithLocation(0).WithArguments("MarshallerType", "byte")); } [Fact] diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CustomMarshallerAttributeFixerTests_StatelessValueShapeValidation.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CustomMarshallerAttributeFixerTests_StatelessValueShapeValidation.cs index 69c18264fbb6f..095fc0dafbba3 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CustomMarshallerAttributeFixerTests_StatelessValueShapeValidation.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CustomMarshallerAttributeFixerTests_StatelessValueShapeValidation.cs @@ -153,7 +153,7 @@ static class MarshallerType await VerifyCS.VerifyAnalyzerAsync( source, - VerifyCS.Diagnostic(CallerAllocConstructorMustHaveBufferSizeRule).WithLocation(0).WithArguments("MarshallerType", "byte")); + VerifyCS.Diagnostic(CallerAllocFromManagedMustHaveBufferSizeRule).WithLocation(0).WithArguments("MarshallerType", "byte")); } } } From 260d1223f0c41f03d57b0424b14bef089221db0d Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 28 Jul 2022 11:09:31 -0700 Subject: [PATCH 2/3] Update resources to be consistent --- .../Resources/Strings.resx | 8 ++++---- .../Resources/xlf/Strings.cs.xlf | 16 ++++++++-------- .../Resources/xlf/Strings.de.xlf | 16 ++++++++-------- .../Resources/xlf/Strings.es.xlf | 16 ++++++++-------- .../Resources/xlf/Strings.fr.xlf | 16 ++++++++-------- .../Resources/xlf/Strings.it.xlf | 16 ++++++++-------- .../Resources/xlf/Strings.ja.xlf | 16 ++++++++-------- .../Resources/xlf/Strings.ko.xlf | 16 ++++++++-------- .../Resources/xlf/Strings.pl.xlf | 16 ++++++++-------- .../Resources/xlf/Strings.pt-BR.xlf | 16 ++++++++-------- .../Resources/xlf/Strings.ru.xlf | 16 ++++++++-------- .../Resources/xlf/Strings.tr.xlf | 16 ++++++++-------- .../Resources/xlf/Strings.zh-Hans.xlf | 16 ++++++++-------- .../Resources/xlf/Strings.zh-Hant.xlf | 16 ++++++++-------- 14 files changed, 108 insertions(+), 108 deletions(-) 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 52f8231668374..ef28d3111831c 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/Strings.resx +++ b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/Strings.resx @@ -463,25 +463,25 @@ LibraryImportAttribute requires unsafe code. - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromManaged' that takes a '{2}' as a parameter and returns 'void' - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromUnmanaged' that takes the 'unmanaged' value as a parameter and returns 'void' - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' 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 d29eed9d161a8..a33a12aaa4810 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 @@ -398,8 +398,8 @@ - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. @@ -408,8 +408,8 @@ - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. @@ -418,8 +418,8 @@ - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. @@ -428,8 +428,8 @@ - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. 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 5b662d16f54e2..e1305d3bac4a7 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 @@ -398,8 +398,8 @@ - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. @@ -408,8 +408,8 @@ - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. @@ -418,8 +418,8 @@ - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. @@ -428,8 +428,8 @@ - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. 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 c7130822d2888..7b22b5d79d340 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 @@ -398,8 +398,8 @@ - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. @@ -408,8 +408,8 @@ - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. @@ -418,8 +418,8 @@ - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. @@ -428,8 +428,8 @@ - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. 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 ad5075ea73073..e6dbc451c8bdd 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 @@ -398,8 +398,8 @@ - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. @@ -408,8 +408,8 @@ - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. @@ -418,8 +418,8 @@ - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. @@ -428,8 +428,8 @@ - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. 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 d063774a00872..b81757e569a84 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 @@ -398,8 +398,8 @@ - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. @@ -408,8 +408,8 @@ - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. @@ -418,8 +418,8 @@ - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. @@ -428,8 +428,8 @@ - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. 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 d57b1ac7c3b10..ab1e1593571f3 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 @@ -398,8 +398,8 @@ - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. @@ -408,8 +408,8 @@ - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. @@ -418,8 +418,8 @@ - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. @@ -428,8 +428,8 @@ - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. 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 4db25633e65c3..3133deb27e2ca 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 @@ -398,8 +398,8 @@ - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. @@ -408,8 +408,8 @@ - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. @@ -418,8 +418,8 @@ - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. @@ -428,8 +428,8 @@ - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. 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 a5227e11b534e..aa29d007e5cf3 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 @@ -398,8 +398,8 @@ - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. @@ -408,8 +408,8 @@ - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. @@ -418,8 +418,8 @@ - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. @@ -428,8 +428,8 @@ - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. 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 9e22028ca4326..0b31a95c51fe1 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 @@ -398,8 +398,8 @@ - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. @@ -408,8 +408,8 @@ - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. @@ -418,8 +418,8 @@ - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. @@ -428,8 +428,8 @@ - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. 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 7dfc725b49d52..cd26475a2eb06 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 @@ -398,8 +398,8 @@ - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. @@ -408,8 +408,8 @@ - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. @@ -418,8 +418,8 @@ - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. @@ -428,8 +428,8 @@ - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. 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 42eccea1f7a9e..8c0a63400f6c5 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 @@ -398,8 +398,8 @@ - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. @@ -408,8 +408,8 @@ - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. @@ -418,8 +418,8 @@ - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. @@ -428,8 +428,8 @@ - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. 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 cb5cde89b2a8e..5cc25c8a2cbc0 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 @@ -398,8 +398,8 @@ - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. @@ -408,8 +408,8 @@ - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. @@ -418,8 +418,8 @@ - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. @@ -428,8 +428,8 @@ - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. 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 4ab7887126eda..c70b714f13181 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 @@ -398,8 +398,8 @@ - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'. @@ -408,8 +408,8 @@ - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. @@ -418,8 +418,8 @@ - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. - A stateful marshaller that supports a unmanaged-to-managed marshal mode must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. + A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. @@ -428,8 +428,8 @@ - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. - A stateful marshaller that supports a managed-to-unmanaged marshal mode must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. + A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. From 4241d410c39b1aa00abd2291ecfc776ea8b7a917 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 28 Jul 2022 13:48:38 -0700 Subject: [PATCH 3/3] PR feedback and fix test build --- .../CustomMarshallerAttributeAnalyzer.cs | 9 +- .../Resources/Strings.resx | 4 +- .../Resources/xlf/Strings.cs.xlf | 8 +- .../Resources/xlf/Strings.de.xlf | 8 +- .../Resources/xlf/Strings.es.xlf | 8 +- .../Resources/xlf/Strings.fr.xlf | 8 +- .../Resources/xlf/Strings.it.xlf | 8 +- .../Resources/xlf/Strings.ja.xlf | 8 +- .../Resources/xlf/Strings.ko.xlf | 8 +- .../Resources/xlf/Strings.pl.xlf | 8 +- .../Resources/xlf/Strings.pt-BR.xlf | 8 +- .../Resources/xlf/Strings.ru.xlf | 8 +- .../Resources/xlf/Strings.tr.xlf | 8 +- .../Resources/xlf/Strings.zh-Hans.xlf | 8 +- .../Resources/xlf/Strings.zh-Hant.xlf | 8 +- .../CollectionTests.cs | 1 + .../CustomMarshallingTests.cs | 2 + ...ixerTests_StatelessValueShapeValidation.cs | 143 ++++++++++++++++++ 18 files changed, 205 insertions(+), 58 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Analyzers/CustomMarshallerAttributeAnalyzer.cs b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Analyzers/CustomMarshallerAttributeAnalyzer.cs index c18635b4b6fe9..9603ec32cbc2c 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Analyzers/CustomMarshallerAttributeAnalyzer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Analyzers/CustomMarshallerAttributeAnalyzer.cs @@ -1187,18 +1187,19 @@ void ReportDiagnosticsForMismatchedMemberSignatures(DiagnosticReporter diagnosti if (ManualTypeMarshallingHelper.ModeUsesUnmanagedToManagedShape(mode)) { // Verify the unmanaged types match unmanaged->managed shape - if (unmanagedType is not null && !SymbolEqualityComparer.Default.Equals(unmanagedType, fromUnmanagedCandidates[0].Parameters[0].Type)) + IMethodSymbol fromUnmanagedMethod = fromUnmanagedCandidates[0]; + if (unmanagedType is not null && !SymbolEqualityComparer.Default.Equals(unmanagedType, fromUnmanagedMethod.Parameters[0].Type)) { // If both shapes are present, verify that the unmanaged types match - diagnosticReporter.CreateAndReportDiagnostic(FirstParameterMustMatchReturnTypeRule, fromUnmanagedCandidates[0].ToDisplayString(), methods.ToUnmanaged.ToDisplayString()); + diagnosticReporter.CreateAndReportDiagnostic(FirstParameterMustMatchReturnTypeRule, fromUnmanagedMethod.ToDisplayString(), methods.ToUnmanaged.ToDisplayString()); } else { - unmanagedType = fromUnmanagedCandidates[0].Parameters[0].Type; + unmanagedType = fromUnmanagedMethod.Parameters[0].Type; if (!unmanagedType.IsUnmanagedType && !unmanagedType.IsStrictlyBlittable()) { - diagnosticReporter.CreateAndReportDiagnostic(UnmanagedTypeMustBeUnmanagedRule, fromUnmanagedCandidates[0].ToDisplayString()); + diagnosticReporter.CreateAndReportDiagnostic(UnmanagedTypeMustBeUnmanagedRule, fromUnmanagedMethod.ToDisplayString()); } } } 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 ef28d3111831c..7d5ea2eeda3a0 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/Strings.resx +++ b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Resources/Strings.resx @@ -472,7 +472,7 @@ A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type. - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' that returns the 'unmanaged' type for the marshaller A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'. @@ -484,7 +484,7 @@ A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'ToManaged' instance method that takes no parameters and returns the managed type. - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' that returns '{2}' A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'. 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 e60788747612d..66842b053ca17 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 @@ -423,8 +423,8 @@ - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' that returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' that returns '{2}' @@ -433,8 +433,8 @@ - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' that returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' that returns the 'unmanaged' type for the marshaller 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 15139de59cc37..b786f3e1f3e5a 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 @@ -423,8 +423,8 @@ - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' that returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' that returns '{2}' @@ -433,8 +433,8 @@ - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' that returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' that returns the 'unmanaged' type for the marshaller 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 e2a786a4429a7..ab690083f9c99 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 @@ -423,8 +423,8 @@ - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' that returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' that returns '{2}' @@ -433,8 +433,8 @@ - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' that returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' that returns the 'unmanaged' type for the marshaller 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 34167f87d1a78..11e2b49ee4bce 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 @@ -423,8 +423,8 @@ - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' that returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' that returns '{2}' @@ -433,8 +433,8 @@ - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' that returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' that returns the 'unmanaged' type for the marshaller 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 06e11945b9d4a..de0a10834b104 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 @@ -423,8 +423,8 @@ - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' that returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' that returns '{2}' @@ -433,8 +433,8 @@ - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' that returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' that returns the 'unmanaged' type for the marshaller 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 4e5fee985e316..f604a6749b55f 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 @@ -423,8 +423,8 @@ - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' that returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' that returns '{2}' @@ -433,8 +433,8 @@ - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' that returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' that returns the 'unmanaged' type for the marshaller 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 bf247f393c4d5..4fa058790e9cc 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 @@ -423,8 +423,8 @@ - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' that returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' that returns '{2}' @@ -433,8 +433,8 @@ - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' that returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' that returns the 'unmanaged' type for the marshaller 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 2d574b4b88a8f..bf9a67b487f4a 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 @@ -423,8 +423,8 @@ - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' that returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' that returns '{2}' @@ -433,8 +433,8 @@ - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' that returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' that returns the 'unmanaged' type for the marshaller 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 93d86af09f4c7..c185aa75f393b 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 @@ -423,8 +423,8 @@ - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' that returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' that returns '{2}' @@ -433,8 +433,8 @@ - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' that returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' that returns the 'unmanaged' type for the marshaller 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 fdb2e357091d0..f08f2c0d68ea2 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 @@ -423,8 +423,8 @@ - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' that returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' that returns '{2}' @@ -433,8 +433,8 @@ - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' that returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' that returns the 'unmanaged' type for the marshaller 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 77c96be415f25..aa25c990d07db 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 @@ -423,8 +423,8 @@ - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' that returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' that returns '{2}' @@ -433,8 +433,8 @@ - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' that returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' that returns the 'unmanaged' type for the marshaller 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 4aca8125b921b..1af45dc43e241 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 @@ -423,8 +423,8 @@ - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' that returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' that returns '{2}' @@ -433,8 +433,8 @@ - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' that returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' that returns the 'unmanaged' type for the marshaller 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 40ecd4a492d8b..e36f25dcd957c 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 @@ -423,8 +423,8 @@ - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' that returns '{2}' + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' that returns '{2}' @@ -433,8 +433,8 @@ - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller - The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' that returns the 'unmanaged' type for the marshaller + The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' that returns the 'unmanaged' type for the marshaller diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/CollectionTests.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/CollectionTests.cs index a991f6bea6940..48d592735280c 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/CollectionTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/CollectionTests.cs @@ -165,6 +165,7 @@ public List ToManagedFinally() public Span GetManagedValuesDestination(int length) => default; public ReadOnlySpan GetUnmanagedValuesSource(int length) => default; public void FromUnmanaged(byte* value) { } + public void Free() {} } } } diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/CustomMarshallingTests.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/CustomMarshallingTests.cs index 791f6d651d4eb..4608a11b6a2d3 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/CustomMarshallingTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.Tests/CustomMarshallingTests.cs @@ -102,6 +102,8 @@ public int ToManagedFinally() } public void FromUnmanaged(int value) { } + + public void Free() {} } } } diff --git a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CustomMarshallerAttributeFixerTests_StatelessValueShapeValidation.cs b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CustomMarshallerAttributeFixerTests_StatelessValueShapeValidation.cs index 19fe26029bf4a..dbfe4d8d2e9e9 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CustomMarshallerAttributeFixerTests_StatelessValueShapeValidation.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/CustomMarshallerAttributeFixerTests_StatelessValueShapeValidation.cs @@ -378,5 +378,148 @@ await VerifyCS.VerifyCodeFixAsync( fixedSource, VerifyCS.Diagnostic(CallerAllocFromManagedMustHaveBufferSizeRule).WithLocation(0).WithArguments("MarshallerType", "byte")); } + + [Fact] + public async Task ModeThatUsesManagedToUnmanagedShape_Missing_ConvertToUnmanagedMethod_Marshaller_DifferentDocument_ReportsDiagnostic() + { + string entryPointTypeSource = """ + using System.Runtime.InteropServices.Marshalling; + + class ManagedType {} + + [CustomMarshaller(typeof(ManagedType), MarshalMode.ManagedToUnmanagedIn, typeof({|SYSLIB1057:OtherMarshallerType|}))] + [CustomMarshaller(typeof(ManagedType), MarshalMode.UnmanagedToManagedOut, typeof({|SYSLIB1057:OtherMarshallerType|}))] + [CustomMarshaller(typeof(ManagedType), MarshalMode.ElementIn, typeof({|SYSLIB1057:OtherMarshallerType|}))] + static class MarshallerType + { + } + """; + + string otherMarshallerTypeOriginalSource = """ + static class OtherMarshallerType + { + } + """; + + string otherMarshallerTypeFixedSource = """ + static class OtherMarshallerType + { + public static nint ConvertToUnmanaged(ManagedType managed) + { + throw new System.NotImplementedException(); + } + } + """; + + var test = new VerifyCS.Test(); + test.TestState.Sources.Add(entryPointTypeSource); + test.TestState.Sources.Add(("OtherMarshaller.cs", otherMarshallerTypeOriginalSource)); + test.FixedState.Sources.Add(entryPointTypeSource); + test.FixedState.Sources.Add(("OtherMarshaller.cs", otherMarshallerTypeFixedSource)); + test.MarkupOptions = MarkupOptions.UseFirstDescriptor; + test.FixedState.MarkupHandling = MarkupMode.IgnoreFixable; + await test.RunAsync(); + } + + [Fact] + [ActiveIssue("https://github.com/dotnet/roslyn-sdk/issues/1000")] + public async Task ModeThatUsesManagedToUnmanagedShape_Missing_ConvertToUnmanagedMethod_Marshaller_DifferentProject_ReportsDiagnostic() + { + string entryPointTypeSource = """ + using System.Runtime.InteropServices.Marshalling; + + class ManagedType {} + + [CustomMarshaller(typeof(ManagedType), MarshalMode.ManagedToUnmanagedIn, typeof({|SYSLIB1057:OtherMarshallerType|}))] + [CustomMarshaller(typeof(ManagedType), MarshalMode.UnmanagedToManagedOut, typeof({|SYSLIB1057:OtherMarshallerType|}))] + [CustomMarshaller(typeof(ManagedType), MarshalMode.ElementIn, typeof({|SYSLIB1057:OtherMarshallerType|}))] + static class MarshallerType + { + } + """; + + string otherMarshallerTypeOriginalSource = """ + public static class OtherMarshallerType + { + } + """; + + string otherMarshallerTypeFixedSource = """ + public static class OtherMarshallerType + { + public static nint ConvertToUnmanaged(ManagedType managed) + { + throw new System.NotImplementedException(); + } + } + """; + + var test = new VerifyCS.Test(); + + string otherProjectName = "OtherMarshallerProject"; + ProjectState otherProjectOriginalState = new ProjectState(otherProjectName, LanguageNames.CSharp, "/1/Other", "cs"); + otherProjectOriginalState.Sources.Add(otherMarshallerTypeOriginalSource); + otherProjectOriginalState.AdditionalReferences.AddRange(test.TestState.AdditionalReferences); + + ProjectState otherProjectFixedState = new ProjectState(otherProjectName, LanguageNames.CSharp, "/1/Other", "cs"); + otherProjectFixedState.Sources.Add(otherMarshallerTypeFixedSource); + otherProjectFixedState.AdditionalReferences.AddRange(test.TestState.AdditionalReferences); + + test.TestState.Sources.Add(entryPointTypeSource); + test.TestState.AdditionalProjects.Add(otherProjectName, otherProjectOriginalState); + test.TestState.AdditionalProjectReferences.Add(otherProjectName); + + test.FixedState.Sources.Add(entryPointTypeSource); + test.FixedState.AdditionalProjects.Add(otherProjectName, otherProjectFixedState); + test.FixedState.AdditionalProjectReferences.Add(otherProjectName); + test.MarkupOptions = MarkupOptions.UseFirstDescriptor; + test.FixedState.MarkupHandling = MarkupMode.IgnoreFixable; + await test.RunAsync(); + } + + [Fact] + public async Task ModeThatUsesManagedToUnmanagedShape_Missing_ConvertToUnmanagedMethod_TwoManagedTypes_ReportsDiagnostic() + { + string source = """ + using System.Runtime.InteropServices.Marshalling; + + class ManagedType {} + class ManagedType2 {} + + [CustomMarshaller(typeof(ManagedType), MarshalMode.ManagedToUnmanagedIn, typeof({|#0:MarshallerType|}))] + [CustomMarshaller(typeof(ManagedType2), MarshalMode.ManagedToUnmanagedIn, typeof({|#1:MarshallerType|}))] + static class MarshallerType + { + } + """; + + string fixedSource = """ + using System.Runtime.InteropServices.Marshalling; + + class ManagedType {} + class ManagedType2 {} + + [CustomMarshaller(typeof(ManagedType), MarshalMode.ManagedToUnmanagedIn, typeof(MarshallerType))] + [CustomMarshaller(typeof(ManagedType2), MarshalMode.ManagedToUnmanagedIn, typeof(MarshallerType))] + static class MarshallerType + { + public static nint ConvertToUnmanaged(ManagedType managed) + { + throw new System.NotImplementedException(); + } + + public static nint ConvertToUnmanaged(ManagedType2 managed) + { + throw new System.NotImplementedException(); + } + } + """; + + await VerifyCS.VerifyCodeFixAsync( + source, + fixedSource, + VerifyCS.Diagnostic(StatelessValueInRequiresConvertToUnmanagedRule).WithLocation(0).WithArguments("MarshallerType", MarshalMode.ManagedToUnmanagedIn, "ManagedType"), + VerifyCS.Diagnostic(StatelessValueInRequiresConvertToUnmanagedRule).WithLocation(1).WithArguments("MarshallerType", MarshalMode.ManagedToUnmanagedIn, "ManagedType2")); + } } }