40 lines
1.5 KiB
C#
40 lines
1.5 KiB
C#
using Microsoft.CodeAnalysis.CSharp.Symbols;
|
|
|
|
namespace Microsoft.CodeAnalysis.CSharp;
|
|
|
|
internal sealed class LazyUnmanagedCallersOnlyMethodCalledDiagnosticInfo : LazyDiagnosticInfo
|
|
{
|
|
private readonly MethodSymbol _method;
|
|
|
|
private readonly bool _isDelegateConversion;
|
|
|
|
internal LazyUnmanagedCallersOnlyMethodCalledDiagnosticInfo(MethodSymbol method, bool isDelegateConversion)
|
|
{
|
|
_method = method;
|
|
_isDelegateConversion = isDelegateConversion;
|
|
}
|
|
|
|
private LazyUnmanagedCallersOnlyMethodCalledDiagnosticInfo(LazyUnmanagedCallersOnlyMethodCalledDiagnosticInfo original, DiagnosticSeverity severity)
|
|
: base(original, severity)
|
|
{
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
|
_method = original._method;
|
|
_isDelegateConversion = original._isDelegateConversion;
|
|
}
|
|
|
|
protected override DiagnosticInfo GetInstanceWithSeverityCore(DiagnosticSeverity severity)
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
return (DiagnosticInfo)(object)new LazyUnmanagedCallersOnlyMethodCalledDiagnosticInfo(this, severity);
|
|
}
|
|
|
|
protected override DiagnosticInfo? ResolveInfo()
|
|
{
|
|
if (_method.GetUnmanagedCallersOnlyAttributeData(forceComplete: true) != null)
|
|
{
|
|
return (DiagnosticInfo?)(object)new CSDiagnosticInfo(_isDelegateConversion ? ErrorCode.ERR_UnmanagedCallersOnlyMethodsCannotBeConvertedToDelegate : ErrorCode.ERR_UnmanagedCallersOnlyMethodsCannotBeCalledDirectly, _method);
|
|
}
|
|
return null;
|
|
}
|
|
}
|