Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<Dependencies>
<ProductDependencies>
<Dependency Name="Microsoft.NETCore.Runtime.CoreCLR" Version="3.0.0-preview-27404-71">
<Dependency Name="Microsoft.NETCore.Runtime.CoreCLR" Version="3.0.0-preview-27410-72">
<Uri>https://github.com/dotnet/coreclr</Uri>
<Sha>a51af0838709ca81b51bee236865a39b31f68f41</Sha>
<Sha>70cf6d489032f42c9f643d59825c994c0402a3f7</Sha>
</Dependency>
<Dependency Name="Microsoft.NETCore.ILAsm" Version="3.0.0-preview-27404-71">
<Dependency Name="Microsoft.NETCore.ILAsm" Version="3.0.0-preview-27410-72">
<Uri>https://github.com/dotnet/coreclr</Uri>
<Sha>a51af0838709ca81b51bee236865a39b31f68f41</Sha>
<Sha>70cf6d489032f42c9f643d59825c994c0402a3f7</Sha>
</Dependency>
<Dependency Name="Microsoft.NET.Sdk.IL" Version="3.0.0-preview-27404-71">
<Dependency Name="Microsoft.NET.Sdk.IL" Version="3.0.0-preview-27410-72">
<Uri>https://github.com/dotnet/coreclr</Uri>
<Sha>a51af0838709ca81b51bee236865a39b31f68f41</Sha>
<Sha>70cf6d489032f42c9f643d59825c994c0402a3f7</Sha>
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
Expand Down
4 changes: 2 additions & 2 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
<MicrosoftNETCoreDotNetHostPackageVersion>3.0.0-preview-27330-4</MicrosoftNETCoreDotNetHostPackageVersion>
<MicrosoftNETCoreDotNetHostPolicyPackageVersion>3.0.0-preview-27330-4</MicrosoftNETCoreDotNetHostPolicyPackageVersion>
<!-- Coreclr dependencies -->
<MicrosoftNETCoreILAsmPackageVersion>3.0.0-preview-27404-71</MicrosoftNETCoreILAsmPackageVersion>
<MicrosoftNETCoreRuntimeCoreCLRPackageVersion>3.0.0-preview-27404-71</MicrosoftNETCoreRuntimeCoreCLRPackageVersion>
<MicrosoftNETCoreILAsmPackageVersion>3.0.0-preview-27410-72</MicrosoftNETCoreILAsmPackageVersion>
<MicrosoftNETCoreRuntimeCoreCLRPackageVersion>3.0.0-preview-27410-72</MicrosoftNETCoreRuntimeCoreCLRPackageVersion>
<!-- Corefx dependencies -->
<MicrosoftNETCorePlatformsPackageVersion>3.0.0-preview.19106.1</MicrosoftNETCorePlatformsPackageVersion>
<!-- Standard dependencies -->
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"msbuild-sdks": {
"Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19081.1",
"Microsoft.DotNet.Helix.Sdk": "2.0.0-beta.19081.1",
"Microsoft.NET.Sdk.IL": "3.0.0-preview-27404-71"
"Microsoft.NET.Sdk.IL": "3.0.0-preview-27410-72"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
<Configurations>netcoreapp-Unix-Debug;netcoreapp-Unix-Release;netcoreapp-Windows_NT-Debug;netcoreapp-Windows_NT-Release;netcoreappaot-Windows_NT-Debug;netcoreappaot-Windows_NT-Release;uap-Windows_NT-Debug;uap-Windows_NT-Release;uapaot-Windows_NT-Debug;uapaot-Windows_NT-Release</Configurations>
</PropertyGroup>
<!-- Default configurations to help VS understand the options -->
<ItemGroup>
<ItemGroup Condition="'$(TargetGroup)'=='uapaot' or '$(TargetGroup)'=='netcoreappaot'">
<Compile Include="FxCopBaseline.cs" />
<Compile Include="$(CommonPath)\CoreLib\System\Diagnostics\Tracing\EventCounter.cs" />
</ItemGroup>
Expand Down
8 changes: 8 additions & 0 deletions src/System.Memory/ref/System.Memory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,29 @@ public static partial class MemoryExtensions
public static System.ReadOnlyMemory<char> AsMemory(this string text) { throw null; }
public static System.ReadOnlyMemory<char> AsMemory(this string text, int start) { throw null; }
public static System.ReadOnlyMemory<char> AsMemory(this string text, int start, int length) { throw null; }
public static System.ReadOnlyMemory<char> AsMemory(this string text, Index startIndex) { throw null; }
public static System.ReadOnlyMemory<char> AsMemory(this string text, Range range) { throw null; }
public static System.Memory<T> AsMemory<T>(this System.ArraySegment<T> segment) { throw null; }
public static System.Memory<T> AsMemory<T>(this System.ArraySegment<T> segment, int start) { throw null; }
public static System.Memory<T> AsMemory<T>(this System.ArraySegment<T> segment, int start, int length) { throw null; }
public static System.Memory<T> AsMemory<T>(this T[] array) { throw null; }
public static System.Memory<T> AsMemory<T>(this T[] array, int start) { throw null; }
public static System.Memory<T> AsMemory<T>(this T[] array, int start, int length) { throw null; }
public static System.Memory<T> AsMemory<T>(this T[] array, Index startIndex) { throw null; }
public static System.Memory<T> AsMemory<T>(this T[] array, Range range) { throw null; }
public static System.ReadOnlySpan<char> AsSpan(this string text) { throw null; }
public static System.ReadOnlySpan<char> AsSpan(this string text, int start) { throw null; }
public static System.ReadOnlySpan<char> AsSpan(this string text, int start, int length) { throw null; }
public static System.Span<T> AsSpan<T>(this System.ArraySegment<T> segment) { throw null; }
public static System.Span<T> AsSpan<T>(this System.ArraySegment<T> segment, int start) { throw null; }
public static System.Span<T> AsSpan<T>(this System.ArraySegment<T> segment, int start, int length) { throw null; }
public static Span<T> AsSpan<T>(this System.ArraySegment<T> segment, Index startIndex) { throw null; }
public static Span<T> AsSpan<T>(this System.ArraySegment<T> segment, Range range) { throw null; }
public static System.Span<T> AsSpan<T>(this T[] array) { throw null; }
public static System.Span<T> AsSpan<T>(this T[] array, int start) { throw null; }
public static System.Span<T> AsSpan<T>(this T[] array, int start, int length) { throw null; }
public static Span<T> AsSpan<T>(this T[] array, Index startIndex) { throw null; }
public static Span<T> AsSpan<T>(this T[] array, Range range) { throw null; }
public static int BinarySearch<T>(this System.ReadOnlySpan<T> span, System.IComparable<T> comparable) { throw null; }
public static int BinarySearch<T>(this System.Span<T> span, System.IComparable<T> comparable) { throw null; }
public static int BinarySearch<T, TComparer>(this System.ReadOnlySpan<T> span, T value, TComparer comparer) where TComparer : System.Collections.Generic.IComparer<T> { throw null; }
Expand Down
100 changes: 100 additions & 0 deletions src/System.Memory/tests/Memory/IndexAndRange.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Xunit;

namespace System.MemoryTests
{
public static partial class MemoryTests
{
[Fact]
public static void SlicingUsingIndexAndRangeTest()
{
Range range;
int[] a = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
Memory<int> memory = a;
ReadOnlyMemory<int> roMemory = a;

for (int i = 0; i < a.Length; i++)
{
range = new Range(Index.FromStart(i), Index.FromEnd(0));
Assert.Equal(memory.Slice(i, a.Length - i), memory[range]);
Assert.Equal(roMemory.Slice(i, a.Length - i), roMemory[range]);

Assert.Equal(memory.Slice(i), memory.Slice(Index.FromStart(i)));
Assert.Equal(roMemory.Slice(i), roMemory.Slice(Index.FromStart(i)));

Assert.Equal(memory.Slice(i, a.Length - i), memory.Slice(range));
Assert.Equal(roMemory.Slice(i, a.Length - i), roMemory.Slice(range));
}

range = new Range(Index.FromStart(0), Index.FromStart(a.Length + 1));
Assert.Throws<ArgumentOutOfRangeException>(() => { Memory<int> m = memory[range]; });
Assert.Throws<ArgumentOutOfRangeException>(() => { ReadOnlyMemory<int> m = roMemory[range]; });
}

[Fact]
public static void MemoryExtensionsTest()
{
Range range;
int[] a = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
Memory<int> memory = a;
ReadOnlyMemory<int> roMemory = a;

for (int i = 0; i < a.Length; i++)
{
Assert.Equal(memory.Slice(i), a.AsMemory(Index.FromStart(i)));

range = new Range(Index.FromStart(i), Index.FromEnd(0));
Assert.Equal(memory.Slice(i, a.Length - i), a.AsMemory(range));
}

range = new Range(Index.FromStart(0), Index.FromStart(a.Length + 1));
Assert.Throws<ArgumentOutOfRangeException>(() => { Memory<int> m = a.AsMemory(Index.FromStart(a.Length + 1)); });
Assert.Throws<ArgumentOutOfRangeException>(() => { Memory<int> m = a.AsMemory(range); });

string s = "0123456789ABCDEF";
ReadOnlyMemory<char> roStringMemory = s.AsMemory();

for (int i = 0; i < s.Length; i++)
{
Assert.Equal(roStringMemory.Slice(i), s.AsMemory(Index.FromStart(i)));

range = new Range(Index.FromStart(i), Index.FromEnd(0));
Assert.Equal(roStringMemory.Slice(i, s.Length - i), s.AsMemory(range));
}

range = new Range(Index.FromStart(0), Index.FromStart(s.Length + 1));
Assert.Throws<ArgumentOutOfRangeException>(() => { ReadOnlyMemory<char> m = s.AsMemory(Index.FromStart(s.Length + 1)); });
Assert.Throws<ArgumentOutOfRangeException>(() => { ReadOnlyMemory<char> m = s.AsMemory(range); });

Span<int> span = a.AsSpan();

for (int i = 0; i < a.Length; i++)
{
Assert.True(span.Slice(i) == a.AsSpan(Index.FromStart(i)));

range = new Range(Index.FromStart(i), Index.FromEnd(0));
Assert.True(span.Slice(i, span.Length - i) == a.AsSpan(range));
}

range = new Range(Index.FromStart(0), Index.FromStart(a.Length + 1));
Assert.Throws<ArgumentOutOfRangeException>(() => { Span<int> sp = a.AsSpan(Index.FromStart(a.Length + 1)); });
Assert.Throws<ArgumentOutOfRangeException>(() => { Span<int> sp = a.AsSpan(range); });

ArraySegment<int> segment = new ArraySegment<int>(a);
for (int i = 0; i < a.Length; i++)
{
Assert.True(span.Slice(i) == segment.AsSpan(Index.FromStart(i)));

range = new Range(Index.FromStart(i), Index.FromEnd(0));
Assert.True(span.Slice(i, span.Length - i) == segment.AsSpan(range));
}

range = new Range(Index.FromStart(0), Index.FromStart(a.Length + 1));
Assert.Throws<ArgumentOutOfRangeException>(() => { Span<int> sp = segment.AsSpan(Index.FromStart(a.Length + 1)); });
Assert.Throws<ArgumentOutOfRangeException>(() => { Span<int> sp = segment.AsSpan(range); });
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@ public static partial class FormatterTests
[MemberData(nameof(TestData.TypesThatCanBeFormatted), MemberType = typeof(TestData))]
public static void TestBadFormat(Type integerType)
{
if ((integerType == typeof(double)) || (integerType == typeof(float)))
{
// double and float support all the same formats as the UTF16 formatter
return;
}

object value = Activator.CreateInstance(integerType);
Assert.Throws<FormatException>(() => TryFormatUtf8(value, Array.Empty<byte>(), out int bytesWritten, new StandardFormat('$', 1)));
}

[Theory]
[MemberData(nameof(TestData.IntegerTypesTheoryData), MemberType = typeof(TestData))]
[InlineData(typeof(decimal))]
[InlineData(typeof(double))]
[InlineData(typeof(float))]
public static void TestGFormatWithPrecisionNotSupported(Type type)
{
object value = Activator.CreateInstance(type);
Expand Down
34 changes: 30 additions & 4 deletions src/System.Memory/tests/Span/Indexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,44 @@ public static void IndexerWithIndexTest()
public static void IndexerWithRangeTest()
{
ReadOnlySpan<char> span = "Hello".AsSpan();
ReadOnlySpan<char> sliced = span[Range.Create(new Index(1, fromEnd: false), new Index(1, fromEnd: true))];
ReadOnlySpan<char> sliced = span[new Range(new Index(1, fromEnd: false), new Index(1, fromEnd: true))];
Assert.True(span.Slice(1, 3) == sliced);

Assert.Throws<ArgumentOutOfRangeException>(() =>
{ ReadOnlySpan<char> s = "Hello".AsSpan()[Range.Create(new Index(1, fromEnd: true), new Index(1, fromEnd: false))]; });
{ ReadOnlySpan<char> s = "Hello".AsSpan()[new Range(new Index(1, fromEnd: true), new Index(1, fromEnd: false))]; });

Span<char> span1 = new Span<char>(new char [] { 'H', 'e', 'l', 'l', 'o'});
Span<char> sliced1 = span1[Range.Create(new Index(2, fromEnd: false), new Index(1, fromEnd: true))];
Span<char> sliced1 = span1[new Range(new Index(2, fromEnd: false), new Index(1, fromEnd: true))];
Assert.True(span1.Slice(2, 2) == sliced1);

Assert.Throws<ArgumentOutOfRangeException>(() =>
{ Span<char> s = new Span<char>(new char [] { 'H', 'i' })[Range.Create(new Index(0, fromEnd: true), new Index(1, fromEnd: false))]; });
{ Span<char> s = new Span<char>(new char [] { 'H', 'i' })[new Range(new Index(0, fromEnd: true), new Index(1, fromEnd: false))]; });
}

[Fact]
public static void SlicingUsingIndexAndRangeTest()
{
Range range;
string s = "0123456789ABCDEF";
ReadOnlySpan<char> roSpan = s.AsSpan();
Span<char> span = new Span<char>(s.ToCharArray());

for (int i = 0; i < span.Length; i++)
{
Assert.True(span.Slice(i) == span.Slice(Index.FromStart(i)));
Assert.True(span.Slice(span.Length - i - 1) == span.Slice(Index.FromEnd(i + 1)));

Assert.True(roSpan.Slice(i) == roSpan.Slice(Index.FromStart(i)));
Assert.True(roSpan.Slice(roSpan.Length - i - 1) == roSpan.Slice(Index.FromEnd(i + 1)));

range = new Range(Index.FromStart(i), Index.FromEnd(0));
Assert.True(span.Slice(i, span.Length - i) == span.Slice(range));
Assert.True(roSpan.Slice(i, roSpan.Length - i) == roSpan.Slice(range));
}

range = new Range(Index.FromStart(0), Index.FromStart(span.Length + 1));
Assert.Throws<ArgumentOutOfRangeException>(() => new Span<char>(s.ToCharArray()).Slice(range));
Assert.Throws<ArgumentOutOfRangeException>(() => s.AsSpan().Slice(range));
}
}
}
1 change: 1 addition & 0 deletions src/System.Memory/tests/System.Memory.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
<Compile Include="Memory\Equality.cs" />
<Compile Include="Memory\GetHashCode.cs" />
<Compile Include="Memory\ImplicitConversion.cs" />
<Compile Include="Memory\IndexAndRange.cs" />
<Compile Include="Memory\MemoryManager.cs" />
<Compile Include="Memory\Pin.cs" />
<Compile Include="Memory\Slice.cs" />
Expand Down
Loading