From c95aa3f48aa591dca870ee00c31c3d8bdc740b5a Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Wed, 26 May 2021 21:51:12 +0200 Subject: [PATCH] Remove NS1.x assets from building and packaging (#53283) * Remove NS1.x assets from build and packaging These ten projects still built for netstandard1.x. This PR trims out these assets from both the build which also results in them not being packaged anymore as there is no harvesting mechanism in the repository anymore. Suppressing the package warnings for the intentionally dropped assets and cleaning up conditions in the project file as well. For more details please see the reasoning in the linked issue. Contributes to https://github.com/dotnet/runtime/issues/53282 --- .../Common/src/System/CodeDom/CodeObject.cs | 4 +- .../src/System/CodeDom/CodeTypeReference.cs | 8 +- .../CodeDom/CodeTypeReferenceCollection.cs | 4 +- .../Common/src/System/HexConverter.cs | 2 +- src/libraries/Common/src/System/SR.cs | 4 +- src/libraries/Directory.Build.targets | 12 +- ...ensions.HostFactoryResolver.Sources.csproj | 7 +- .../System.CodeDom/src/System.CodeDom.csproj | 4 +- .../pkg/System.Collections.Immutable.pkgproj | 5 +- .../ref/System.Collections.Immutable.cs | 30 +- .../ref/System.Collections.Immutable.csproj | 20 +- .../src/System.Collections.Immutable.csproj | 18 +- .../Immutable/ImmutableArray_1.Builder.cs | 2 - .../Immutable/ImmutableArray_1.Minimal.cs | 2 - .../Collections/Immutable/ImmutableArray_1.cs | 3 +- .../ImmutableDictionary_2.HashBucket.cs | 12 - .../ImmutableHashSet_1.HashBucket.cs | 4 - .../Immutable/ImmutableHashSet_1.cs | 6 +- .../Immutable/ImmutableList_1.Builder.cs | 7 - .../Immutable/ImmutableList_1.Node.cs | 7 - .../Collections/Immutable/ImmutableList_1.cs | 6 - .../Collections/Immutable/ImmutableQueue_1.cs | 2 - .../ImmutableSortedDictionary_2.Builder.cs | 2 - .../ImmutableSortedDictionary_2.Node.cs | 2 - .../Immutable/ImmutableSortedDictionary_2.cs | 2 - .../Immutable/ImmutableSortedSet_1.Builder.cs | 6 - .../Immutable/ImmutableSortedSet_1.Node.cs | 2 - .../Immutable/ImmutableSortedSet_1.cs | 12 +- .../Collections/Immutable/ImmutableStack_1.cs | 2 - ...ystem.Diagnostics.DiagnosticSource.pkgproj | 8 +- ...System.Diagnostics.DiagnosticSource.csproj | 14 +- ...System.Diagnostics.DiagnosticSource.csproj | 66 +- .../System/Diagnostics/DiagnosticListener.cs | 8 - .../DiagnosticSourceEventSource.cs | 29 +- .../src/System/Drawing/macFunctions.cs | 3 +- .../pkg/System.IO.Packaging.pkgproj | 9 +- .../ref/System.IO.Packaging.csproj | 10 +- .../src/System.IO.Packaging.csproj | 9 +- .../IO/Packaging/FileFormatException.cs | 6 - .../pkg/System.Numerics.Tensors.pkgproj | 5 +- .../ref/System.Numerics.Tensors.csproj | 2 +- .../src/System.Numerics.Tensors.csproj | 6 +- .../CodeAnalysis/NullableAttributes.cs | 3 + ...m.Private.DataContractSerialization.csproj | 1 - .../pkg/System.Reflection.Context.pkgproj | 5 +- .../ref/System.Reflection.Context.csproj | 2 +- .../src/System.Reflection.Context.csproj | 2 +- .../Reflection/DispatchProxyGenerator.cs | 5 +- .../pkg/System.Reflection.Metadata.pkgproj | 5 +- .../ref/ReferenceSourceExcludeApi.txt | 5 - .../ref/System.Reflection.Metadata.Manual.cs | 2 - .../ref/System.Reflection.Metadata.csproj | 17 +- .../src/System.Reflection.Metadata.csproj | 38 +- ...CriticalDisposableObject.netstandard1.1.cs | 39 - .../FileStreamReadLightUp.netstandard1.1.cs | 114 --- .../MemoryMapLightUp.netstandard1.1.cs | 268 ----- ...em.Runtime.CompilerServices.Unsafe.pkgproj | 9 +- ...tem.Runtime.CompilerServices.Unsafe.csproj | 2 +- ...tem.Runtime.CompilerServices.Unsafe.ilproj | 6 +- .../pkg/System.Threading.Channels.pkgproj | 8 +- .../ref/System.Threading.Channels.csproj | 18 +- .../src/System.Threading.Channels.csproj | 19 +- .../Channels/AsyncOperation.netstandard1.cs | 24 - .../System.Threading.Tasks.Dataflow.pkgproj | 5 +- .../System.Threading.Tasks.Dataflow.csproj | 7 +- .../src/Base/DataflowBlock.cs | 4 - .../src/Blocks/ActionBlock.cs | 2 - .../src/Blocks/BatchBlock.cs | 4 - .../src/Blocks/BatchedJoinBlock.cs | 4 - .../src/Blocks/BroadcastBlock.cs | 8 - .../src/Blocks/BufferBlock.cs | 4 - .../src/Blocks/JoinBlock.cs | 6 - .../src/Blocks/TransformBlock.cs | 2 - .../src/Blocks/TransformManyBlock.cs | 2 - .../src/Blocks/WriteOnceBlock.cs | 6 - .../src/Internal/Common.cs | 4 - .../src/Internal/ConcurrentQueue.cs | 918 ------------------ .../src/Internal/DataflowEtwProvider.cs | 4 - .../Internal/IProducerConsumerCollection.cs | 113 --- .../src/Internal/ProducerConsumerQueues.cs | 4 - .../src/Internal/SourceCore.cs | 4 - .../src/Internal/SpscTargetCore.cs | 4 - .../src/Internal/TargetCore.cs | 4 - .../src/Internal/TargetRegistry.cs | 4 - .../src/Internal/Threading.cs | 53 - .../System.Threading.Tasks.Dataflow.csproj | 32 +- 86 files changed, 162 insertions(+), 2000 deletions(-) delete mode 100644 src/libraries/System.Reflection.Metadata/ref/ReferenceSourceExcludeApi.txt delete mode 100644 src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/CriticalDisposableObject.netstandard1.1.cs delete mode 100644 src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/FileStreamReadLightUp.netstandard1.1.cs delete mode 100644 src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/MemoryMapLightUp.netstandard1.1.cs delete mode 100644 src/libraries/System.Threading.Channels/src/System/Threading/Channels/AsyncOperation.netstandard1.cs delete mode 100644 src/libraries/System.Threading.Tasks.Dataflow/src/Internal/ConcurrentQueue.cs delete mode 100644 src/libraries/System.Threading.Tasks.Dataflow/src/Internal/IProducerConsumerCollection.cs delete mode 100644 src/libraries/System.Threading.Tasks.Dataflow/src/Internal/Threading.cs diff --git a/src/libraries/Common/src/System/CodeDom/CodeObject.cs b/src/libraries/Common/src/System/CodeDom/CodeObject.cs index 74aa7a9ebf11f..1a4898c9610e7 100644 --- a/src/libraries/Common/src/System/CodeDom/CodeObject.cs +++ b/src/libraries/Common/src/System/CodeDom/CodeObject.cs @@ -4,13 +4,13 @@ using System.Collections; using System.Collections.Specialized; -#if !FEATURE_SERIALIZATION +#if CODEDOM namespace System.CodeDom #else namespace System.Runtime.Serialization #endif { -#if !FEATURE_SERIALIZATION +#if CODEDOM public class CodeObject #else internal class CodeObject diff --git a/src/libraries/Common/src/System/CodeDom/CodeTypeReference.cs b/src/libraries/Common/src/System/CodeDom/CodeTypeReference.cs index cbe065b5a5a4b..ffeb0c92d406a 100644 --- a/src/libraries/Common/src/System/CodeDom/CodeTypeReference.cs +++ b/src/libraries/Common/src/System/CodeDom/CodeTypeReference.cs @@ -5,14 +5,14 @@ using System.Diagnostics; using System.Globalization; -#if !FEATURE_SERIALIZATION +#if CODEDOM namespace System.CodeDom #else namespace System.Runtime.Serialization #endif { [Flags] -#if !FEATURE_SERIALIZATION +#if CODEDOM public enum CodeTypeReferenceOptions #else internal enum CodeTypeReferenceOptions @@ -22,7 +22,7 @@ internal enum CodeTypeReferenceOptions GenericTypeParameter = 0x00000002 } -#if !FEATURE_SERIALIZATION +#if CODEDOM public class CodeTypeReference : CodeObject #else internal sealed class CodeTypeReference : CodeObject @@ -281,7 +281,7 @@ public CodeTypeReference(string typeName, params CodeTypeReference[] typeArgumen } } -#if !FEATURE_SERIALIZATION +#if CODEDOM public CodeTypeReference(CodeTypeParameter typeParameter) : this(typeParameter?.Name) { diff --git a/src/libraries/Common/src/System/CodeDom/CodeTypeReferenceCollection.cs b/src/libraries/Common/src/System/CodeDom/CodeTypeReferenceCollection.cs index 92df60156f9be..ffdfa8e4a3301 100644 --- a/src/libraries/Common/src/System/CodeDom/CodeTypeReferenceCollection.cs +++ b/src/libraries/Common/src/System/CodeDom/CodeTypeReferenceCollection.cs @@ -3,13 +3,13 @@ using System.Collections; -#if !FEATURE_SERIALIZATION +#if CODEDOM namespace System.CodeDom #else namespace System.Runtime.Serialization #endif { -#if !FEATURE_SERIALIZATION +#if CODEDOM public class CodeTypeReferenceCollection : CollectionBase #else internal sealed class CodeTypeReferenceCollection : CollectionBase diff --git a/src/libraries/Common/src/System/HexConverter.cs b/src/libraries/Common/src/System/HexConverter.cs index 02426f6e0501d..bd3f5737a4953 100644 --- a/src/libraries/Common/src/System/HexConverter.cs +++ b/src/libraries/Common/src/System/HexConverter.cs @@ -169,7 +169,7 @@ public static void EncodeToUtf16(ReadOnlySpan bytes, Span chars, Cas #endif public static unsafe string ToString(ReadOnlySpan bytes, Casing casing = Casing.Upper) { -#if NETFRAMEWORK || NETSTANDARD1_0 || NETSTANDARD1_3 || NETSTANDARD2_0 +#if NETFRAMEWORK || NETSTANDARD2_0 Span result = stackalloc char[0]; if (bytes.Length > 16) { diff --git a/src/libraries/Common/src/System/SR.cs b/src/libraries/Common/src/System/SR.cs index 84da3bc46878a..25894922254a6 100644 --- a/src/libraries/Common/src/System/SR.cs +++ b/src/libraries/Common/src/System/SR.cs @@ -8,7 +8,7 @@ namespace System { internal static partial class SR { -#if (!NETSTANDARD1_0 && !NETSTANDARD1_1 && !NET45) // AppContext is not supported on < NetStandard1.3 or < .NET Framework 4.5 +#if !NET45 // AppContext is not supported on < .NET Framework 4.5 private static readonly bool s_usingResourceKeys = AppContext.TryGetSwitch("System.Resources.UseSystemResourceKeys", out bool usingResourceKeys) ? usingResourceKeys : false; #endif @@ -17,7 +17,7 @@ internal static partial class SR // Native code generators can replace the value this returns based on user input at the time of native code generation. // The Linker is also capable of replacing the value of this method when the application is being trimmed. private static bool UsingResourceKeys() => -#if (!NETSTANDARD1_0 && !NETSTANDARD1_1 && !NET45) // AppContext is not supported on < NetStandard1.3 or < .NET Framework 4.5 +#if !NET45 // AppContext is not supported on < .NET Framework 4.5 s_usingResourceKeys; #else false; diff --git a/src/libraries/Directory.Build.targets b/src/libraries/Directory.Build.targets index f166ddc4aadef..56d428cd34ed5 100644 --- a/src/libraries/Directory.Build.targets +++ b/src/libraries/Directory.Build.targets @@ -241,14 +241,10 @@ - - - - - - - - + + + + true diff --git a/src/libraries/Microsoft.Extensions.HostFactoryResolver/src/Microsoft.Extensions.HostFactoryResolver.Sources.csproj b/src/libraries/Microsoft.Extensions.HostFactoryResolver/src/Microsoft.Extensions.HostFactoryResolver.Sources.csproj index 8d18a805d2d8e..43edfb9491a63 100644 --- a/src/libraries/Microsoft.Extensions.HostFactoryResolver/src/Microsoft.Extensions.HostFactoryResolver.Sources.csproj +++ b/src/libraries/Microsoft.Extensions.HostFactoryResolver/src/Microsoft.Extensions.HostFactoryResolver.Sources.csproj @@ -1,17 +1,16 @@ + netstandard2.0 true false true + true false Internal package for sharing Microsoft.Extensions.Hosting.HostFactoryResolver type. - - - - diff --git a/src/libraries/System.CodeDom/src/System.CodeDom.csproj b/src/libraries/System.CodeDom/src/System.CodeDom.csproj index cd0e3a2edd236..84dd24091ba61 100644 --- a/src/libraries/System.CodeDom/src/System.CodeDom.csproj +++ b/src/libraries/System.CodeDom/src/System.CodeDom.csproj @@ -7,9 +7,9 @@ - true + true - + diff --git a/src/libraries/System.Collections.Immutable/pkg/System.Collections.Immutable.pkgproj b/src/libraries/System.Collections.Immutable/pkg/System.Collections.Immutable.pkgproj index 9383884e5e8eb..1db0e1915d389 100644 --- a/src/libraries/System.Collections.Immutable/pkg/System.Collections.Immutable.pkgproj +++ b/src/libraries/System.Collections.Immutable/pkg/System.Collections.Immutable.pkgproj @@ -2,7 +2,7 @@ - net45;netcore45;netcoreapp1.0;wp8;wpa81;$(AllXamarinFrameworks) + net461;netcoreapp2.0;uap10.0.16299;$(AllXamarinFrameworks) + \ No newline at end of file diff --git a/src/libraries/System.Collections.Immutable/ref/System.Collections.Immutable.cs b/src/libraries/System.Collections.Immutable/ref/System.Collections.Immutable.cs index 2da1db4d2828f..7e060514da2bf 100644 --- a/src/libraries/System.Collections.Immutable/ref/System.Collections.Immutable.cs +++ b/src/libraries/System.Collections.Immutable/ref/System.Collections.Immutable.cs @@ -118,10 +118,8 @@ public static partial class ImmutableArray public System.Collections.Immutable.ImmutableArray Add(T item) { throw null; } public System.Collections.Immutable.ImmutableArray AddRange(System.Collections.Generic.IEnumerable items) { throw null; } public System.Collections.Immutable.ImmutableArray AddRange(System.Collections.Immutable.ImmutableArray items) { throw null; } -#if !NETSTANDARD1_0 public System.ReadOnlyMemory AsMemory() { throw null; } public System.ReadOnlySpan AsSpan() { throw null; } -#endif public System.Collections.Immutable.ImmutableArray< #nullable disable TOther @@ -154,9 +152,7 @@ public void CopyTo(T[] destination, int destinationIndex) { } public System.Collections.Immutable.ImmutableArray Insert(int index, T item) { throw null; } public System.Collections.Immutable.ImmutableArray InsertRange(int index, System.Collections.Generic.IEnumerable items) { throw null; } public System.Collections.Immutable.ImmutableArray InsertRange(int index, System.Collections.Immutable.ImmutableArray items) { throw null; } -#if !NETSTANDARD1_0 public ref readonly T ItemRef(int index) { throw null; } -#endif public int LastIndexOf(T item) { throw null; } public int LastIndexOf(T item, int startIndex) { throw null; } public int LastIndexOf(T item, int startIndex, int count) { throw null; } @@ -239,9 +235,7 @@ public void CopyTo(T[] array, int index) { } public int IndexOf(T item, int startIndex, int count) { throw null; } public int IndexOf(T item, int startIndex, int count, System.Collections.Generic.IEqualityComparer? equalityComparer) { throw null; } public void Insert(int index, T item) { } -#if !NETSTANDARD1_0 public ref readonly T ItemRef(int index) { throw null; } -#endif public int LastIndexOf(T item) { throw null; } public int LastIndexOf(T item, int startIndex) { throw null; } public int LastIndexOf(T item, int startIndex, int count) { throw null; } @@ -423,7 +417,7 @@ public static partial class ImmutableHashSet public static System.Collections.Immutable.ImmutableHashSet ToImmutableHashSet(this System.Collections.Immutable.ImmutableHashSet.Builder builder) { throw null; } } - #if !NETSTANDARD1_0 && !NETSTANDARD1_3 && !NETSTANDARD2_0 && !NETFRAMEWORK + #if !NETSTANDARD2_0 && !NETFRAMEWORK public sealed partial class ImmutableHashSet : System.Collections.Generic.ICollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.ISet, System.Collections.Generic.IReadOnlySet, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.Immutable.IImmutableSet #else public sealed partial class ImmutableHashSet : System.Collections.Generic.ICollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.ISet, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.Immutable.IImmutableSet @@ -598,9 +592,7 @@ public void ForEach(System.Action action) { } public int IndexOf(T item, int index, int count, System.Collections.Generic.IEqualityComparer? equalityComparer) { throw null; } public System.Collections.Immutable.ImmutableList Insert(int index, T item) { throw null; } public System.Collections.Immutable.ImmutableList InsertRange(int index, System.Collections.Generic.IEnumerable items) { throw null; } -#if !NETSTANDARD1_0 public ref readonly T ItemRef(int index) { throw null; } -#endif public int LastIndexOf(T item, int index, int count, System.Collections.Generic.IEqualityComparer? equalityComparer) { throw null; } public System.Collections.Immutable.ImmutableList Remove(T value) { throw null; } public System.Collections.Immutable.ImmutableList Remove(T value, System.Collections.Generic.IEqualityComparer? equalityComparer) { throw null; } @@ -688,9 +680,7 @@ public void ForEach(System.Action action) { } public int IndexOf(T item, int index, int count, System.Collections.Generic.IEqualityComparer? equalityComparer) { throw null; } public void Insert(int index, T item) { } public void InsertRange(int index, System.Collections.Generic.IEnumerable items) { } -#if !NETSTANDARD1_0 public ref readonly T ItemRef(int index) { throw null; } -#endif public int LastIndexOf(T item) { throw null; } public int LastIndexOf(T item, int startIndex) { throw null; } public int LastIndexOf(T item, int startIndex, int count) { throw null; } @@ -747,9 +737,7 @@ internal ImmutableQueue() { } public System.Collections.Immutable.ImmutableQueue Enqueue(T value) { throw null; } public System.Collections.Immutable.ImmutableQueue.Enumerator GetEnumerator() { throw null; } public T Peek() { throw null; } -#if !NETSTANDARD1_0 public ref readonly T PeekRef() { throw null; } -#endif System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } System.Collections.Immutable.IImmutableQueue System.Collections.Immutable.IImmutableQueue.Clear() { throw null; } @@ -840,9 +828,7 @@ void System.Collections.IDictionary.Remove(object key) { } public System.Collections.Immutable.ImmutableSortedDictionary.Builder ToBuilder() { throw null; } public bool TryGetKey(TKey equalKey, out TKey actualKey) { throw null; } public bool TryGetValue(TKey key, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TValue value) { throw null; } -#if !NETSTANDARD1_0 public ref readonly TValue ValueRef(TKey key) { throw null; } -#endif public System.Collections.Immutable.ImmutableSortedDictionary WithComparers(System.Collections.Generic.IComparer? keyComparer) { throw null; } public System.Collections.Immutable.ImmutableSortedDictionary WithComparers(System.Collections.Generic.IComparer? keyComparer, System.Collections.Generic.IEqualityComparer? valueComparer) { throw null; } public sealed partial class Builder : System.Collections.Generic.ICollection>, System.Collections.Generic.IDictionary, System.Collections.Generic.IEnumerable>, System.Collections.Generic.IReadOnlyCollection>, System.Collections.Generic.IReadOnlyDictionary, System.Collections.ICollection, System.Collections.IDictionary, System.Collections.IEnumerable @@ -888,9 +874,7 @@ void System.Collections.IDictionary.Remove(object key) { } public System.Collections.Immutable.ImmutableSortedDictionary ToImmutable() { throw null; } public bool TryGetKey(TKey equalKey, out TKey actualKey) { throw null; } public bool TryGetValue(TKey key, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TValue value) { throw null; } -#if !NETSTANDARD1_0 public ref readonly TValue ValueRef(TKey key) { throw null; } -#endif } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] public partial struct Enumerator : System.Collections.Generic.IEnumerator>, System.Collections.IEnumerator, System.IDisposable @@ -921,11 +905,11 @@ public static partial class ImmutableSortedSet public static System.Collections.Immutable.ImmutableSortedSet ToImmutableSortedSet(this System.Collections.Immutable.ImmutableSortedSet.Builder builder) { throw null; } } - #if !NETSTANDARD1_0 && !NETSTANDARD1_3 && !NETSTANDARD2_0 && !NETFRAMEWORK +#if !NETSTANDARD2_0 && !NETFRAMEWORK public sealed partial class ImmutableSortedSet : System.Collections.Generic.ICollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IList, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.Generic.ISet, System.Collections.Generic.IReadOnlySet, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList, System.Collections.Immutable.IImmutableSet - #else +#else public sealed partial class ImmutableSortedSet : System.Collections.Generic.ICollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IList, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.Generic.ISet, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList, System.Collections.Immutable.IImmutableSet - #endif +#endif { internal ImmutableSortedSet() { } public static readonly System.Collections.Immutable.ImmutableSortedSet Empty; @@ -953,9 +937,7 @@ internal ImmutableSortedSet() { } public bool IsProperSupersetOf(System.Collections.Generic.IEnumerable other) { throw null; } public bool IsSubsetOf(System.Collections.Generic.IEnumerable other) { throw null; } public bool IsSupersetOf(System.Collections.Generic.IEnumerable other) { throw null; } -#if !NETSTANDARD1_0 public ref readonly T ItemRef(int index) { throw null; } -#endif public bool Overlaps(System.Collections.Generic.IEnumerable other) { throw null; } public System.Collections.Immutable.ImmutableSortedSet Remove(T value) { throw null; } public System.Collections.Generic.IEnumerable Reverse() { throw null; } @@ -1014,9 +996,7 @@ public void IntersectWith(System.Collections.Generic.IEnumerable other) { } public bool IsProperSupersetOf(System.Collections.Generic.IEnumerable other) { throw null; } public bool IsSubsetOf(System.Collections.Generic.IEnumerable other) { throw null; } public bool IsSupersetOf(System.Collections.Generic.IEnumerable other) { throw null; } -#if !NETSTANDARD1_0 public ref readonly T ItemRef(int index) { throw null; } -#endif public bool Overlaps(System.Collections.Generic.IEnumerable other) { throw null; } public bool Remove(T item) { throw null; } public System.Collections.Generic.IEnumerable Reverse() { throw null; } @@ -1059,9 +1039,7 @@ internal ImmutableStack() { } public System.Collections.Immutable.ImmutableStack Clear() { throw null; } public System.Collections.Immutable.ImmutableStack.Enumerator GetEnumerator() { throw null; } public T Peek() { throw null; } -#if !NETSTANDARD1_0 public ref readonly T PeekRef() { throw null; } -#endif public System.Collections.Immutable.ImmutableStack Pop() { throw null; } public System.Collections.Immutable.ImmutableStack Pop(out T value) { throw null; } public System.Collections.Immutable.ImmutableStack Push(T value) { throw null; } diff --git a/src/libraries/System.Collections.Immutable/ref/System.Collections.Immutable.csproj b/src/libraries/System.Collections.Immutable/ref/System.Collections.Immutable.csproj index 57d3d7cec3d4d..3d1674e34b356 100644 --- a/src/libraries/System.Collections.Immutable/ref/System.Collections.Immutable.csproj +++ b/src/libraries/System.Collections.Immutable/ref/System.Collections.Immutable.csproj @@ -1,6 +1,6 @@ - $(NetCoreAppCurrent);netstandard1.0;netstandard1.3;netstandard2.0;net461 + $(NetCoreAppCurrent);netstandard2.0;net461 true enable @@ -8,21 +8,11 @@ - - - + + + - + - - - - - - - - \ No newline at end of file diff --git a/src/libraries/System.Collections.Immutable/src/System.Collections.Immutable.csproj b/src/libraries/System.Collections.Immutable/src/System.Collections.Immutable.csproj index 5197bc1ad3b8f..b9993c0d4afcc 100644 --- a/src/libraries/System.Collections.Immutable/src/System.Collections.Immutable.csproj +++ b/src/libraries/System.Collections.Immutable/src/System.Collections.Immutable.csproj @@ -1,13 +1,9 @@ - $(NetCoreAppCurrent);netstandard1.0;netstandard1.3;netstandard2.0;net461 + $(NetCoreAppCurrent);netstandard2.0;net461 true enable - - - netstandard1.0;portable-net45+win8+wp8+wpa81 - @@ -89,10 +85,6 @@ Link="Common\System\Runtime\Versioning\NonVersionableAttribute.cs" /> - - - @@ -107,13 +99,7 @@ - - - - - + diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.Builder.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.Builder.cs index 87f6e75131c2a..bdbb036a4b7e7 100644 --- a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.Builder.cs +++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.Builder.cs @@ -157,7 +157,6 @@ public T this[int index] } } -#if !NETSTANDARD1_0 /// /// Gets a read-only reference to the element at the specified index. /// @@ -174,7 +173,6 @@ public ref readonly T ItemRef(int index) return ref this._elements[index]; } -#endif /// /// Gets a value indicating whether the is read-only. diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.Minimal.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.Minimal.cs index a2294fcc22b32..560fd76d18adf 100644 --- a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.Minimal.cs +++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.Minimal.cs @@ -132,7 +132,6 @@ public T this[int index] } } -#if !NETSTANDARD1_0 /// /// Gets a read-only reference to the element at the specified index in the read-only list. /// @@ -147,7 +146,6 @@ public ref readonly T ItemRef(int index) // of removing array bounds checking to work. return ref this.array![index]; } -#endif /// /// Gets a value indicating whether this collection is empty. diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.cs index 248551c8c44bc..e8661bd05e509 100644 --- a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.cs +++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.cs @@ -90,11 +90,10 @@ T IReadOnlyList.this[int index] } } -#if !NETSTANDARD1_0 public ReadOnlySpan AsSpan() => new ReadOnlySpan(array); public ReadOnlyMemory AsMemory() => new ReadOnlyMemory(array); -#endif + /// /// Searches the array for the specified item. /// diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableDictionary_2.HashBucket.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableDictionary_2.HashBucket.cs index 77e65ecf25dd5..aa8d7636cfbca 100644 --- a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableDictionary_2.HashBucket.cs +++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableDictionary_2.HashBucket.cs @@ -186,11 +186,7 @@ internal HashBucket Add(TKey key, TValue value, IEqualityComparer valueComparer, out T exi int index = _additionalElements.IndexOf(value, valueComparer); if (index >= 0) { -#if !NETSTANDARD1_0 existingValue = _additionalElements.ItemRef(index); -#else - existingValue = _additionalElements[index]; -#endif return true; } } diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableHashSet_1.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableHashSet_1.cs index 411c38a4ea3df..3f67d39ef067a 100644 --- a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableHashSet_1.cs +++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableHashSet_1.cs @@ -14,11 +14,11 @@ namespace System.Collections.Immutable /// The type of elements in the set. [DebuggerDisplay("Count = {Count}")] [DebuggerTypeProxy(typeof(ImmutableEnumerableDebuggerProxy<>))] - #if !NETSTANDARD1_0 && !NETSTANDARD1_3 && !NETSTANDARD2_0 && !NETFRAMEWORK +#if !NETSTANDARD2_0 && !NETFRAMEWORK public sealed partial class ImmutableHashSet : IImmutableSet, IHashKeyCollection, IReadOnlyCollection, ICollection, ISet, IReadOnlySet, ICollection, IStrongEnumerable.Enumerator> - #else +#else public sealed partial class ImmutableHashSet : IImmutableSet, IHashKeyCollection, IReadOnlyCollection, ICollection, ISet, ICollection, IStrongEnumerable.Enumerator> - #endif +#endif { /// /// An empty immutable hash set with the default comparer for . diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableList_1.Builder.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableList_1.Builder.cs index 3395d3cc81b0e..fa7410b840426 100644 --- a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableList_1.Builder.cs +++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableList_1.Builder.cs @@ -129,13 +129,8 @@ public T this[int index] { get { -#if !NETSTANDARD1_0 return this.Root.ItemRef(index); -#else - return this.Root[index]; -#endif } - set { this.Root = this.Root.ReplaceAt(index, value); @@ -153,7 +148,6 @@ T IOrderedCollection.this[int index] } } -#if !NETSTANDARD1_0 /// /// Gets a read-only reference to the value for a given index into the list. /// @@ -163,7 +157,6 @@ public ref readonly T ItemRef(int index) { return ref this.Root.ItemRef(index); } -#endif #endregion diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableList_1.Node.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableList_1.Node.cs index ef0381384f29a..ed4ee0a12f036 100644 --- a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableList_1.Node.cs +++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableList_1.Node.cs @@ -186,7 +186,6 @@ internal T this[int index] } } -#if !NETSTANDARD1_0 /// /// Gets a read-only reference to the element of the set at the given index. /// @@ -209,7 +208,6 @@ internal ref readonly T ItemRef(int index) return ref _key; } -#endif #region IEnumerable Members @@ -524,13 +522,8 @@ internal Node Reverse(int index, int count) int end = index + count - 1; while (start < end) { -#if !NETSTANDARD1_0 T a = result.ItemRef(start); T b = result.ItemRef(end); -#else - T a = result[start]; - T b = result[end]; -#endif result = result .ReplaceAt(end, a) .ReplaceAt(start, b); diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableList_1.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableList_1.cs index 9597b0a98b6ae..eda985d56077a 100644 --- a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableList_1.cs +++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableList_1.cs @@ -166,13 +166,8 @@ private ImmutableList(Node root) /// The 0-based index of the element in the set to return. /// The element at the given position. /// Thrown from getter when is negative or not less than . -#if !NETSTANDARD1_0 public T this[int index] => _root.ItemRef(index); -#else - public T this[int index] => _root[index]; -#endif -#if !NETSTANDARD1_0 /// /// Gets a read-only reference to the element of the set at the given index. /// @@ -180,7 +175,6 @@ private ImmutableList(Node root) /// A read-only reference to the element at the given position. /// Thrown when is negative or not less than . public ref readonly T ItemRef(int index) => ref _root.ItemRef(index); -#endif #endregion diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableQueue_1.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableQueue_1.cs index 7d6f6b97391d0..1f2ae3e284c79 100644 --- a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableQueue_1.cs +++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableQueue_1.cs @@ -133,7 +133,6 @@ public T Peek() return _forwards.Peek(); } -#if !NETSTANDARD1_0 /// /// Gets a read-only reference to the element at the front of the queue. /// @@ -147,7 +146,6 @@ public ref readonly T PeekRef() return ref _forwards.PeekRef(); } -#endif /// /// Adds an element to the back of the queue. diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableSortedDictionary_2.Builder.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableSortedDictionary_2.Builder.cs index 911208abcac79..75bb852de5528 100644 --- a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableSortedDictionary_2.Builder.cs +++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableSortedDictionary_2.Builder.cs @@ -197,7 +197,6 @@ public TValue this[TKey key] } } -#if !NETSTANDARD1_0 /// /// Returns a read-only reference to the value associated with the provided key. /// @@ -208,7 +207,6 @@ public ref readonly TValue ValueRef(TKey key) return ref _root.ValueRef(key, _keyComparer); } -#endif #endregion diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableSortedDictionary_2.Node.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableSortedDictionary_2.Node.cs index 99173a5b2715c..26daa6ef73ffd 100644 --- a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableSortedDictionary_2.Node.cs +++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableSortedDictionary_2.Node.cs @@ -327,7 +327,6 @@ internal Node Remove(TKey key, IComparer keyComparer, out bool mutated) return this.RemoveRecursive(key, keyComparer, out mutated); } -#if !NETSTANDARD1_0 /// /// Returns a read-only reference to the value associated with the provided key. /// @@ -345,7 +344,6 @@ internal ref readonly TValue ValueRef(TKey key, IComparer keyComparer) return ref match._value; } -#endif /// /// Tries to get the value. diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableSortedDictionary_2.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableSortedDictionary_2.cs index 31d2b34974ec4..c720eb275e538 100644 --- a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableSortedDictionary_2.cs +++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableSortedDictionary_2.cs @@ -206,7 +206,6 @@ public TValue this[TKey key] } } -#if !NETSTANDARD1_0 /// /// Returns a read-only reference to the value associated with the provided key. /// @@ -217,7 +216,6 @@ public ref readonly TValue ValueRef(TKey key) return ref _root.ValueRef(key, _keyComparer); } -#endif #endregion diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableSortedSet_1.Builder.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableSortedSet_1.Builder.cs index 2a1c606d12aac..4290f5c2ddeed 100644 --- a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableSortedSet_1.Builder.cs +++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableSortedSet_1.Builder.cs @@ -100,14 +100,9 @@ bool ICollection.IsReadOnly /// public T this[int index] { -#if !NETSTANDARD1_0 get { return _root.ItemRef(index); } -#else - get { return _root[index]; } -#endif } -#if !NETSTANDARD1_0 /// /// Gets a read-only reference to the element of the set at the given index. /// @@ -117,7 +112,6 @@ public ref readonly T ItemRef(int index) { return ref _root.ItemRef(index); } -#endif /// /// Gets the maximum value in the collection, as defined by the comparer. diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableSortedSet_1.Node.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableSortedSet_1.Node.cs index 89b044c0ce979..aea4caff1bea2 100644 --- a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableSortedSet_1.Node.cs +++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableSortedSet_1.Node.cs @@ -252,7 +252,6 @@ internal T this[int index] } } -#if !NETSTANDARD1_0 /// /// Gets a read-only reference to the element of the set at the given index. /// @@ -275,7 +274,6 @@ internal ref readonly T ItemRef(int index) return ref _key; } -#endif #region IEnumerable Members diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableSortedSet_1.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableSortedSet_1.cs index 08dbda353bc60..1beb3df403dbd 100644 --- a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableSortedSet_1.cs +++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableSortedSet_1.cs @@ -19,11 +19,11 @@ namespace System.Collections.Immutable /// [DebuggerDisplay("Count = {Count}")] [DebuggerTypeProxy(typeof(ImmutableEnumerableDebuggerProxy<>))] - #if !NETSTANDARD1_0 && !NETSTANDARD1_3 && !NETSTANDARD2_0 && !NETFRAMEWORK +#if !NETSTANDARD2_0 && !NETFRAMEWORK public sealed partial class ImmutableSortedSet : IImmutableSet, ISortKeyCollection, IReadOnlySet, IReadOnlyList, IList, ISet, IList, IStrongEnumerable.Enumerator> - #else +#else public sealed partial class ImmutableSortedSet : IImmutableSet, ISortKeyCollection, IReadOnlyList, IList, ISet, IList, IStrongEnumerable.Enumerator> - #endif +#endif { /// /// This is the factor between the small collection's size and the large collection's size in a bulk operation, @@ -149,15 +149,10 @@ public T this[int index] { get { -#if !NETSTANDARD1_0 return _root.ItemRef(index); -#else - return _root[index]; -#endif } } -#if !NETSTANDARD1_0 /// /// Gets a read-only reference of the element of the set at the given index. /// @@ -167,7 +162,6 @@ public ref readonly T ItemRef(int index) { return ref _root.ItemRef(index); } -#endif #endregion diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableStack_1.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableStack_1.cs index f8b70a0a230d8..980477889121d 100644 --- a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableStack_1.cs +++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableStack_1.cs @@ -112,7 +112,6 @@ public T Peek() return _head!; } -#if !NETSTANDARD1_0 /// /// Gets a read-only reference to the element on the top of the stack. /// @@ -129,7 +128,6 @@ public ref readonly T PeekRef() return ref _head!; } -#endif /// /// Pushes an element onto a stack and returns the new stack. diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/pkg/System.Diagnostics.DiagnosticSource.pkgproj b/src/libraries/System.Diagnostics.DiagnosticSource/pkg/System.Diagnostics.DiagnosticSource.pkgproj index dc25775f6733e..b85c37851526b 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/pkg/System.Diagnostics.DiagnosticSource.pkgproj +++ b/src/libraries/System.Diagnostics.DiagnosticSource/pkg/System.Diagnostics.DiagnosticSource.pkgproj @@ -2,11 +2,8 @@ - net46;net45;netcore45;netcoreapp1.0;wpa81;$(AllXamarinFrameworks) + net45;netcoreapp2.0;uap10.0.16299;$(AllXamarinFrameworks) - - + diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/ref/System.Diagnostics.DiagnosticSource.csproj b/src/libraries/System.Diagnostics.DiagnosticSource/ref/System.Diagnostics.DiagnosticSource.csproj index 983dd3b07d4c3..db3fc7b0d1015 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/ref/System.Diagnostics.DiagnosticSource.csproj +++ b/src/libraries/System.Diagnostics.DiagnosticSource/ref/System.Diagnostics.DiagnosticSource.csproj @@ -1,28 +1,22 @@ - netstandard2.0;netstandard1.1;netstandard1.3;net45 + netstandard2.0;net45 false enable - true - $(DefineConstants);ALLOW_PARTIALLY_TRUSTED_CALLERS - - true + $(DefineConstants);ALLOW_PARTIALLY_TRUSTED_CALLERS + - - + - - - \ No newline at end of file diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/src/System.Diagnostics.DiagnosticSource.csproj b/src/libraries/System.Diagnostics.DiagnosticSource/src/System.Diagnostics.DiagnosticSource.csproj index 32e49f46ad47b..0a453be435ba8 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/src/System.Diagnostics.DiagnosticSource.csproj +++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/System.Diagnostics.DiagnosticSource.csproj @@ -4,24 +4,14 @@ false $(NoWarn);SA1205 enable - $(NetCoreAppCurrent);net5.0;netstandard1.1;netstandard1.3;net45;net46;netstandard2.0 + $(NetCoreAppCurrent);net5.0;netstandard2.0;net46;net45 true - - netstandard1.1;portable-net45+win8+wpa81 - $(DefineConstants);NO_EVENTSOURCE_COMPLEX_TYPE_SUPPORT;NO_ARRAY_EMPTY_SUPPORT - $(DefineConstants);EVENTSOURCE_ACTIVITY_SUPPORT - $(DefineConstants);EVENTSOURCE_ENUMERATE_SUPPORT - $(DefineConstants);ALLOW_PARTIALLY_TRUSTED_CALLERS;ENABLE_HTTP_HANDLER - true + $(DefineConstants);NO_EVENTSOURCE_COMPLEX_TYPE_SUPPORT;NO_ARRAY_EMPTY_SUPPORT + $(DefineConstants);ALLOW_PARTIALLY_TRUSTED_CALLERS;ENABLE_HTTP_HANDLER $(DefineConstants);W3C_DEFAULT_ID_FORMAT - - true @@ -29,13 +19,13 @@ - + - + @@ -65,42 +55,41 @@ - + Common\System\LocalAppContextSwitches.Common.cs - + - + - + - + - + - + + + + @@ -108,33 +97,12 @@ - - - - - - - - - - - - - - - - - - + - - - diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DiagnosticListener.cs b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DiagnosticListener.cs index 0960ab03a9a06..cd588e6e49953 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DiagnosticListener.cs +++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DiagnosticListener.cs @@ -263,14 +263,6 @@ public override void Write(string name, object? value) curSubscription.Observer.OnNext(new KeyValuePair(name, value)); } - /// - /// We don't have Activities in NetStandard1.1. but it is a pain to ifdef out all references to the Activity type - /// in DiagnosticSubscription so we just define a private type for it here just so things compile. - /// -#if NETSTANDARD1_1 - private sealed class Activity {} -#endif - // Note that Subscriptions are READ ONLY. This means you never update any fields (even on removal!) private sealed class DiagnosticSubscription : IDisposable { diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DiagnosticSourceEventSource.cs b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DiagnosticSourceEventSource.cs index 893bef690789d..2c3ee45d30119 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DiagnosticSourceEventSource.cs +++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DiagnosticSourceEventSource.cs @@ -548,13 +548,11 @@ public static void CreateFilterAndTransformList(ref FilterAndTransform? specList while (startIdx < endIdx && char.IsWhiteSpace(filterAndPayloadSpecs[startIdx])) startIdx++; -#if EVENTSOURCE_ACTIVITY_SUPPORT if (IsActivitySourceEntry(filterAndPayloadSpecs, startIdx, endIdx)) { AddNewActivitySourceTransform(filterAndPayloadSpecs, startIdx, endIdx, eventSource); } else -#endif // EVENTSOURCE_ACTIVITY_SUPPORT { specList = new FilterAndTransform(filterAndPayloadSpecs, startIdx, endIdx, eventSource, specList); } @@ -563,13 +561,12 @@ public static void CreateFilterAndTransformList(ref FilterAndTransform? specList if (endIdx < 0) break; } -#if EVENTSOURCE_ACTIVITY_SUPPORT + if (eventSource._activitySourceSpecs != null) { NormalizeActivitySourceSpecsList(eventSource); CreateActivityListener(eventSource); } -#endif // EVENTSOURCE_ACTIVITY_SUPPORT } /// @@ -579,11 +576,9 @@ public static void CreateFilterAndTransformList(ref FilterAndTransform? specList /// public static void DestroyFilterAndTransformList(ref FilterAndTransform? specList, DiagnosticSourceEventSource eventSource) { -#if EVENTSOURCE_ACTIVITY_SUPPORT eventSource._activityListener?.Dispose(); eventSource._activityListener = null; eventSource._activitySourceSpecs = null; // nothing to dispose inside this list. -#endif // EVENTSOURCE_ACTIVITY_SUPPORT var curSpec = specList; specList = null; // Null out the list @@ -737,7 +732,6 @@ void OnEventWritten(KeyValuePair evnt) })); } -#if EVENTSOURCE_ACTIVITY_SUPPORT internal FilterAndTransform(string filterAndPayloadSpec, int endIdx, int colonIdx, string activitySourceName, string? activityName, ActivityEvents events, ActivitySamplingResult samplingResult, DiagnosticSourceEventSource eventSource) { _eventSource = eventSource; @@ -1063,7 +1057,6 @@ internal static void NormalizeActivitySourceSpecsList(DiagnosticSourceEventSourc eventSource._activitySourceSpecs = firstSpecificList; } -#endif // EVENTSOURCE_ACTIVITY_SUPPORT private void Dispose() { @@ -1156,13 +1149,11 @@ private void Dispose() // Specific ActivitySource Transforms information -#if EVENTSOURCE_ACTIVITY_SUPPORT internal const string c_ActivitySourcePrefix = "[AS]"; internal string? SourceName { get; set; } internal string? ActivityName { get; set; } internal DiagnosticSourceEventSource.ActivityEvents Events { get; set; } internal ActivitySamplingResult SamplingResult { get; set; } -#endif // EVENTSOURCE_ACTIVITY_SUPPORT #region private @@ -1364,25 +1355,13 @@ public static PropertyFetch FetcherForProperty(Type? type, string propertyName) return new PropertyFetch(type); // returns null on any fetch. if (propertyName == CurrentActivityPropertyName) { -#if EVENTSOURCE_ACTIVITY_SUPPORT return new CurrentActivityPropertyFetch(); -#else - // In netstandard1.1 the Activity.Current API doesn't exist - Logger.Message($"{CurrentActivityPropertyName} not supported for this TFM"); - return new PropertyFetch(type); -#endif } Debug.Assert(type != null, "Type should only be null for the well-known static fetchers already checked"); TypeInfo typeInfo = type.GetTypeInfo(); if (propertyName == EnumeratePropertyName) { -#if !EVENTSOURCE_ENUMERATE_SUPPORT - // In netstandard1.1 and 1.3 the reflection APIs needed to implement Enumerate support aren't - // available - Logger.Message($"{EnumeratePropertyName} not supported for this TFM"); - return new PropertyFetch(type); -#else // If there are multiple implementations of IEnumerable, this arbitrarily uses the first one foreach (Type iFaceType in typeInfo.GetInterfaces()) { @@ -1402,7 +1381,6 @@ public static PropertyFetch FetcherForProperty(Type? type, string propertyName) // no implementation of IEnumerable found, return a null fetcher Logger.Message($"*Enumerate applied to non-enumerable type {type}"); return new PropertyFetch(type); -#endif } else { @@ -1470,8 +1448,6 @@ public ValueTypedFetchProperty(Type type, PropertyInfo property) : base(type) private readonly StructFunc _propertyFetch; } - -#if EVENTSOURCE_ACTIVITY_SUPPORT /// /// A fetcher that returns the result of Activity.Current /// @@ -1483,7 +1459,6 @@ public CurrentActivityPropertyFetch() : base(null) { } return Activity.Current; } } -#endif /// /// A fetcher that enumerates and formats an IEnumerable @@ -1546,10 +1521,8 @@ public Subscriptions(IDisposable subscription, Subscriptions? next) #endregion private FilterAndTransform? _specs; // Transformation specifications that indicate which sources/events are forwarded. -#if EVENTSOURCE_ACTIVITY_SUPPORT private FilterAndTransform? _activitySourceSpecs; // ActivitySource Transformation specifications that indicate which sources/events are forwarded. private ActivityListener? _activityListener; -#endif // EVENTSOURCE_ACTIVITY_SUPPORT #endregion } } diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/macFunctions.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/macFunctions.cs index a5d9bfd74b76b..13e75725b83fd 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/macFunctions.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/macFunctions.cs @@ -51,7 +51,6 @@ internal static class MacSupport private static Delegate? GetHwndDelegate() { -#if !NETSTANDARD1_6 foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies()) { if (string.Equals(asm.GetName().Name, "System.Windows.Forms")) @@ -63,7 +62,7 @@ internal static class MacSupport } } } -#endif + return null; } diff --git a/src/libraries/System.IO.Packaging/pkg/System.IO.Packaging.pkgproj b/src/libraries/System.IO.Packaging/pkg/System.IO.Packaging.pkgproj index 8d587674b7bef..79cc61de537d1 100644 --- a/src/libraries/System.IO.Packaging/pkg/System.IO.Packaging.pkgproj +++ b/src/libraries/System.IO.Packaging/pkg/System.IO.Packaging.pkgproj @@ -2,15 +2,12 @@ - net46;netcore50;netcoreapp1.0;$(AllXamarinFrameworks) + net46;netcoreapp2.0;uap10.0.16299;$(AllXamarinFrameworks) - - + + \ No newline at end of file diff --git a/src/libraries/System.IO.Packaging/ref/System.IO.Packaging.csproj b/src/libraries/System.IO.Packaging/ref/System.IO.Packaging.csproj index 94936bb92e45a..fa560a52611c6 100644 --- a/src/libraries/System.IO.Packaging/ref/System.IO.Packaging.csproj +++ b/src/libraries/System.IO.Packaging/ref/System.IO.Packaging.csproj @@ -1,19 +1,15 @@ - netstandard2.0;netstandard1.3;net46 + netstandard2.0;net46 enable - - - - - - + + \ No newline at end of file diff --git a/src/libraries/System.IO.Packaging/src/System.IO.Packaging.csproj b/src/libraries/System.IO.Packaging/src/System.IO.Packaging.csproj index d8d6ce3f3da35..f563b9ebc16c1 100644 --- a/src/libraries/System.IO.Packaging/src/System.IO.Packaging.csproj +++ b/src/libraries/System.IO.Packaging/src/System.IO.Packaging.csproj @@ -1,13 +1,12 @@ true - netstandard2.0;net46;netstandard1.3 + netstandard2.0;net46 enable - $(DefineConstants);FEATURE_SERIALIZATION - true + true @@ -37,9 +36,9 @@ - + - + \ No newline at end of file diff --git a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/FileFormatException.cs b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/FileFormatException.cs index 70ce130d2c975..6574ee7d0322d 100644 --- a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/FileFormatException.cs +++ b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/FileFormatException.cs @@ -1,9 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if FEATURE_SERIALIZATION using System.Runtime.Serialization; -#endif namespace System.IO { @@ -11,10 +9,8 @@ namespace System.IO /// The FileFormatException class is thrown when an input file or a data stream that is supposed to conform /// to a certain file format specification is malformed. /// -#if FEATURE_SERIALIZATION [Serializable] [System.Runtime.CompilerServices.TypeForwardedFrom("WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")] -#endif public class FileFormatException : FormatException { /// @@ -116,7 +112,6 @@ public FileFormatException(Uri? sourceUri, string? message, Exception? innerExce _sourceUri = sourceUri; } -#if FEATURE_SERIALIZATION protected FileFormatException(SerializationInfo info, StreamingContext context) : base(info, context) { string? sourceUriString = info.GetString("SourceUri"); @@ -134,7 +129,6 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont base.GetObjectData(info, context); info.AddValue("SourceUri", SourceUri?.GetComponents(UriComponents.SerializationInfoString, UriFormat.SafeUnescaped), typeof(string)); } -#endif /// /// Returns the name of a file that caused this exception. This property may be equal to an empty string diff --git a/src/libraries/System.Numerics.Tensors/pkg/System.Numerics.Tensors.pkgproj b/src/libraries/System.Numerics.Tensors/pkg/System.Numerics.Tensors.pkgproj index b3bc61caec5f1..75855f8b61ef0 100644 --- a/src/libraries/System.Numerics.Tensors/pkg/System.Numerics.Tensors.pkgproj +++ b/src/libraries/System.Numerics.Tensors/pkg/System.Numerics.Tensors.pkgproj @@ -6,8 +6,11 @@ 2. We don't currently have a good mechanism for telling nuget to include the xml doc from the implementation project in the ref folder for the generated package --> - net45;wpa81;win8;netcoreapp1.0;$(AllXamarinFrameworks) + net461;netcoreapp2.0;uap10.0.16299;$(AllXamarinFrameworks) + + + diff --git a/src/libraries/System.Numerics.Tensors/ref/System.Numerics.Tensors.csproj b/src/libraries/System.Numerics.Tensors/ref/System.Numerics.Tensors.csproj index c3ce692b4dfec..ae9c55011f812 100644 --- a/src/libraries/System.Numerics.Tensors/ref/System.Numerics.Tensors.csproj +++ b/src/libraries/System.Numerics.Tensors/ref/System.Numerics.Tensors.csproj @@ -1,6 +1,6 @@ - netstandard2.0;netstandard1.1;net461 + netstandard2.0;net461 enable diff --git a/src/libraries/System.Numerics.Tensors/src/System.Numerics.Tensors.csproj b/src/libraries/System.Numerics.Tensors/src/System.Numerics.Tensors.csproj index b69fb20b8395b..b87c193207be5 100644 --- a/src/libraries/System.Numerics.Tensors/src/System.Numerics.Tensors.csproj +++ b/src/libraries/System.Numerics.Tensors/src/System.Numerics.Tensors.csproj @@ -1,13 +1,9 @@ true - netstandard2.0;netstandard1.1;net461 + netstandard2.0;net461 enable - - - true - diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/NullableAttributes.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/NullableAttributes.cs index ff64dbf87889b..586d76d022275 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/NullableAttributes.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/NullableAttributes.cs @@ -3,6 +3,8 @@ namespace System.Diagnostics.CodeAnalysis { +// These attributes already shipped with .NET Core 3.1 in System.Runtime +#if !NETCOREAPP3_0 && !NETCOREAPP3_1 && !NETSTANDARD2_1 /// Specifies that null is allowed as an input even if the corresponding type disallows it. [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property, Inherited = false)] #if SYSTEM_PRIVATE_CORELIB @@ -124,6 +126,7 @@ sealed class DoesNotReturnIfAttribute : Attribute /// Gets the condition parameter value. public bool ParameterValue { get; } } +#endif /// Specifies that the method or property will ensure that the listed field and property members have not-null values. [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)] diff --git a/src/libraries/System.Private.DataContractSerialization/src/System.Private.DataContractSerialization.csproj b/src/libraries/System.Private.DataContractSerialization/src/System.Private.DataContractSerialization.csproj index 03db991db953d..57474c6e2464b 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System.Private.DataContractSerialization.csproj +++ b/src/libraries/System.Private.DataContractSerialization/src/System.Private.DataContractSerialization.csproj @@ -2,7 +2,6 @@ $(NoWarn);1634;1691;649 true - $(DefineConstants);FEATURE_SERIALIZATION $(NetCoreAppCurrent) false diff --git a/src/libraries/System.Reflection.Context/pkg/System.Reflection.Context.pkgproj b/src/libraries/System.Reflection.Context/pkg/System.Reflection.Context.pkgproj index ed4d4cb13313c..6f15c9c669941 100644 --- a/src/libraries/System.Reflection.Context/pkg/System.Reflection.Context.pkgproj +++ b/src/libraries/System.Reflection.Context/pkg/System.Reflection.Context.pkgproj @@ -2,7 +2,7 @@ - uap10.0.16299;netcoreapp2.0;net45 + uap10.0.16299;netcoreapp2.0;net45;$(AllXamarinFrameworks) @@ -16,6 +16,9 @@ UAP + + + diff --git a/src/libraries/System.Reflection.Context/ref/System.Reflection.Context.csproj b/src/libraries/System.Reflection.Context/ref/System.Reflection.Context.csproj index 4bce12a352273..077aa393f180a 100644 --- a/src/libraries/System.Reflection.Context/ref/System.Reflection.Context.csproj +++ b/src/libraries/System.Reflection.Context/ref/System.Reflection.Context.csproj @@ -4,7 +4,7 @@ plan on shipping a new desktop version out of band. Instead add API to a different assembly. --> 4.0.0.0 - netstandard2.0;netstandard1.1 + netstandard2.0 enable diff --git a/src/libraries/System.Reflection.Context/src/System.Reflection.Context.csproj b/src/libraries/System.Reflection.Context/src/System.Reflection.Context.csproj index 09daf8ff6c46d..dcbd6df8556d2 100644 --- a/src/libraries/System.Reflection.Context/src/System.Reflection.Context.csproj +++ b/src/libraries/System.Reflection.Context/src/System.Reflection.Context.csproj @@ -1,6 +1,6 @@ - netstandard2.1;netstandard2.0;netstandard1.1 + netstandard2.1;netstandard2.0 enable diff --git a/src/libraries/System.Reflection.DispatchProxy/src/System/Reflection/DispatchProxyGenerator.cs b/src/libraries/System.Reflection.DispatchProxy/src/System/Reflection/DispatchProxyGenerator.cs index 70380de2e18a8..78e1cd2095f8f 100644 --- a/src/libraries/System.Reflection.DispatchProxy/src/System/Reflection/DispatchProxyGenerator.cs +++ b/src/libraries/System.Reflection.DispatchProxy/src/System/Reflection/DispatchProxyGenerator.cs @@ -831,9 +831,8 @@ public sealed override bool Equals(MethodInfo? left, MethodInfo? right) else if (right == null) return false; - // This assembly should work in netstandard1.3, - // so we cannot use MemberInfo.MetadataToken here. - // Therefore, it compares honestly referring ECMA-335 I.8.6.1.6 Signature Matching. + // TODO: switch to use MemberInfo.MetadataToken here. + // It compares honestly referring ECMA-335 I.8.6.1.6 Signature Matching. if (!Equals(left.DeclaringType, right.DeclaringType)) return false; diff --git a/src/libraries/System.Reflection.Metadata/pkg/System.Reflection.Metadata.pkgproj b/src/libraries/System.Reflection.Metadata/pkg/System.Reflection.Metadata.pkgproj index a097651294578..99b92561bd292 100644 --- a/src/libraries/System.Reflection.Metadata/pkg/System.Reflection.Metadata.pkgproj +++ b/src/libraries/System.Reflection.Metadata/pkg/System.Reflection.Metadata.pkgproj @@ -2,7 +2,7 @@ - net45;netcore45;netcoreapp1.0;wpa81;$(AllXamarinFrameworks) + net461;netcoreapp2.0;uap10.0.16299;$(AllXamarinFrameworks) + \ No newline at end of file diff --git a/src/libraries/System.Reflection.Metadata/ref/ReferenceSourceExcludeApi.txt b/src/libraries/System.Reflection.Metadata/ref/ReferenceSourceExcludeApi.txt deleted file mode 100644 index 85a0855953cd8..0000000000000 --- a/src/libraries/System.Reflection.Metadata/ref/ReferenceSourceExcludeApi.txt +++ /dev/null @@ -1,5 +0,0 @@ -// exclusions to work around netstandard1.1 builds, c.f. System.Reflection.Metadata.Manual.cs - -M:System.Reflection.Metadata.AssemblyDefinition.GetAssemblyName -M:System.Reflection.Metadata.AssemblyReference.GetAssemblyName -M:System.Reflection.Metadata.ImageFormatLimitationException.#ctor(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext) diff --git a/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.Manual.cs b/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.Manual.cs index 18fb9896e75b6..4a615aec89750 100644 --- a/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.Manual.cs +++ b/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.Manual.cs @@ -6,7 +6,6 @@ namespace System.Reflection.Metadata { -#if !NETSTANDARD1_1 public readonly partial struct AssemblyDefinition { public System.Reflection.AssemblyName GetAssemblyName() { throw null; } @@ -19,5 +18,4 @@ public partial class ImageFormatLimitationException : System.Exception { protected ImageFormatLimitationException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } -#endif } diff --git a/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.csproj b/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.csproj index d3f3c661e77fb..5ae1a3762e53a 100644 --- a/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.csproj +++ b/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.csproj @@ -2,24 +2,17 @@ true false - $(NetCoreAppCurrent);netstandard1.1;netstandard2.0;net461 + $(NetCoreAppCurrent);netstandard2.0;net461 enable - - - - - - - - - - - + + + + \ No newline at end of file diff --git a/src/libraries/System.Reflection.Metadata/src/System.Reflection.Metadata.csproj b/src/libraries/System.Reflection.Metadata/src/System.Reflection.Metadata.csproj index e099ac354b03f..b07bbd75ebac2 100644 --- a/src/libraries/System.Reflection.Metadata/src/System.Reflection.Metadata.csproj +++ b/src/libraries/System.Reflection.Metadata/src/System.Reflection.Metadata.csproj @@ -3,26 +3,24 @@ true en-US false - $(NetCoreAppCurrent);netstandard1.1;netstandard2.0;net461 + $(NetCoreAppCurrent);netstandard2.0;net461 true enable - $(DefineConstants);FEATURE_CER - netstandard1.1;portable-net45+win8 + $(DefineConstants);FEATURE_CER + Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp' "/> + Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp' "/> - - + @@ -65,15 +63,15 @@ - + - - + + @@ -102,18 +100,16 @@ - - - - - + + + + - + - - + @@ -184,7 +180,7 @@ - + @@ -251,7 +247,7 @@ - + @@ -271,7 +267,7 @@ - + diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/CriticalDisposableObject.netstandard1.1.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/CriticalDisposableObject.netstandard1.1.cs deleted file mode 100644 index ccade004759d3..0000000000000 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/CriticalDisposableObject.netstandard1.1.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.InteropServices; - -namespace System.Reflection.Internal -{ - // HACK: CriticalFinalizerObject is not available in netstandard 1.x - // Use CriticalHandle instead -- we don't actually use the handle, - // just the fact that CriticalHandle derives from CriticalFinalizerObject to ensure critical finalizer. - internal abstract class CriticalDisposableObject : CriticalHandle - { - public CriticalDisposableObject() - : base(IntPtr.Zero) - { - } - - public sealed override bool IsInvalid => true; - - protected sealed override bool ReleaseHandle() => - throw ExceptionUtilities.Unreachable; - - protected new void SetHandle(IntPtr handle) => - throw ExceptionUtilities.Unreachable; - - protected sealed override void Dispose(bool disposing) - { - // do not call base dispose - Release(); - - if (disposing) - { - GC.SuppressFinalize(this); - } - } - - protected abstract void Release(); - } -} diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/FileStreamReadLightUp.netstandard1.1.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/FileStreamReadLightUp.netstandard1.1.cs deleted file mode 100644 index 774def66573f7..0000000000000 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/FileStreamReadLightUp.netstandard1.1.cs +++ /dev/null @@ -1,114 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics; -using System.IO; -using System.Runtime.InteropServices; - -namespace System.Reflection.Internal -{ - internal static class FileStreamReadLightUp - { - internal static Lazy FileStreamType = new Lazy(() => - { - const string systemIOFileSystem = "System.IO.FileSystem, Version=4.0.0.0, Culture=neutral, PublicKeyToken = b03f5f7f11d50a3a"; - const string mscorlib = "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"; - - return LightUpHelper.GetType("System.IO.FileStream", systemIOFileSystem, mscorlib); - }); - - internal static Lazy SafeFileHandle = new Lazy(() => - { - return FileStreamType.Value.GetTypeInfo().GetDeclaredProperty("SafeFileHandle"); - }); - - // internal for testing - internal static bool readFileNotAvailable; - internal static bool safeFileHandleNotAvailable; - - internal static bool IsFileStream(Stream stream) - { - if (FileStreamType.Value == null) - { - return false; - } - - var type = stream.GetType(); - return type == FileStreamType.Value || type.GetTypeInfo().IsSubclassOf(FileStreamType.Value); - } - - internal static SafeHandle GetSafeFileHandle(Stream stream) - { - Debug.Assert(FileStreamType.IsValueCreated && FileStreamType.Value != null && IsFileStream(stream)); - - if (safeFileHandleNotAvailable) - { - return null; - } - - PropertyInfo safeFileHandleProperty = SafeFileHandle.Value; - if (safeFileHandleProperty == null) - { - safeFileHandleNotAvailable = true; - return null; - } - - SafeHandle handle; - try - { - handle = (SafeHandle)safeFileHandleProperty.GetValue(stream); - } - catch (MemberAccessException) - { - safeFileHandleNotAvailable = true; - return null; - } - catch (InvalidOperationException) - { - // thrown when accessing unapproved API in a Windows Store app - safeFileHandleNotAvailable = true; - return null; - } - catch (TargetInvocationException) - { - // Some FileStream implementations (e.g. IsolatedStorage) restrict access to the underlying handle by throwing - // Tolerate it and fall back to slow path. - return null; - } - - if (handle != null && handle.IsInvalid) - { - // Also allow for FileStream implementations that do return a non-null, but invalid underlying OS handle. - // This is how brokered files on WinRT will work. Fall back to slow path. - return null; - } - - return handle; - } - - internal static unsafe int ReadFile(Stream stream, byte* buffer, int size) - { - if (readFileNotAvailable) - { - return 0; - } - - SafeHandle handle = GetSafeFileHandle(stream); - if (handle == null) - { - return 0; - } - - try - { - int result = Interop.Kernel32.ReadFile(handle, buffer, size, out int bytesRead, IntPtr.Zero); - return result == 0 ? 0 : bytesRead; - } - catch - { - readFileNotAvailable = true; - return 0; - } - } - } -} diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/MemoryMapLightUp.netstandard1.1.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/MemoryMapLightUp.netstandard1.1.cs deleted file mode 100644 index 156650da78da5..0000000000000 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/MemoryMapLightUp.netstandard1.1.cs +++ /dev/null @@ -1,268 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics; -using System.IO; -using System.Runtime.ExceptionServices; -using System.Runtime.InteropServices; - -namespace System.Reflection.Internal -{ - internal static class MemoryMapLightUp - { - private static Type s_lazyMemoryMappedFileType; - private static Type s_lazyMemoryMappedViewAccessorType; - private static Type s_lazyMemoryMappedFileAccessType; - private static Type s_lazyMemoryMappedFileSecurityType; - private static Type s_lazyHandleInheritabilityType; - private static MethodInfo s_lazyCreateFromFile; - private static MethodInfo s_lazyCreateFromFileClassic; - private static MethodInfo s_lazyCreateViewAccessor; - private static PropertyInfo s_lazySafeMemoryMappedViewHandle; - private static PropertyInfo s_lazyPointerOffset; - private static FieldInfo s_lazyInternalViewField; - private static PropertyInfo s_lazyInternalPointerOffset; - - private static readonly object s_MemoryMappedFileAccess_Read = 1; - private static readonly object s_HandleInheritability_None = 0; - private static readonly object s_LongZero = (long)0; - private static readonly object s_True = true; - - private static bool? s_lazyIsAvailable; - - internal static bool IsAvailable - { - get - { - if (!s_lazyIsAvailable.HasValue) - { - s_lazyIsAvailable = TryLoadTypes(); - } - - return s_lazyIsAvailable.Value; - } - } - - private static bool TryLoadType(string typeName, string modernAssembly, string classicAssembly, out Type type) - { - type = LightUpHelper.GetType(typeName, modernAssembly, classicAssembly); - return type != null; - } - - private static bool TryLoadTypes() - { - const string systemIOMemoryMappedFiles = "System.IO.MemoryMappedFiles, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"; - const string systemRuntimeHandles = "System.Runtime.Handles, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"; - const string systemCore = "System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"; - - TryLoadType("System.IO.MemoryMappedFiles.MemoryMappedFileSecurity", systemIOMemoryMappedFiles, systemCore, out s_lazyMemoryMappedFileSecurityType); - - return FileStreamReadLightUp.FileStreamType.Value != null - && TryLoadType("System.IO.MemoryMappedFiles.MemoryMappedFile", systemIOMemoryMappedFiles, systemCore, out s_lazyMemoryMappedFileType) - && TryLoadType("System.IO.MemoryMappedFiles.MemoryMappedViewAccessor", systemIOMemoryMappedFiles, systemCore, out s_lazyMemoryMappedViewAccessorType) - && TryLoadType("System.IO.MemoryMappedFiles.MemoryMappedFileAccess", systemIOMemoryMappedFiles, systemCore, out s_lazyMemoryMappedFileAccessType) - && TryLoadType("System.IO.HandleInheritability", systemRuntimeHandles, systemCore, out s_lazyHandleInheritabilityType) - && TryLoadMembers(); - } - - private static bool TryLoadMembers() - { - // .NET Core, .NET 4.6+ - s_lazyCreateFromFile = LightUpHelper.GetMethod( - s_lazyMemoryMappedFileType, - "CreateFromFile", - FileStreamReadLightUp.FileStreamType.Value, - typeof(string), - typeof(long), - s_lazyMemoryMappedFileAccessType, - s_lazyHandleInheritabilityType, - typeof(bool) - ); - - // .NET < 4.6 - if (s_lazyCreateFromFile == null) - { - if (s_lazyMemoryMappedFileSecurityType != null) - { - s_lazyCreateFromFileClassic = LightUpHelper.GetMethod( - s_lazyMemoryMappedFileType, - "CreateFromFile", - FileStreamReadLightUp.FileStreamType.Value, - typeof(string), - typeof(long), - s_lazyMemoryMappedFileAccessType, - s_lazyMemoryMappedFileSecurityType, - s_lazyHandleInheritabilityType, - typeof(bool)); - } - - if (s_lazyCreateFromFileClassic == null) - { - return false; - } - } - - s_lazyCreateViewAccessor = LightUpHelper.GetMethod( - s_lazyMemoryMappedFileType, - "CreateViewAccessor", - typeof(long), - typeof(long), - s_lazyMemoryMappedFileAccessType); - - if (s_lazyCreateViewAccessor == null) - { - return false; - } - - s_lazySafeMemoryMappedViewHandle = s_lazyMemoryMappedViewAccessorType.GetTypeInfo().GetDeclaredProperty("SafeMemoryMappedViewHandle"); - if (s_lazySafeMemoryMappedViewHandle == null) - { - return false; - } - - // .NET Core, .NET 4.5.1+ - s_lazyPointerOffset = s_lazyMemoryMappedViewAccessorType.GetTypeInfo().GetDeclaredProperty("PointerOffset"); - - // .NET < 4.5.1 - if (s_lazyPointerOffset == null) - { - s_lazyInternalViewField = s_lazyMemoryMappedViewAccessorType.GetTypeInfo().GetDeclaredField("m_view"); - if (s_lazyInternalViewField == null) - { - return false; - } - - s_lazyInternalPointerOffset = s_lazyInternalViewField.FieldType.GetTypeInfo().GetDeclaredProperty("PointerOffset"); - if (s_lazyInternalPointerOffset == null) - { - return false; - } - } - - return true; - } - - internal static IDisposable CreateMemoryMap(Stream stream) - { - Debug.Assert(s_lazyIsAvailable.GetValueOrDefault()); - - try - { - if (s_lazyCreateFromFile != null) - { - return (IDisposable)s_lazyCreateFromFile.Invoke(null, new object[6] - { - stream, // fileStream - null, // mapName - s_LongZero, // capacity - s_MemoryMappedFileAccess_Read, // access - s_HandleInheritability_None, // inheritability - s_True, // leaveOpen - }); - } - else - { - Debug.Assert(s_lazyCreateFromFileClassic != null); - return (IDisposable)s_lazyCreateFromFileClassic.Invoke(null, new object[7] - { - stream, // fileStream - null, // mapName - s_LongZero, // capacity - s_MemoryMappedFileAccess_Read, // access - null, // memoryMappedFileSecurity - s_HandleInheritability_None, // inheritability - s_True, // leaveOpen - }); - } - } - catch (MemberAccessException) - { - s_lazyIsAvailable = false; - return null; - } - catch (InvalidOperationException) - { - // thrown when accessing unapproved API in a Windows Store app - s_lazyIsAvailable = false; - return null; - } - catch (TargetInvocationException ex) - { - ExceptionDispatchInfo.Capture(ex.InnerException).Throw(); - throw; - } - } - - internal static IDisposable CreateViewAccessor(object memoryMap, long start, int size) - { - Debug.Assert(s_lazyIsAvailable.GetValueOrDefault()); - try - { - return (IDisposable)s_lazyCreateViewAccessor.Invoke(memoryMap, new object[3] - { - start, // start - (long)size, // size - s_MemoryMappedFileAccess_Read, // access - }); - } - catch (MemberAccessException) - { - s_lazyIsAvailable = false; - return null; - } - catch (InvalidOperationException) - { - s_lazyIsAvailable = false; - return null; - } - catch (TargetInvocationException ex) when (ex.InnerException is UnauthorizedAccessException) - { - throw new IOException(ex.InnerException.Message, ex.InnerException); - } - catch (TargetInvocationException ex) - { - ExceptionDispatchInfo.Capture(ex.InnerException).Throw(); - throw; - } - } - - internal static bool TryGetSafeBufferAndPointerOffset(object accessor, out SafeBuffer safeBuffer, out long offset) - { - Debug.Assert(s_lazyIsAvailable.GetValueOrDefault()); - - safeBuffer = (SafeBuffer)s_lazySafeMemoryMappedViewHandle.GetValue(accessor); - offset = 0; - - try - { - if (s_lazyPointerOffset != null) - { - offset = (long)s_lazyPointerOffset.GetValue(accessor); - } - else - { - object internalView = s_lazyInternalViewField.GetValue(accessor); - offset = (long)s_lazyInternalPointerOffset.GetValue(internalView); - } - - return true; - } - catch (MemberAccessException) - { - s_lazyIsAvailable = false; - return false; - } - catch (InvalidOperationException) - { - // thrown when accessing unapproved API in a Windows Store app - s_lazyIsAvailable = false; - return false; - } - catch (TargetInvocationException ex) - { - ExceptionDispatchInfo.Capture(ex.InnerException).Throw(); - throw; - } - } - } -} diff --git a/src/libraries/System.Runtime.CompilerServices.Unsafe/pkg/System.Runtime.CompilerServices.Unsafe.pkgproj b/src/libraries/System.Runtime.CompilerServices.Unsafe/pkg/System.Runtime.CompilerServices.Unsafe.pkgproj index d46b21c27009b..95b425ded6954 100644 --- a/src/libraries/System.Runtime.CompilerServices.Unsafe/pkg/System.Runtime.CompilerServices.Unsafe.pkgproj +++ b/src/libraries/System.Runtime.CompilerServices.Unsafe/pkg/System.Runtime.CompilerServices.Unsafe.pkgproj @@ -3,14 +3,10 @@ - net45;netcoreapp1.0;netcore50;netcore45;wp8;wpa81;$(AllXamarinFrameworks) + net45;netcoreapp2.0;uap10.0.16299;$(AllXamarinFrameworks) - - - + \ No newline at end of file diff --git a/src/libraries/System.Runtime.CompilerServices.Unsafe/ref/System.Runtime.CompilerServices.Unsafe.csproj b/src/libraries/System.Runtime.CompilerServices.Unsafe/ref/System.Runtime.CompilerServices.Unsafe.csproj index ebe1f4af9854a..3b9a084c85457 100644 --- a/src/libraries/System.Runtime.CompilerServices.Unsafe/ref/System.Runtime.CompilerServices.Unsafe.csproj +++ b/src/libraries/System.Runtime.CompilerServices.Unsafe/ref/System.Runtime.CompilerServices.Unsafe.csproj @@ -3,7 +3,7 @@ true false enable - netstandard2.0;netstandard1.0;netstandard2.1;net45;net461 + netstandard2.1;netstandard2.0;net461;net45 true diff --git a/src/libraries/System.Runtime.CompilerServices.Unsafe/src/System.Runtime.CompilerServices.Unsafe.ilproj b/src/libraries/System.Runtime.CompilerServices.Unsafe/src/System.Runtime.CompilerServices.Unsafe.ilproj index 14050c3272f90..7efe0fd535302 100644 --- a/src/libraries/System.Runtime.CompilerServices.Unsafe/src/System.Runtime.CompilerServices.Unsafe.ilproj +++ b/src/libraries/System.Runtime.CompilerServices.Unsafe/src/System.Runtime.CompilerServices.Unsafe.ilproj @@ -1,6 +1,6 @@  - $(NetCoreAppCurrent);netstandard2.0;netcoreapp2.0;netstandard1.0;net45 + $(NetCoreAppCurrent);netstandard2.0;netcoreapp2.0;net45 true IMPL @@ -13,7 +13,6 @@ #define netcoreapp System.Runtime netstandard - true mscorlib @@ -26,9 +25,6 @@ - - - net46;netcore50;netcoreapp1.0;$(AllXamarinFrameworks) + net461;netcoreapp2.0;uap10.0.16299;$(AllXamarinFrameworks) - - + .NETCoreApp + + + diff --git a/src/libraries/System.Threading.Channels/ref/System.Threading.Channels.csproj b/src/libraries/System.Threading.Channels/ref/System.Threading.Channels.csproj index 464fca7b6b679..8feb18682fce6 100644 --- a/src/libraries/System.Threading.Channels/ref/System.Threading.Channels.csproj +++ b/src/libraries/System.Threading.Channels/ref/System.Threading.Channels.csproj @@ -1,27 +1,21 @@ - $(NetCoreAppCurrent);netcoreapp3.0;netstandard1.3;netstandard2.0;netstandard2.1;net461 + $(NetCoreAppCurrent);netcoreapp3.0;netstandard2.1;netstandard2.0;net461 true enable + - - + + - - - - + - - \ No newline at end of file diff --git a/src/libraries/System.Threading.Channels/src/System.Threading.Channels.csproj b/src/libraries/System.Threading.Channels/src/System.Threading.Channels.csproj index 5e469cc4a7c1d..b0ad74ab4a030 100644 --- a/src/libraries/System.Threading.Channels/src/System.Threading.Channels.csproj +++ b/src/libraries/System.Threading.Channels/src/System.Threading.Channels.csproj @@ -1,6 +1,6 @@ - $(NetCoreAppCurrent);netstandard1.3;netstandard2.0;netstandard2.1;netcoreapp3.0;net461 + $(NetCoreAppCurrent);netcoreapp3.0;netstandard2.1;netstandard2.0;net461 true enable @@ -8,17 +8,18 @@ - - - + + - + - + @@ -32,8 +33,7 @@ - + @@ -45,8 +45,7 @@ - + diff --git a/src/libraries/System.Threading.Channels/src/System/Threading/Channels/AsyncOperation.netstandard1.cs b/src/libraries/System.Threading.Channels/src/System/Threading/Channels/AsyncOperation.netstandard1.cs deleted file mode 100644 index 40e4d62a32bc9..0000000000000 --- a/src/libraries/System.Threading.Channels/src/System/Threading/Channels/AsyncOperation.netstandard1.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Threading.Tasks; - -namespace System.Threading.Channels -{ - internal partial class AsyncOperation - { - private void UnsafeQueueSetCompletionAndInvokeContinuation() => - Task.Factory.StartNew(s => ((AsyncOperation)s).SetCompletionAndInvokeContinuation(), this, - CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default); - - private void UnsafeQueueUserWorkItem(Action action, object? state) => - QueueUserWorkItem(action, state); - - private static void QueueUserWorkItem(Action action, object? state) => - Task.Factory.StartNew(action, state, - CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default); - - private static CancellationTokenRegistration UnsafeRegister(CancellationToken cancellationToken, Action action, object? state) => - cancellationToken.Register(action, state); - } -} diff --git a/src/libraries/System.Threading.Tasks.Dataflow/pkg/System.Threading.Tasks.Dataflow.pkgproj b/src/libraries/System.Threading.Tasks.Dataflow/pkg/System.Threading.Tasks.Dataflow.pkgproj index cefd60681b014..eeb275654e55e 100644 --- a/src/libraries/System.Threading.Tasks.Dataflow/pkg/System.Threading.Tasks.Dataflow.pkgproj +++ b/src/libraries/System.Threading.Tasks.Dataflow/pkg/System.Threading.Tasks.Dataflow.pkgproj @@ -2,7 +2,7 @@ - net45;netcore45;wp8;wpa81;netcoreapp1.0;$(AllXamarinFrameworks) + net461;netcoreapp2.0;uap10.0.16299;$(AllXamarinFrameworks) + \ No newline at end of file diff --git a/src/libraries/System.Threading.Tasks.Dataflow/ref/System.Threading.Tasks.Dataflow.csproj b/src/libraries/System.Threading.Tasks.Dataflow/ref/System.Threading.Tasks.Dataflow.csproj index d24314b3be17e..6a5bb818fe9b7 100644 --- a/src/libraries/System.Threading.Tasks.Dataflow/ref/System.Threading.Tasks.Dataflow.csproj +++ b/src/libraries/System.Threading.Tasks.Dataflow/ref/System.Threading.Tasks.Dataflow.csproj @@ -1,12 +1,11 @@ - netstandard2.1;netstandard2.0;netstandard1.0;netstandard1.1;net461 + netstandard2.1;netstandard2.0;net461 enable - - - + diff --git a/src/libraries/System.Threading.Tasks.Dataflow/src/Base/DataflowBlock.cs b/src/libraries/System.Threading.Tasks.Dataflow/src/Base/DataflowBlock.cs index cfdb8e5dcdf4b..9cca871101592 100644 --- a/src/libraries/System.Threading.Tasks.Dataflow/src/Base/DataflowBlock.cs +++ b/src/libraries/System.Threading.Tasks.Dataflow/src/Base/DataflowBlock.cs @@ -16,10 +16,6 @@ using System.Runtime.CompilerServices; using System.Threading.Tasks.Dataflow.Internal; -#if USE_INTERNAL_THREADING -using System.Threading.Tasks.Dataflow.Internal.Threading; -#endif - namespace System.Threading.Tasks.Dataflow { /// diff --git a/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/ActionBlock.cs b/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/ActionBlock.cs index bfb6419e7c134..3b8f05674b124 100644 --- a/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/ActionBlock.cs +++ b/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/ActionBlock.cs @@ -114,13 +114,11 @@ private ActionBlock(Delegate action, ExecutionDataflowBlockOptions dataflowBlock Common.WireCancellationToComplete( dataflowBlockOptions.CancellationToken, Completion, state => ((TargetCore)state!).Complete(exception: null, dropPendingMessages: true), _defaultTarget); } -#if FEATURE_TRACING DataflowEtwProvider etwLog = DataflowEtwProvider.Log; if (etwLog.IsEnabled()) { etwLog.DataflowBlockCreated(this, dataflowBlockOptions); } -#endif Debug.Assert((_spscTarget != null) ^ (_defaultTarget != null), "One and only one of the two targets must be non-null after construction"); } diff --git a/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/BatchBlock.cs b/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/BatchBlock.cs index c0189c1b247a0..ae3c92c2acba2 100644 --- a/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/BatchBlock.cs +++ b/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/BatchBlock.cs @@ -88,13 +88,11 @@ public BatchBlock(int batchSize, GroupingDataflowBlockOptions dataflowBlockOptio // Handle async cancellation requests by declining on the target Common.WireCancellationToComplete( dataflowBlockOptions.CancellationToken, _source.Completion, state => ((BatchBlockTargetCore)state!).Complete(exception: null, dropPendingMessages: true, releaseReservedMessages: false), _target); -#if FEATURE_TRACING DataflowEtwProvider etwLog = DataflowEtwProvider.Log; if (etwLog.IsEnabled()) { etwLog.DataflowBlockCreated(this, dataflowBlockOptions); } -#endif } /// @@ -640,7 +638,6 @@ private void ProcessAsyncIfNecessary_Slow(bool isReplacementReplica) _nonGreedyState!.TaskForInputProcessing = new Task(thisBatchTarget => ((BatchBlockTargetCore)thisBatchTarget!).ProcessMessagesLoopCore(), this, Common.GetCreationOptionsForTask(isReplacementReplica)); -#if FEATURE_TRACING DataflowEtwProvider etwLog = DataflowEtwProvider.Log; if (etwLog.IsEnabled()) { @@ -648,7 +645,6 @@ private void ProcessAsyncIfNecessary_Slow(bool isReplacementReplica) _owningBatch, _nonGreedyState.TaskForInputProcessing, DataflowEtwProvider.TaskLaunchedReason.ProcessingInputMessages, _messages.Count + _nonGreedyState.PostponedMessages.Count); } -#endif // Start the task handling scheduling exceptions Exception? exception = Common.StartTaskSafe(_nonGreedyState.TaskForInputProcessing, _dataflowBlockOptions.TaskScheduler); diff --git a/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/BatchedJoinBlock.cs b/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/BatchedJoinBlock.cs index c8d72e028c4e9..c47a75075a31b 100644 --- a/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/BatchedJoinBlock.cs +++ b/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/BatchedJoinBlock.cs @@ -106,13 +106,11 @@ public BatchedJoinBlock(int batchSize, GroupingDataflowBlockOptions dataflowBloc // Handle async cancellation requests by declining on the target Common.WireCancellationToComplete( dataflowBlockOptions.CancellationToken, _source.Completion, state => ((BatchedJoinBlock)state!).CompleteEachTarget(), this); -#if FEATURE_TRACING DataflowEtwProvider etwLog = DataflowEtwProvider.Log; if (etwLog.IsEnabled()) { etwLog.DataflowBlockCreated(this, dataflowBlockOptions); } -#endif } /// Gets the size of the batches generated by this . @@ -357,13 +355,11 @@ public BatchedJoinBlock(int batchSize, GroupingDataflowBlockOptions dataflowBloc // Handle async cancellation requests by declining on the target Common.WireCancellationToComplete( dataflowBlockOptions.CancellationToken, _source.Completion, state => ((BatchedJoinBlock)state!).CompleteEachTarget(), this); -#if FEATURE_TRACING DataflowEtwProvider etwLog = DataflowEtwProvider.Log; if (etwLog.IsEnabled()) { etwLog.DataflowBlockCreated(this, dataflowBlockOptions); } -#endif } /// Gets the size of the batches generated by this . diff --git a/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/BroadcastBlock.cs b/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/BroadcastBlock.cs index 3240b2e8cf1d5..e7ee8f5f1e55c 100644 --- a/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/BroadcastBlock.cs +++ b/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/BroadcastBlock.cs @@ -96,13 +96,11 @@ public BroadcastBlock(Func? cloningFunction, DataflowBlockOptions dataflow // Handle async cancellation requests by declining on the target Common.WireCancellationToComplete( dataflowBlockOptions.CancellationToken, _source.Completion, state => ((BroadcastBlock)state!).Complete(), this); -#if FEATURE_TRACING DataflowEtwProvider etwLog = DataflowEtwProvider.Log; if (etwLog.IsEnabled()) { etwLog.DataflowBlockCreated(this, dataflowBlockOptions); } -#endif } /// @@ -257,7 +255,6 @@ internal void ConsumeAsyncIfNecessary(bool isReplacementReplica = false) new Task(state => ((BroadcastBlock)state!).ConsumeMessagesLoopCore(), this, Common.GetCreationOptionsForTask(isReplacementReplica)); -#if FEATURE_TRACING DataflowEtwProvider etwLog = DataflowEtwProvider.Log; if (etwLog.IsEnabled()) { @@ -265,7 +262,6 @@ internal void ConsumeAsyncIfNecessary(bool isReplacementReplica = false) this, _boundingState.TaskForInputProcessing, DataflowEtwProvider.TaskLaunchedReason.ProcessingInputMessages, _boundingState.PostponedMessages.Count); } -#endif // Start the task handling scheduling exceptions Exception? exception = Common.StartTaskSafe(_boundingState.TaskForInputProcessing, _source.DataflowBlockOptions.TaskScheduler); @@ -836,14 +832,12 @@ private void OfferAsyncIfNecessary(bool isReplacementReplica = false) _taskForOutputProcessing = new Task(thisSourceCore => ((BroadcastingSourceCore)thisSourceCore!).OfferMessagesLoopCore(), this, Common.GetCreationOptionsForTask(isReplacementReplica)); -#if FEATURE_TRACING DataflowEtwProvider etwLog = DataflowEtwProvider.Log; if (etwLog.IsEnabled()) { etwLog.TaskLaunchedForMessageHandling( _owningSource, _taskForOutputProcessing, DataflowEtwProvider.TaskLaunchedReason.OfferingOutputMessages, _messages.Count); } -#endif // Start the task handling scheduling exceptions Exception? exception = Common.StartTaskSafe(_taskForOutputProcessing, _dataflowBlockOptions.TaskScheduler); @@ -999,13 +993,11 @@ private void CompleteBlockOncePossible() // Now that the completion task is completed, we may propagate completion to the linked targets _targetRegistry.PropagateCompletion(linkedTargets); -#if FEATURE_TRACING DataflowEtwProvider etwLog = DataflowEtwProvider.Log; if (etwLog.IsEnabled()) { etwLog.DataflowBlockCompleted(_owningSource); } -#endif } /// diff --git a/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/BufferBlock.cs b/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/BufferBlock.cs index 52865354eb416..c4e0250d5fe00 100644 --- a/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/BufferBlock.cs +++ b/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/BufferBlock.cs @@ -77,13 +77,11 @@ public BufferBlock(DataflowBlockOptions dataflowBlockOptions) // Handle async cancellation requests by declining on the target Common.WireCancellationToComplete( dataflowBlockOptions.CancellationToken, _source.Completion, owningSource => ((BufferBlock)owningSource!).Complete(), this); -#if FEATURE_TRACING DataflowEtwProvider etwLog = DataflowEtwProvider.Log; if (etwLog.IsEnabled()) { etwLog.DataflowBlockCreated(this, dataflowBlockOptions); } -#endif } /// @@ -257,7 +255,6 @@ internal void ConsumeAsyncIfNecessary(bool isReplacementReplica = false) new Task(state => ((BufferBlock)state!).ConsumeMessagesLoopCore(), this, Common.GetCreationOptionsForTask(isReplacementReplica)); -#if FEATURE_TRACING DataflowEtwProvider etwLog = DataflowEtwProvider.Log; if (etwLog.IsEnabled()) { @@ -265,7 +262,6 @@ internal void ConsumeAsyncIfNecessary(bool isReplacementReplica = false) this, _boundingState.TaskForInputProcessing, DataflowEtwProvider.TaskLaunchedReason.ProcessingInputMessages, _boundingState.PostponedMessages.Count); } -#endif // Start the task handling scheduling exceptions Exception? exception = Common.StartTaskSafe(_boundingState.TaskForInputProcessing, _source.DataflowBlockOptions.TaskScheduler); diff --git a/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/JoinBlock.cs b/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/JoinBlock.cs index 54e44b361eab0..9b336c3d6f351 100644 --- a/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/JoinBlock.cs +++ b/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/JoinBlock.cs @@ -100,13 +100,11 @@ public JoinBlock(GroupingDataflowBlockOptions dataflowBlockOptions) // Handle async cancellation requests by declining on the target Common.WireCancellationToComplete( dataflowBlockOptions.CancellationToken, _source.Completion, state => ((JoinBlock)state!)._sharedResources.CompleteEachTarget(), this); -#if FEATURE_TRACING DataflowEtwProvider etwLog = DataflowEtwProvider.Log; if (etwLog.IsEnabled()) { etwLog.DataflowBlockCreated(this, dataflowBlockOptions); } -#endif } /// @@ -322,13 +320,11 @@ public JoinBlock(GroupingDataflowBlockOptions dataflowBlockOptions) // Handle async cancellation requests by declining on the target Common.WireCancellationToComplete( dataflowBlockOptions.CancellationToken, _source.Completion, state => ((JoinBlock)state!)._sharedResources.CompleteEachTarget(), this); -#if FEATURE_TRACING DataflowEtwProvider etwLog = DataflowEtwProvider.Log; if (etwLog.IsEnabled()) { etwLog.DataflowBlockCreated(this, dataflowBlockOptions); } -#endif } /// @@ -1273,7 +1269,6 @@ private void ProcessAsyncIfNecessary_Slow(bool isReplacementReplica) _taskForInputProcessing = new Task(thisSharedResources => ((JoinBlockTargetSharedResources)thisSharedResources!).ProcessMessagesLoopCore(), this, Common.GetCreationOptionsForTask(isReplacementReplica)); -#if FEATURE_TRACING DataflowEtwProvider etwLog = DataflowEtwProvider.Log; if (etwLog.IsEnabled()) { @@ -1281,7 +1276,6 @@ private void ProcessAsyncIfNecessary_Slow(bool isReplacementReplica) _ownerJoin, _taskForInputProcessing, DataflowEtwProvider.TaskLaunchedReason.ProcessingInputMessages, _targets.Max(t => t.NumberOfMessagesAvailableOrPostponed)); } -#endif // Start the task handling scheduling exceptions Exception? exception = Common.StartTaskSafe(_taskForInputProcessing, _dataflowBlockOptions.TaskScheduler); diff --git a/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/TransformBlock.cs b/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/TransformBlock.cs index 7e72a5fdb8f21..72f837445a60d 100644 --- a/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/TransformBlock.cs +++ b/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/TransformBlock.cs @@ -156,13 +156,11 @@ private TransformBlock(Func? transformSync, Func ((TargetCore)state!).Complete(exception: null, dropPendingMessages: true), _target); -#if FEATURE_TRACING DataflowEtwProvider etwLog = DataflowEtwProvider.Log; if (etwLog.IsEnabled()) { etwLog.DataflowBlockCreated(this, dataflowBlockOptions); } -#endif } /// Processes the message with a user-provided transform function that returns a TOutput. diff --git a/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/TransformManyBlock.cs b/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/TransformManyBlock.cs index d8ab698095a98..55bacb242ea74 100644 --- a/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/TransformManyBlock.cs +++ b/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/TransformManyBlock.cs @@ -173,13 +173,11 @@ private TransformManyBlock(Func>? transformSync, Fu // Handle async cancellation requests by declining on the target Common.WireCancellationToComplete( dataflowBlockOptions.CancellationToken, Completion, state => ((TargetCore)state!).Complete(exception: null, dropPendingMessages: true), _target); -#if FEATURE_TRACING DataflowEtwProvider etwLog = DataflowEtwProvider.Log; if (etwLog.IsEnabled()) { etwLog.DataflowBlockCreated(this, dataflowBlockOptions); } -#endif } /// Processes the message with a user-provided transform function that returns an enumerable. diff --git a/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/WriteOnceBlock.cs b/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/WriteOnceBlock.cs index e00fb8adfb913..ba46828913e28 100644 --- a/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/WriteOnceBlock.cs +++ b/src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/WriteOnceBlock.cs @@ -96,13 +96,11 @@ public WriteOnceBlock(Func? cloningFunction, DataflowBlockOptions dataflow dataflowBlockOptions.CancellationToken, _lazyCompletionTaskSource.Task, state => ((WriteOnceBlock)state!).Complete(), this); } } -#if FEATURE_TRACING DataflowEtwProvider etwLog = DataflowEtwProvider.Log; if (etwLog.IsEnabled()) { etwLog.DataflowBlockCreated(this, dataflowBlockOptions); } -#endif } /// Asynchronously completes the block on another task. @@ -123,14 +121,12 @@ private void CompleteBlockAsync(IList? exceptions) var taskForOutputProcessing = new Task(state => ((WriteOnceBlock)state!).OfferToTargetsAndCompleteBlock(), this, Common.GetCreationOptionsForTask()); -#if FEATURE_TRACING DataflowEtwProvider etwLog = DataflowEtwProvider.Log; if (etwLog.IsEnabled()) { etwLog.TaskLaunchedForMessageHandling( this, taskForOutputProcessing, DataflowEtwProvider.TaskLaunchedReason.OfferingOutputMessages, _header.IsValid ? 1 : 0); } -#endif // Start the task handling scheduling exceptions Exception? exception = Common.StartTaskSafe(taskForOutputProcessing, _dataflowBlockOptions.TaskScheduler); @@ -200,13 +196,11 @@ private void CompleteBlock(IList? exceptions) // Now that the completion task is completed, we may propagate completion to the linked targets _targetRegistry.PropagateCompletion(linkedTargets); -#if FEATURE_TRACING DataflowEtwProvider etwLog = DataflowEtwProvider.Log; if (etwLog.IsEnabled()) { etwLog.DataflowBlockCompleted(this); } -#endif } /// diff --git a/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/Common.cs b/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/Common.cs index 14c46c7f79947..5ef1bd2980fbf 100644 --- a/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/Common.cs +++ b/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/Common.cs @@ -16,10 +16,6 @@ using System.Collections; using System.Runtime.ExceptionServices; -#if USE_INTERNAL_THREADING -using System.Threading.Tasks.Dataflow.Internal.Threading; -#endif - namespace System.Threading.Tasks.Dataflow.Internal { /// Internal helper utilities. diff --git a/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/ConcurrentQueue.cs b/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/ConcurrentQueue.cs deleted file mode 100644 index e6ab9036cb120..0000000000000 --- a/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/ConcurrentQueue.cs +++ /dev/null @@ -1,918 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ -// -// ConcurrentQueue.cs -// -// -// A lock-free, concurrent queue primitive, and its associated debugger view type. -// -// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - -#nullable disable // old copy used only for netstandard1.0 build -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; -using System.Runtime.InteropServices; -using System.Security; -using System.Threading; - -namespace System.Threading.Tasks.Dataflow.Internal.Collections -{ - /// - /// Represents a thread-safe first-in, first-out collection of objects. - /// - /// Specifies the type of elements in the queue. - /// - /// All public and protected members of are thread-safe and may be used - /// concurrently from multiple threads. - /// - [DebuggerDisplay("Count = {Count}")] - [DebuggerTypeProxy(typeof(SystemCollectionsConcurrent_ProducerConsumerCollectionDebugView<>))] - internal class ConcurrentQueue : IProducerConsumerCollection - { - private volatile Segment _head; - private volatile Segment _tail; - private const int SEGMENT_SIZE = 32; - //number of snapshot takers, GetEnumerator(), ToList() and ToArray() operations take snapshot. - internal volatile int _numSnapshotTakers; - - /// - /// Initializes a new instance of the class. - /// - public ConcurrentQueue() - { - _head = _tail = new Segment(0, this); - } - - /// - /// Initializes the contents of the queue from an existing collection. - /// - /// A collection from which to copy elements. - private void InitializeFromCollection(IEnumerable collection) - { - Segment localTail = new Segment(0, this);//use this local variable to avoid the extra volatile read/write. this is safe because it is only called from ctor - _head = localTail; - - int index = 0; - foreach (T element in collection) - { - Debug.Assert(index >= 0 && index < SEGMENT_SIZE); - localTail.UnsafeAdd(element); - index++; - - if (index >= SEGMENT_SIZE) - { - localTail = localTail.UnsafeGrow(); - index = 0; - } - } - - _tail = localTail; - } - - /// - /// Initializes a new instance of the - /// class that contains elements copied from the specified collection - /// - /// The collection whose elements are copied to the new . - /// The argument is - /// null. - public ConcurrentQueue(IEnumerable collection) - { - if (collection == null) - { - throw new ArgumentNullException(nameof(collection)); - } - - InitializeFromCollection(collection); - } - - /// - /// Copies the elements of the to an , starting at a particular - /// index. - /// - /// The one-dimensional Array that is the - /// destination of the elements copied from the - /// . The Array must have zero-based indexing. - /// The zero-based index in at which copying - /// begins. - /// is a null reference (Nothing in - /// Visual Basic). - /// is less than - /// zero. - /// - /// is multidimensional. -or- - /// does not have zero-based indexing. -or- - /// is equal to or greater than the length of the - /// -or- The number of elements in the source is - /// greater than the available space from to the end of the destination - /// . -or- The type of the source cannot be cast automatically to the type of the - /// destination . - /// - void ICollection.CopyTo(Array array, int index) - { - // Validate arguments. - if (array == null) - { - throw new ArgumentNullException(nameof(array)); - } - - // We must be careful not to corrupt the array, so we will first accumulate an - // internal list of elements that we will then copy to the array. This requires - // some extra allocation, but is necessary since we don't know up front whether - // the array is sufficiently large to hold the stack's contents. - ((ICollection)ToList()).CopyTo(array, index); - } - - /// - /// Gets a value indicating whether access to the is - /// synchronized with the SyncRoot. - /// - /// true if access to the is synchronized - /// with the SyncRoot; otherwise, false. For , this property always - /// returns false. - bool ICollection.IsSynchronized - { - // Gets a value indicating whether access to this collection is synchronized. Always returns - // false. The reason is subtle. While access is in face thread safe, it's not the case that - // locking on the SyncRoot would have prevented concurrent pushes and pops, as this property - // would typically indicate; that's because we internally use CAS operations vs. true locks. - get { return false; } - } - - - /// - /// Gets an object that can be used to synchronize access to the . This property is not supported. - /// - /// The SyncRoot property is not supported. - object ICollection.SyncRoot - { - get - { - throw new NotSupportedException(SR.ConcurrentCollection_SyncRoot_NotSupported); - } - } - - /// - /// Returns an enumerator that iterates through a collection. - /// - /// An that can be used to iterate through the collection. - IEnumerator IEnumerable.GetEnumerator() - { - return ((IEnumerable)this).GetEnumerator(); - } - - /// - /// Attempts to add an object to the . - /// - /// The object to add to the . The value can be a null - /// reference (Nothing in Visual Basic) for reference types. - /// - /// true if the object was added successfully; otherwise, false. - /// For , this operation will always add the object to the - /// end of the - /// and return true. - bool IProducerConsumerCollection.TryAdd(T item) - { - Enqueue(item); - return true; - } - - /// - /// Attempts to remove and return an object from the . - /// - /// - /// When this method returns, if the operation was successful, contains the - /// object removed. If no object was available to be removed, the value is unspecified. - /// - /// true if an element was removed and returned successfully; otherwise, false. - /// For , this operation will attempt to remove the object - /// from the beginning of the . - /// - bool IProducerConsumerCollection.TryTake(out T item) - { - return TryDequeue(out item); - } - - /// - /// Gets a value that indicates whether the is empty. - /// - /// true if the is empty; otherwise, false. - /// - /// For determining whether the collection contains any items, use of this property is recommended - /// rather than retrieving the number of items from the property and comparing it - /// to 0. However, as this collection is intended to be accessed concurrently, it may be the case - /// that another thread will modify the collection after returns, thus invalidating - /// the result. - /// - public bool IsEmpty - { - get - { - Segment head = _head; - if (!head.IsEmpty) - //fast route 1: - //if current head is not empty, then queue is not empty - return false; - else if (head.Next == null) - //fast route 2: - //if current head is empty and it's the last segment - //then queue is empty - return true; - else - //slow route: - //current head is empty and it is NOT the last segment, - //it means another thread is growing new segment - { - SpinWait spin = default; - while (head.IsEmpty) - { - if (head.Next == null) - return true; - - spin.SpinOnce(); - head = _head; - } - return false; - } - } - } - - /// - /// Copies the elements stored in the to a new array. - /// - /// A new array containing a snapshot of elements copied from the . - public T[] ToArray() - { - return ToList().ToArray(); - } - - /// - /// Copies the elements to a new . - /// - /// A new containing a snapshot of - /// elements copied from the . - private List ToList() - { - // Increments the number of active snapshot takers. This increment must happen before the snapshot is - // taken. At the same time, Decrement must happen after list copying is over. Only in this way, can it - // eliminate race condition when Segment.TryRemove() checks whether _numSnapshotTakers == 0. - Interlocked.Increment(ref _numSnapshotTakers); - - List list = new List(); - try - { - //store head and tail positions in buffer, - Segment head, tail; - int headLow, tailHigh; - GetHeadTailPositions(out head, out tail, out headLow, out tailHigh); - - if (head == tail) - { - head.AddToList(list, headLow, tailHigh); - } - else - { - head.AddToList(list, headLow, SEGMENT_SIZE - 1); - Segment curr = head.Next; - while (curr != tail) - { - curr.AddToList(list, 0, SEGMENT_SIZE - 1); - curr = curr.Next; - } - //Add tail segment - tail.AddToList(list, 0, tailHigh); - } - } - finally - { - // This Decrement must happen after copying is over. - Interlocked.Decrement(ref _numSnapshotTakers); - } - return list; - } - - /// - /// Store the position of the current head and tail positions. - /// - /// return the head segment - /// return the tail segment - /// return the head offset, value range [0, SEGMENT_SIZE] - /// return the tail offset, value range [-1, SEGMENT_SIZE-1] - private void GetHeadTailPositions(out Segment head, out Segment tail, - out int headLow, out int tailHigh) - { - head = _head; - tail = _tail; - headLow = head.Low; - tailHigh = tail.High; - SpinWait spin = default; - - //we loop until the observed values are stable and sensible. - //This ensures that any update order by other methods can be tolerated. - while ( - //if head and tail changed, retry - head != _head || tail != _tail - //if low and high pointers, retry - || headLow != head.Low || tailHigh != tail.High - //if head jumps ahead of tail because of concurrent grow and dequeue, retry - || head._index > tail._index) - { - spin.SpinOnce(); - head = _head; - tail = _tail; - headLow = head.Low; - tailHigh = tail.High; - } - } - - - /// - /// Gets the number of elements contained in the . - /// - /// The number of elements contained in the . - /// - /// For determining whether the collection contains any items, use of the - /// property is recommended rather than retrieving the number of items from the - /// property and comparing it to 0. - /// - public int Count - { - get - { - //store head and tail positions in buffer, - Segment head, tail; - int headLow, tailHigh; - GetHeadTailPositions(out head, out tail, out headLow, out tailHigh); - - if (head == tail) - { - return tailHigh - headLow + 1; - } - - //head segment - int count = SEGMENT_SIZE - headLow; - - //middle segment(s), if any, are full. - //We don't deal with overflow to be consistent with the behavior of generic types in CLR. - count += SEGMENT_SIZE * ((int)(tail._index - head._index - 1)); - - //tail segment - count += tailHigh + 1; - - return count; - } - } - - - /// - /// Copies the elements to an existing one-dimensional Array, starting at the specified array index. - /// - /// The one-dimensional Array that is the - /// destination of the elements copied from the - /// . The Array must have zero-based - /// indexing. - /// The zero-based index in at which copying - /// begins. - /// is a null reference (Nothing in - /// Visual Basic). - /// is less than - /// zero. - /// is equal to or greater than the - /// length of the - /// -or- The number of elements in the source is greater than the - /// available space from to the end of the destination . - /// - public void CopyTo(T[] array, int index) - { - if (array == null) - { - throw new ArgumentNullException(nameof(array)); - } - - // We must be careful not to corrupt the array, so we will first accumulate an - // internal list of elements that we will then copy to the array. This requires - // some extra allocation, but is necessary since we don't know up front whether - // the array is sufficiently large to hold the stack's contents. - ToList().CopyTo(array, index); - } - - - /// - /// Returns an enumerator that iterates through the . - /// - /// An enumerator for the contents of the . - /// - /// The enumeration represents a moment-in-time snapshot of the contents - /// of the queue. It does not reflect any updates to the collection after - /// was called. The enumerator is safe to use - /// concurrently with reads from and writes to the queue. - /// - public IEnumerator GetEnumerator() - { - // Increments the number of active snapshot takers. This increment must happen before the snapshot is - // taken. At the same time, Decrement must happen after the enumeration is over. Only in this way, can it - // eliminate race condition when Segment.TryRemove() checks whether _numSnapshotTakers == 0. - Interlocked.Increment(ref _numSnapshotTakers); - - // Takes a snapshot of the queue. - // A design flaw here: if a Thread.Abort() happens, we cannot decrement _numSnapshotTakers. But we cannot - // wrap the following with a try/finally block, otherwise the decrement will happen before the yield return - // statements in the GetEnumerator (head, tail, headLow, tailHigh) method. - Segment head, tail; - int headLow, tailHigh; - GetHeadTailPositions(out head, out tail, out headLow, out tailHigh); - - //If we put yield-return here, the iterator will be lazily evaluated. As a result a snapshot of - // the queue is not taken when GetEnumerator is initialized but when MoveNext() is first called. - // This is inconsistent with existing generic collections. In order to prevent it, we capture the - // value of _head in a buffer and call out to a helper method. - //The old way of doing this was to return the ToList().GetEnumerator(), but ToList() was an - // unnecessary performance hit. - return GetEnumerator(head, tail, headLow, tailHigh); - } - - /// - /// Helper method of GetEnumerator to separate out yield return statement, and prevent lazy evaluation. - /// - private IEnumerator GetEnumerator(Segment head, Segment tail, int headLow, int tailHigh) - { - try - { - SpinWait spin = default; - - if (head == tail) - { - for (int i = headLow; i <= tailHigh; i++) - { - // If the position is reserved by an Enqueue operation, but the value is not written into, - // spin until the value is available. - spin.Reset(); - while (!head._state[i]._value) - { - spin.SpinOnce(); - } - yield return head._array[i]; - } - } - else - { - //iterate on head segment - for (int i = headLow; i < SEGMENT_SIZE; i++) - { - // If the position is reserved by an Enqueue operation, but the value is not written into, - // spin until the value is available. - spin.Reset(); - while (!head._state[i]._value) - { - spin.SpinOnce(); - } - yield return head._array[i]; - } - //iterate on middle segments - Segment curr = head.Next; - while (curr != tail) - { - for (int i = 0; i < SEGMENT_SIZE; i++) - { - // If the position is reserved by an Enqueue operation, but the value is not written into, - // spin until the value is available. - spin.Reset(); - while (!curr._state[i]._value) - { - spin.SpinOnce(); - } - yield return curr._array[i]; - } - curr = curr.Next; - } - - //iterate on tail segment - for (int i = 0; i <= tailHigh; i++) - { - // If the position is reserved by an Enqueue operation, but the value is not written into, - // spin until the value is available. - spin.Reset(); - while (!tail._state[i]._value) - { - spin.SpinOnce(); - } - yield return tail._array[i]; - } - } - } - finally - { - // This Decrement must happen after the enumeration is over. - Interlocked.Decrement(ref _numSnapshotTakers); - } - } - - /// - /// Adds an object to the end of the . - /// - /// The object to add to the end of the . The value can be a null reference - /// (Nothing in Visual Basic) for reference types. - /// - public void Enqueue(T item) - { - SpinWait spin = default; - while (true) - { - Segment tail = _tail; - if (tail.TryAppend(item)) - return; - spin.SpinOnce(); - } - } - - - /// - /// Attempts to remove and return the object at the beginning of the . - /// - /// - /// When this method returns, if the operation was successful, contains the - /// object removed. If no object was available to be removed, the value is unspecified. - /// - /// true if an element was removed and returned from the beginning of the - /// successfully; otherwise, false. - public bool TryDequeue(out T result) - { - while (!IsEmpty) - { - Segment head = _head; - if (head.TryRemove(out result)) - return true; - //since method IsEmpty spins, we don't need to spin in the while loop - } - result = default(T); - return false; - } - - /// - /// Attempts to return an object from the beginning of the - /// without removing it. - /// - /// When this method returns, contains an object from - /// the beginning of the or an - /// unspecified value if the operation failed. - /// true if and object was returned successfully; otherwise, false. - public bool TryPeek(out T result) - { - Interlocked.Increment(ref _numSnapshotTakers); - - while (!IsEmpty) - { - Segment head = _head; - if (head.TryPeek(out result)) - { - Interlocked.Decrement(ref _numSnapshotTakers); - return true; - } - //since method IsEmpty spins, we don't need to spin in the while loop - } - result = default(T); - Interlocked.Decrement(ref _numSnapshotTakers); - return false; - } - - - /// - /// private class for ConcurrentQueue. - /// a queue is a linked list of small arrays, each node is called a segment. - /// A segment contains an array, a pointer to the next segment, and _low, _high indices recording - /// the first and last valid elements of the array. - /// - private sealed class Segment - { - //we define two volatile arrays: _array and _state. Note that the accesses to the array items - //do not get volatile treatment. But we don't need to worry about loading adjacent elements or - //store/load on adjacent elements would suffer reordering. - // - Two stores: these are at risk, but CLRv2 memory model guarantees store-release hence we are safe. - // - Two loads: because one item from two volatile arrays are accessed, the loads of the array references - // are sufficient to prevent reordering of the loads of the elements. - internal volatile T[] _array; - - // For each entry in _array, the corresponding entry in _state indicates whether this position contains - // a valid value. _state is initially all false. - internal volatile VolatileBool[] _state; - - //pointer to the next segment. null if the current segment is the last segment - private volatile Segment _next; - - //We use this zero based index to track how many segments have been created for the queue, and - //to compute how many active segments are there currently. - // * The number of currently active segments is : _tail._index - _head._index + 1; - // * _index is incremented with every Segment.Grow operation. We use Int64 type, and we can safely - // assume that it never overflows. To overflow, we need to do 2^63 increments, even at a rate of 4 - // billion (2^32) increments per second, it takes 2^31 seconds, which is about 64 years. - internal readonly long _index; - - //indices of where the first and last valid values - // - _low points to the position of the next element to pop from this segment, range [0, infinity) - // _low >= SEGMENT_SIZE implies the segment is disposable - // - _high points to the position of the latest pushed element, range [-1, infinity) - // _high == -1 implies the segment is new and empty - // _high >= SEGMENT_SIZE-1 means this segment is ready to grow. - // and the thread who sets _high to SEGMENT_SIZE-1 is responsible to grow the segment - // - Math.Min(_low, SEGMENT_SIZE) > Math.Min(_high, SEGMENT_SIZE-1) implies segment is empty - // - initially _low =0 and _high=-1; - private volatile int _low; - private volatile int _high; - - private volatile ConcurrentQueue _source; - - /// - /// Create and initialize a segment with the specified index. - /// - internal Segment(long index, ConcurrentQueue source) - { - _array = new T[SEGMENT_SIZE]; - _state = new VolatileBool[SEGMENT_SIZE]; //all initialized to false - _high = -1; - Debug.Assert(index >= 0); - _index = index; - _source = source; - } - - /// - /// return the next segment - /// - internal Segment Next - { - get { return _next; } - } - - - /// - /// return true if the current segment is empty (doesn't have any element available to dequeue, - /// false otherwise - /// - internal bool IsEmpty - { - get { return (Low > High); } - } - - /// - /// Add an element to the tail of the current segment - /// exclusively called by ConcurrentQueue.InitializedFromCollection - /// InitializeFromCollection is responsible to guarantee that there is no index overflow, - /// and there is no contention - /// - /// - internal void UnsafeAdd(T value) - { - Debug.Assert(_high < SEGMENT_SIZE - 1); - _high++; - _array[_high] = value; - _state[_high]._value = true; - } - - /// - /// Create a new segment and append to the current one - /// Does not update the _tail pointer - /// exclusively called by ConcurrentQueue.InitializedFromCollection - /// InitializeFromCollection is responsible to guarantee that there is no index overflow, - /// and there is no contention - /// - /// the reference to the new Segment - internal Segment UnsafeGrow() - { - Debug.Assert(_high >= SEGMENT_SIZE - 1); - Segment newSegment = new Segment(_index + 1, _source); //_index is Int64, we don't need to worry about overflow - _next = newSegment; - return newSegment; - } - - /// - /// Create a new segment and append to the current one - /// Update the _tail pointer - /// This method is called when there is no contention - /// - internal void Grow() - { - //no CAS is needed, since there is no contention (other threads are blocked, busy waiting) - Segment newSegment = new Segment(_index + 1, _source); //_index is Int64, we don't need to worry about overflow - _next = newSegment; - Debug.Assert(_source._tail == this); - _source._tail = _next; - } - - - /// - /// Try to append an element at the end of this segment. - /// - /// the element to append - /// true if the element is appended, false if the current segment is full - /// if appending the specified element succeeds, and after which the segment is full, - /// then grow the segment - internal bool TryAppend(T value) - { - //quickly check if _high is already over the boundary, if so, bail out - if (_high >= SEGMENT_SIZE - 1) - { - return false; - } - - //Now we will use a CAS to increment _high, and store the result in newhigh. - //Depending on how many free spots left in this segment and how many threads are doing this Increment - //at this time, the returning "newhigh" can be - // 1) < SEGMENT_SIZE - 1 : we took a spot in this segment, and not the last one, just insert the value - // 2) == SEGMENT_SIZE - 1 : we took the last spot, insert the value AND grow the segment - // 3) > SEGMENT_SIZE - 1 : we failed to reserve a spot in this segment, we return false to - // Queue.Enqueue method, telling it to try again in the next segment. - - int newhigh = SEGMENT_SIZE; //initial value set to be over the boundary - - //We need do Interlocked.Increment and value/state update in a finally block to ensure that they run - //without interruption. This is to prevent anything from happening between them, and another dequeue - //thread maybe spinning forever to wait for _state[] to be true; - try - { } - finally - { - newhigh = Interlocked.Increment(ref _high); - if (newhigh <= SEGMENT_SIZE - 1) - { - _array[newhigh] = value; - _state[newhigh]._value = true; - } - - //if this thread takes up the last slot in the segment, then this thread is responsible - //to grow a new segment. Calling Grow must be in the finally block too for reliability reason: - //if thread abort during Grow, other threads will be left busy spinning forever. - if (newhigh == SEGMENT_SIZE - 1) - { - Grow(); - } - } - - //if newhigh <= SEGMENT_SIZE-1, it means the current thread successfully takes up a spot - return newhigh <= SEGMENT_SIZE - 1; - } - - - /// - /// try to remove an element from the head of current segment - /// - /// The result. - /// return false only if the current segment is empty - internal bool TryRemove(out T result) - { - SpinWait spin = default; - int lowLocal = Low, highLocal = High; - while (lowLocal <= highLocal) - { - //try to update _low - if (Interlocked.CompareExchange(ref _low, lowLocal + 1, lowLocal) == lowLocal) - { - //if the specified value is not available (this spot is taken by a push operation, - // but the value is not written into yet), then spin - SpinWait spinLocal = default; - while (!_state[lowLocal]._value) - { - spinLocal.SpinOnce(); - } - result = _array[lowLocal]; - - // If there is no other thread taking snapshot (GetEnumerator(), ToList(), etc), reset the deleted entry to null. - // It is ok if after this conditional check _numSnapshotTakers becomes > 0, because new snapshots won't include - // the deleted entry at _array[lowLocal]. - if (_source._numSnapshotTakers <= 0) - { - _array[lowLocal] = default(T); //release the reference to the object. - } - - //if the current thread sets _low to SEGMENT_SIZE, which means the current segment becomes - //disposable, then this thread is responsible to dispose this segment, and reset _head - if (lowLocal + 1 >= SEGMENT_SIZE) - { - // Invariant: we only dispose the current _head, not any other segment - // In usual situation, disposing a segment is simply setting _head to _head._next - // But there is one special case, where _head and _tail points to the same and ONLY - //segment of the queue: Another thread A is doing Enqueue and finds that it needs to grow, - //while the *current* thread is doing *this* Dequeue operation, and finds that it needs to - //dispose the current (and ONLY) segment. Then we need to wait till thread A finishes its - //Grow operation, this is the reason of having the following while loop - spinLocal = default; - while (_next == null) - { - spinLocal.SpinOnce(); - } - Debug.Assert(_source._head == this); - _source._head = _next; - } - return true; - } - else - { - //CAS failed due to contention: spin briefly and retry - spin.SpinOnce(); - lowLocal = Low; highLocal = High; - } - }//end of while - result = default(T); - return false; - } - - /// - /// try to peek the current segment - /// - /// holds the return value of the element at the head position, - /// value set to default(T) if there is no such an element - /// true if there are elements in the current segment, false otherwise - internal bool TryPeek(out T result) - { - result = default(T); - int lowLocal = Low; - if (lowLocal > High) - return false; - SpinWait spin = default; - while (!_state[lowLocal]._value) - { - spin.SpinOnce(); - } - result = _array[lowLocal]; - return true; - } - - /// - /// Adds part or all of the current segment into a List. - /// - /// the list to which to add - /// the start position - /// the end position - internal void AddToList(List list, int start, int end) - { - for (int i = start; i <= end; i++) - { - SpinWait spin = default; - while (!_state[i]._value) - { - spin.SpinOnce(); - } - list.Add(_array[i]); - } - } - - /// - /// return the position of the head of the current segment - /// Value range [0, SEGMENT_SIZE], if it's SEGMENT_SIZE, it means this segment is exhausted and thus empty - /// - internal int Low - { - get - { - return Math.Min(_low, SEGMENT_SIZE); - } - } - - /// - /// return the logical position of the tail of the current segment - /// Value range [-1, SEGMENT_SIZE-1]. When it's -1, it means this is a new segment and has no element yet - /// - internal int High - { - get - { - //if _high > SEGMENT_SIZE, it means it's out of range, we should return - //SEGMENT_SIZE-1 as the logical position - return Math.Min(_high, SEGMENT_SIZE - 1); - } - } - } - }//end of class Segment - - /// - /// A wrapper struct for volatile bool, please note the copy of the struct it self will not be volatile - /// for example this statement will not include in volatile operation volatileBool1 = volatileBool2 the jit will copy the struct and will ignore the volatile - /// - internal struct VolatileBool - { - public VolatileBool(bool value) - { - _value = value; - } - public volatile bool _value; - } -} diff --git a/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/DataflowEtwProvider.cs b/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/DataflowEtwProvider.cs index 9318c850a2688..895aa05c20712 100644 --- a/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/DataflowEtwProvider.cs +++ b/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/DataflowEtwProvider.cs @@ -14,13 +14,10 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Security; -#if FEATURE_TRACING using System.Diagnostics.Tracing; -#endif namespace System.Threading.Tasks.Dataflow.Internal { -#if FEATURE_TRACING /// Provides an event source for tracing Dataflow information. [EventSource( Name = "System.Threading.Tasks.Dataflow.DataflowEventSource", @@ -220,5 +217,4 @@ private void DataflowBlockUnlinking(int sourceId, int targetId) } #endregion } -#endif } diff --git a/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/IProducerConsumerCollection.cs b/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/IProducerConsumerCollection.cs deleted file mode 100644 index 8df8be6c39131..0000000000000 --- a/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/IProducerConsumerCollection.cs +++ /dev/null @@ -1,113 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ -// -// IProducerConsumerCollection.cs -// -// -// A common interface for all concurrent collections. -// -// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - -#nullable disable // copy used only for netstandard1.0 build -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; - -namespace System.Threading.Tasks.Dataflow.Internal.Collections -{ - /// - /// Defines methods to manipulate thread-safe collections intended for producer/consumer usage. - /// - /// Specifies the type of elements in the collection. - /// - /// All implementations of this interface must enable all members of this interface - /// to be used concurrently from multiple threads. - /// - internal interface IProducerConsumerCollection : IEnumerable, ICollection - { - /// - /// Copies the elements of the to - /// an - /// , starting at a specified index. - /// - /// The one-dimensional that is the destination of - /// the elements copied from the . - /// The array must have zero-based indexing. - /// The zero-based index in at which copying - /// begins. - /// is a null reference (Nothing in - /// Visual Basic). - /// is less than - /// zero. - /// is equal to or greater than the - /// length of the - /// -or- The number of elements in the source is greater than the - /// available space from to the end of the destination . - /// - void CopyTo(T[] array, int index); - - /// - /// Attempts to add an object to the . - /// - /// The object to add to the . - /// true if the object was added successfully; otherwise, false. - /// The was invalid for this collection. - bool TryAdd(T item); - - /// - /// Attempts to remove and return an object from the . - /// - /// - /// When this method returns, if the object was removed and returned successfully, contains the removed object. If no object was available to be removed, the value is - /// unspecified. - /// - /// true if an object was removed and returned successfully; otherwise, false. - bool TryTake(out T item); - - /// - /// Copies the elements contained in the to a new array. - /// - /// A new array containing the elements copied from the . - T[] ToArray(); - } - - - /// - /// A debugger view of the IProducerConsumerCollection that makes it simple to browse the - /// collection's contents at a point in time. - /// - /// The type of elements stored within. - internal sealed class SystemCollectionsConcurrent_ProducerConsumerCollectionDebugView - { - private IProducerConsumerCollection _collection; // The collection being viewed. - - /// - /// Constructs a new debugger view object for the provided collection object. - /// - /// A collection to browse in the debugger. - public SystemCollectionsConcurrent_ProducerConsumerCollectionDebugView(IProducerConsumerCollection collection) - { - if (collection == null) - { - throw new ArgumentNullException(nameof(collection)); - } - - _collection = collection; - } - - /// - /// Returns a snapshot of the underlying collection's elements. - /// - [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] - public T[] Items - { - get { return _collection.ToArray(); } - } - } -} diff --git a/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/ProducerConsumerQueues.cs b/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/ProducerConsumerQueues.cs index 24b2640ecbbd5..2017ef2274e27 100644 --- a/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/ProducerConsumerQueues.cs +++ b/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/ProducerConsumerQueues.cs @@ -23,11 +23,7 @@ // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- using System.Collections; -#if USE_INTERNAL_CONCURRENT_COLLECTIONS -using System.Threading.Tasks.Dataflow.Internal.Collections; -#else using System.Collections.Concurrent; -#endif using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; diff --git a/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/SourceCore.cs b/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/SourceCore.cs index 22bf0f851fa85..2cf653c6c20aa 100644 --- a/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/SourceCore.cs +++ b/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/SourceCore.cs @@ -753,14 +753,12 @@ private void OfferAsyncIfNecessary_Slow(bool isReplacementReplica, bool outgoing _taskForOutputProcessing = new Task(thisSourceCore => ((SourceCore)thisSourceCore!).OfferMessagesLoopCore(), this, Common.GetCreationOptionsForTask(isReplacementReplica)); -#if FEATURE_TRACING DataflowEtwProvider etwLog = DataflowEtwProvider.Log; if (etwLog.IsEnabled()) { etwLog.TaskLaunchedForMessageHandling( _owningSource, _taskForOutputProcessing, DataflowEtwProvider.TaskLaunchedReason.OfferingOutputMessages, _messages.Count); } -#endif // Start the task handling scheduling exceptions Exception? exception = Common.StartTaskSafe(_taskForOutputProcessing, _dataflowBlockOptions.TaskScheduler); @@ -968,13 +966,11 @@ private void CompleteBlockOncePossible() // Now that the completion task is completed, we may propagate completion to the linked targets _targetRegistry.PropagateCompletion(linkedTargets); -#if FEATURE_TRACING DataflowEtwProvider etwLog = DataflowEtwProvider.Log; if (etwLog.IsEnabled()) { etwLog.DataflowBlockCompleted(_owningSource); } -#endif } /// Gets the object to display in the debugger display attribute. diff --git a/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/SpscTargetCore.cs b/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/SpscTargetCore.cs index 5ed362347a159..65daf01fcc5a9 100644 --- a/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/SpscTargetCore.cs +++ b/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/SpscTargetCore.cs @@ -169,14 +169,12 @@ private void ScheduleConsumerIfNecessary(bool isReplica) { // We won the race. This task is now the consumer. -#if FEATURE_TRACING DataflowEtwProvider etwLog = DataflowEtwProvider.Log; if (etwLog.IsEnabled()) { etwLog.TaskLaunchedForMessageHandling( _owningTarget, newConsumer, DataflowEtwProvider.TaskLaunchedReason.ProcessingInputMessages, _messages.Count); } -#endif // Start the task. In the erroneous case where the scheduler throws an exception, // just allow it to propagate. Our other option would be to fault the block with @@ -346,13 +344,11 @@ private void CompleteBlockOncePossible() // seeing _activeTask as null and queueing a new consumer task even // though the block has completed. -#if FEATURE_TRACING DataflowEtwProvider etwLog = DataflowEtwProvider.Log; if (etwLog.IsEnabled()) { etwLog.DataflowBlockCompleted(_owningTarget); } -#endif } /// diff --git a/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/TargetCore.cs b/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/TargetCore.cs index e25516933c163..ded6e9a053b07 100644 --- a/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/TargetCore.cs +++ b/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/TargetCore.cs @@ -371,7 +371,6 @@ private void ProcessAsyncIfNecessary_Slow(bool repeat) var taskForInputProcessing = new Task(thisTargetCore => ((TargetCore)thisTargetCore!).ProcessMessagesLoopCore(), this, Common.GetCreationOptionsForTask(repeat)); -#if FEATURE_TRACING DataflowEtwProvider etwLog = DataflowEtwProvider.Log; if (etwLog.IsEnabled()) { @@ -379,7 +378,6 @@ private void ProcessAsyncIfNecessary_Slow(bool repeat) _owningTarget, taskForInputProcessing, DataflowEtwProvider.TaskLaunchedReason.ProcessingInputMessages, _messages.Count + (_boundingState != null ? _boundingState.PostponedMessages.Count : 0)); } -#endif // Start the task handling scheduling exceptions Exception? exception = Common.StartTaskSafe(taskForInputProcessing, _dataflowBlockOptions.TaskScheduler); @@ -781,7 +779,6 @@ private void CompleteBlockOncePossible() { _completionSource.TrySetResult(default(VoidResult)); } -#if FEATURE_TRACING // We only want to do tracing for block completion if this target core represents the whole block. // If it only represents a part of the block (i.e. there's a source associated with it as well), // then we shouldn't log just for the first half of the block; the source half will handle logging. @@ -791,7 +788,6 @@ private void CompleteBlockOncePossible() { etwLog.DataflowBlockCompleted(_owningTarget); } -#endif } /// Gets whether the target core is operating in a bounded mode. diff --git a/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/TargetRegistry.cs b/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/TargetRegistry.cs index 2b49a7de8fc73..735b727327ca2 100644 --- a/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/TargetRegistry.cs +++ b/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/TargetRegistry.cs @@ -98,13 +98,11 @@ internal void Add(ref ITargetBlock target, DataflowLinkOptions linkOptions) // Increment the optimization counter if needed Debug.Assert(_linksWithRemainingMessages >= 0, "_linksWithRemainingMessages must be non-negative at any time."); if (node.RemainingMessages > 0) _linksWithRemainingMessages++; -#if FEATURE_TRACING DataflowEtwProvider etwLog = DataflowEtwProvider.Log; if (etwLog.IsEnabled()) { etwLog.DataflowBlockLinking(_owningSource, target); } -#endif } /// Gets whether the registry contains a particular target. @@ -161,13 +159,11 @@ private void Remove_Slow(ITargetBlock target, bool onlyIfReachedMaxMessages) // Decrement the optimization counter if needed if (node.RemainingMessages == 0) _linksWithRemainingMessages--; Debug.Assert(_linksWithRemainingMessages >= 0, "_linksWithRemainingMessages must be non-negative at any time."); -#if FEATURE_TRACING DataflowEtwProvider etwLog = DataflowEtwProvider.Log; if (etwLog.IsEnabled()) { etwLog.DataflowBlockUnlinking(_owningSource, target); } -#endif } // If the target is to stay and we are counting the remaining messages for this link, decrement the counter else if (node.RemainingMessages > 0) diff --git a/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/Threading.cs b/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/Threading.cs deleted file mode 100644 index dd50a03d1e322..0000000000000 --- a/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/Threading.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -#nullable disable // used only for netstandard1.0 build -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace System.Threading.Tasks.Dataflow.Internal.Threading -{ - internal delegate void TimerCallback(object state); - - internal sealed class Timer : CancellationTokenSource, IDisposable - { - internal Timer(TimerCallback callback, object state, int dueTime, int period) - { - Debug.Assert(period == -1, "This stub implementation only supports dueTime."); - Task.Delay(dueTime, Token).ContinueWith((t, s) => - { - var tuple = (Tuple)s; - tuple.Item1(tuple.Item2); - }, Tuple.Create(callback, state), CancellationToken.None, - TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnRanToCompletion, - TaskScheduler.Default); - } - - public new void Dispose() { base.Cancel(); } - } - - internal sealed class Thread - { - internal static bool Yield() { return true; } - } - - internal delegate void WaitCallback(object state); - - internal sealed class ThreadPool - { - private static readonly SynchronizationContext _ctx = new SynchronizationContext(); - - internal static void QueueUserWorkItem(WaitCallback callback, object state) - { - _ctx.Post(s => - { - var tuple = (Tuple)s; - tuple.Item1(tuple.Item2); - }, Tuple.Create(callback, state)); - } - } -} diff --git a/src/libraries/System.Threading.Tasks.Dataflow/src/System.Threading.Tasks.Dataflow.csproj b/src/libraries/System.Threading.Tasks.Dataflow/src/System.Threading.Tasks.Dataflow.csproj index 0f879cda9781a..0625f1b876b92 100644 --- a/src/libraries/System.Threading.Tasks.Dataflow/src/System.Threading.Tasks.Dataflow.csproj +++ b/src/libraries/System.Threading.Tasks.Dataflow/src/System.Threading.Tasks.Dataflow.csproj @@ -1,22 +1,17 @@ - $(NetCoreAppCurrent);netstandard2.1;netstandard2.0;netstandard1.0;netstandard1.1;net461 + $(NetCoreAppCurrent);netstandard2.1;netstandard2.0;net461 true enable - - - $(DefineConstants);FEATURE_TRACING - $(DefineConstants);USE_INTERNAL_CONCURRENT_COLLECTIONS - $(DefineConstants);USE_INTERNAL_THREADING - netstandard1.1;portable-net45+win8+wpa81 - + @@ -47,27 +42,14 @@ - - - - - - - - - - + - - - - - - + @@ -77,7 +59,7 @@ - +