Skip to content

Commit

Permalink
Merge in 'release/8.0-rc2' changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dotnet-bot committed Sep 23, 2023
2 parents 392922b + 1e50b05 commit 8261a7b
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 9 deletions.
8 changes: 4 additions & 4 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -371,13 +371,13 @@
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>9233e36abc5e2ca263dbd4d1616f35623440a935</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0-beta1.23468.1">
<Dependency Name="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0-beta1.23472.1">
<Uri>https://github.com/dotnet/roslyn-analyzers</Uri>
<Sha>2c9a20b6706b8a9ad650b41bff30980cf5af67ed</Sha>
<Sha>4a7701fd72094614897b33e4cb1d9640c221d862</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0-preview.23468.1">
<Dependency Name="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0-preview.23472.1">
<Uri>https://github.com/dotnet/roslyn-analyzers</Uri>
<Sha>2c9a20b6706b8a9ad650b41bff30980cf5af67ed</Sha>
<Sha>4a7701fd72094614897b33e4cb1d9640c221d862</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.ApiCompat.Task" Version="8.0.100-preview.7.23329.3">
<Uri>https://github.com/dotnet/sdk</Uri>
Expand Down
4 changes: 2 additions & 2 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
</ItemGroup>
<PropertyGroup>
<!-- dotnet/roslyn-analyzers dependencies -->
<MicrosoftCodeAnalysisAnalyzersVersion>3.11.0-beta1.23468.1</MicrosoftCodeAnalysisAnalyzersVersion>
<MicrosoftCodeAnalysisNetAnalyzersVersion>8.0.0-preview.23468.1</MicrosoftCodeAnalysisNetAnalyzersVersion>
<MicrosoftCodeAnalysisAnalyzersVersion>3.11.0-beta1.23472.1</MicrosoftCodeAnalysisAnalyzersVersion>
<MicrosoftCodeAnalysisNetAnalyzersVersion>8.0.0-preview.23472.1</MicrosoftCodeAnalysisNetAnalyzersVersion>
<!-- dotnet/roslyn dependencies -->
<!--
These versions should not be used by any project that contributes to the design-time experience in VS, such as an analyzer, code-fix, or generator assembly.
Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/vm/callsiteinspect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,8 @@ void CallsiteInspect::PropagateOutParametersBackToCallsite(
*(ARG_SLOT *)(frame->GetReturnValuePtr()) = retVal;
}
#ifdef ENREGISTERED_RETURNTYPE_MAXSIZE
else if (argit.HasNonStandardByvalReturn())
else if (argit.HasNonStandardByvalReturn()
&& !(flags & CallsiteDetails::HResultReturn))
{
// In these cases, put the pointer to the return buffer into
// the frame's return value slot.
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/vm/callsiteinspect.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct CallsiteDetails
BeginInvoke = 0x01,
EndInvoke = 0x02,
Ctor = 0x04,
HResultReturn = 0x08,
};
INT32 Flags;
};
Expand Down
14 changes: 12 additions & 2 deletions src/coreclr/vm/clrtocomcall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ UINT32 CLRToCOMEventCallWorker(ComPlusMethodFrame* pFrame, ComPlusCallMethodDesc
return 0;
}

CallsiteDetails CreateCallsiteDetails(_In_ FramedMethodFrame *pFrame)
static CallsiteDetails CreateCallsiteDetails(_In_ FramedMethodFrame *pFrame)
{
CONTRACTL
{
Expand Down Expand Up @@ -442,10 +442,20 @@ CallsiteDetails CreateCallsiteDetails(_In_ FramedMethodFrame *pFrame)
SigTypeContext::InitTypeContext(pMD, actualType, &typeContext);
}

// If the signature is marked preserve sig, then the return
// is required to be an HRESULT, per COM rules. We set a flag to
// indicate this state to avoid issues when a C# developer defines
// an HRESULT in C# as a ValueClass with a single int field. This
// is convenient but does violate the COM ABI. Setting the flag
// lets us permit this convention and allow either a 4 byte primitive
// or the commonly used C# type "struct HResult { int Value; }".
if (IsMiPreserveSig(pMD->GetImplAttrs()))
callsiteFlags |= CallsiteDetails::HResultReturn;

_ASSERTE(!signature.IsEmpty() && pModule != nullptr);

// Create details
return CallsiteDetails{ { signature, pModule, &typeContext }, pFrame, pMD, fIsDelegate };
return CallsiteDetails{ { signature, pModule, &typeContext }, pFrame, pMD, fIsDelegate, callsiteFlags };
}

