You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enable derived COM interfaces to hide base methods with the new keyword (dotnet#101577)
When a COM interface method is defined with the new keyword, we should avoid creating a new shadowing method on the derived interface, and remove the new keyword when creating implementations of methods. This change tracks whether a method was declared with the new keyword. If it was, we search all the inherited methods for one with the same name and signature. If found, we mark that method as "HiddenOnDerivedInterface". The hidden method may not be found if the method hides a non-COM method. When generating methods, we only generate new shadowing method declarations for inherited methods that aren't already hidden, and we don't generate any stubs for inherited hidden methods. The diff for the generated code for the new test interfaces is shown below.
---------
Co-authored-by: Aaron Robinson <arobins@microsoft.com>
varmethodSyntaxTemplate=newContainingSyntax(newSyntaxTokenList(syntax.Modifiers.Where(static m =>!m.IsKind(SyntaxKind.NewKeyword))).StripAccessibilityModifiers(),SyntaxKind.MethodDeclaration,syntax.Identifier,syntax.TypeParameterList);
if(GenerationContext.VtableIndexData.Directionis not (MarshalDirection.ManagedToUnmanaged or MarshalDirection.Bidirectional))
80
+
if(GenerationContext.VtableIndexData.Directionis not (MarshalDirection.ManagedToUnmanaged or MarshalDirection.Bidirectional)||IsHiddenOnDerivedInterface)
if(GenerationContext.VtableIndexData.Directionis not (MarshalDirection.UnmanagedToManaged or MarshalDirection.Bidirectional))
94
+
if(GenerationContext.VtableIndexData.Directionis not (MarshalDirection.UnmanagedToManaged or MarshalDirection.Bidirectional)||IsHiddenOnDerivedInterface)
0 commit comments