From 222043719d772ca9abea2131dce6412ef1b2a159 Mon Sep 17 00:00:00 2001 From: Maryam Ariyan Date: Mon, 2 Mar 2020 13:58:22 -0800 Subject: [PATCH] Setup build/pkg on Microsoft.Extensions.Primitives - Fix ref/src build on supported frameworks - Use GenerateReferenceSource to properly set ref APIs - Enable tests - Add packaging setup --- src/libraries/Directory.Build.props | 7 +- .../Microsoft.Extensions.Primitives.pkgproj | 9 + ....cs => Microsoft.Extensions.Primitives.cs} | 53 +++-- .../Microsoft.Extensions.Primitives.csproj | 10 +- ...ft.Extensions.Primitives.netstandard2.0.cs | 203 ------------------ .../src/CancellationChangeToken.cs | 2 +- .../Microsoft.Extensions.Primitives.csproj | 45 ++-- .../Strings.resx} | 0 .../src/StringSegment.cs | 4 +- .../src/StringSegmentComparer.cs | 4 +- .../src/StringValues.cs | 3 +- .../src/ThrowHelper.cs | 2 +- ...crosoft.Extensions.Primitives.Tests.csproj | 13 ++ src/libraries/pkg/baseline/packageIndex.json | 22 ++ src/libraries/pkg/descriptions.json | 9 + 15 files changed, 121 insertions(+), 265 deletions(-) create mode 100644 src/libraries/Microsoft.Extensions.Primitives/pkg/Microsoft.Extensions.Primitives.pkgproj rename src/libraries/Microsoft.Extensions.Primitives/ref/{Microsoft.Extensions.Primitives.netcoreapp.cs => Microsoft.Extensions.Primitives.cs} (77%) delete mode 100644 src/libraries/Microsoft.Extensions.Primitives/ref/Microsoft.Extensions.Primitives.netstandard2.0.cs rename src/libraries/Microsoft.Extensions.Primitives/src/{Resources.resx => Resources/Strings.resx} (100%) diff --git a/src/libraries/Directory.Build.props b/src/libraries/Directory.Build.props index 70d9fd39aa3b24..3aa2471808e575 100644 --- a/src/libraries/Directory.Build.props +++ b/src/libraries/Directory.Build.props @@ -5,14 +5,19 @@ + + + - + MicrosoftAspNetCore true + + $(NoWarn);SA1129;SA1028;SA1027;SA1121;CA1200 diff --git a/src/libraries/Microsoft.Extensions.Primitives/pkg/Microsoft.Extensions.Primitives.pkgproj b/src/libraries/Microsoft.Extensions.Primitives/pkg/Microsoft.Extensions.Primitives.pkgproj new file mode 100644 index 00000000000000..07273ae288cef3 --- /dev/null +++ b/src/libraries/Microsoft.Extensions.Primitives/pkg/Microsoft.Extensions.Primitives.pkgproj @@ -0,0 +1,9 @@ + + + + + net461;netcoreapp2.0;uap10.0.16299;$(AllXamarinFrameworks) + + + + \ No newline at end of file diff --git a/src/libraries/Microsoft.Extensions.Primitives/ref/Microsoft.Extensions.Primitives.netcoreapp.cs b/src/libraries/Microsoft.Extensions.Primitives/ref/Microsoft.Extensions.Primitives.cs similarity index 77% rename from src/libraries/Microsoft.Extensions.Primitives/ref/Microsoft.Extensions.Primitives.netcoreapp.cs rename to src/libraries/Microsoft.Extensions.Primitives/ref/Microsoft.Extensions.Primitives.cs index c2397dd21b4e81..37f8f8a869baf7 100644 --- a/src/libraries/Microsoft.Extensions.Primitives/ref/Microsoft.Extensions.Primitives.netcoreapp.cs +++ b/src/libraries/Microsoft.Extensions.Primitives/ref/Microsoft.Extensions.Primitives.cs @@ -1,13 +1,16 @@ // 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. +// ------------------------------------------------------------------------------ +// Changes to this file must follow the https://aka.ms/api-review process. +// ------------------------------------------------------------------------------ namespace Microsoft.Extensions.Primitives { public partial class CancellationChangeToken : Microsoft.Extensions.Primitives.IChangeToken { public CancellationChangeToken(System.Threading.CancellationToken cancellationToken) { } - public bool ActiveChangeCallbacks { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } + public bool ActiveChangeCallbacks { get { throw null; } } public bool HasChanged { get { throw null; } } public System.IDisposable RegisterChangeCallback(System.Action callback, object state) { throw null; } } @@ -19,8 +22,8 @@ public static partial class ChangeToken public partial class CompositeChangeToken : Microsoft.Extensions.Primitives.IChangeToken { public CompositeChangeToken(System.Collections.Generic.IReadOnlyList changeTokens) { } - public bool ActiveChangeCallbacks { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } - public System.Collections.Generic.IReadOnlyList ChangeTokens { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } + public bool ActiveChangeCallbacks { get { throw null; } } + public System.Collections.Generic.IReadOnlyList ChangeTokens { get { throw null; } } public bool HasChanged { get { throw null; } } public System.IDisposable RegisterChangeCallback(System.Action callback, object state) { throw null; } } @@ -34,9 +37,6 @@ public partial interface IChangeToken bool HasChanged { get; } System.IDisposable RegisterChangeCallback(System.Action callback, object state); } - [System.Diagnostics.DebuggerDisplayAttribute("Value = {_value}")] - [System.ObsoleteAttribute("This type is obsolete and will be removed in a future version.")] - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public partial struct InplaceStringBuilder { private object _dummy; @@ -44,42 +44,41 @@ public partial struct InplaceStringBuilder public InplaceStringBuilder(int capacity) { throw null; } public int Capacity { get { throw null; } set { } } public void Append(Microsoft.Extensions.Primitives.StringSegment segment) { } - [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]public void Append(char c) { } + public void Append(char c) { } public void Append(string value) { } - [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]public void Append(string value, int offset, int count) { } + public void Append(string value, int offset, int count) { } public override string ToString() { throw null; } } - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct StringSegment : System.IEquatable, System.IEquatable { private readonly object _dummy; private readonly int _dummyPrimitive; public static readonly Microsoft.Extensions.Primitives.StringSegment Empty; public StringSegment(string buffer) { throw null; } - [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]public StringSegment(string buffer, int offset, int length) { throw null; } - public string Buffer { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } + public StringSegment(string buffer, int offset, int length) { throw null; } + public string Buffer { get { throw null; } } public bool HasValue { get { throw null; } } public char this[int index] { get { throw null; } } - public int Length { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } - public int Offset { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } + public int Length { get { throw null; } } + public int Offset { get { throw null; } } public string Value { get { throw null; } } public System.ReadOnlyMemory AsMemory() { throw null; } public System.ReadOnlySpan AsSpan() { throw null; } public static int Compare(Microsoft.Extensions.Primitives.StringSegment a, Microsoft.Extensions.Primitives.StringSegment b, System.StringComparison comparisonType) { throw null; } - [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]public bool EndsWith(string text, System.StringComparison comparisonType) { throw null; } + public bool EndsWith(string text, System.StringComparison comparisonType) { throw null; } public bool Equals(Microsoft.Extensions.Primitives.StringSegment other) { throw null; } public static bool Equals(Microsoft.Extensions.Primitives.StringSegment a, Microsoft.Extensions.Primitives.StringSegment b, System.StringComparison comparisonType) { throw null; } public bool Equals(Microsoft.Extensions.Primitives.StringSegment other, System.StringComparison comparisonType) { throw null; } public override bool Equals(object obj) { throw null; } public bool Equals(string text) { throw null; } - [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]public bool Equals(string text, System.StringComparison comparisonType) { throw null; } - [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]public override int GetHashCode() { throw null; } + public bool Equals(string text, System.StringComparison comparisonType) { throw null; } + public override int GetHashCode() { throw null; } public int IndexOf(char c) { throw null; } public int IndexOf(char c, int start) { throw null; } - [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]public int IndexOf(char c, int start, int count) { throw null; } + public int IndexOf(char c, int start, int count) { throw null; } public int IndexOfAny(char[] anyOf) { throw null; } public int IndexOfAny(char[] anyOf, int startIndex) { throw null; } - [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]public int IndexOfAny(char[] anyOf, int startIndex, int count) { throw null; } + public int IndexOfAny(char[] anyOf, int startIndex, int count) { throw null; } public static bool IsNullOrEmpty(Microsoft.Extensions.Primitives.StringSegment value) { throw null; } public int LastIndexOf(char value) { throw null; } public static bool operator ==(Microsoft.Extensions.Primitives.StringSegment left, Microsoft.Extensions.Primitives.StringSegment right) { throw null; } @@ -88,11 +87,11 @@ public void Append(string value) { } public static implicit operator Microsoft.Extensions.Primitives.StringSegment (string value) { throw null; } public static bool operator !=(Microsoft.Extensions.Primitives.StringSegment left, Microsoft.Extensions.Primitives.StringSegment right) { throw null; } public Microsoft.Extensions.Primitives.StringTokenizer Split(char[] chars) { throw null; } - [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]public bool StartsWith(string text, System.StringComparison comparisonType) { throw null; } + public bool StartsWith(string text, System.StringComparison comparisonType) { throw null; } public Microsoft.Extensions.Primitives.StringSegment Subsegment(int offset) { throw null; } public Microsoft.Extensions.Primitives.StringSegment Subsegment(int offset, int length) { throw null; } public string Substring(int offset) { throw null; } - [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]public string Substring(int offset, int length) { throw null; } + public string Substring(int offset, int length) { throw null; } public override string ToString() { throw null; } public Microsoft.Extensions.Primitives.StringSegment Trim() { throw null; } public Microsoft.Extensions.Primitives.StringSegment TrimEnd() { throw null; } @@ -101,13 +100,12 @@ public void Append(string value) { } public partial class StringSegmentComparer : System.Collections.Generic.IComparer, System.Collections.Generic.IEqualityComparer { internal StringSegmentComparer() { } - public static Microsoft.Extensions.Primitives.StringSegmentComparer Ordinal { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } - public static Microsoft.Extensions.Primitives.StringSegmentComparer OrdinalIgnoreCase { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } + public static Microsoft.Extensions.Primitives.StringSegmentComparer Ordinal { get { throw null; } } + public static Microsoft.Extensions.Primitives.StringSegmentComparer OrdinalIgnoreCase { get { throw null; } } public int Compare(Microsoft.Extensions.Primitives.StringSegment x, Microsoft.Extensions.Primitives.StringSegment y) { throw null; } public bool Equals(Microsoft.Extensions.Primitives.StringSegment x, Microsoft.Extensions.Primitives.StringSegment y) { throw null; } public int GetHashCode(Microsoft.Extensions.Primitives.StringSegment obj) { throw null; } } - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct StringTokenizer : System.Collections.Generic.IEnumerable, System.Collections.IEnumerable { private readonly object _dummy; @@ -117,20 +115,18 @@ internal StringSegmentComparer() { } public Microsoft.Extensions.Primitives.StringTokenizer.Enumerator GetEnumerator() { throw null; } System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public partial struct Enumerator : System.Collections.Generic.IEnumerator, System.Collections.IEnumerator, System.IDisposable { private object _dummy; private int _dummyPrimitive; public Enumerator(ref Microsoft.Extensions.Primitives.StringTokenizer tokenizer) { throw null; } - public Microsoft.Extensions.Primitives.StringSegment Current { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } + public readonly Microsoft.Extensions.Primitives.StringSegment Current { get { throw null; } } object System.Collections.IEnumerator.Current { get { throw null; } } public void Dispose() { } public bool MoveNext() { throw null; } public void Reset() { } } } - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct StringValues : System.Collections.Generic.ICollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IList, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable, System.IEquatable, System.IEquatable, System.IEquatable { private readonly object _dummy; @@ -138,8 +134,8 @@ public void Reset() { } public static readonly Microsoft.Extensions.Primitives.StringValues Empty; public StringValues(string value) { throw null; } public StringValues(string[] values) { throw null; } - public int Count { [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]get { throw null; } } - public string this[int index] { [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]get { throw null; } } + public int Count { get { throw null; } } + public string this[int index] { get { throw null; } } bool System.Collections.Generic.ICollection.IsReadOnly { get { throw null; } } string System.Collections.Generic.IList.this[int index] { get { throw null; } set { } } public static Microsoft.Extensions.Primitives.StringValues Concat(Microsoft.Extensions.Primitives.StringValues values1, Microsoft.Extensions.Primitives.StringValues values2) { throw null; } @@ -187,7 +183,6 @@ public void Reset() { } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } public string[] ToArray() { throw null; } public override string ToString() { throw null; } - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public partial struct Enumerator : System.Collections.Generic.IEnumerator, System.Collections.IEnumerator, System.IDisposable { private object _dummy; diff --git a/src/libraries/Microsoft.Extensions.Primitives/ref/Microsoft.Extensions.Primitives.csproj b/src/libraries/Microsoft.Extensions.Primitives/ref/Microsoft.Extensions.Primitives.csproj index 9623f02f73388d..a96a2cac069ce3 100644 --- a/src/libraries/Microsoft.Extensions.Primitives/ref/Microsoft.Extensions.Primitives.csproj +++ b/src/libraries/Microsoft.Extensions.Primitives/ref/Microsoft.Extensions.Primitives.csproj @@ -1,15 +1,11 @@ - - netstandard2.0;$(DefaultNetCoreTargetFramework) + netstandard2.0;netstandard2.1 - - - - - + + diff --git a/src/libraries/Microsoft.Extensions.Primitives/ref/Microsoft.Extensions.Primitives.netstandard2.0.cs b/src/libraries/Microsoft.Extensions.Primitives/ref/Microsoft.Extensions.Primitives.netstandard2.0.cs deleted file mode 100644 index c2397dd21b4e81..00000000000000 --- a/src/libraries/Microsoft.Extensions.Primitives/ref/Microsoft.Extensions.Primitives.netstandard2.0.cs +++ /dev/null @@ -1,203 +0,0 @@ -// 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. - -namespace Microsoft.Extensions.Primitives -{ - public partial class CancellationChangeToken : Microsoft.Extensions.Primitives.IChangeToken - { - public CancellationChangeToken(System.Threading.CancellationToken cancellationToken) { } - public bool ActiveChangeCallbacks { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } - public bool HasChanged { get { throw null; } } - public System.IDisposable RegisterChangeCallback(System.Action callback, object state) { throw null; } - } - public static partial class ChangeToken - { - public static System.IDisposable OnChange(System.Func changeTokenProducer, System.Action changeTokenConsumer) { throw null; } - public static System.IDisposable OnChange(System.Func changeTokenProducer, System.Action changeTokenConsumer, TState state) { throw null; } - } - public partial class CompositeChangeToken : Microsoft.Extensions.Primitives.IChangeToken - { - public CompositeChangeToken(System.Collections.Generic.IReadOnlyList changeTokens) { } - public bool ActiveChangeCallbacks { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } - public System.Collections.Generic.IReadOnlyList ChangeTokens { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } - public bool HasChanged { get { throw null; } } - public System.IDisposable RegisterChangeCallback(System.Action callback, object state) { throw null; } - } - public static partial class Extensions - { - public static System.Text.StringBuilder Append(this System.Text.StringBuilder builder, Microsoft.Extensions.Primitives.StringSegment segment) { throw null; } - } - public partial interface IChangeToken - { - bool ActiveChangeCallbacks { get; } - bool HasChanged { get; } - System.IDisposable RegisterChangeCallback(System.Action callback, object state); - } - [System.Diagnostics.DebuggerDisplayAttribute("Value = {_value}")] - [System.ObsoleteAttribute("This type is obsolete and will be removed in a future version.")] - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] - public partial struct InplaceStringBuilder - { - private object _dummy; - private int _dummyPrimitive; - public InplaceStringBuilder(int capacity) { throw null; } - public int Capacity { get { throw null; } set { } } - public void Append(Microsoft.Extensions.Primitives.StringSegment segment) { } - [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]public void Append(char c) { } - public void Append(string value) { } - [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]public void Append(string value, int offset, int count) { } - public override string ToString() { throw null; } - } - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] - public readonly partial struct StringSegment : System.IEquatable, System.IEquatable - { - private readonly object _dummy; - private readonly int _dummyPrimitive; - public static readonly Microsoft.Extensions.Primitives.StringSegment Empty; - public StringSegment(string buffer) { throw null; } - [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]public StringSegment(string buffer, int offset, int length) { throw null; } - public string Buffer { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } - public bool HasValue { get { throw null; } } - public char this[int index] { get { throw null; } } - public int Length { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } - public int Offset { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } - public string Value { get { throw null; } } - public System.ReadOnlyMemory AsMemory() { throw null; } - public System.ReadOnlySpan AsSpan() { throw null; } - public static int Compare(Microsoft.Extensions.Primitives.StringSegment a, Microsoft.Extensions.Primitives.StringSegment b, System.StringComparison comparisonType) { throw null; } - [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]public bool EndsWith(string text, System.StringComparison comparisonType) { throw null; } - public bool Equals(Microsoft.Extensions.Primitives.StringSegment other) { throw null; } - public static bool Equals(Microsoft.Extensions.Primitives.StringSegment a, Microsoft.Extensions.Primitives.StringSegment b, System.StringComparison comparisonType) { throw null; } - public bool Equals(Microsoft.Extensions.Primitives.StringSegment other, System.StringComparison comparisonType) { throw null; } - public override bool Equals(object obj) { throw null; } - public bool Equals(string text) { throw null; } - [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]public bool Equals(string text, System.StringComparison comparisonType) { throw null; } - [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]public override int GetHashCode() { throw null; } - public int IndexOf(char c) { throw null; } - public int IndexOf(char c, int start) { throw null; } - [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]public int IndexOf(char c, int start, int count) { throw null; } - public int IndexOfAny(char[] anyOf) { throw null; } - public int IndexOfAny(char[] anyOf, int startIndex) { throw null; } - [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]public int IndexOfAny(char[] anyOf, int startIndex, int count) { throw null; } - public static bool IsNullOrEmpty(Microsoft.Extensions.Primitives.StringSegment value) { throw null; } - public int LastIndexOf(char value) { throw null; } - public static bool operator ==(Microsoft.Extensions.Primitives.StringSegment left, Microsoft.Extensions.Primitives.StringSegment right) { throw null; } - public static implicit operator System.ReadOnlyMemory (Microsoft.Extensions.Primitives.StringSegment segment) { throw null; } - public static implicit operator System.ReadOnlySpan (Microsoft.Extensions.Primitives.StringSegment segment) { throw null; } - public static implicit operator Microsoft.Extensions.Primitives.StringSegment (string value) { throw null; } - public static bool operator !=(Microsoft.Extensions.Primitives.StringSegment left, Microsoft.Extensions.Primitives.StringSegment right) { throw null; } - public Microsoft.Extensions.Primitives.StringTokenizer Split(char[] chars) { throw null; } - [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]public bool StartsWith(string text, System.StringComparison comparisonType) { throw null; } - public Microsoft.Extensions.Primitives.StringSegment Subsegment(int offset) { throw null; } - public Microsoft.Extensions.Primitives.StringSegment Subsegment(int offset, int length) { throw null; } - public string Substring(int offset) { throw null; } - [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]public string Substring(int offset, int length) { throw null; } - public override string ToString() { throw null; } - public Microsoft.Extensions.Primitives.StringSegment Trim() { throw null; } - public Microsoft.Extensions.Primitives.StringSegment TrimEnd() { throw null; } - public Microsoft.Extensions.Primitives.StringSegment TrimStart() { throw null; } - } - public partial class StringSegmentComparer : System.Collections.Generic.IComparer, System.Collections.Generic.IEqualityComparer - { - internal StringSegmentComparer() { } - public static Microsoft.Extensions.Primitives.StringSegmentComparer Ordinal { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } - public static Microsoft.Extensions.Primitives.StringSegmentComparer OrdinalIgnoreCase { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } - public int Compare(Microsoft.Extensions.Primitives.StringSegment x, Microsoft.Extensions.Primitives.StringSegment y) { throw null; } - public bool Equals(Microsoft.Extensions.Primitives.StringSegment x, Microsoft.Extensions.Primitives.StringSegment y) { throw null; } - public int GetHashCode(Microsoft.Extensions.Primitives.StringSegment obj) { throw null; } - } - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] - public readonly partial struct StringTokenizer : System.Collections.Generic.IEnumerable, System.Collections.IEnumerable - { - private readonly object _dummy; - private readonly int _dummyPrimitive; - public StringTokenizer(Microsoft.Extensions.Primitives.StringSegment value, char[] separators) { throw null; } - public StringTokenizer(string value, char[] separators) { throw null; } - public Microsoft.Extensions.Primitives.StringTokenizer.Enumerator GetEnumerator() { throw null; } - System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] - public partial struct Enumerator : System.Collections.Generic.IEnumerator, System.Collections.IEnumerator, System.IDisposable - { - private object _dummy; - private int _dummyPrimitive; - public Enumerator(ref Microsoft.Extensions.Primitives.StringTokenizer tokenizer) { throw null; } - public Microsoft.Extensions.Primitives.StringSegment Current { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } - object System.Collections.IEnumerator.Current { get { throw null; } } - public void Dispose() { } - public bool MoveNext() { throw null; } - public void Reset() { } - } - } - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] - public readonly partial struct StringValues : System.Collections.Generic.ICollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IList, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable, System.IEquatable, System.IEquatable, System.IEquatable - { - private readonly object _dummy; - private readonly int _dummyPrimitive; - public static readonly Microsoft.Extensions.Primitives.StringValues Empty; - public StringValues(string value) { throw null; } - public StringValues(string[] values) { throw null; } - public int Count { [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]get { throw null; } } - public string this[int index] { [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]get { throw null; } } - bool System.Collections.Generic.ICollection.IsReadOnly { get { throw null; } } - string System.Collections.Generic.IList.this[int index] { get { throw null; } set { } } - public static Microsoft.Extensions.Primitives.StringValues Concat(Microsoft.Extensions.Primitives.StringValues values1, Microsoft.Extensions.Primitives.StringValues values2) { throw null; } - public static Microsoft.Extensions.Primitives.StringValues Concat(in Microsoft.Extensions.Primitives.StringValues values, string value) { throw null; } - public static Microsoft.Extensions.Primitives.StringValues Concat(string value, in Microsoft.Extensions.Primitives.StringValues values) { throw null; } - public bool Equals(Microsoft.Extensions.Primitives.StringValues other) { throw null; } - public static bool Equals(Microsoft.Extensions.Primitives.StringValues left, Microsoft.Extensions.Primitives.StringValues right) { throw null; } - public static bool Equals(Microsoft.Extensions.Primitives.StringValues left, string right) { throw null; } - public static bool Equals(Microsoft.Extensions.Primitives.StringValues left, string[] right) { throw null; } - public override bool Equals(object obj) { throw null; } - public bool Equals(string other) { throw null; } - public static bool Equals(string left, Microsoft.Extensions.Primitives.StringValues right) { throw null; } - public bool Equals(string[] other) { throw null; } - public static bool Equals(string[] left, Microsoft.Extensions.Primitives.StringValues right) { throw null; } - public Microsoft.Extensions.Primitives.StringValues.Enumerator GetEnumerator() { throw null; } - public override int GetHashCode() { throw null; } - public static bool IsNullOrEmpty(Microsoft.Extensions.Primitives.StringValues value) { throw null; } - public static bool operator ==(Microsoft.Extensions.Primitives.StringValues left, Microsoft.Extensions.Primitives.StringValues right) { throw null; } - public static bool operator ==(Microsoft.Extensions.Primitives.StringValues left, object right) { throw null; } - public static bool operator ==(Microsoft.Extensions.Primitives.StringValues left, string right) { throw null; } - public static bool operator ==(Microsoft.Extensions.Primitives.StringValues left, string[] right) { throw null; } - public static bool operator ==(object left, Microsoft.Extensions.Primitives.StringValues right) { throw null; } - public static bool operator ==(string left, Microsoft.Extensions.Primitives.StringValues right) { throw null; } - public static bool operator ==(string[] left, Microsoft.Extensions.Primitives.StringValues right) { throw null; } - public static implicit operator string (Microsoft.Extensions.Primitives.StringValues values) { throw null; } - public static implicit operator string[] (Microsoft.Extensions.Primitives.StringValues value) { throw null; } - public static implicit operator Microsoft.Extensions.Primitives.StringValues (string value) { throw null; } - public static implicit operator Microsoft.Extensions.Primitives.StringValues (string[] values) { throw null; } - public static bool operator !=(Microsoft.Extensions.Primitives.StringValues left, Microsoft.Extensions.Primitives.StringValues right) { throw null; } - public static bool operator !=(Microsoft.Extensions.Primitives.StringValues left, object right) { throw null; } - public static bool operator !=(Microsoft.Extensions.Primitives.StringValues left, string right) { throw null; } - public static bool operator !=(Microsoft.Extensions.Primitives.StringValues left, string[] right) { throw null; } - public static bool operator !=(object left, Microsoft.Extensions.Primitives.StringValues right) { throw null; } - public static bool operator !=(string left, Microsoft.Extensions.Primitives.StringValues right) { throw null; } - public static bool operator !=(string[] left, Microsoft.Extensions.Primitives.StringValues right) { throw null; } - void System.Collections.Generic.ICollection.Add(string item) { } - void System.Collections.Generic.ICollection.Clear() { } - bool System.Collections.Generic.ICollection.Contains(string item) { throw null; } - void System.Collections.Generic.ICollection.CopyTo(string[] array, int arrayIndex) { } - bool System.Collections.Generic.ICollection.Remove(string item) { throw null; } - System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } - int System.Collections.Generic.IList.IndexOf(string item) { throw null; } - void System.Collections.Generic.IList.Insert(int index, string item) { } - void System.Collections.Generic.IList.RemoveAt(int index) { } - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } - public string[] ToArray() { throw null; } - public override string ToString() { throw null; } - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] - public partial struct Enumerator : System.Collections.Generic.IEnumerator, System.Collections.IEnumerator, System.IDisposable - { - private object _dummy; - private int _dummyPrimitive; - public Enumerator(ref Microsoft.Extensions.Primitives.StringValues values) { throw null; } - public string Current { get { throw null; } } - object System.Collections.IEnumerator.Current { get { throw null; } } - public void Dispose() { } - public bool MoveNext() { throw null; } - void System.Collections.IEnumerator.Reset() { } - } - } -} diff --git a/src/libraries/Microsoft.Extensions.Primitives/src/CancellationChangeToken.cs b/src/libraries/Microsoft.Extensions.Primitives/src/CancellationChangeToken.cs index bb1a754cb4a620..1df95d5a66a74a 100644 --- a/src/libraries/Microsoft.Extensions.Primitives/src/CancellationChangeToken.cs +++ b/src/libraries/Microsoft.Extensions.Primitives/src/CancellationChangeToken.cs @@ -32,7 +32,7 @@ public CancellationChangeToken(CancellationToken cancellationToken) /// public IDisposable RegisterChangeCallback(Action callback, object state) { -#if NETCOREAPP +#if NETCOREAPP || NETSTANDARD2_1 try { return Token.UnsafeRegister(callback, state); diff --git a/src/libraries/Microsoft.Extensions.Primitives/src/Microsoft.Extensions.Primitives.csproj b/src/libraries/Microsoft.Extensions.Primitives/src/Microsoft.Extensions.Primitives.csproj index 81dc5fe5977b79..407d76de016d8e 100644 --- a/src/libraries/Microsoft.Extensions.Primitives/src/Microsoft.Extensions.Primitives.csproj +++ b/src/libraries/Microsoft.Extensions.Primitives/src/Microsoft.Extensions.Primitives.csproj @@ -1,27 +1,38 @@  - - Primitives shared by framework extensions. Commonly used types include: -Microsoft.Extensions.Primitives.IChangeToken -Microsoft.Extensions.Primitives.StringValues -Microsoft.Extensions.Primitives.StringSegment - netstandard2.0;$(DefaultNetCoreTargetFramework) - $(DefaultNetCoreTargetFramework) - $(NoWarn);CS1591 + $(NetCoreAppCurrent);netcoreapp3.0;netstandard2.0 true - true - primitives - true - true + true - - + + Common\src\Extensions\HashCodeCombiner\HashCodeCombiner.cs + + + + + + + + + + + + + + + + + + + + + + + - - - + \ No newline at end of file diff --git a/src/libraries/Microsoft.Extensions.Primitives/src/Resources.resx b/src/libraries/Microsoft.Extensions.Primitives/src/Resources/Strings.resx similarity index 100% rename from src/libraries/Microsoft.Extensions.Primitives/src/Resources.resx rename to src/libraries/Microsoft.Extensions.Primitives/src/Resources/Strings.resx diff --git a/src/libraries/Microsoft.Extensions.Primitives/src/StringSegment.cs b/src/libraries/Microsoft.Extensions.Primitives/src/StringSegment.cs index 3802070637587a..68150af110c04f 100644 --- a/src/libraries/Microsoft.Extensions.Primitives/src/StringSegment.cs +++ b/src/libraries/Microsoft.Extensions.Primitives/src/StringSegment.cs @@ -246,9 +246,9 @@ public bool Equals(string text, StringComparison comparisonType) [MethodImpl(MethodImplOptions.AggressiveInlining)] public override int GetHashCode() { -#if NETCOREAPP +#if NETCOREAPP || NETSTANDARD2_1 return string.GetHashCode(AsSpan()); -#elif NETSTANDARD +#elif NETSTANDARD2_0 // This GetHashCode is expensive since it allocates on every call. // However this is required to ensure we retain any behavior (such as hash code randomization) that // string.GetHashCode has. diff --git a/src/libraries/Microsoft.Extensions.Primitives/src/StringSegmentComparer.cs b/src/libraries/Microsoft.Extensions.Primitives/src/StringSegmentComparer.cs index 1c4777b3ac8a8c..eaecc9efb764cf 100644 --- a/src/libraries/Microsoft.Extensions.Primitives/src/StringSegmentComparer.cs +++ b/src/libraries/Microsoft.Extensions.Primitives/src/StringSegmentComparer.cs @@ -28,7 +28,7 @@ public int Compare(StringSegment x, StringSegment y) { return StringSegment.Compare(x, y, Comparison); } - + public bool Equals(StringSegment x, StringSegment y) { return StringSegment.Equals(x, y, Comparison); @@ -36,7 +36,7 @@ public bool Equals(StringSegment x, StringSegment y) public int GetHashCode(StringSegment obj) { -#if NETCOREAPP +#if NETCOREAPP || NETSTANDARD2_1 return string.GetHashCode(obj.AsSpan(), Comparison); #else if (!obj.HasValue) diff --git a/src/libraries/Microsoft.Extensions.Primitives/src/StringValues.cs b/src/libraries/Microsoft.Extensions.Primitives/src/StringValues.cs index 489fbbd2383f3b..5fe99cb6c188eb 100644 --- a/src/libraries/Microsoft.Extensions.Primitives/src/StringValues.cs +++ b/src/libraries/Microsoft.Extensions.Primitives/src/StringValues.cs @@ -219,7 +219,7 @@ static string GetJoinedStringValueFromArray(string[] values) length += value.Length; } } -#if NETCOREAPP +#if NETCOREAPP || NETSTANDARD2_1 // Create the new string return string.Create(length, values, (span, strings) => { var offset = 0; @@ -622,7 +622,6 @@ public static bool Equals(StringValues left, StringValues right) /// true if the value of is the same as this instance; otherwise, false. public bool Equals(string[] other) => Equals(this, new StringValues(other)); - /// public static bool operator ==(StringValues left, string right) => Equals(left, new StringValues(right)); diff --git a/src/libraries/Microsoft.Extensions.Primitives/src/ThrowHelper.cs b/src/libraries/Microsoft.Extensions.Primitives/src/ThrowHelper.cs index 6556fae6e2cdfa..a3ea5ac13b59a0 100644 --- a/src/libraries/Microsoft.Extensions.Primitives/src/ThrowHelper.cs +++ b/src/libraries/Microsoft.Extensions.Primitives/src/ThrowHelper.cs @@ -53,7 +53,7 @@ internal static ArgumentException GetArgumentException(ExceptionResource resourc private static string GetResourceText(ExceptionResource resource) { - return Resources.ResourceManager.GetString(GetResourceName(resource), Resources.Culture); + return SR.GetResourceString(GetResourceName(resource)); } private static string GetArgumentName(ExceptionArgument argument) diff --git a/src/libraries/Microsoft.Extensions.Primitives/tests/Microsoft.Extensions.Primitives.Tests.csproj b/src/libraries/Microsoft.Extensions.Primitives/tests/Microsoft.Extensions.Primitives.Tests.csproj index 8dc0ca80baf58d..44baa5385bd42c 100644 --- a/src/libraries/Microsoft.Extensions.Primitives/tests/Microsoft.Extensions.Primitives.Tests.csproj +++ b/src/libraries/Microsoft.Extensions.Primitives/tests/Microsoft.Extensions.Primitives.Tests.csproj @@ -4,6 +4,19 @@ $(DefaultNetCoreTargetFramework);net472 + + + + + + + + + + + + + diff --git a/src/libraries/pkg/baseline/packageIndex.json b/src/libraries/pkg/baseline/packageIndex.json index dbf70e5c32f096..19d9a7039dc49c 100644 --- a/src/libraries/pkg/baseline/packageIndex.json +++ b/src/libraries/pkg/baseline/packageIndex.json @@ -145,6 +145,28 @@ "5.0.0.0": "5.0.0" } }, + "Microsoft.Extensions.Primitives": { + "StableVersions": [ + "1.0.0", + "1.0.1", + "1.1.0", + "1.1.1", + "2.0.0", + "2.1.0", + "2.1.1", + "2.1.6", + "2.2.0", + "3.0.0", + "3.0.1", + "3.0.2", + "3.1.0", + "3.1.1" + ], + "InboxOn": {}, + "AssemblyVersionInPackageVersion": { + "5.0.0.0": "5.0.0" + } + }, "Microsoft.IO.Redist": { "StableVersions": [ "4.6.0" diff --git a/src/libraries/pkg/descriptions.json b/src/libraries/pkg/descriptions.json index 2fcc2a383465e2..9c10db8a8bcfec 100644 --- a/src/libraries/pkg/descriptions.json +++ b/src/libraries/pkg/descriptions.json @@ -14,6 +14,15 @@ "Description": "Provides a portable version of the Microsoft.Cci library", "CommonTypes": [] }, + { + "Name": "Microsoft.Extensions.Primitives", + "Description": "Primitives shared by framework extensions. Commonly used types include:", + "CommonTypes": [ + "Microsoft.Extensions.Primitives.IChangeToken", + "Microsoft.Extensions.Primitives.StringValues", + "Microsoft.Extensions.Primitives.StringSegment" + ] + }, { "Name": "Microsoft.Bcl.HashCode", "Description": "Provides the HashCode type for .NET Standard 2.0. This package is not required starting with .NET Standard 2.1 and .NET Core 3.0.",