CsWinRT icon indicating copy to clipboard operation
CsWinRT copied to clipboard

Unnecessary GuidGenerator calls for custom delegates in authored types

Open Sergio0694 opened this issue 1 year ago • 2 comments

Describe the bug

We're emitting some GuidGenerator calls when using custom delegates in authored components:

image

Pretty sure we could just literally hardcoded that same GUID we added on the ABI type for the delegate instead?

To Reproduce

public sealed unsafe partial class HelloWorldEffect
{
    public event MyEventHandler Foo;
}

public delegate void MyEventHandler(object sender, string args);

Expected behavior

We should probably emit that IID in a static readonly field, and then reference it wherever needed.

Version Info

2.0.5-prerelease.240203.7

Sergio0694 avatar Feb 04 '24 23:02 Sergio0694

This is probably getting optimized by IIDOptimizer today, but I agree we can move this to a readonly static field.

manodasanW avatar Feb 05 '24 17:02 manodasanW

If that's the case I think we should probably also fix #1478? Because otherwise IIDOptimizer will break in libraries, and if you just opt-out, then that path will not be optimized by it. I mean I agree here we can just update the code writer, but this just makes me think that in general, the IIDOptimizer should also run on authored libraries then? 🤔

Sergio0694 avatar Feb 05 '24 18:02 Sergio0694