From 1d1498f5ece1ffefadba06d38a65061f94bc6041 Mon Sep 17 00:00:00 2001 From: tmat Date: Tue, 29 Apr 2025 09:46:24 -0700 Subject: [PATCH] Move Range and Index to Contracts source package --- .../Contracts}/Index.cs | 10 +++++++++- .../Microsoft.CodeAnalysis.Contracts.projitems | 2 ++ .../Contracts}/Range.cs | 14 +++++++++----- .../BuildTask/SemanticSearch.BuildTask.csproj | 5 ----- .../Compiler/Core/CompilerExtensions.projitems | 6 ------ 5 files changed, 20 insertions(+), 17 deletions(-) rename src/{Compilers/Core/Portable/InternalUtilities => Dependencies/Contracts}/Index.cs (94%) rename src/{Compilers/Core/Portable/InternalUtilities => Dependencies/Contracts}/Range.cs (91%) diff --git a/src/Compilers/Core/Portable/InternalUtilities/Index.cs b/src/Dependencies/Contracts/Index.cs similarity index 94% rename from src/Compilers/Core/Portable/InternalUtilities/Index.cs rename to src/Dependencies/Contracts/Index.cs index 2dff6f0bb8834..8903fd515a3b5 100644 --- a/src/Compilers/Core/Portable/InternalUtilities/Index.cs +++ b/src/Dependencies/Contracts/Index.cs @@ -2,8 +2,16 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#if !NETCOREAPP +#if NET + +#pragma warning disable RS0016 // Add public types and members to the declared API (this is a supporting forwarder for an internal polyfill API) +[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Index))] +#pragma warning restore RS0016 // Add public types and members to the declared API + +#else + using System.Runtime.CompilerServices; + namespace System { /// Represent a type can be used to index a collection either from the start or the end. diff --git a/src/Dependencies/Contracts/Microsoft.CodeAnalysis.Contracts.projitems b/src/Dependencies/Contracts/Microsoft.CodeAnalysis.Contracts.projitems index b98b83ea55567..bcbde6e95d62b 100644 --- a/src/Dependencies/Contracts/Microsoft.CodeAnalysis.Contracts.projitems +++ b/src/Dependencies/Contracts/Microsoft.CodeAnalysis.Contracts.projitems @@ -25,6 +25,8 @@ + + diff --git a/src/Compilers/Core/Portable/InternalUtilities/Range.cs b/src/Dependencies/Contracts/Range.cs similarity index 91% rename from src/Compilers/Core/Portable/InternalUtilities/Range.cs rename to src/Dependencies/Contracts/Range.cs index 84d1afdf48b1f..2792c21056613 100644 --- a/src/Compilers/Core/Portable/InternalUtilities/Range.cs +++ b/src/Dependencies/Contracts/Range.cs @@ -2,9 +2,15 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#if !NETCOREAPP +#if NET + +#pragma warning disable RS0016 // Add public types and members to the declared API (this is a supporting forwarder for an internal polyfill API) +[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Range))] +#pragma warning restore RS0016 // Add public types and members to the declared API + +#else using System.Runtime.CompilerServices; -using Roslyn.Utilities; + namespace System { /// Represent a range has start and end indexes. @@ -46,9 +52,7 @@ value is Range r && /// Returns the hash code for this instance. public override int GetHashCode() - { - return Hash.Combine(Start.GetHashCode(), End.GetHashCode()); - } + => unchecked(Start.GetHashCode() * (int)0xA5555529 + End.GetHashCode()); /// Converts the value of the current Range object to its equivalent string representation. public override string ToString() diff --git a/src/Tools/SemanticSearch/BuildTask/SemanticSearch.BuildTask.csproj b/src/Tools/SemanticSearch/BuildTask/SemanticSearch.BuildTask.csproj index f0184c57d0cd0..bd0f6a73dcc83 100644 --- a/src/Tools/SemanticSearch/BuildTask/SemanticSearch.BuildTask.csproj +++ b/src/Tools/SemanticSearch/BuildTask/SemanticSearch.BuildTask.csproj @@ -16,10 +16,5 @@ - - - - - diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems index c05dfea8823bd..da34ac9ba2f30 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems @@ -113,9 +113,6 @@ InternalUtilities\ImmutableListExtensions.cs - - InternalUtilities\Index.cs - InternalUtilities\ISetExtensions.cs @@ -140,9 +137,6 @@ InternalUtilities\PlatformInformation.cs - - InternalUtilities\Range.cs - InternalUtilities\ReaderWriterLockSlimExtensions.cs