/// <inheritdoc />
        public bool IsEquivalent(UnmanagedFunctionPointerAttribute attribute)
        {
            // Default convention is StdCall on Windows, Cdecl elsewhere.
            if (attribute == null)
            {
                return(this.Equals(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? StdCall : Cdecl));
            }

            return(attribute.CallingConvention switch
            {
                CallingConvention.Cdecl => this.Equals(Cdecl),
                CallingConvention.StdCall => this.Equals(StdCall),
                CallingConvention.ThisCall => this.Equals(MicrosoftThiscall),

                // Not supported by runtime, is new or depends on platform
                _ => false,
            });
예제 #2
0
        public void Ctor_CallingConvention(CallingConvention callingConvention)
        {
            var attribute = new UnmanagedFunctionPointerAttribute(callingConvention);

            Assert.Equal(callingConvention, attribute.CallingConvention);
        }