diff --git a/src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs b/src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs index c635839523a05cf60e0f2f844cd4b2c6cae8dc16..d7bda37ffc177499f5fedf2c0ed88dd4c4853ea4 100644 --- a/src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs +++ b/src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs @@ -3334,7 +3334,7 @@ static CustomModifier getCustomModifierForType(INamedTypeSymbol type, CSharpComp } var internalType = type.EnsureCSharpSymbolOrNull($"{nameof(callingConventionTypes)}[{index}]"); - if (!FunctionPointerTypeSymbol.IsCallingConventionModifier(internalType) || @this.Assembly.CorLibrary != internalType.ContainingAssembly.CorLibrary) + if (!FunctionPointerTypeSymbol.IsCallingConventionModifier(internalType) || @this.Assembly.CorLibrary != internalType.ContainingAssembly) { throw new ArgumentException(string.Format(CSharpResources.CallingConventionTypeIsInvalid, type.ToDisplayString())); } diff --git a/src/Compilers/CSharp/Test/Symbol/Symbols/FunctionPointerTypeSymbolTests.cs b/src/Compilers/CSharp/Test/Symbol/Symbols/FunctionPointerTypeSymbolTests.cs index e2daf4d0b99ab814366d188a425889ff7c4fdfcd..6a4cf967a217822cb3e5ca0742cd23a46039a95a 100644 --- a/src/Compilers/CSharp/Test/Symbol/Symbols/FunctionPointerTypeSymbolTests.cs +++ b/src/Compilers/CSharp/Test/Symbol/Symbols/FunctionPointerTypeSymbolTests.cs @@ -1655,6 +1655,10 @@ public void PublicApi_CallingConventions_Modopts() AssertEx.Equal("delegate* unmanaged[Cdecl, Stdcall]", ptr.ToTestDisplayString()); ptr = comp.CreateFunctionPointerTypeSymbol(@string, returnRefKind: RefKind.RefReadOnly, parameterTypes: ImmutableArray.Empty, parameterRefKinds: ImmutableArray.Empty, SignatureCallingConvention.Unmanaged, ImmutableArray.Create(cdeclType, stdcallType)!); AssertEx.Equal("delegate* unmanaged[Cdecl, Stdcall]", ptr.ToTestDisplayString()); + + ptr = comp.CreateFunctionPointerTypeSymbol(@string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray.Empty, parameterRefKinds: ImmutableArray.Empty, SignatureCallingConvention.Unmanaged, ImmutableArray.Create(cdeclType)!); + AssertEx.Equal("delegate* unmanaged[Cdecl]", ptr.ToTestDisplayString()); + Assert.Equal(SignatureCallingConvention.Unmanaged, ptr.Signature.CallingConvention); } [Fact] @@ -1959,11 +1963,11 @@ public static class RuntimeFeature } ", options: TestOptions.UnsafeReleaseDll, parseOptions: TestOptions.RegularPreview); - var mainComp = CreateCompilation("", references: new[] { otherCorLib.ToMetadataReference() }); + var mainComp = CreateCompilation(""); var returnType = mainComp.GetSpecialType(SpecialType.System_String).GetPublicSymbol(); var testConvention = otherCorLib.GetTypeByMetadataName("System.Runtime.CompilerServices.CallConvTest"); Assert.NotNull(testConvention); - Assert.True((object)testConvention!.ContainingAssembly.CorLibrary != mainComp.Assembly.CorLibrary); + Assert.NotSame(testConvention!.ContainingAssembly.CorLibrary, mainComp.Assembly.CorLibrary); Assert.True(FunctionPointerTypeSymbol.IsCallingConventionModifier(testConvention)); Assert.Throws(() => mainComp.CreateFunctionPointerTypeSymbol( diff --git a/src/Compilers/Core/Portable/Collections/ImmutableArrayExtensions.cs b/src/Compilers/Core/Portable/Collections/ImmutableArrayExtensions.cs index ffe3ed653a546d7faf143d90f8f395a519e1feeb..a7f21921ee42dc3f2f3a1ac4705b73324aae8403 100644 --- a/src/Compilers/Core/Portable/Collections/ImmutableArrayExtensions.cs +++ b/src/Compilers/Core/Portable/Collections/ImmutableArrayExtensions.cs @@ -140,19 +140,6 @@ public static ImmutableArray ToImmutable(this MemoryStream stream) return ImmutableArray.CreateRange(items, map); } - /// - /// Maps an immutable array to another immutable array, passing the current index. - /// - /// - /// - /// The sequence to map - /// The mapping delegate - /// If the items's length is 0, this will return an empty immutable array. - public static ImmutableArray SelectAsArray(this ImmutableArray items, Func map) - { - return items.SelectAsArray((item, i, mapper) => mapper(item, i), map); - } - /// /// Maps an immutable array to another immutable array. /// diff --git a/src/Compilers/Core/Portable/SymbolDisplay/SymbolDisplayMiscellaneousOptions.cs b/src/Compilers/Core/Portable/SymbolDisplay/SymbolDisplayMiscellaneousOptions.cs index cab5feb98c3c132da5e0ae9087163b4acbb70a3f..0423a3a179dca9e00c4f1c2576c3035b9b2ec74c 100644 --- a/src/Compilers/Core/Portable/SymbolDisplay/SymbolDisplayMiscellaneousOptions.cs +++ b/src/Compilers/Core/Portable/SymbolDisplay/SymbolDisplayMiscellaneousOptions.cs @@ -76,7 +76,7 @@ public enum SymbolDisplayMiscellaneousOptions IncludeNotNullableReferenceTypeModifier = 1 << 8, /// - /// Explicitly put `managed` as the calling convention for function pointer types. + /// Use the `managed` keyword for managed function pointer types. /// UseExplicitManagedCallingConventionSpecifier = 1 << 9, }