Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fall back to the forwarder generator for invalid [In, Out] attributes instead of using the already-selected generator with additional diagnostics #88055

Merged
merged 1 commit into from
Jun 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace Microsoft.Interop
/// </summary>
public class ByValueContentsMarshalKindValidator : IMarshallingGeneratorFactory
{
private static readonly Forwarder s_forwarder = new();

private readonly IMarshallingGeneratorFactory _inner;

public ByValueContentsMarshalKindValidator(IMarshallingGeneratorFactory inner)
Expand All @@ -35,34 +37,25 @@ private static ResolvedGenerator ValidateByValueMarshalKind(TypePositionInfo inf

if (info.IsByRef && info.ByValueContentsMarshalKind != ByValueContentsMarshalKind.Default)
{
return generator with
return ResolvedGenerator.ResolvedWithDiagnostics(s_forwarder, generator.Diagnostics.Add(new GeneratorDiagnostic.NotSupported(info, context)
AaronRobinsonMSFT marked this conversation as resolved.
Show resolved Hide resolved
{
Diagnostics = generator.Diagnostics.Add(new GeneratorDiagnostic.NotSupported(info, context)
{
NotSupportedDetails = SR.InOutAttributeByRefNotSupported
})
};
NotSupportedDetails = SR.InOutAttributeByRefNotSupported
}));
}
else if (info.ByValueContentsMarshalKind == ByValueContentsMarshalKind.In)
{
return generator with
return ResolvedGenerator.ResolvedWithDiagnostics(s_forwarder, generator.Diagnostics.Add(new GeneratorDiagnostic.NotSupported(info, context)
{
Diagnostics = generator.Diagnostics.Add(new GeneratorDiagnostic.NotSupported(info, context)
{
NotSupportedDetails = SR.InAttributeNotSupportedWithoutOut
})
};
NotSupportedDetails = SR.InAttributeNotSupportedWithoutOut
}));
}
else if (info.ByValueContentsMarshalKind != ByValueContentsMarshalKind.Default
&& !generator.Generator.SupportsByValueMarshalKind(info.ByValueContentsMarshalKind, context))
{
return generator with
return ResolvedGenerator.ResolvedWithDiagnostics(s_forwarder, generator.Diagnostics.Add(new GeneratorDiagnostic.NotSupported(info, context)
{
Diagnostics = generator.Diagnostics.Add(new GeneratorDiagnostic.NotSupported(info, context)
{
NotSupportedDetails = SR.InOutAttributeMarshalerNotSupported
})
};
NotSupportedDetails = SR.InOutAttributeMarshalerNotSupported
}));
}
return generator;
}
Expand Down