Skip to content

Commit cf3bf7a

Browse files
authored
Update the CustomMarshallerAttributeFixer to support adding missing methods for stateless marshaller shapes (#72869)
1 parent ad58ce5 commit cf3bf7a

4 files changed

Lines changed: 946 additions & 72 deletions

File tree

src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Analyzers/CustomMarshallerAttributeAnalyzer.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ internal static DiagnosticDescriptor GetDefaultMarshalModeDiagnostic(DiagnosticD
424424
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics =>
425425
ImmutableArray.Create(
426426
MarshallerTypeMustSpecifyManagedTypeRule,
427+
MarshallerTypeMustBeStaticClassOrStructRule,
427428
UnmanagedTypeMustBeUnmanagedRule,
428429
GetPinnableReferenceReturnTypeBlittableRule,
429430
TypeMustHaveExplicitCastFromVoidPointerRule,
@@ -653,7 +654,7 @@ void ReportDiagnosticsForMissingMembers(DiagnosticReporter diagnosticReporter)
653654
if (isLinearCollectionMarshaller)
654655
{
655656
// Verify that all of the following methods are present with valid shapes:
656-
// - AllocateContainerForUnmanagedElements
657+
// - AllocateContainerForManagedElements
657658
// - GetUnmanagedValuesSource
658659
// - GetManagedValuesDestination
659660
if (methods.ToManaged is null && methods.ToManagedFinally is null)
@@ -662,7 +663,7 @@ void ReportDiagnosticsForMissingMembers(DiagnosticReporter diagnosticReporter)
662663
StatelessLinearCollectionRequiresTwoParameterAllocateContainerForManagedElementsRule,
663664
MissingMemberNames.CreateDiagnosticPropertiesForMissingMembersDiagnostic(
664665
mode,
665-
ShapeMemberNames.LinearCollection.Stateless.AllocateContainerForUnmanagedElements),
666+
ShapeMemberNames.LinearCollection.Stateless.AllocateContainerForManagedElements),
666667
marshallerType.ToDisplayString(),
667668
mode,
668669
managedType.ToDisplayString());

0 commit comments

Comments
 (0)