UINT32 CLRToCOMLateBoundWorker(
Expand Down
15 changes: 15 additions & 0 deletions src/tests/Interop/COM/NETClients/IDispatch/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,21 @@ static void Validate_Exception()
Assert.Equal(GetErrorCodeFromHResult(e.HResult), errorCode);
// Failing HRESULT exceptions contain CLR generated messages
}

// Calling methods through IDispatch::Invoke() (i.e., late-bound) doesn't
// propagate the HRESULT when marked with PreserveSig. It is always 0.
{
Console.WriteLine($"Calling {nameof(DispatchTesting.TriggerException)} (PreserveSig) with {nameof(IDispatchTesting_Exception.Int)} {errorCode}...");
var dispatchTesting2 = (IDispatchTestingPreserveSig1)dispatchTesting;
Assert.Equal(0, dispatchTesting2.TriggerException(IDispatchTesting_Exception.Int, errorCode));
}

{
// Validate the HRESULT as a value type construct works for IDispatch.
Console.WriteLine($"Calling {nameof(DispatchTesting.TriggerException)} (PreserveSig, ValueType) with {nameof(IDispatchTesting_Exception.Int)} {errorCode}...");
var dispatchTesting3 = (IDispatchTestingPreserveSig2)dispatchTesting;
Assert.Equal(0, dispatchTesting3.TriggerException(IDispatchTesting_Exception.Int, errorCode).Value);
}
}

static void Validate_StructNotSupported()
Expand Down
1 change: 1 addition & 0 deletions src/tests/Interop/COM/NETServer/DispatchTesting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public void TriggerException(IDispatchTesting_Exception excep, int errorCode)
case IDispatchTesting_Exception.Disp:
throw new Exception();
case IDispatchTesting_Exception.HResult:
case IDispatchTesting_Exception.Int:
throw new System.ComponentModel.Win32Exception(errorCode);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/tests/Interop/COM/NativeServer/DispatchTesting.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ class DispatchTesting : public UnknownImpl, public IDispatchTesting
return DISP_E_EXCEPTION;
case IDispatchTesting_Exception_HResult:
return HRESULT_FROM_WIN32(errorCode);
case IDispatchTesting_Exception_Int:
return errorCode;
default:
return S_FALSE; // Return a success case to indicate failure to trigger a failure.
}
Expand Down
33 changes: 33 additions & 0 deletions src/tests/Interop/COM/ServerContracts/Server.Contracts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ public enum IDispatchTesting_Exception
{
Disp,
HResult,
Int,
}

[StructLayout(LayoutKind.Sequential)]
Expand All @@ -220,6 +221,12 @@ public struct HFA_4
public float w;
}

[StructLayout(LayoutKind.Sequential)]
public struct HRESULT
{
public int Value;
}

[ComVisible(true)]
[Guid("a5e04c1c-474e-46d2-bbc0-769d04e12b54")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
Expand Down Expand Up @@ -257,6 +264,32 @@ void DoubleNumeric_ReturnByRef (
System.Collections.IEnumerator GetEnumerator();
}

[ComVisible(true)]
[Guid("a5e04c1c-474e-46d2-bbc0-769d04e12b54")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface IDispatchTestingPreserveSig1
{
void Reserved1();
void Reserved2();
void Reserved3();

[PreserveSig]
int TriggerException(IDispatchTesting_Exception excep, int errorCode);
}

[ComVisible(true)]
[Guid("a5e04c1c-474e-46d2-bbc0-769d04e12b54")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface IDispatchTestingPreserveSig2
{
void Reserved1();
void Reserved2();
void Reserved3();

[PreserveSig]
HRESULT TriggerException(IDispatchTesting_Exception excep, int errorCode);
}

[ComVisible(true)]
[Guid("83AFF8E4-C46A-45DB-9D91-2ADB5164545E")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
Expand Down
1 change: 1 addition & 0 deletions src/tests/Interop/COM/ServerContracts/Server.Contracts.h
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ enum IDispatchTesting_Exception
{
IDispatchTesting_Exception_Disp,
IDispatchTesting_Exception_HResult,
IDispatchTesting_Exception_Int,
};

struct __declspec(uuid("a5e04c1c-474e-46d2-bbc0-769d04e12b54"))
Expand Down

0 comments on commit 8261a7b

Please sign in to comment.