Skip to content

Commit 197f528

Browse files
committed
GH-1881 - Fix interface method attributes when generating proxies
1 parent baee90e commit 197f528

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/NHibernate/Proxy/ProxyBuilderHelper.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,24 @@ internal static MethodBuilder GetObjectDataMethodBuilder(TypeBuilder typeBuilder
137137
internal static MethodBuilder GenerateMethodSignature(string name, MethodInfo method, TypeBuilder typeBuilder)
138138
{
139139
//TODO: Should we use attributes of base method?
140-
var methodAttributes = MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Virtual;
140+
MethodAttributes methodAttributes;
141+
if (method.DeclaringType.IsInterface)
142+
{
143+
// These are the attributes used for an explicit interface method implementation in .NET.
144+
methodAttributes =
145+
MethodAttributes.Private |
146+
MethodAttributes.Final |
147+
MethodAttributes.Virtual |
148+
MethodAttributes.HideBySig |
149+
MethodAttributes.NewSlot |
150+
MethodAttributes.SpecialName;
151+
// .NET uses an expanded name for explicit interface implementation methods.
152+
name = typeBuilder.FullName + "." + method.DeclaringType.FullName + "." + name;
153+
}
154+
else
155+
{
156+
methodAttributes = MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Virtual;
157+
}
141158

142159
if (method.IsSpecialName)
143160
methodAttributes |= MethodAttributes.SpecialName;

0 commit comments

Comments
 (0)