diff --git a/eng/Directory.Packages.props b/eng/Directory.Packages.props index 5af59759c1dc2..7b2982ef1f035 100644 --- a/eng/Directory.Packages.props +++ b/eng/Directory.Packages.props @@ -5,7 +5,7 @@ 8.0.0-preview.23468.1 1.1.3-beta1.24319.1 0.1.187-beta - <_BasicReferenceAssembliesVersion>1.7.7 + <_BasicReferenceAssembliesVersion>1.7.8 4.8.0-3.final 17.10.191 diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs index 46af23bd47153..37e621fc00955 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs @@ -775,7 +775,7 @@ .assembly extern mscorlib { } .assembly extern System.ValueTuple { .publickeytoken = (CC 7B 13 FF CD 2D DD 51 ) - .ver 4:0:1:0 + .ver 4:0:3:0 } .class public auto ansi C @@ -871,7 +871,7 @@ .assembly extern mscorlib { } .assembly extern System.ValueTuple { .publickeytoken = (CC 7B 13 FF CD 2D DD 51 ) - .ver 4:0:1:0 + .ver 4:0:3:0 } .class public auto ansi C @@ -969,7 +969,7 @@ .assembly extern mscorlib { } .assembly extern System.ValueTuple { .publickeytoken = (CC 7B 13 FF CD 2D DD 51 ) - .ver 4:0:1:0 + .ver 4:0:3:0 } .class public auto ansi beforefieldinit Base`1 @@ -21205,7 +21205,7 @@ .assembly extern mscorlib { } .assembly extern System.ValueTuple { .publickeytoken = (CC 7B 13 FF CD 2D DD 51 ) - .ver 4:0:1:0 + .ver 4:0:3:0 } .class public auto ansi beforefieldinit Base @@ -22273,9 +22273,9 @@ public class B var comp = CreateCompilationWithMscorlib40(source, references: new[] { lib.ToMetadataReference() }); comp.VerifyDiagnostics( - // (4,24): error CS0012: The type '(, )' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. + // (4,24): error CS0012: The type '(, )' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. // void M2() { return A.M(); } - Diagnostic(ErrorCode.ERR_NoTypeDef, "A.M").WithArguments("(, )", "System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51").WithLocation(4, 24) + Diagnostic(ErrorCode.ERR_NoTypeDef, "A.M").WithArguments("(, )", "System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51").WithLocation(4, 24) ); var methodM = comp.GetMember("A.M"); @@ -22313,9 +22313,9 @@ public class B var comp = CreateCompilationWithMscorlib40(source, references: new[] { lib.ToMetadataReference() }); comp.VerifyDiagnostics( - // (4,24): error CS0012: The type '(, )' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. + // (4,24): error CS0012: The type '(, )' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. // void M2() { return A.M(); } - Diagnostic(ErrorCode.ERR_NoTypeDef, "A.M").WithArguments("(, )", "System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51").WithLocation(4, 24) + Diagnostic(ErrorCode.ERR_NoTypeDef, "A.M").WithArguments("(, )", "System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51").WithLocation(4, 24) ); var methodM = comp.GetMember("A.M"); @@ -23145,7 +23145,7 @@ public void ValueTupleBaseError_NoSystemRuntime() { ((int, int), (int, int)) F(); }"; - var comp = CreateCompilationWithMscorlib40(source, references: new[] { ValueTupleRef }); + var comp = CreateCompilationWithMscorlib40(source, references: [ValueTupleLegacyRef]); comp.VerifyEmitDiagnostics( // (3,6): error CS0012: The type 'ValueType' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. // ((int, int), (int, int)) F(); @@ -23766,7 +23766,7 @@ .assembly extern System.Core .assembly extern System.ValueTuple { .publickeytoken = (CC 7B 13 FF CD 2D DD 51 ) // .{...-.Q - .ver 4:0:1:0 + .ver 4:0:3:0 } // =============== CLASS MEMBERS DECLARATION =================== @@ -23923,16 +23923,14 @@ static void M() } "; - var compilation = CreateCompilationWithMscorlib40(source, - references: new[] { ValueTupleRef }); + var compilation = CreateCompilationWithMscorlib40(source, references: [ValueTupleLegacyRef]); Assert.Equal(TypeKind.Class, compilation.GetWellKnownType(WellKnownType.System_ValueTuple_T2).TypeKind); compilation.VerifyDiagnostics( - // (6,17): error CS0012: The type 'ValueType' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. - // var o = (1, 2); - Diagnostic(ErrorCode.ERR_NoTypeDef, "(1, 2)").WithArguments("System.ValueType", "System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a").WithLocation(6, 17) - ); + // (6,17): error CS0012: The type 'ValueType' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. + // var o = (1, 2); + Diagnostic(ErrorCode.ERR_NoTypeDef, "(1, 2)").WithArguments("System.ValueType", "System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a").WithLocation(6, 17)); } [Fact] @@ -23969,7 +23967,6 @@ static void Main(string[] args) public void Iterator_02() { var source = @" -using System; using System.Collections.Generic; public class C @@ -23981,17 +23978,14 @@ public class C } "; - var compilation = CreateCompilationWithMscorlib40(source, - references: new[] { ValueTupleRef }); - + var compilation = CreateCompilationWithMscorlib40(source, references: new[] { ValueTupleLegacyRef }); compilation.VerifyEmitDiagnostics( - // (7,24): error CS0012: The type 'ValueType' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. + // (6,24): error CS0012: The type 'ValueType' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. // public IEnumerable<(int, int)> entries() - Diagnostic(ErrorCode.ERR_NoTypeDef, "(int, int)").WithArguments("System.ValueType", "System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a").WithLocation(7, 24), - // (9,22): error CS0012: The type 'ValueType' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. + Diagnostic(ErrorCode.ERR_NoTypeDef, "(int, int)").WithArguments("System.ValueType", "System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a").WithLocation(6, 24), + // (8,22): error CS0012: The type 'ValueType' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. // yield return (1, 2); - Diagnostic(ErrorCode.ERR_NoTypeDef, "(1, 2)").WithArguments("System.ValueType", "System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a").WithLocation(9, 22) - ); + Diagnostic(ErrorCode.ERR_NoTypeDef, "(1, 2)").WithArguments("System.ValueType", "System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a").WithLocation(8, 22)); } [Fact] diff --git a/src/Compilers/CSharp/Test/Emit2/Attributes/AttributeTests_Tuples.cs b/src/Compilers/CSharp/Test/Emit2/Attributes/AttributeTests_Tuples.cs index 8e7a84e934681..c9b301a768a5f 100644 --- a/src/Compilers/CSharp/Test/Emit2/Attributes/AttributeTests_Tuples.cs +++ b/src/Compilers/CSharp/Test/Emit2/Attributes/AttributeTests_Tuples.cs @@ -221,12 +221,12 @@ class C // (4,12): error CS0518: Predefined type 'System.String' is not defined or imported // static (int x, int y) M() => (0, 0); Diagnostic(ErrorCode.ERR_PredefinedTypeNotFound, "(int x, int y)").WithArguments("System.String").WithLocation(4, 12), - // (4,12): error CS0012: The type 'ValueType' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. + // (4,12): error CS0012: The type 'ValueType' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. // static (int x, int y) M() => (0, 0); - Diagnostic(ErrorCode.ERR_NoTypeDef, "(int x, int y)").WithArguments("System.ValueType", "System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a").WithLocation(4, 12), - // (4,34): error CS0012: The type 'ValueType' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. + Diagnostic(ErrorCode.ERR_NoTypeDef, "(int x, int y)").WithArguments("System.ValueType", "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089").WithLocation(4, 12), + // (4,34): error CS0012: The type 'ValueType' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. // static (int x, int y) M() => (0, 0); - Diagnostic(ErrorCode.ERR_NoTypeDef, "(0, 0)").WithArguments("System.ValueType", "System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a").WithLocation(4, 34) + Diagnostic(ErrorCode.ERR_NoTypeDef, "(0, 0)").WithArguments("System.ValueType", "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089").WithLocation(4, 34) ); } @@ -816,34 +816,34 @@ public struct S }"; var comp = CreateCompilationWithMscorlib40(text, references: s_attributeRefs); comp.VerifyDiagnostics( - // (31,2): error CS8331: Cannot reference 'System.Runtime.CompilerServices.TupleElementNamesAttribute' explicitly. Use the tuple syntax to define tuple names. - // [TupleElementNames(new[] { "a", "b" })] - Diagnostic(ErrorCode.ERR_ExplicitTupleElementNamesAttribute, @"TupleElementNames(new[] { ""a"", ""b"" })").WithLocation(31, 2), - // (5,2): error CS8331: Cannot reference 'System.Runtime.CompilerServices.TupleElementNamesAttribute' explicitly. Use the tuple syntax to define tuple names. + // (5,2): error CS8138: Cannot reference 'System.Runtime.CompilerServices.TupleElementNamesAttribute' explicitly. Use the tuple syntax to define tuple names. // [TupleElementNames(new[] { "a", "b" })] Diagnostic(ErrorCode.ERR_ExplicitTupleElementNamesAttribute, @"TupleElementNames(new[] { ""a"", ""b"" })").WithLocation(5, 2), - // (18,10): error CS8331: Cannot reference 'System.Runtime.CompilerServices.TupleElementNamesAttribute' explicitly. Use the tuple syntax to define tuple names. + // (31,2): error CS8138: Cannot reference 'System.Runtime.CompilerServices.TupleElementNamesAttribute' explicitly. Use the tuple syntax to define tuple names. + // [TupleElementNames(new[] { "a", "b" })] + Diagnostic(ErrorCode.ERR_ExplicitTupleElementNamesAttribute, @"TupleElementNames(new[] { ""a"", ""b"" })").WithLocation(31, 2), + // (18,10): error CS8138: Cannot reference 'System.Runtime.CompilerServices.TupleElementNamesAttribute' explicitly. Use the tuple syntax to define tuple names. // [TupleElementNames(new[] { "x" })]ValueTuple args); Diagnostic(ErrorCode.ERR_ExplicitTupleElementNamesAttribute, @"TupleElementNames(new[] { ""x"" })").WithLocation(18, 10), - // (11,6): error CS8331: Cannot reference 'System.Runtime.CompilerServices.TupleElementNamesAttribute' explicitly. Use the tuple syntax to define tuple names. + // (11,6): error CS8138: Cannot reference 'System.Runtime.CompilerServices.TupleElementNamesAttribute' explicitly. Use the tuple syntax to define tuple names. // [TupleElementNames(new[] { "x", "y" })] Diagnostic(ErrorCode.ERR_ExplicitTupleElementNamesAttribute, @"TupleElementNames(new[] { ""x"", ""y"" })").WithLocation(11, 6), - // (14,14): error CS8331: Cannot reference 'System.Runtime.CompilerServices.TupleElementNamesAttribute' explicitly. Use the tuple syntax to define tuple names. + // (14,14): error CS8138: Cannot reference 'System.Runtime.CompilerServices.TupleElementNamesAttribute' explicitly. Use the tuple syntax to define tuple names. // [return: TupleElementNames(new string[] { null, null })] Diagnostic(ErrorCode.ERR_ExplicitTupleElementNamesAttribute, "TupleElementNames(new string[] { null, null })").WithLocation(14, 14), - // (15,36): error CS8331: Cannot reference 'System.Runtime.CompilerServices.TupleElementNamesAttribute' explicitly. Use the tuple syntax to define tuple names. + // (15,36): error CS8138: Cannot reference 'System.Runtime.CompilerServices.TupleElementNamesAttribute' explicitly. Use the tuple syntax to define tuple names. // public ValueTuple M([TupleElementNames(new string[] { null})] ValueTuple x) => (0, 0); Diagnostic(ErrorCode.ERR_ExplicitTupleElementNamesAttribute, "TupleElementNames(new string[] { null})").WithLocation(15, 36), - // (20,6): error CS0592: Attribute 'TupleElementNames' is not valid on this declaration type. It is only valid on 'class, struct, property, indexer, field, parameter, return' declarations. + // (20,6): error CS8138: Cannot reference 'System.Runtime.CompilerServices.TupleElementNamesAttribute' explicitly. Use the tuple syntax to define tuple names. // [TupleElementNames(new[] { "y" })] - Diagnostic(ErrorCode.ERR_AttributeOnBadSymbolType, "TupleElementNames").WithArguments("TupleElementNames", "class, struct, property, indexer, field, parameter, return").WithLocation(20, 6), - // (27,6): error CS8331: Cannot reference 'System.Runtime.CompilerServices.TupleElementNamesAttribute' explicitly. Use the tuple syntax to define tuple names. + Diagnostic(ErrorCode.ERR_ExplicitTupleElementNamesAttribute, @"TupleElementNames(new[] { ""y"" })").WithLocation(20, 6), + // (27,6): error CS8138: Cannot reference 'System.Runtime.CompilerServices.TupleElementNamesAttribute' explicitly. Use the tuple syntax to define tuple names. // [TupleElementNames(new[] { "a", "b" })] Diagnostic(ErrorCode.ERR_ExplicitTupleElementNamesAttribute, @"TupleElementNames(new[] { ""a"", ""b"" })").WithLocation(27, 6), - // (28,33): error CS8331: Cannot reference 'System.Runtime.CompilerServices.TupleElementNamesAttribute' explicitly. Use the tuple syntax to define tuple names. + // (28,33): error CS7036: There is no argument given that corresponds to the required parameter 'transformNames' of 'TupleElementNamesAttribute.TupleElementNamesAttribute(string[])' // public (int x, int y) this[[TupleElementNames](int a, int b) t] => t; - Diagnostic(ErrorCode.ERR_ExplicitTupleElementNamesAttribute, "TupleElementNames").WithLocation(28, 33), - // (8,6): error CS8331: Cannot reference 'System.Runtime.CompilerServices.TupleElementNamesAttribute' explicitly. Use the tuple syntax to define tuple names. + Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "TupleElementNames").WithArguments("transformNames", "System.Runtime.CompilerServices.TupleElementNamesAttribute.TupleElementNamesAttribute(string[])").WithLocation(28, 33), + // (8,6): error CS8138: Cannot reference 'System.Runtime.CompilerServices.TupleElementNamesAttribute' explicitly. Use the tuple syntax to define tuple names. // [TupleElementNames(new string[] { null, null })] Diagnostic(ErrorCode.ERR_ExplicitTupleElementNamesAttribute, "TupleElementNames(new string[] { null, null })").WithLocation(8, 6)); } diff --git a/src/Compilers/CSharp/Test/Symbol/Symbols/Source/CustomModifierCopyTests.cs b/src/Compilers/CSharp/Test/Symbol/Symbols/Source/CustomModifierCopyTests.cs index 27b140fe6ef97..253e4c222f453 100644 --- a/src/Compilers/CSharp/Test/Symbol/Symbols/Source/CustomModifierCopyTests.cs +++ b/src/Compilers/CSharp/Test/Symbol/Symbols/Source/CustomModifierCopyTests.cs @@ -974,7 +974,7 @@ public void TupleWithCustomModifiersInInterfaceMethod() var il = @" .assembly extern mscorlib { .ver 4:0:0:0 .publickeytoken = (B7 7A 5C 56 19 34 E0 89) } .assembly extern System.Core {} -.assembly extern System.ValueTuple { .publickeytoken = (CC 7B 13 FF CD 2D DD 51 ) .ver 4:0:1:0 } +.assembly extern System.ValueTuple { .publickeytoken = (CC 7B 13 FF CD 2D DD 51 ) .ver 4:0:3:0 } .assembly '<>' { } .class interface public abstract auto ansi I @@ -1092,7 +1092,7 @@ public void TupleWithCustomModifiersInInterfaceProperty() var il = @" .assembly extern mscorlib { .ver 4:0:0:0 .publickeytoken = (B7 7A 5C 56 19 34 E0 89) } .assembly extern System.Core {} -.assembly extern System.ValueTuple { .publickeytoken = (CC 7B 13 FF CD 2D DD 51 ) .ver 4:0:1:0 } +.assembly extern System.ValueTuple { .publickeytoken = (CC 7B 13 FF CD 2D DD 51 ) .ver 4:0:3:0 } .assembly '<>' { } .class interface public abstract auto ansi I @@ -1189,7 +1189,7 @@ public void TupleWithCustomModifiersInOverride() var il = @" .assembly extern mscorlib { .ver 4:0:0:0 .publickeytoken = (B7 7A 5C 56 19 34 E0 89) } .assembly extern System.Core {} -.assembly extern System.ValueTuple { .publickeytoken = (CC 7B 13 FF CD 2D DD 51 ) .ver 4:0:1:0 } +.assembly extern System.ValueTuple { .publickeytoken = (CC 7B 13 FF CD 2D DD 51 ) .ver 4:0:3:0 } .assembly '<>' { } .class public auto ansi beforefieldinit Base diff --git a/src/Compilers/Test/Core/TargetFrameworkUtil.cs b/src/Compilers/Test/Core/TargetFrameworkUtil.cs index 9d105b0cd7f04..f73c0fc7d4aca 100644 --- a/src/Compilers/Test/Core/TargetFrameworkUtil.cs +++ b/src/Compilers/Test/Core/TargetFrameworkUtil.cs @@ -119,10 +119,7 @@ public static class NetFramework /// /// Need to special case tuples until we move to net472 /// - public static ImmutableArray References { get; } = - ImmutableArray - .CreateRange(Net461.References.All) - .Add(NetFx.ValueTuple.tuplelib); + public static ImmutableArray References { get; } = [.. Net461.References.All, Net461.ExtraReferences.SystemValueTuple]; /// /// This is a limited set of references on this .NET Framework TFM. This should be avoided in new code @@ -132,13 +129,14 @@ public static class NetFramework /// Need to special case tuples until we move to net472 /// public static ImmutableArray Standard { get; } = - ImmutableArray.Create( + [ Net461.References.mscorlib, Net461.References.System, Net461.References.SystemCore, Net461.References.SystemData, - NetFx.ValueTuple.tuplelib, - Net461.References.SystemRuntime); + Net461.References.SystemRuntime, + Net461.ExtraReferences.SystemValueTuple + ]; public static PortableExecutableReference mscorlib { get; } = Net461.References.mscorlib; public static PortableExecutableReference System { get; } = Net461.References.System; @@ -147,6 +145,7 @@ public static class NetFramework public static PortableExecutableReference SystemData { get; } = Net461.References.SystemData; public static PortableExecutableReference SystemThreadingTasks { get; } = Net461.References.SystemThreadingTasks; public static PortableExecutableReference SystemXml { get; } = Net461.References.SystemXml; + public static PortableExecutableReference SystemValueTuple { get; } = Net461.ExtraReferences.SystemValueTuple; public static PortableExecutableReference MicrosoftCSharp { get; } = Net461.References.MicrosoftCSharp; public static PortableExecutableReference MicrosoftVisualBasic { get; } = Net461.References.MicrosoftVisualBasic; } @@ -180,26 +179,27 @@ .. TestBase.WinRtRefs [ TestBase.MinAsyncCorlibRef ]; - public static ImmutableArray Mscorlib45ExtendedReferences => + + /* + * ⚠ Dev note ⚠: TestBase properties end here. + */ + + public static ImmutableArray Mscorlib45ExtendedReferences { get; } = [ NetFramework.mscorlib, NetFramework.System, NetFramework.SystemCore, - TestBase.ValueTupleRef, - NetFramework.SystemRuntime + NetFramework.SystemRuntime, + NetFramework.SystemValueTuple, ]; - public static ImmutableArray Mscorlib46ExtendedReferences => + public static ImmutableArray Mscorlib46ExtendedReferences { get; } = [ Net461.References.mscorlib, Net461.References.System, Net461.References.SystemCore, - TestBase.ValueTupleRef, - Net461.References.SystemRuntime + Net461.References.SystemRuntime, + Net461.ExtraReferences.SystemValueTuple, ]; - /* - * ⚠ Dev note ⚠: TestBase properties end here. - */ - public static ImmutableArray Mscorlib40References { get; } = [ Net40.References.mscorlib @@ -238,8 +238,8 @@ .. TestBase.WinRtRefs Net461.References.mscorlib, Net461.References.System, Net461.References.SystemCore, - NetFx.ValueTuple.tuplelib, - Net461.References.SystemRuntime + Net461.References.SystemRuntime, + Net461.ExtraReferences.SystemValueTuple, ]; public static ImmutableArray Mscorlib461AndCSharpReferences { get; } = [ diff --git a/src/Compilers/Test/Core/TestBase.cs b/src/Compilers/Test/Core/TestBase.cs index bc37f63b8352d..4c52c0168b1f2 100644 --- a/src/Compilers/Test/Core/TestBase.cs +++ b/src/Compilers/Test/Core/TestBase.cs @@ -235,7 +235,7 @@ public virtual void Dispose() public static MetadataReference MinAsyncCorlibRef => TestReferences.NetFx.Minimal.minasynccorlib; - public static MetadataReference ValueTupleRef => TestReferences.NetFx.ValueTuple.tuplelib; + public static MetadataReference ValueTupleRef => NetFramework.SystemValueTuple; public static MetadataReference MsvbRef => NetFramework.MicrosoftVisualBasic; @@ -243,6 +243,19 @@ public virtual void Dispose() public static MetadataReference CSharpRef => CSharpDesktopRef; + /// + /// This is a legacy copy of System.ValueTuple. The origin is unclear as this does not appear to be a released + /// binary on nuget.org (possible a pre-release copy). This does have a few properties that were interesting + /// for a particular style of bug in VS that cannot be reproduced with modern TFMs. Specifically that it + /// depends on System.Runtime for parts of the impl and can't compile with only a reference to mscorlib. As + /// such this is kept around for those tests. + /// + /// Related issues + /// - https://github.com/dotnet/roslyn/issues/14888 + /// - https://github.com/dotnet/roslyn/issues/14267 + /// + public static MetadataReference ValueTupleLegacyRef => TestReferences.NetFx.ValueTuple.tuplelib; + private static readonly Lazy s_desktopCSharpRef = new Lazy( () => AssemblyMetadata.CreateFromImage(Net461.Resources.MicrosoftCSharp).GetReference(display: "Microsoft.CSharp.v4.0.30319.dll"), LazyThreadSafetyMode.PublicationOnly); diff --git a/src/Compilers/VisualBasic/Test/Emit/Attributes/AttributeTests_Tuples.vb b/src/Compilers/VisualBasic/Test/Emit/Attributes/AttributeTests_Tuples.vb index c2bd550b02eaa..05a55db004fc0 100644 --- a/src/Compilers/VisualBasic/Test/Emit/Attributes/AttributeTests_Tuples.vb +++ b/src/Compilers/VisualBasic/Test/Emit/Attributes/AttributeTests_Tuples.vb @@ -664,19 +664,19 @@ BC37269: Cannot reference 'System.Runtime.CompilerServices.TupleElementNamesAttr BC37269: Cannot reference 'System.Runtime.CompilerServices.TupleElementNamesAttribute' explicitly. Use the tuple syntax to define tuple names. Public Delegate Sub Delegate1(Of T)(sender As Object, args As ValueTuple(Of T)) ~~~~~~~~~~~~~~~~~~~~~~~~ -BC30662: Attribute 'TupleElementNamesAttribute' cannot be applied to 'Event1' because the attribute is not valid on this declaration type. +BC37269: Cannot reference 'System.Runtime.CompilerServices.TupleElementNamesAttribute' explicitly. Use the tuple syntax to define tuple names. - ~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~ BC37269: Cannot reference 'System.Runtime.CompilerServices.TupleElementNamesAttribute' explicitly. Use the tuple syntax to define tuple names. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -BC37269: Cannot reference 'System.Runtime.CompilerServices.TupleElementNamesAttribute' explicitly. Use the tuple syntax to define tuple names. +BC30455: Argument not specified for parameter 'transformNames' of 'Public Overloads Sub New(transformNames As String())'. Default Public ReadOnly Property Item1( t As (a As Integer, b As Integer)) As (a As Integer, b As Integer) ~~~~~~~~~~~~~~~~~ BC37269: Cannot reference 'System.Runtime.CompilerServices.TupleElementNamesAttribute' explicitly. Use the tuple syntax to define tuple names. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ]]> +]]> ) End Sub diff --git a/src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb b/src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb index bf8ca1a5506c7..b1ae0b1ca9935 100644 --- a/src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb +++ b/src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb @@ -9090,7 +9090,7 @@ End Class comp.AssertTheseDiagnostics( -BC30652: Reference required to assembly 'System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' containing the type 'ValueTuple(Of ,)'. Add one to your project. +BC30652: Reference required to assembly 'System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' containing the type 'ValueTuple(Of ,)'. Add one to your project. A.M() ~~~~~ ) @@ -19359,7 +19359,7 @@ Interface I End Interface , - references:={ValueTupleRef}) + references:={ValueTupleLegacyRef}) comp.AssertTheseEmitDiagnostics( BC30652: Reference required to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' containing the type 'ValueType'. Add one to your project. @@ -20066,7 +20066,7 @@ Module C End Module ]]> -, additionalRefs:={ValueTupleRef}) +, additionalRefs:={ValueTupleLegacyRef}) Assert.Equal(TypeKind.Class, comp.GetWellKnownType(WellKnownType.System_ValueTuple_T2).TypeKind) @@ -20113,7 +20113,6 @@ options:=TestOptions.ReleaseExe, additionalRefs:=s_valueTupleRefs) Dim comp = CreateCompilationWithMscorlib40AndVBRuntime( -Imports System Imports System.Collections.Generic Public Class C @@ -20122,7 +20121,7 @@ Public Class C End Function End Class -, additionalRefs:={ValueTupleRef}) +, additionalRefs:={ValueTupleLegacyRef}) comp.AssertTheseEmitDiagnostics( diff --git a/src/Compilers/VisualBasic/Test/Symbol/SymbolDisplay/SymbolDisplayTests.vb b/src/Compilers/VisualBasic/Test/Symbol/SymbolDisplay/SymbolDisplayTests.vb index f6a88d3fa4574..e67cb60331d87 100644 --- a/src/Compilers/VisualBasic/Test/Symbol/SymbolDisplay/SymbolDisplayTests.vb +++ b/src/Compilers/VisualBasic/Test/Symbol/SymbolDisplay/SymbolDisplayTests.vb @@ -5014,13 +5014,13 @@ End Class SymbolDisplayPartKind.Space, SymbolDisplayPartKind.Keyword, SymbolDisplayPartKind.Space, - SymbolDisplayPartKind.ClassName, + SymbolDisplayPartKind.StructName, SymbolDisplayPartKind.Punctuation, SymbolDisplayPartKind.Keyword, SymbolDisplayPartKind.Space, SymbolDisplayPartKind.StructName, SymbolDisplayPartKind.Punctuation}, - references:={MetadataReference.CreateFromImage(TestResources.NetFX.ValueTuple.tuplelib)}) + references:={Net461.ExtraReferences.SystemValueTuple}) End Sub diff --git a/src/EditorFeatures/Test/MetadataAsSource/AbstractMetadataAsSourceTests.cs b/src/EditorFeatures/Test/MetadataAsSource/AbstractMetadataAsSourceTests.cs index f5e13a0de22ca..8b641988f588b 100644 --- a/src/EditorFeatures/Test/MetadataAsSource/AbstractMetadataAsSourceTests.cs +++ b/src/EditorFeatures/Test/MetadataAsSource/AbstractMetadataAsSourceTests.cs @@ -28,7 +28,7 @@ public virtual Task InitializeAsync() AssemblyResolver.TestAccessor.AddInMemoryImage(TestBase.MscorlibRef_v46, "mscorlib.v4_6_1038_0.dll", ImmutableArray.Create(Net461.ReferenceInfos.mscorlib.ImageBytes)); AssemblyResolver.TestAccessor.AddInMemoryImage(TestBase.SystemRef_v46, "System.v4_6_1038_0.dll", ImmutableArray.Create(Net461.ReferenceInfos.System.ImageBytes)); AssemblyResolver.TestAccessor.AddInMemoryImage(TestBase.SystemCoreRef_v46, "System.Core.v4_6_1038_0.dll", ImmutableArray.Create(Net461.ReferenceInfos.SystemCore.ImageBytes)); - AssemblyResolver.TestAccessor.AddInMemoryImage(TestBase.ValueTupleRef, "System.ValueTuple.dll", ImmutableArray.Create(TestResources.NetFX.ValueTuple.tuplelib)); + AssemblyResolver.TestAccessor.AddInMemoryImage(TestBase.ValueTupleRef, "System.ValueTuple.dll", ImmutableArray.Create(Net461.ExtraReferenceInfos.SystemValueTuple.ImageBytes)); AssemblyResolver.TestAccessor.AddInMemoryImage(TestBase.SystemRuntimeFacadeRef, "System.Runtime.dll", ImmutableArray.Create(Net461.Resources.SystemRuntime)); AssemblyResolver.TestAccessor.AddInMemoryImage(TestBase.MsvbRef, "Microsoft.VisualBasic.dll", ImmutableArray.Create(Net461.Resources.MicrosoftVisualBasic)); AssemblyResolver.TestAccessor.AddInMemoryImage(TestBase.SystemXmlRef, "System.Xml.v4_0_30319.dll", ImmutableArray.Create(Net461.Resources.SystemXml)); diff --git a/src/EditorFeatures/Test/MetadataAsSource/MetadataAsSourceTests.CSharp.cs b/src/EditorFeatures/Test/MetadataAsSource/MetadataAsSourceTests.CSharp.cs index a782265a2c907..29e81ac37afbf 100644 --- a/src/EditorFeatures/Test/MetadataAsSource/MetadataAsSourceTests.CSharp.cs +++ b/src/EditorFeatures/Test/MetadataAsSource/MetadataAsSourceTests.CSharp.cs @@ -157,9 +157,9 @@ public class [|C|] {string.Format(FeaturesResources.Found_single_assembly_0, "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")} {string.Format(FeaturesResources.Load_from_0, "mscorlib.v4_6_1038_0.dll")} ------------------ -{string.Format(FeaturesResources.Resolve_0, "System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51")} -{string.Format(FeaturesResources.Found_single_assembly_0, "System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51")} -{string.Format(FeaturesResources.Load_from_0, "System.ValueTuple.dll")} +{string.Format(FeaturesResources.Resolve_0, "System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51")} +{string.Format(FeaturesResources.Found_single_assembly_0, "System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51")} +{string.Format(FeaturesResources.Load_from_0, "System.ValueTuple (net461)")} #endif", }; @@ -173,8 +173,8 @@ public async Task TestValueTuple(bool signaturesOnly) var expected = signaturesOnly switch { - true => $@"#region {FeaturesResources.Assembly} System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 -// System.ValueTuple.dll + true => $@"#region {FeaturesResources.Assembly} System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 +// System.ValueTuple (net461) #endregion using System.Collections; @@ -199,12 +199,13 @@ public struct [|ValueTuple|] : IEquatable, IStructuralEquatable, ISt public override string ToString(); }} }}", - false => $@"#region {FeaturesResources.Assembly} System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 -// System.ValueTuple.dll + false => $@"#region {FeaturesResources.Assembly} System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 +// System.ValueTuple (net461) // Decompiled with ICSharpCode.Decompiler {ICSharpCodeDecompilerVersion} #endregion using System.Collections; +using System.Numerics.Hashing; using System.Runtime.InteropServices; namespace System; @@ -336,67 +337,49 @@ public static (T1, T2, T3, T4, T5, T6, T7, T8) Create $@"#Region ""{FeaturesResources.Assembly} System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"" -' System.ValueTuple.dll + true => $@"#Region ""{FeaturesResources.Assembly} System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"" +' System.ValueTuple (net461) #End Region Imports System.Collections @@ -226,12 +226,13 @@ Public Overrides Function GetHashCode() As Integer Public Overrides Function ToString() As String End Structure End Namespace", - false => $@"#region {FeaturesResources.Assembly} System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 + false => $@"#region {FeaturesResources.Assembly} System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 // {FeaturesResources.location_unknown} // Decompiled with ICSharpCode.Decompiler {ICSharpCodeDecompilerVersion} #endregion using System.Collections; +using System.Numerics.Hashing; using System.Runtime.InteropServices; namespace System; @@ -363,67 +364,49 @@ public static (T1, T2, T3, T4, T5, T6, T7, T8) Create + WithRuntimeInstance(comp, [Net461.References.mscorlib, ValueTupleLegacyRef], runtime => { ImmutableArray blocks; Guid moduleVersionId; diff --git a/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/TupleTests.cs b/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/TupleTests.cs index 60da715ed7e0f..9398a0d79b427 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/TupleTests.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/TupleTests.cs @@ -434,8 +434,8 @@ static void M() { } }"; - var comp = CreateCompilationWithMscorlib40(source, new[] { ValueTupleRef, SystemRuntimeFacadeRef }, options: TestOptions.DebugDll); - WithRuntimeInstance(comp, new[] { ValueTupleRef, SystemRuntimeFacadeRef, MscorlibRef }, runtime => + var comp = CreateCompilationWithMscorlib40(source, new[] { ValueTupleLegacyRef, SystemRuntimeFacadeRef }, options: TestOptions.DebugDll); + WithRuntimeInstance(comp, new[] { ValueTupleLegacyRef, SystemRuntimeFacadeRef, MscorlibRef }, runtime => { var context = CreateMethodContext( runtime, @@ -499,8 +499,8 @@ static void M() { } }"; - var comp = CreateCompilationWithMscorlib40(source, new[] { SystemRuntimeFacadeRef, ValueTupleRef }, options: TestOptions.DebugDll); - WithRuntimeInstance(comp, new[] { MscorlibRef, SystemCoreRef, SystemRuntimeFacadeRef, ValueTupleRef }, runtime => + var comp = CreateCompilationWithMscorlib40(source, new[] { SystemRuntimeFacadeRef, ValueTupleLegacyRef }, options: TestOptions.DebugDll); + WithRuntimeInstance(comp, new[] { MscorlibRef, SystemCoreRef, SystemRuntimeFacadeRef, ValueTupleLegacyRef }, runtime => { var context = CreateMethodContext(runtime, "C.M"); var alias = new Alias( diff --git a/src/ExpressionEvaluator/VisualBasic/Test/ExpressionCompiler/MissingAssemblyTests.vb b/src/ExpressionEvaluator/VisualBasic/Test/ExpressionCompiler/MissingAssemblyTests.vb index 18338763d72f1..9a76d1d8ab6c1 100644 --- a/src/ExpressionEvaluator/VisualBasic/Test/ExpressionCompiler/MissingAssemblyTests.vb +++ b/src/ExpressionEvaluator/VisualBasic/Test/ExpressionCompiler/MissingAssemblyTests.vb @@ -16,6 +16,7 @@ Imports Microsoft.VisualStudio.Debugger.Evaluation Imports Roslyn.Test.Utilities Imports Roslyn.Utilities Imports Xunit +Imports Basic.Reference.Assemblies Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator.UnitTests Public Class MissingAssemblyTests @@ -668,10 +669,10 @@ End Class" Private Shared Sub TupleContextNoSystemRuntime(source As String, methodName As String, expression As String, expectedIL As String, Optional languageVersion As LanguageVersion = LanguageVersion.VisualBasic15) - Dim comp = CreateCompilationWithMscorlib40({source}, references:={ValueTupleRef, SystemRuntimeFacadeRef}, options:=TestOptions.DebugDll, + Dim comp = CreateEmptyCompilation({source}, references:={Net461.References.mscorlib, Net461.References.SystemRuntime, ValueTupleLegacyRef}, options:=TestOptions.DebugDll, parseOptions:=TestOptions.Regular.WithLanguageVersion(languageVersion)) - Using systemRuntime = SystemRuntimeFacadeRef.ToModuleInstance() - WithRuntimeInstance(comp, {MscorlibRef, ValueTupleRef}, + Using systemRuntime = Net461.References.SystemRuntime.ToModuleInstance() + WithRuntimeInstance(comp, {Net461.References.mscorlib, ValueTupleLegacyRef}, Sub(runtime) Dim methodBlocks As ImmutableArray(Of MetadataBlock) = Nothing Dim moduleVersionId As Guid = Nothing diff --git a/src/ExpressionEvaluator/VisualBasic/Test/ExpressionCompiler/TupleTests.vb b/src/ExpressionEvaluator/VisualBasic/Test/ExpressionCompiler/TupleTests.vb index a8629e8bd01f9..392a6a0893c11 100644 --- a/src/ExpressionEvaluator/VisualBasic/Test/ExpressionCompiler/TupleTests.vb +++ b/src/ExpressionEvaluator/VisualBasic/Test/ExpressionCompiler/TupleTests.vb @@ -429,8 +429,8 @@ End Class" Shared Sub M() End Sub End Class" - Dim comp = CreateCompilationWithMscorlib40({source}, references:={ValueTupleRef, SystemRuntimeFacadeRef}, options:=TestOptions.DebugDll) - WithRuntimeInstance(comp, {MscorlibRef, ValueTupleRef, SystemRuntimeFacadeRef}, + Dim comp = CreateCompilationWithMscorlib40({source}, references:={ValueTupleLegacyRef, SystemRuntimeFacadeRef}, options:=TestOptions.DebugDll) + WithRuntimeInstance(comp, {MscorlibRef, ValueTupleLegacyRef, SystemRuntimeFacadeRef}, Sub(runtime) Dim context = CreateMethodContext(runtime, "C.M") Dim locals = ArrayBuilder(Of LocalAndMethod).GetInstance() @@ -487,9 +487,9 @@ End Class" Shared Sub M() End Sub End Class" - Dim comp = CreateCompilationWithMscorlib40({source}, references:={SystemRuntimeFacadeRef, ValueTupleRef}, options:=TestOptions.DebugDll) + Dim comp = CreateCompilationWithMscorlib40({source}, references:={SystemRuntimeFacadeRef, ValueTupleLegacyRef}, options:=TestOptions.DebugDll) WithRuntimeInstance(comp, - {MscorlibRef, SystemCoreRef, SystemRuntimeFacadeRef, ValueTupleRef}, + {MscorlibRef, SystemCoreRef, SystemRuntimeFacadeRef, ValueTupleLegacyRef}, Sub(runtime) Dim context = CreateMethodContext(runtime, "C.M") Dim [alias] = New [Alias]( diff --git a/src/Features/Test/FindUsages/DefinitionItemFactoryTests.cs b/src/Features/Test/FindUsages/DefinitionItemFactoryTests.cs index 1dc05c322800e..e37bf86c3b4ad 100644 --- a/src/Features/Test/FindUsages/DefinitionItemFactoryTests.cs +++ b/src/Features/Test/FindUsages/DefinitionItemFactoryTests.cs @@ -353,7 +353,7 @@ public async Task ToClassifiedDefinitionItemAsync_Namespace_Metadata() "mscorlib 4.0.0.0 'Z:\\FxReferenceAssembliesUri'", "System 4.0.0.0 ''", "System.Core 4.0.0.0 ''", - "System.ValueTuple 4.0.1.0 ''", + "System.ValueTuple 4.0.3.0 'System.ValueTuple.dll'", "System.Runtime 4.0.20.0 ''" ], tags: @@ -405,7 +405,7 @@ namespace System { class D {} } "mscorlib 4.0.0.0 'Z:\\FxReferenceAssembliesUri'", "System 4.0.0.0 ''", "System.Core 4.0.0.0 ''", - "System.ValueTuple 4.0.1.0 ''", + "System.ValueTuple 4.0.3.0 'System.ValueTuple.dll'", "System.Runtime 4.0.20.0 ''" ], sourceSpans: @@ -735,7 +735,7 @@ public async Task ToClassifiedDefinitionItemAsync_TupleSyntax() // the symbol has metadata locations because the generic type is in metadata: metadataLocations: [ - "System.ValueTuple 4.0.1.0 ''" + "System.ValueTuple 4.0.3.0 'System.ValueTuple.dll'" ], tags: [ @@ -791,7 +791,7 @@ public async Task ToClassifiedDefinitionItemAsync_ValueTuple() ], metadataLocations: [ - "System.ValueTuple 4.0.1.0 ''" + "System.ValueTuple 4.0.3.0 'System.ValueTuple.dll'" ], tags: [ diff --git a/src/Workspaces/CSharpTest/CodeGeneration/SyntaxGeneratorTests.cs b/src/Workspaces/CSharpTest/CodeGeneration/SyntaxGeneratorTests.cs index 7158bcee3a6af..4949dfdd5c143 100644 --- a/src/Workspaces/CSharpTest/CodeGeneration/SyntaxGeneratorTests.cs +++ b/src/Workspaces/CSharpTest/CodeGeneration/SyntaxGeneratorTests.cs @@ -41,7 +41,7 @@ private SyntaxGenerator Generator public static Compilation Compile(string code) { return CSharpCompilation.Create("test") - .AddReferences(NetFramework.mscorlib, NetFramework.System, NetFramework.SystemCore, NetFramework.SystemRuntime, TestReferences.NetFx.ValueTuple.tuplelib) + .AddReferences(NetFramework.mscorlib, NetFramework.System, NetFramework.SystemCore, NetFramework.SystemRuntime, NetFramework.SystemValueTuple) .AddSyntaxTrees(ParseSyntaxTree(code)); }