protected override DiagnosticInfo?ResolveInfo()
        {
            UnmanagedCallersOnlyAttributeData?unmanagedCallersOnlyAttributeData = _method.GetUnmanagedCallersOnlyAttributeData(forceComplete: true);

            Debug.Assert(!ReferenceEquals(unmanagedCallersOnlyAttributeData, UnmanagedCallersOnlyAttributeData.Uninitialized));
            Debug.Assert(!ReferenceEquals(unmanagedCallersOnlyAttributeData, UnmanagedCallersOnlyAttributeData.AttributePresentDataNotBound));

            return(unmanagedCallersOnlyAttributeData is null
                ? null
                : new CSDiagnosticInfo(_isDelegateConversion
                                           ? ErrorCode.ERR_UnmanagedCallersOnlyMethodsCannotBeConvertedToDelegate
                                           : ErrorCode.ERR_UnmanagedCallersOnlyMethodsCannotBeCalledDirectly,
                                       _method));
        }
Exemple #2
0
        internal override DiagnosticInfo GetResolvedInfo()
        {
            if (_lazyActualUnmanagedCallersOnlyDiagnostic is null)
            {
                UnmanagedCallersOnlyAttributeData?unmanagedCallersOnlyAttributeData =
                    _method.GetUnmanagedCallersOnlyAttributeData(forceComplete: true);
                Debug.Assert(
                    !ReferenceEquals(
                        unmanagedCallersOnlyAttributeData,
                        UnmanagedCallersOnlyAttributeData.Uninitialized
                        )
                    );
                Debug.Assert(
                    !ReferenceEquals(
                        unmanagedCallersOnlyAttributeData,
                        UnmanagedCallersOnlyAttributeData.AttributePresentDataNotBound
                        )
                    );

                var info = unmanagedCallersOnlyAttributeData is null
                    ? CSDiagnosticInfo.VoidDiagnosticInfo
                    : new CSDiagnosticInfo(
                    _isDelegateConversion
                            ? ErrorCode.ERR_UnmanagedCallersOnlyMethodsCannotBeConvertedToDelegate
                            : ErrorCode.ERR_UnmanagedCallersOnlyMethodsCannotBeCalledDirectly,
                    _method
                    );

                Interlocked.CompareExchange(
                    ref _lazyActualUnmanagedCallersOnlyDiagnostic,
                    info,
                    null
                    );
            }

            return(_lazyActualUnmanagedCallersOnlyDiagnostic);
        }
Exemple #3
0
 internal override UnmanagedCallersOnlyAttributeData?GetUnmanagedCallersOnlyAttributeData(bool forceComplete)
 {
     return(_underlyingMethod.GetUnmanagedCallersOnlyAttributeData(forceComplete));
 }