Skip to content

Accept NativeCallableInternalAttribute to support legacy scenario #37621

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

Merged
2 commits merged into from
Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/coreclr/src/vm/dllimportcallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,9 @@ VOID UMThunkMarshInfo::SetUpForUnmanagedCallersOnly()
CorPinvokeMap callConv = (CorPinvokeMap)0;

HRESULT hr = pMD->GetCustomAttribute(WellKnownAttribute::UnmanagedCallersOnly, (const VOID **)(&pData), (ULONG *)&cData);
if (hr == S_FALSE)
hr = pMD->GetCustomAttribute(WellKnownAttribute::NativeCallableInternal, (const VOID **)(&pData), (ULONG *)&cData);

IfFailThrow(hr);

_ASSERTE(cData > 0);
Expand Down
9 changes: 9 additions & 0 deletions src/coreclr/src/vm/method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5429,6 +5429,15 @@ BOOL MethodDesc::HasUnmanagedCallersOnlyAttribute()
WellKnownAttribute::UnmanagedCallersOnly,
nullptr,
nullptr);
if (hr != S_OK)
{
// See https://github.com/dotnet/runtime/issues/37622
hr = GetCustomAttribute(
WellKnownAttribute::NativeCallableInternal,
nullptr,
nullptr);
}

return (hr == S_OK) ? TRUE : FALSE;
}

Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/src/vm/wellknownattributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ enum class WellKnownAttribute : DWORD
PrimaryInteropAssembly,
ManagedToNativeComInteropStub,
UnmanagedCallersOnly,
NativeCallableInternal, // This is needed to support MCG scenarios
TypeIdentifier,
UnmanagedFunctionPointer,
ThreadStatic,
Expand Down Expand Up @@ -92,6 +93,8 @@ inline const char *GetWellKnownAttributeName(WellKnownAttribute attribute)
return "System.Runtime.InteropServices.ManagedToNativeComInteropStubAttribute";
case WellKnownAttribute::UnmanagedCallersOnly:
return "System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute";
case WellKnownAttribute::NativeCallableInternal:
return "System.Runtime.InteropServices.NativeCallableInternalAttribute";
case WellKnownAttribute::TypeIdentifier:
return "System.Runtime.InteropServices.TypeIdentifierAttribute";
case WellKnownAttribute::UnmanagedFunctionPointer:
Expand Down