Publicizing overridden methods causing ambiguity errors in Rider
Publicizing an assembly which contain private methods that are overrides from a base class/interface causes ambiguity errors in certain IDE's (Rider in my case).
I remember fixing this using a custom assembly publicizer a while back by not publicizing the overridden method, and it looked something like this:
foreach (var method in type.Methods)
{
// Detect whether or not this method is present multiple times (as an override)
// This will only publicize the method defined by the type, and keeps the overridden method as-is
if (!method.HasOverrides ||
type.Methods.Count(m =>
m.Name.ToString() == method.Name.ToString().Split(".").Last() ||
m.Name.ToString() == method.Name.ToString()) == 1)
{
// Make method public
method.Access |= MethodAttributes.Public;
method.Access &= ~MethodAttributes.Private;
}
// Clear method instructions and exception handlers
method.Body?.ExceptionHandlers?.Clear();
method.Body?.Instructions?.Clear();
}
This however used dnlib and I have since decided to switch over to BepInEx.AssemblyPublicizer due to it being much more feature-complete
An example assembly that will generate ambiguity errors is Unity's Animation Rigging package, where the constraint data property becomes ambiguous.
Note: The assembly still compiles, and not every IDE will show the errors, however some others do and it generates a bunch of benign errors which impact DX.
I can reproduce this with explicit interface implementations, but can you provide any repro code for when it happens with just overriding base class methods?