diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs index c19a3e0b9b6b837f20e21c6e1c5238bd8d4adb5a..aefc9f31f5b81f0ba706916fae862b15e0c21615 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs @@ -4830,6 +4830,8 @@ public void CreateTupleTypeSymbol_WithValueTuple() Assert.True(tupleWithoutNames.TupleElementNames.IsDefault); Assert.Equal(new[] { "System.Int32", "System.String" }, tupleWithoutNames.TupleElementTypes.Select(t => t.ToTestDisplayString())); Assert.Equal(SymbolKind.NamedType, tupleWithoutNames.Kind); + Assert.All(tupleWithoutNames.GetMembers().OfType().Select(f => f.Locations.FirstOrDefault()), + loc => Assert.Equal(loc, null)); } [Fact] @@ -4873,6 +4875,8 @@ public void CreateTupleTypeSymbol_NoNames() Assert.True(tupleWithoutNames.TupleElementNames.IsDefault); Assert.Equal(new[] { "System.Int32", "System.String" }, tupleWithoutNames.TupleElementTypes.Select(t => t.ToTestDisplayString())); Assert.Equal(SymbolKind.NamedType, tupleWithoutNames.Kind); + Assert.All(tupleWithoutNames.GetMembers().OfType().Select(f => f.Locations.FirstOrDefault()), + loc => Assert.Equal(loc, null)); } [Fact] @@ -4890,6 +4894,8 @@ public void CreateTupleTypeSymbol_WithNames() Assert.Equal(new[] { "Alice", "Bob" }, tupleWithNames.TupleElementNames); Assert.Equal(new[] { "System.Int32", "System.String" }, tupleWithNames.TupleElementTypes.Select(t => t.ToTestDisplayString())); Assert.Equal(SymbolKind.NamedType, tupleWithNames.Kind); + Assert.All(tupleWithNames.GetMembers().OfType().Select(f => f.Locations.FirstOrDefault()), + loc => Assert.Equal(loc, null)); } [Fact] @@ -4907,6 +4913,8 @@ public void CreateTupleTypeSymbol_WithSomeNames() Assert.Equal(new[] { null, "Item2", "Charlie" }, tupleWithSomeNames.TupleElementNames); Assert.Equal(new[] { "System.Int32", "System.String", "System.Int32" }, tupleWithSomeNames.TupleElementTypes.Select(t => t.ToTestDisplayString())); Assert.Equal(SymbolKind.NamedType, tupleWithSomeNames.Kind); + Assert.All(tupleWithSomeNames.GetMembers().OfType().Select(f => f.Locations.FirstOrDefault()), + loc => Assert.Equal(loc, null)); } [Fact] @@ -4923,6 +4931,8 @@ public void CreateTupleTypeSymbol_WithBadNames() Assert.Equal(new[] { "Item2", "Item1" }, tupleWithNames.TupleElementNames); Assert.Equal(new[] { "System.Int32", "System.Int32" }, tupleWithNames.TupleElementTypes.Select(t => t.ToTestDisplayString())); Assert.Equal(SymbolKind.NamedType, tupleWithNames.Kind); + Assert.All(tupleWithNames.GetMembers().OfType().Select(f => f.Locations.FirstOrDefault()), + loc => Assert.Equal(loc, null)); } [Fact] @@ -4945,6 +4955,8 @@ public void CreateTupleTypeSymbol_Tuple8NoNames() Assert.Equal(new[] { "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String" }, tuple8WithoutNames.TupleElementTypes.Select(t => t.ToTestDisplayString())); + Assert.All(tuple8WithoutNames.GetMembers().OfType().Select(f => f.Locations.FirstOrDefault()), + loc => Assert.Equal(loc, null)); } [Fact] @@ -4968,6 +4980,8 @@ public void CreateTupleTypeSymbol_Tuple8WithNames() Assert.Equal(new[] { "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String" }, tuple8WithNames.TupleElementTypes.Select(t => t.ToTestDisplayString())); + Assert.All(tuple8WithNames.GetMembers().OfType().Select(f => f.Locations.FirstOrDefault()), + loc => Assert.Equal(loc, null)); } [Fact] @@ -4991,6 +5005,8 @@ public void CreateTupleTypeSymbol_Tuple9NoNames() Assert.Equal(new[] { "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32" }, tuple9WithoutNames.TupleElementTypes.Select(t => t.ToTestDisplayString())); + Assert.All(tuple9WithoutNames.GetMembers().OfType().Select(f => f.Locations.FirstOrDefault()), + loc => Assert.Equal(loc, null)); } [Fact] @@ -5014,6 +5030,9 @@ public void CreateTupleTypeSymbol_Tuple9WithNames() Assert.Equal(new[] { "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32" }, tuple9WithNames.TupleElementTypes.Select(t => t.ToTestDisplayString())); + + Assert.All(tuple9WithNames.GetMembers().OfType().Select(f => f.Locations.FirstOrDefault()), + loc => Assert.Equal(loc, null)); } [Fact] @@ -5040,6 +5059,9 @@ public void CreateTupleTypeSymbol_Tuple9WithDefaultNames() Assert.Equal(new[] { "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.Int32", "System.Int32" }, tuple9WithNames.TupleElementTypes.Select(t => t.ToTestDisplayString())); + + Assert.All(tuple9WithNames.GetMembers().OfType().Select(f => f.Locations.FirstOrDefault()), + loc => Assert.Equal(loc, null)); } [Fact] @@ -5060,6 +5082,8 @@ public void CreateTupleTypeSymbol_ElementTypeIsError() Assert.Equal(2, types.Length); Assert.Equal(SymbolKind.NamedType, types[0].Kind); Assert.Equal(SymbolKind.ErrorType, types[1].Kind); + Assert.All(tupleWithoutNames.GetMembers().OfType().Select(f => f.Locations.FirstOrDefault()), + loc => Assert.Equal(loc, null)); } [Fact, WorkItem(13277, "https://github.com/dotnet/roslyn/issues/13277")] diff --git a/src/Compilers/Core/Portable/Compilation/Compilation.cs b/src/Compilers/Core/Portable/Compilation/Compilation.cs index badffbe0291817f3081df29855ec2132d8510cd4..e56911a45dac82e501ee7712777836e86d9376e2 100644 --- a/src/Compilers/Core/Portable/Compilation/Compilation.cs +++ b/src/Compilers/Core/Portable/Compilation/Compilation.cs @@ -885,7 +885,8 @@ protected static ImmutableArray CheckTupleElementNames(int cardinality, return elementNames; } - protected static void CheckTupleElementLocations(int cardinality, + protected static void CheckTupleElementLocations( + int cardinality, ImmutableArray elementLocations) { if (!elementLocations.IsDefault) diff --git a/src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb b/src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb index 31948de34a65a3349826b996bec72759e039668a..f0ca52194d02d688424ef61f3147858c65f9222d 100644 --- a/src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb +++ b/src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb @@ -5059,7 +5059,8 @@ End Class Assert.True(tupleWithoutNames.TupleElementNames.IsDefault) Assert.Equal(New String() {"System.Int32", "System.String"}, tupleWithoutNames.TupleElementTypes.Select(Function(t) t.ToTestDisplayString())) Assert.Equal(SymbolKind.NamedType, tupleWithoutNames.Kind) - + Assert.All(tupleWithoutNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()), + Sub(Loc) Assert.Equal(Loc, Nothing)) End Sub @@ -5107,7 +5108,8 @@ End Class Assert.True(tupleWithoutNames.TupleElementNames.IsDefault) Assert.Equal(New String() {"System.Int32", "System.String"}, tupleWithoutNames.TupleElementTypes.Select(Function(t) t.ToTestDisplayString())) Assert.Equal(SymbolKind.NamedType, tupleWithoutNames.Kind) - + Assert.All(tupleWithoutNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()), + Sub(Loc) Assert.Equal(Loc, Nothing)) End Sub @@ -5126,7 +5128,8 @@ End Class Assert.Equal(New String() {"Alice", "Bob"}, tupleWithoutNames.TupleElementNames) Assert.Equal(New String() {"System.Int32", "System.String"}, tupleWithoutNames.TupleElementTypes.Select(Function(t) t.ToTestDisplayString())) Assert.Equal(SymbolKind.NamedType, tupleWithoutNames.Kind) - + Assert.All(tupleWithoutNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()), + Sub(Loc) Assert.Equal(Loc, Nothing)) End Sub @@ -5148,7 +5151,8 @@ End Class tupleWithSomeNames.TupleElementTypes.Select(Function(t) t.ToTestDisplayString())) Assert.Equal(SymbolKind.NamedType, tupleWithSomeNames.Kind) - + Assert.All(tupleWithSomeNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()), + Sub(Loc) Assert.Equal(Loc, Nothing)) End Sub @@ -5165,7 +5169,8 @@ End Class Assert.Equal(New String() {"Item2", "Item1"}, tupleWithoutNames.TupleElementNames) Assert.Equal(New String() {"System.Int32", "System.Int32"}, tupleWithoutNames.TupleElementTypes.Select(Function(t) t.ToTestDisplayString())) Assert.Equal(SymbolKind.NamedType, tupleWithoutNames.Kind) - + Assert.All(tupleWithoutNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()), + Sub(Loc) Assert.Equal(Loc, Nothing)) End Sub @@ -5189,7 +5194,8 @@ End Class Assert.Equal(New String() {"System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String"}, tuple8WithoutNames.TupleElementTypes.Select(Function(t) t.ToTestDisplayString())) - + Assert.All(tuple8WithoutNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()), + Sub(Loc) Assert.Equal(Loc, Nothing)) End Sub @@ -5213,7 +5219,8 @@ End Class Assert.Equal(New String() {"System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String"}, tuple8WithNames.TupleElementTypes.Select(Function(t) t.ToTestDisplayString())) - + Assert.All(tuple8WithNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()), + Sub(Loc) Assert.Equal(Loc, Nothing)) End Sub @@ -5237,7 +5244,8 @@ End Class Assert.Equal(New String() {"System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32"}, tuple9WithoutNames.TupleElementTypes.Select(Function(t) t.ToTestDisplayString())) - + Assert.All(tuple9WithoutNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()), + Sub(Loc) Assert.Equal(Loc, Nothing)) End Sub @@ -5261,7 +5269,8 @@ End Class Assert.Equal(New String() {"System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32"}, tuple9WithNames.TupleElementTypes.Select(Function(t) t.ToTestDisplayString())) - + Assert.All(tuple9WithNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()), + Sub(Loc) Assert.Equal(Loc, Nothing)) End Sub @@ -5285,7 +5294,8 @@ End Class Assert.Equal(New String() {"System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32"}, tuple9WithNames.TupleElementTypes.Select(Function(t) t.ToTestDisplayString())) - + Assert.All(tuple9WithNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()), + Sub(Loc) Assert.Equal(Loc, Nothing)) End Sub @@ -5308,7 +5318,8 @@ End Class Assert.Equal(2, types.Length) Assert.Equal(SymbolKind.NamedType, types(0).Kind) Assert.Equal(SymbolKind.ErrorType, types(1).Kind) - + Assert.All(tupleWithoutNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()), + Sub(Loc) Assert.Equal(Loc, Nothing)) End Sub