-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove dependency on all Roslyn assemblies from build host #73497
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -764,19 +764,6 @@ public static ImmutableArray<T> Distinct<T>(this ImmutableArray<T> array, IEqual | |
return result; | ||
} | ||
|
||
internal static bool HasAnyErrors<T>(this ImmutableArray<T> diagnostics) where T : Diagnostic | ||
{ | ||
foreach (var diagnostic in diagnostics) | ||
{ | ||
if (diagnostic.Severity == DiagnosticSeverity.Error) | ||
{ | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
// In DEBUG, swap the first and last elements of a read-only array, yielding a new read only array. | ||
// This helps to avoid depending on accidentally sorted arrays. | ||
internal static ImmutableArray<T> ConditionallyDeOrder<T>(this ImmutableArray<T> array) | ||
|
@@ -1034,8 +1021,8 @@ internal static void CreateNameToMembersMap<TKey, TNamespaceOrTypeSymbol, TNamed | |
where TNamedTypeSymbol : class, TNamespaceOrTypeSymbol | ||
where TNamespaceSymbol : class, TNamespaceOrTypeSymbol | ||
{ | ||
foreach (var (name, value) in dictionary) | ||
result.Add(name, createMembers(value)); | ||
foreach (var entry in dictionary) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid dependency on KeyValuePair deconstructor extension |
||
result.Add(entry.Key, createMembers(entry.Value)); | ||
|
||
return; | ||
|
||
|
@@ -1076,11 +1063,11 @@ internal static Dictionary<TKey, ImmutableArray<TNamedTypeSymbol>> GetTypesFromM | |
|
||
var dictionary = new Dictionary<TKey, ImmutableArray<TNamedTypeSymbol>>(capacity, comparer); | ||
|
||
foreach (var (name, members) in map) | ||
foreach (var entry in map) | ||
{ | ||
var namedTypes = getOrCreateNamedTypes(members); | ||
var namedTypes = getOrCreateNamedTypes(entry.Value); | ||
if (namedTypes.Length > 0) | ||
dictionary.Add(name, namedTypes); | ||
dictionary.Add(entry.Key, namedTypes); | ||
} | ||
|
||
return dictionary; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Collections.Immutable; | ||
|
||
namespace Microsoft.CodeAnalysis; | ||
|
||
internal static class DiagnosticArrayExtensions | ||
{ | ||
internal static bool HasAnyErrors<T>(this ImmutableArray<T> diagnostics) where T : Diagnostic | ||
{ | ||
foreach (var diagnostic in diagnostics) | ||
{ | ||
if (diagnostic.Severity == DiagnosticSeverity.Error) | ||
{ | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,39 +2,13 @@ | |
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using Microsoft.CodeAnalysis; | ||
using System; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Text; | ||
|
||
namespace Microsoft.CodeAnalysis | ||
{ | ||
internal static partial class EncodingExtensions | ||
{ | ||
/// <summary> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved and simplified |
||
/// Get maximum char count needed to decode the entire stream. | ||
/// </summary> | ||
/// <exception cref="IOException">Stream is so big that max char count can't fit in <see cref="int"/>.</exception> | ||
internal static int GetMaxCharCountOrThrowIfHuge(this Encoding encoding, Stream stream) | ||
{ | ||
Debug.Assert(stream.CanSeek); | ||
long length = stream.Length; | ||
|
||
if (encoding.TryGetMaxCharCount(length, out int maxCharCount)) | ||
{ | ||
return maxCharCount; | ||
} | ||
|
||
#if CODE_STYLE | ||
throw new IOException(CodeStyleResources.Stream_is_too_long); | ||
#elif WORKSPACE | ||
throw new IOException(WorkspacesResources.Stream_is_too_long); | ||
#else | ||
throw new IOException(CodeAnalysisResources.StreamIsTooLong); | ||
#endif | ||
} | ||
|
||
internal static bool TryGetMaxCharCount(this Encoding encoding, long length, out int maxCharCount) | ||
{ | ||
maxCharCount = 0; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,45 +11,6 @@ namespace Roslyn.Utilities | |
{ | ||
internal static class EnumUtilities | ||
{ | ||
/// <summary> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved, renamed and simplified |
||
/// Convert a boxed primitive (generally of the backing type of an enum) into a ulong. | ||
/// </summary> | ||
/// <remarks> | ||
/// </remarks> | ||
internal static ulong ConvertEnumUnderlyingTypeToUInt64(object value, SpecialType specialType) | ||
{ | ||
RoslynDebug.Assert(value != null); | ||
Debug.Assert(value.GetType().GetTypeInfo().IsPrimitive); | ||
|
||
unchecked | ||
{ | ||
switch (specialType) | ||
{ | ||
case SpecialType.System_SByte: | ||
return (ulong)(sbyte)value; | ||
case SpecialType.System_Int16: | ||
return (ulong)(short)value; | ||
case SpecialType.System_Int32: | ||
return (ulong)(int)value; | ||
case SpecialType.System_Int64: | ||
return (ulong)(long)value; | ||
case SpecialType.System_Byte: | ||
return (byte)value; | ||
case SpecialType.System_UInt16: | ||
return (ushort)value; | ||
case SpecialType.System_UInt32: | ||
return (uint)value; | ||
case SpecialType.System_UInt64: | ||
return (ulong)value; | ||
|
||
default: | ||
// not using ExceptionUtilities.UnexpectedValue() because this is used by the Services layer | ||
// which doesn't have those utilities. | ||
throw new InvalidOperationException(string.Format("{0} is not a valid underlying type for an enum", specialType)); | ||
} | ||
} | ||
} | ||
|
||
internal static T[] GetValues<T>() where T : struct | ||
{ | ||
return (T[])Enum.GetValues(typeof(T)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved