Skip to content

Commit

Permalink
Update Roslyn to 4.13.0-1.24510.9 (#109467)
Browse files Browse the repository at this point in the history
* Update Roslyn to 4.13.0-1.24510.9

* Update roslyn-analyzers

* Fix first-class Span breaks

* Remove LangVersion=latest

* Fixup more places

* Updates and fixes

---------

Co-authored-by: Jan Jones <janjones@microsoft.com>
  • Loading branch information
am11 and jjonescz authored Nov 2, 2024
1 parent c7190e3 commit 1e41404
Show file tree
Hide file tree
Showing 20 changed files with 76 additions and 65 deletions.
16 changes: 8 additions & 8 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -380,17 +380,17 @@
<Uri>https://github.com/dotnet/runtime-assets</Uri>
<Sha>8254bfd574d0f7a89450a2e191d9e9f3dfb8ad59</Sha>
</Dependency>
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="4.12.0-3.24523.10">
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="4.13.0-2.24531.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>16f58fa314e7deff4b3df36c862f157609ace2b4</Sha>
<Sha>9bb57bf3b4a88a3d3c1fabb95e7b34d03da1478c</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis" Version="4.12.0-3.24523.10">
<Dependency Name="Microsoft.CodeAnalysis" Version="4.13.0-2.24531.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>16f58fa314e7deff4b3df36c862f157609ace2b4</Sha>
<Sha>9bb57bf3b4a88a3d3c1fabb95e7b34d03da1478c</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp" Version="4.12.0-3.24523.10">
<Dependency Name="Microsoft.CodeAnalysis.CSharp" Version="4.13.0-2.24531.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>16f58fa314e7deff4b3df36c862f157609ace2b4</Sha>
<Sha>9bb57bf3b4a88a3d3c1fabb95e7b34d03da1478c</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Analyzers" Version="3.12.0-beta1.24516.1">
<Uri>https://github.com/dotnet/roslyn-analyzers</Uri>
Expand All @@ -401,9 +401,9 @@
<Sha>5dd0dd5db8fa79932517f153854c0f2c24ac98a3</Sha>
</Dependency>
<!-- Intermediate is necessary for source build. -->
<Dependency Name="Microsoft.SourceBuild.Intermediate.roslyn" Version="4.12.0-3.24523.10">
<Dependency Name="Microsoft.SourceBuild.Intermediate.roslyn" Version="4.13.0-2.24531.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>16f58fa314e7deff4b3df36c862f157609ace2b4</Sha>
<Sha>9bb57bf3b4a88a3d3c1fabb95e7b34d03da1478c</Sha>
<SourceBuild RepoName="roslyn" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.DotNet.ApiCompat.Task" Version="10.0.100-alpha.1.24480.5">
Expand Down
6 changes: 3 additions & 3 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
Any tools that contribute to the design-time experience should use the MicrosoftCodeAnalysisVersion_LatestVS property above to ensure
they do not break the local dev experience.
-->
<MicrosoftCodeAnalysisCSharpVersion>4.12.0-3.24523.10</MicrosoftCodeAnalysisCSharpVersion>
<MicrosoftCodeAnalysisVersion>4.12.0-3.24523.10</MicrosoftCodeAnalysisVersion>
<MicrosoftNetCompilersToolsetVersion>4.12.0-3.24523.10</MicrosoftNetCompilersToolsetVersion>
<MicrosoftCodeAnalysisCSharpVersion>4.13.0-2.24531.4</MicrosoftCodeAnalysisCSharpVersion>
<MicrosoftCodeAnalysisVersion>4.13.0-2.24531.4</MicrosoftCodeAnalysisVersion>
<MicrosoftNetCompilersToolsetVersion>4.13.0-2.24531.4</MicrosoftNetCompilersToolsetVersion>
</PropertyGroup>
<!--
For source generator support we need to target multiple versions of Roslyn in order to be able to run on older versions of Roslyn.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ private IEnumerable<string> VerifyReferences (AssemblyDefinition original, Assem
.Select (name => name.Name)
.ToArray ();

if (!actual.SequenceEqual(expected))
if (!actual!.SequenceEqual(expected))
yield return $"Expected references do not match actual references:\n\tExpected: {string.Join(", ", expected)}\n\tActual: {string.Join(", ", actual)}";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ public void DisposesInReverseOrderOfCreation()

// Assert
Assert.Equal(outer, callback.Disposed[0]);
Assert.Equal(multipleServices.Reverse(), callback.Disposed.Skip(1).Take(3).OfType<IFakeMultipleService>());
Assert.Equal(Enumerable.Reverse(multipleServices), callback.Disposed.Skip(1).Take(3).OfType<IFakeMultipleService>());
Assert.Equal(outer.SingleService, callback.Disposed[4]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,19 +453,19 @@ public void DefaultNullOrEmpty_Concat(StringValues stringValues)
{
string[] expected = new[] { "abc", "bcd", "foo" };
StringValues expectedStringValues = new StringValues(expected);
Assert.Equal(expected, StringValues.Concat(stringValues, expectedStringValues));
Assert.Equal(expected, StringValues.Concat(expectedStringValues, stringValues));
Assert.Equal(expected, StringValues.Concat((string)null, in expectedStringValues));
Assert.Equal(expected, StringValues.Concat(in expectedStringValues, (string)null));
Assert.Equal(expected, StringValues.Concat(stringValues, expectedStringValues).ToArray());
Assert.Equal(expected, StringValues.Concat(expectedStringValues, stringValues).ToArray());
Assert.Equal(expected, StringValues.Concat((string)null, in expectedStringValues).ToArray());
Assert.Equal(expected, StringValues.Concat(in expectedStringValues, (string)null).ToArray());

string[] empty = new string[0];
StringValues emptyStringValues = new StringValues(empty);
Assert.Equal(empty, StringValues.Concat(stringValues, StringValues.Empty));
Assert.Equal(empty, StringValues.Concat(StringValues.Empty, stringValues));
Assert.Equal(empty, StringValues.Concat(stringValues, new StringValues()));
Assert.Equal(empty, StringValues.Concat(new StringValues(), stringValues));
Assert.Equal(empty, StringValues.Concat((string)null, in emptyStringValues));
Assert.Equal(empty, StringValues.Concat(in emptyStringValues, (string)null));
Assert.Equal(empty, StringValues.Concat(stringValues, StringValues.Empty).ToArray());
Assert.Equal(empty, StringValues.Concat(StringValues.Empty, stringValues).ToArray());
Assert.Equal(empty, StringValues.Concat(stringValues, new StringValues()).ToArray());
Assert.Equal(empty, StringValues.Concat(new StringValues(), stringValues).ToArray());
Assert.Equal(empty, StringValues.Concat((string)null, in emptyStringValues).ToArray());
Assert.Equal(empty, StringValues.Concat(in emptyStringValues, (string)null).ToArray());
}

[Theory]
Expand All @@ -475,24 +475,24 @@ public void Concat(StringValues stringValues, string[] array)
string[] filled = new[] { "abc", "bcd", "foo" };

string[] expectedPrepended = array.Concat(filled).ToArray();
Assert.Equal(expectedPrepended, StringValues.Concat(stringValues, new StringValues(filled)));
Assert.Equal(expectedPrepended, StringValues.Concat(stringValues, new StringValues(filled)).ToArray());

string[] expectedAppended = filled.Concat(array).ToArray();
Assert.Equal(expectedAppended, StringValues.Concat(new StringValues(filled), stringValues));
Assert.Equal(expectedAppended, StringValues.Concat(new StringValues(filled), stringValues).ToArray());

StringValues values = stringValues;
foreach (string s in filled)
{
values = StringValues.Concat(in values, s);
}
Assert.Equal(expectedPrepended, values);
Assert.Equal(expectedPrepended, (string[])values);

values = stringValues;
foreach (string s in filled.Reverse())
foreach (string s in Enumerable.Reverse(filled))
{
values = StringValues.Concat(s, in values);
}
Assert.Equal(expectedAppended, values);
Assert.Equal(expectedAppended, (string[])values);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public void PeekRef_Empty()
protected override IEnumerable<T> GetEnumerableOf<T>(params T[] contents)
{
ImmutableStack<T> stack = ImmutableStack<T>.Empty;
foreach (T value in contents.Reverse())
foreach (T value in Enumerable.Reverse(contents))
{
stack = stack.Push(value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public static void Set_CustomComparerTest()

int visited = s_dictionaryData.Length;

Assert.All(s_dictionaryData.Reverse(), element =>
Assert.All(Enumerable.Reverse(s_dictionaryData), element =>
{
string newValue = "new" + element.Value;
Assert.True(ld.Contains(element.Key));
Expand All @@ -154,7 +154,7 @@ public static void Remove_CustomComparerTest()
ObservableStringComparer comparer = new ObservableStringComparer();
ListDictionary ld = Fill(new ListDictionary(comparer), s_dictionaryData);

Assert.All(s_dictionaryData.Reverse(), element =>
Assert.All(Enumerable.Reverse(s_dictionaryData), element =>
{
int originalSize = ld.Count;
Assert.True(ld.Contains(element.Key));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ public void Queue_Generic_ToArray_NonWrappedQueue(int count)
Queue<T> collection = new Queue<T>(count + 1);
AddToCollection(collection, count);
T[] elements = collection.ToArray();
elements.Reverse();
Assert.True(Enumerable.SequenceEqual(elements, collection.ToArray<T>()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void Stack_Generic_Constructor_IEnumerable(EnumerableType enumerableType,
_ = numberOfMatchingElements;
IEnumerable<T> enumerable = CreateEnumerable(enumerableType, null, enumerableLength, 0, numberOfDuplicateElements);
Stack<T> stack = new Stack<T>(enumerable);
Assert.Equal(enumerable.ToArray().Reverse(), stack.ToArray());
Assert.Equal(Enumerable.Reverse(enumerable.ToArray()), stack.ToArray());
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ private static CompositionError CreateCompositionError(CompositionErrorId id, st
private static CompositionError CreateCompositionError(params string[] messages)
{
CompositionError error = null;
foreach (string message in messages.Reverse())
foreach (string message in Enumerable.Reverse(messages))
{
CompositionException exception = null;
if (error != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ public void WriteFooterTest_LogicalOperationStack()
listener.Flush();

Assert.Contains("LogicalOperationStack=", listener.Output);
Assert.Contains(string.Join(", ", items.Reverse()), listener.Output);
Assert.Contains(string.Join(", ", Enumerable.Reverse(items)), listener.Output);
}
finally
{
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/System.Memory/tests/Memory/CopyTo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static void TryCopyToArraySegmentImplicit()
Memory<int> srcMemory = src;
bool success = srcMemory.TryCopyTo(segment);
Assert.True(success);
Assert.Equal(src, segment);
Assert.Equal(src.AsSpan(), segment);
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/System.Memory/tests/ReadOnlySpan/CopyTo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static void TryCopyToArraySegmentImplicit()
ReadOnlySpan<int> srcSpan = new ReadOnlySpan<int>(src);
bool success = srcSpan.TryCopyTo(segment);
Assert.True(success);
Assert.Equal(src, segment);
Assert.Equal(src.AsSpan(), segment);
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/System.Memory/tests/Span/CopyTo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static void TryCopyToArraySegmentImplicit()
Span<int> srcSpan = new Span<int>(src);
bool success = srcSpan.TryCopyTo(segment);
Assert.True(success);
Assert.Equal(src, segment);
Assert.Equal(src.AsSpan(), segment);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ internal static void GetStoreValuesAsStringOrStringArray(HeaderDescriptor descri
else
{
Debug.Assert(length > 1, "The header should have been removed when it became empty");
values = multiValue = new string[length];
values = (multiValue = new string[length])!;
}

int currentIndex = 0;
Expand Down Expand Up @@ -1205,8 +1205,8 @@ internal static int GetStoreValuesIntoStringArray(HeaderDescriptor descriptor, o
}

int currentIndex = 0;
ReadStoreValues<object?>(values, info.ParsedAndInvalidValues, descriptor.Parser, ref currentIndex);
ReadStoreValues<string?>(values, info.RawValue, null, ref currentIndex);
ReadStoreValues<object?>(values!, info.ParsedAndInvalidValues, descriptor.Parser, ref currentIndex);
ReadStoreValues<string?>(values!, info.RawValue, null, ref currentIndex);
Debug.Assert(currentIndex == length);

return length;
Expand Down
40 changes: 20 additions & 20 deletions src/libraries/System.Numerics.Tensors/tests/TensorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ public static void TensorMultiplyTests()
Tensor<int> t1 = Tensor.Create(Enumerable.Range(0, 3), [3, 1]);
Tensor<int> t2 = Tensor.Multiply(t0.AsReadOnlyTensorSpan(), t1);

Assert.Equal([3,3], t2.Lengths.ToArray());
Assert.Equal([3,3], t2.Lengths);
Assert.Equal(0, t2[0, 0]);
Assert.Equal(0, t2[0, 1]);
Assert.Equal(0, t2[0, 2]);
Expand All @@ -697,7 +697,7 @@ public static void TensorMultiplyTests()

t2 = Tensor.Multiply(t1.AsReadOnlyTensorSpan(), t0);

Assert.Equal([3, 3], t2.Lengths.ToArray());
Assert.Equal([3, 3], t2.Lengths);
Assert.Equal(0, t2[0, 0]);
Assert.Equal(0, t2[0, 1]);
Assert.Equal(0, t2[0, 2]);
Expand All @@ -711,7 +711,7 @@ public static void TensorMultiplyTests()
t1 = Tensor.Create(Enumerable.Range(0, 9), [3, 3]);
t2 = Tensor.Multiply(t0.AsReadOnlyTensorSpan(), t1);

Assert.Equal([3, 3], t2.Lengths.ToArray());
Assert.Equal([3, 3], t2.Lengths);
Assert.Equal(0, t2[0, 0]);
Assert.Equal(1, t2[0, 1]);
Assert.Equal(4, t2[0, 2]);
Expand All @@ -729,7 +729,7 @@ public static void TensorBroadcastTests()
Tensor<int> t0 = Tensor.Create(Enumerable.Range(0, 3), [1, 3, 1, 1, 1]);
Tensor<int> t1 = Tensor.Broadcast<int>(t0, [1, 3, 1, 2, 1]);

Assert.Equal([1, 3, 1, 2, 1], t1.Lengths.ToArray());
Assert.Equal([1, 3, 1, 2, 1], t1.Lengths);

Assert.Equal(0, t1[0, 0, 0, 0, 0]);
Assert.Equal(0, t1[0, 0, 0, 1, 0]);
Expand All @@ -739,7 +739,7 @@ public static void TensorBroadcastTests()
Assert.Equal(2, t1[0, 2, 0, 1, 0]);

t1 = Tensor.Broadcast<int>(t0, [1, 3, 2, 1, 1]);
Assert.Equal([1, 3, 2, 1, 1], t1.Lengths.ToArray());
Assert.Equal([1, 3, 2, 1, 1], t1.Lengths);

Assert.Equal(0, t1[0, 0, 0, 0, 0]);
Assert.Equal(0, t1[0, 0, 1, 0, 0]);
Expand All @@ -751,7 +751,7 @@ public static void TensorBroadcastTests()
t0 = Tensor.Create(Enumerable.Range(0, 3), [1, 3]);
t1 = Tensor.Create(Enumerable.Range(0, 3), [3, 1]);
var t2 = Tensor.Broadcast<int>(t0, [3, 3]);
Assert.Equal([3, 3], t2.Lengths.ToArray());
Assert.Equal([3, 3], t2.Lengths);

Assert.Equal(0, t2[0, 0]);
Assert.Equal(1, t2[0, 1]);
Expand All @@ -765,7 +765,7 @@ public static void TensorBroadcastTests()

t1 = Tensor.Create(Enumerable.Range(0, 3), [3, 1]);
t2 = Tensor.Broadcast<int>(t1, [3, 3]);
Assert.Equal([3, 3], t2.Lengths.ToArray());
Assert.Equal([3, 3], t2.Lengths);

Assert.Equal(0, t2[0, 0]);
Assert.Equal(0, t2[0, 1]);
Expand All @@ -789,11 +789,11 @@ public static void TensorBroadcastTests()
Assert.Equal(2, s1[2, 2]);

var t3 = t2.Slice(0..1, ..);
Assert.Equal([1, 3], t3.Lengths.ToArray());
Assert.Equal([1, 3], t3.Lengths);

t1 = Tensor.Create(Enumerable.Range(0, 3), default);
t2 = Tensor.Broadcast<int>(t1, [3, 3]);
Assert.Equal([3, 3], t2.Lengths.ToArray());
Assert.Equal([3, 3], t2.Lengths);

Assert.Equal(0, t2[0, 0]);
Assert.Equal(1, t2[0, 1]);
Expand All @@ -811,15 +811,15 @@ public static void TensorResizeTests()
{
Tensor<int> t0 = Tensor.Create(Enumerable.Range(0, 8), [2, 2, 2]);
var t1 = Tensor.Resize(t0, [1]);
Assert.Equal([1], t1.Lengths.ToArray());
Assert.Equal([1], t1.Lengths);
Assert.Equal(0, t1[0]);

t1 = Tensor.Resize(t0, [1, 1]);
Assert.Equal([1, 1], t1.Lengths.ToArray());
Assert.Equal([1, 1], t1.Lengths);
Assert.Equal(0, t1[0, 0]);

t1 = Tensor.Resize(t0, [6]);
Assert.Equal([6], t1.Lengths.ToArray());
Assert.Equal([6], t1.Lengths);
Assert.Equal(0, t1[0]);
Assert.Equal(1, t1[1]);
Assert.Equal(2, t1[2]);
Expand All @@ -828,7 +828,7 @@ public static void TensorResizeTests()
Assert.Equal(5, t1[5]);

t1 = Tensor.Resize(t0, [10]);
Assert.Equal([10], t1.Lengths.ToArray());
Assert.Equal([10], t1.Lengths);
Assert.Equal(0, t1[0]);
Assert.Equal(1, t1[1]);
Assert.Equal(2, t1[2]);
Expand All @@ -841,7 +841,7 @@ public static void TensorResizeTests()
Assert.Equal(0, t1[9]);

t1 = Tensor.Resize(t0, [2, 5]);
Assert.Equal([2, 5], t1.Lengths.ToArray());
Assert.Equal([2, 5], t1.Lengths);
Assert.Equal(0, t1[0, 0]);
Assert.Equal(1, t1[0, 1]);
Assert.Equal(2, t1[0, 2]);
Expand All @@ -859,8 +859,8 @@ public static void TensorSplitTests()
{
Tensor<int> t0 = Tensor.Create(Enumerable.Range(0, 8), [2, 2, 2]);
var t1 = Tensor.Split<int>(t0, 2, 0);
Assert.Equal([1, 2, 2], t1[0].Lengths.ToArray());
Assert.Equal([1, 2, 2], t1[1].Lengths.ToArray());
Assert.Equal([1, 2, 2], t1[0].Lengths);
Assert.Equal([1, 2, 2], t1[1].Lengths);
Assert.Equal(0, t1[0][0, 0, 0]);
Assert.Equal(1, t1[0][0, 0, 1]);
Assert.Equal(2, t1[0][0, 1, 0]);
Expand All @@ -871,8 +871,8 @@ public static void TensorSplitTests()
Assert.Equal(7, t1[1][0, 1, 1]);

t1 = Tensor.Split<int>(t0, 2, 1);
Assert.Equal([2, 1, 2], t1[0].Lengths.ToArray());
Assert.Equal([2, 1, 2], t1[1].Lengths.ToArray());
Assert.Equal([2, 1, 2], t1[0].Lengths);
Assert.Equal([2, 1, 2], t1[1].Lengths);
Assert.Equal(0, t1[0][0, 0, 0]);
Assert.Equal(1, t1[0][0, 0, 1]);
Assert.Equal(4, t1[0][1, 0, 0]);
Expand All @@ -883,8 +883,8 @@ public static void TensorSplitTests()
Assert.Equal(7, t1[1][1, 0, 1]);

t1 = Tensor.Split<int>(t0, 2, 2);
Assert.Equal([2, 2, 1], t1[0].Lengths.ToArray());
Assert.Equal([2, 2, 1], t1[1].Lengths.ToArray());
Assert.Equal([2, 2, 1], t1[0].Lengths);
Assert.Equal([2, 2, 1], t1[1].Lengths);
Assert.Equal(0, t1[0][0, 0, 0]);
Assert.Equal(2, t1[0][0, 1, 0]);
Assert.Equal(4, t1[0][1, 0, 0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ internal static ObjectHandleOnStack Create<T>(ref T o) where T : class?
internal ref struct ByteRef
{
private ref byte _ref;

internal ByteRef(ref byte byteReference)
{
_ref = ref byteReference;
}

internal ref byte Get()
{
return ref _ref;
Expand Down
Loading

0 comments on commit 1e41404

Please sign in to comment.