-
Notifications
You must be signed in to change notification settings - Fork 5k
[GeneratedComInterface] in CCW-only mode produces CA2256 warning #90922
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
Comments
Tagging subscribers to this area: @dotnet/interop-contrib Issue DetailsDescriptionWhen using Reproduction Steps[Guid("7448E99B-0904-4B6A-9CC2-51DD9A71032A")]
[GeneratedComInterface(Options = ComInterfaceOptions.ManagedObjectWrapper)]
public partial interface IFoo
{
void Foo();
} Expected behaviorNo build warnings or errors. Actual behavior
Regression?No, it's a new feature. Configuration
|
It's been almost a year, and this issue is still present in latest releases. What's the status? Can someone who actually understands the generated code and attribute explain if this is at least safe to ignore? |
So, I found a workaround at least, for anyone else seeing this. In a using System.Diagnostics.CodeAnalysis;
// Until https://github.com/dotnet/runtime/issues/90922 is resolved, this is the only way
// to suppress the warning in the generated code. The analyzer is ignoring that it is
// generated, and partial (where the declarations live in a different partial class
// [in the same "file"])
[assembly: SuppressMessage(
"Usage",
"CA2256:All members declared in parent interfaces must have an implementation in a DynamicInterfaceCastableImplementation-attributed interface",
Justification = "Generated Code and analyzer ignores that it is generated AND partial",
Scope = "type",
Target = "~T:InterfaceImplementation")
] Since the generated code uses the |
@jkoritzinsky adding this to #114179 since we're now hitting this in CsWinRT as well. Not a blocker though, just tracking it 🙂 |
Uh oh!
There was an error while loading. Please reload this page.
Description
When using
[GeneratedComInterface]
withComInterfaceOptions.ManagedObjectWrapper
, the generator emits an empty interface declaration with[DynamicInterfaceCastableImplementation]
, which then produces a warning:Reproduction Steps
Expected behavior
No build warnings or errors.
Actual behavior
Regression?
No, it's a new feature.
Configuration
The text was updated successfully, but these errors were encountered: