提交 2d871994 编写于 作者: A Andy Gocke 提交者: GitHub

Tuples! (#15075)

Use tuple syntax in the compiler
上级 bf8d2ec7
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis.Collections;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.RuntimeMembers;
using Roslyn.Utilities;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using Microsoft.CodeAnalysis.Collections;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.RuntimeMembers;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp
{
......@@ -755,13 +755,14 @@ private Symbol UnwrapAlias(Symbol symbol, out AliasSymbol alias, DiagnosticBag d
if ((object)type != null)
{
// pass args in a value tuple to avoid allocating a closure
var args = ValueTuple.Create(this, diagnostics, syntax);
var args = (this, diagnostics, syntax);
type.VisitType((typePart, argTuple, isNested) =>
{
argTuple.Item1.ReportDiagnosticsIfObsolete(argTuple.Item2, typePart, argTuple.Item3, hasBaseReceiver: false);
return false;
}, args);
}
return result;
}
......@@ -2098,4 +2099,4 @@ internal static void CheckFeatureAvailability(Location location, MessageID featu
}
}
}
}
}
\ No newline at end of file
......@@ -388,7 +388,7 @@ internal enum ExprContext
internal sealed class StackOptimizerPass1 : BoundTreeRewriter
{
private readonly bool _debugFriendly;
private readonly ArrayBuilder<ValueTuple<BoundExpression, ExprContext>> _evalStack;
private readonly ArrayBuilder<(BoundExpression, ExprContext)> _evalStack;
private int _counter;
private ExprContext _context;
......@@ -535,7 +535,7 @@ protected override BoundExpression VisitExpressionWithoutStackGuard(BoundExpress
private void PushEvalStack(BoundExpression result, ExprContext context)
{
Debug.Assert(result != null || context == ExprContext.None);
_evalStack.Add(ValueTuple.Create(result, context));
_evalStack.Add((result, context));
}
private int StackDepth()
......
......@@ -849,13 +849,8 @@ public override ImmutableArray<MetadataReference> DirectiveReferences
}
}
internal override IDictionary<ValueTuple<string, string>, MetadataReference> ReferenceDirectiveMap
{
get
{
return GetBoundReferenceManager().ReferenceDirectiveMap;
}
}
internal override IDictionary<(string path, string content), MetadataReference> ReferenceDirectiveMap
=> GetBoundReferenceManager().ReferenceDirectiveMap;
// for testing purposes
internal IEnumerable<string> ExternAliases
......@@ -916,7 +911,7 @@ internal override IEnumerable<ReferenceDirective> ReferenceDirectives
public MetadataReference GetDirectiveReference(ReferenceDirectiveTriviaSyntax directive)
{
MetadataReference reference;
return ReferenceDirectiveMap.TryGetValue(ValueTuple.Create(directive.SyntaxTree.FilePath, directive.File.ValueText), out reference) ? reference : null;
return ReferenceDirectiveMap.TryGetValue((directive.SyntaxTree.FilePath, directive.File.ValueText), out reference) ? reference : null;
}
/// <summary>
......
......@@ -555,7 +555,7 @@ private void ReportExportedTypeNameCollisions(ImmutableArray<Cci.ExportedType> e
if (wellKnownAttributeData?.ForwardedTypes?.Count > 0)
{
// (type, index of the parent exported type in builder, or -1 if the type is a top-level type)
var stack = ArrayBuilder<ValueTuple<NamedTypeSymbol, int>>.GetInstance();
var stack = ArrayBuilder<(NamedTypeSymbol type, int parentIndex)>.GetInstance();
foreach (NamedTypeSymbol forwardedType in wellKnownAttributeData.ForwardedTypes)
{
......@@ -569,13 +569,11 @@ private void ReportExportedTypeNameCollisions(ImmutableArray<Cci.ExportedType> e
// Return all nested types.
// Note the order: depth first, children in reverse order (to match dev10, not a requirement).
Debug.Assert(stack.Count == 0);
stack.Push(ValueTuple.Create(originalDefinition, -1));
stack.Push((originalDefinition, -1));
while (stack.Count > 0)
{
var entry = stack.Pop();
NamedTypeSymbol type = entry.Item1;
int parentIndex = entry.Item2;
var (type, parentIndex) = stack.Pop();
// In general, we don't want private types to appear in the ExportedTypes table.
// BREAK: dev11 emits these types. The problem was discovered in dev10, but failed
......@@ -595,7 +593,7 @@ private void ReportExportedTypeNameCollisions(ImmutableArray<Cci.ExportedType> e
ImmutableArray<NamedTypeSymbol> nested = type.GetTypeMembers(); // Ordered.
for (int i = nested.Length - 1; i >= 0; i--)
{
stack.Push(ValueTuple.Create(nested[i], index));
stack.Push((nested[i], index));
}
}
}
......
......@@ -345,7 +345,7 @@ private bool CreateAndSetSourceAssemblyFullBind(CSharpCompilation compilation)
try
{
IDictionary<ValueTuple<string, string>, MetadataReference> boundReferenceDirectiveMap;
IDictionary<(string, string), MetadataReference> boundReferenceDirectiveMap;
ImmutableArray<MetadataReference> boundReferenceDirectives;
ImmutableArray<AssemblyData> referencedAssemblies;
ImmutableArray<PEModule> modules; // To make sure the modules are not collected ahead of time.
......
......@@ -1047,7 +1047,7 @@ public override ImmutableArray<NamedTypeSymbol> GetTypeMembers(string name, int
private Dictionary<string, ImmutableArray<NamedTypeSymbol>> MakeTypeMembers(DiagnosticBag diagnostics)
{
var symbols = ArrayBuilder<NamedTypeSymbol>.GetInstance();
var conflictDict = new Dictionary<ValueTuple<string, int>, SourceNamedTypeSymbol>();
var conflictDict = new Dictionary<(string, int), SourceNamedTypeSymbol>();
try
{
foreach (var childDeclaration in declaration.Children)
......@@ -1055,7 +1055,7 @@ public override ImmutableArray<NamedTypeSymbol> GetTypeMembers(string name, int
var t = new SourceNamedTypeSymbol(this, childDeclaration, diagnostics);
this.CheckMemberNameDistinctFromType(t, diagnostics);
var key = new ValueTuple<string, int>(t.Name, t.Arity);
var key = (t.Name, t.Arity);
SourceNamedTypeSymbol other;
if (conflictDict.TryGetValue(key, out other))
{
......
......@@ -418,9 +418,6 @@
<Compile Include="InternalUtilities\ThreadSafeFlagOperations.cs" />
<Compile Include="InternalUtilities\ThreeState.cs" />
<Compile Include="InternalUtilities\UICultureUtilities.cs" />
<Compile Include="InternalUtilities\ValueTuple.cs" />
<Compile Include="InternalUtilities\ValueTuple`2.cs" />
<Compile Include="InternalUtilities\ValueTuple`3.cs" />
<Compile Include="InternalUtilities\WeakList.cs" />
<Compile Include="InternalUtilities\WeakReferenceExtensions.cs" />
<Compile Include="InternalUtilities\XmlUtilities.cs" />
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Roslyn.Utilities;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Immutable;
......@@ -93,15 +94,15 @@ public ArrayMethod GetArrayAddress(Cci.IArrayTypeReference arrayType)
/// <summary>
/// Maps {array type, method kind} tuples to implementing pseudo-methods.
/// </summary>
private readonly ConcurrentDictionary<ValueTuple<byte, Cci.IArrayTypeReference>, ArrayMethod> _dict =
new ConcurrentDictionary<ValueTuple<byte, Cci.IArrayTypeReference>, ArrayMethod>();
private readonly ConcurrentDictionary<(byte methodKind, Cci.IArrayTypeReference arrayType), ArrayMethod> _dict =
new ConcurrentDictionary<(byte, Cci.IArrayTypeReference), ArrayMethod>();
/// <summary>
/// lazily fetches or creates a new array method.
/// </summary>
private ArrayMethod GetArrayMethod(Cci.IArrayTypeReference arrayType, ArrayMethodKind id)
{
var key = ValueTuple.Create((byte)id, arrayType);
var key = ((byte)id, arrayType);
ArrayMethod result;
var dict = _dict;
......
......@@ -501,7 +501,7 @@ internal CommonReferenceManager GetBoundReferenceManager()
/// <summary>
/// Maps values of #r references to resolved metadata references.
/// </summary>
internal abstract IDictionary<ValueTuple<string, string>, MetadataReference> ReferenceDirectiveMap { get; }
internal abstract IDictionary<(string path, string content), MetadataReference> ReferenceDirectiveMap { get; }
/// <summary>
/// All metadata references -- references passed to the compilation
......
......@@ -17,7 +17,7 @@ internal sealed class DebugDocumentsBuilder
// NOTE: We are not considering how filesystem or debuggers do the comparisons, but how native implementations did.
// Deviating from that may result in unexpected warnings or different behavior (possibly without warnings).
private readonly ConcurrentDictionary<string, Cci.DebugSourceDocument> _debugDocuments;
private readonly ConcurrentCache<ValueTuple<string, string>, string> _normalizedPathsCache;
private readonly ConcurrentCache<(string, string), string> _normalizedPathsCache;
private readonly SourceReferenceResolver _resolverOpt;
private ImmutableArray<Cci.DebugSourceDocument> _embeddedDocuments;
......@@ -30,7 +30,7 @@ public DebugDocumentsBuilder(SourceReferenceResolver resolverOpt, bool isDocumen
StringComparer.Ordinal :
StringComparer.OrdinalIgnoreCase);
_normalizedPathsCache = new ConcurrentCache<ValueTuple<string, string>, string>(16);
_normalizedPathsCache = new ConcurrentCache<(string, string), string>(16);
_embeddedDocuments = ImmutableArray<Cci.DebugSourceDocument>.Empty;
}
......@@ -71,7 +71,7 @@ internal string NormalizeDebugDocumentPath(string path, string basePath)
return path;
}
var key = ValueTuple.Create(path, basePath);
var key = (path, basePath);
string normalizedPath;
if (!_normalizedPathsCache.TryGetValue(key, out normalizedPath))
{
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Roslyn.Utilities
{
// tuple factory
internal static class ValueTuple
{
public static ValueTuple<T1, T2> Create<T1, T2>(T1 item1, T2 item2)
{
return new ValueTuple<T1, T2>(item1, item2);
}
public static ValueTuple<T1, T2, T3> Create<T1, T2, T3>(T1 item1, T2 item2, T3 item3)
{
return new ValueTuple<T1, T2, T3>(item1, item2, item3);
}
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
namespace Roslyn.Utilities
{
// struct with two values
internal struct ValueTuple<T1, T2> : IEquatable<ValueTuple<T1, T2>>
{
private static readonly EqualityComparer<T1> s_comparer1 = EqualityComparer<T1>.Default;
private static readonly EqualityComparer<T2> s_comparer2 = EqualityComparer<T2>.Default;
public readonly T1 Item1;
public readonly T2 Item2;
public ValueTuple(T1 item1, T2 item2)
{
this.Item1 = item1;
this.Item2 = item2;
}
public bool Equals(ValueTuple<T1, T2> other)
{
return s_comparer1.Equals(this.Item1, other.Item1)
&& s_comparer2.Equals(this.Item2, other.Item2);
}
public override bool Equals(object obj)
{
if (obj is ValueTuple<T1, T2>)
{
var other = (ValueTuple<T1, T2>)obj;
return this.Equals(other);
}
return false;
}
public override int GetHashCode()
{
return Hash.Combine(s_comparer1.GetHashCode(Item1), s_comparer2.GetHashCode(Item2));
}
public static bool operator ==(ValueTuple<T1, T2> left, ValueTuple<T1, T2> right)
{
return left.Equals(right);
}
public static bool operator !=(ValueTuple<T1, T2> left, ValueTuple<T1, T2> right)
{
return !left.Equals(right);
}
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
namespace Roslyn.Utilities
{
// struct with three values
internal struct ValueTuple<T1, T2, T3> : IEquatable<ValueTuple<T1, T2, T3>>
{
private static readonly EqualityComparer<T1> s_comparer1 = EqualityComparer<T1>.Default;
private static readonly EqualityComparer<T2> s_comparer2 = EqualityComparer<T2>.Default;
private static readonly EqualityComparer<T3> s_comparer3 = EqualityComparer<T3>.Default;
public readonly T1 Item1;
public readonly T2 Item2;
public readonly T3 Item3;
public ValueTuple(T1 item1, T2 item2, T3 item3)
{
this.Item1 = item1;
this.Item2 = item2;
this.Item3 = item3;
}
public bool Equals(ValueTuple<T1, T2, T3> other)
{
return s_comparer1.Equals(this.Item1, other.Item1)
&& s_comparer2.Equals(this.Item2, other.Item2)
&& s_comparer3.Equals(this.Item3, other.Item3);
}
public override bool Equals(object obj)
{
if (obj is ValueTuple<T1, T2, T3>)
{
var other = (ValueTuple<T1, T2, T3>)obj;
return this.Equals(other);
}
return false;
}
public override int GetHashCode()
{
return Hash.Combine(
Hash.Combine(
s_comparer1.GetHashCode(Item1),
s_comparer2.GetHashCode(Item2)),
s_comparer3.GetHashCode(Item3));
}
public static bool operator ==(ValueTuple<T1, T2, T3> left, ValueTuple<T1, T2, T3> right)
{
return left.Equals(right);
}
public static bool operator !=(ValueTuple<T1, T2, T3> left, ValueTuple<T1, T2, T3> right)
{
return !left.Equals(right);
}
}
}
......@@ -230,7 +230,7 @@ internal partial class CommonReferenceManager<TCompilation, TAssemblySymbol>
Dictionary<MetadataReference, MergedAliases> lazyAliasMap = null;
// metadata references and corresponding bindings of their references, used to calculate a fixed point:
var referenceBindingsToProcess = ArrayBuilder<ValueTuple<MetadataReference, ArraySegment<AssemblyReferenceBinding>>>.GetInstance();
var referenceBindingsToProcess = ArrayBuilder<(MetadataReference, ArraySegment<AssemblyReferenceBinding>)>.GetInstance();
// collect all missing identities, resolve the assemblies and bind their references against explicit definitions:
GetInitialReferenceBindingsToProcess(explicitModules, explicitReferences, explicitReferenceMap, referenceBindings, totalReferencedAssemblyCount, referenceBindingsToProcess);
......@@ -296,7 +296,7 @@ internal partial class CommonReferenceManager<TCompilation, TAssemblySymbol>
var referenceBinding = data.BindAssemblyReferences(explicitAssemblies, IdentityComparer);
referenceBindings.Add(referenceBinding);
referenceBindingsToProcess.Push(ValueTuple.Create((MetadataReference)resolvedReference, new ArraySegment<AssemblyReferenceBinding>(referenceBinding)));
referenceBindingsToProcess.Push((resolvedReference, new ArraySegment<AssemblyReferenceBinding>(referenceBinding)));
}
}
......@@ -361,7 +361,7 @@ internal partial class CommonReferenceManager<TCompilation, TAssemblySymbol>
ImmutableArray<ResolvedReference> explicitReferenceMap,
ArrayBuilder<AssemblyReferenceBinding[]> referenceBindings,
int totalReferencedAssemblyCount,
[Out]ArrayBuilder<ValueTuple<MetadataReference, ArraySegment<AssemblyReferenceBinding>>> result)
[Out]ArrayBuilder<(MetadataReference, ArraySegment<AssemblyReferenceBinding>)> result)
{
Debug.Assert(result.Count == 0);
......@@ -376,9 +376,9 @@ internal partial class CommonReferenceManager<TCompilation, TAssemblySymbol>
var moduleReference = explicitReferences[explicitModuleToReferenceMap[moduleIndex]];
var moduleBindingsCount = explicitModules[moduleIndex].ReferencedAssemblies.Length;
result.Add(ValueTuple.Create(
moduleReference,
new ArraySegment<AssemblyReferenceBinding>(bindingsOfAssemblyBeingBuilt, bindingIndex, moduleBindingsCount)));
result.Add(
(moduleReference,
new ArraySegment<AssemblyReferenceBinding>(bindingsOfAssemblyBeingBuilt, bindingIndex, moduleBindingsCount)));
bindingIndex += moduleBindingsCount;
}
......@@ -395,9 +395,9 @@ internal partial class CommonReferenceManager<TCompilation, TAssemblySymbol>
}
// +1 for the assembly being built
result.Add(ValueTuple.Create(
explicitReferences[referenceIndex],
new ArraySegment<AssemblyReferenceBinding>(referenceBindings[explicitReferenceMapping.Index + 1])));
result.Add(
(explicitReferences[referenceIndex],
new ArraySegment<AssemblyReferenceBinding>(referenceBindings[explicitReferenceMapping.Index + 1])));
}
// we have a reference binding for each module and for each referenced assembly:
......
......@@ -194,7 +194,7 @@ public ReferencedAssemblyIdentity(AssemblyIdentity identity, MetadataReference r
TCompilation compilation,
[Out] Dictionary<string, List<ReferencedAssemblyIdentity>> assemblyReferencesBySimpleName,
out ImmutableArray<MetadataReference> references,
out IDictionary<ValueTuple<string, string>, MetadataReference> boundReferenceDirectiveMap,
out IDictionary<(string, string), MetadataReference> boundReferenceDirectiveMap,
out ImmutableArray<MetadataReference> boundReferenceDirectives,
out ImmutableArray<AssemblyData> assemblies,
out ImmutableArray<PEModule> modules,
......@@ -746,7 +746,7 @@ private static void AddModule(PEModule module, int referenceIndex, ResolvedRefer
TCompilation compilation,
DiagnosticBag diagnostics,
out ImmutableArray<MetadataReference> references,
out IDictionary<ValueTuple<string, string>, MetadataReference> boundReferenceDirectives,
out IDictionary<(string, string), MetadataReference> boundReferenceDirectives,
out ImmutableArray<Location> referenceDirectiveLocations)
{
boundReferenceDirectives = null;
......@@ -765,7 +765,7 @@ private static void AddModule(PEModule module, int referenceIndex, ResolvedRefer
}
// we already successfully bound #r with the same value:
if (boundReferenceDirectives != null && boundReferenceDirectives.ContainsKey(ValueTuple.Create(referenceDirective.Location.SourceTree.FilePath, referenceDirective.File)))
if (boundReferenceDirectives != null && boundReferenceDirectives.ContainsKey((referenceDirective.Location.SourceTree.FilePath, referenceDirective.File)))
{
continue;
}
......@@ -779,13 +779,13 @@ private static void AddModule(PEModule module, int referenceIndex, ResolvedRefer
if (boundReferenceDirectives == null)
{
boundReferenceDirectives = new Dictionary<ValueTuple<string, string>, MetadataReference>();
boundReferenceDirectives = new Dictionary<(string, string), MetadataReference>();
referenceDirectiveLocationsBuilder = ArrayBuilder<Location>.GetInstance();
}
referencesBuilder.Add(boundReference);
referenceDirectiveLocationsBuilder.Add(referenceDirective.Location);
boundReferenceDirectives.Add(ValueTuple.Create(referenceDirective.Location.SourceTree.FilePath, referenceDirective.File), boundReference);
boundReferenceDirectives.Add((referenceDirective.Location.SourceTree.FilePath, referenceDirective.File), boundReference);
}
// add external reference at the end, so that they are processed first:
......@@ -801,7 +801,7 @@ private static void AddModule(PEModule module, int referenceIndex, ResolvedRefer
if (boundReferenceDirectives == null)
{
// no directive references resolved successfully:
boundReferenceDirectives = SpecializedCollections.EmptyDictionary<ValueTuple<string, string>, MetadataReference>();
boundReferenceDirectives = SpecializedCollections.EmptyDictionary<(string, string), MetadataReference>();
}
references = referencesBuilder.ToImmutable();
......
......@@ -36,7 +36,7 @@ internal abstract class CommonReferenceManager
/// <summary>
/// Enumerates all referenced assemblies and their aliases.
/// </summary>
internal abstract IEnumerable<ValueTuple<IAssemblySymbol, ImmutableArray<string>>> GetReferencedAssemblyAliases();
internal abstract IEnumerable<(IAssemblySymbol, ImmutableArray<string>)> GetReferencedAssemblyAliases();
internal abstract MetadataReference GetMetadataReference(IAssemblySymbol assemblySymbol);
internal abstract ImmutableArray<MetadataReference> ExplicitReferences { get; }
......@@ -100,7 +100,7 @@ internal partial class CommonReferenceManager<TCompilation, TAssemblySymbol> : C
/// Maps (containing syntax tree file name, reference string) of #r directive to a resolved metadata reference.
/// If multiple #r's in the same tree use the same value as a reference the resolved metadata reference is the same as well.
/// </summary>
private IDictionary<ValueTuple<string, string>, MetadataReference> _lazyReferenceDirectiveMap;
private IDictionary<(string, string), MetadataReference> _lazyReferenceDirectiveMap;
/// <summary>
/// Array of unique bound #r references.
......@@ -216,7 +216,7 @@ internal bool HasCircularReference
}
}
internal IDictionary<ValueTuple<string, string>, MetadataReference> ReferenceDirectiveMap
internal IDictionary<(string, string), MetadataReference> ReferenceDirectiveMap
{
get
{
......@@ -373,7 +373,7 @@ internal bool IsBound
internal void InitializeNoLock(
Dictionary<MetadataReference, int> referencedAssembliesMap,
Dictionary<MetadataReference, int> referencedModulesMap,
IDictionary<ValueTuple<string, string>, MetadataReference> boundReferenceDirectiveMap,
IDictionary<(string, string), MetadataReference> boundReferenceDirectiveMap,
ImmutableArray<MetadataReference> directiveReferences,
ImmutableArray<MetadataReference> explicitReferences,
ImmutableArray<MetadataReference> implicitReferences,
......@@ -662,11 +662,11 @@ internal override MetadataReference GetMetadataReference(IAssemblySymbol assembl
return null;
}
internal override IEnumerable<ValueTuple<IAssemblySymbol, ImmutableArray<string>>> GetReferencedAssemblyAliases()
internal override IEnumerable<(IAssemblySymbol, ImmutableArray<string>)> GetReferencedAssemblyAliases()
{
for (int i = 0; i < ReferencedAssemblies.Length; i++)
{
yield return ValueTuple.Create((IAssemblySymbol)ReferencedAssemblies[i], AliasesOfReferencedAssemblies[i]);
yield return ((IAssemblySymbol)ReferencedAssemblies[i], AliasesOfReferencedAssemblies[i]);
}
}
......
......@@ -646,15 +646,16 @@ public void WriteTo(System.IO.TextWriter writer)
protected internal void WriteTo(TextWriter writer, bool leading, bool trailing)
{
// Use an actual Stack so we can write out deeply recursive structures without overflowing.
var stack = new Stack<ValueTuple<GreenNode, bool, bool>>();
stack.Push(ValueTuple.Create(this, leading, trailing));
var stack = new Stack<(GreenNode node, bool leading, bool trailing)>();
stack.Push((this, leading, trailing));
// Separated out stack processing logic so that it does not unintentially refer to
// "this", "leading" or "trailing.
ProcessStack(writer, stack);
}
private static void ProcessStack(TextWriter writer, Stack<ValueTuple<GreenNode, bool, bool>> stack)
private static void ProcessStack(TextWriter writer,
Stack<(GreenNode node, bool leading, bool trailing)> stack)
{
while (stack.Count > 0)
{
......@@ -685,7 +686,7 @@ private static void ProcessStack(TextWriter writer, Stack<ValueTuple<GreenNode,
{
var first = i == firstIndex;
var last = i == lastIndex;
stack.Push(ValueTuple.Create(child, currentLeading | !first, currentTrailing | !last));
stack.Push((child, currentLeading | !first, currentTrailing | !last));
}
}
}
......
......@@ -20,6 +20,7 @@
"System.Text.Encoding": "4.0.11",
"System.Text.Encoding.CodePages": "4.0.1",
"System.Text.Encoding.Extensions": "4.0.11",
"System.ValueTuple": "4.0.1-beta-24425-02",
"System.Xml.ReaderWriter": "4.0.11",
"System.Xml.XDocument": "4.0.11",
"System.Xml.XmlDocument": "4.0.1",
......
......@@ -1191,7 +1191,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End Get
End Property
Friend Overrides ReadOnly Property ReferenceDirectiveMap As IDictionary(Of ValueTuple(Of String, String), MetadataReference)
Friend Overrides ReadOnly Property ReferenceDirectiveMap As IDictionary(Of (path As String, content As String), MetadataReference)
Get
Return GetBoundReferenceManager().ReferenceDirectiveMap
End Get
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
......
......@@ -12,6 +12,7 @@
using Microsoft.CodeAnalysis.Shared.Extensions.ContextQuery;
using Roslyn.Utilities;
using Microsoft.CodeAnalysis.Shared.Utilities;
using System;
namespace Microsoft.CodeAnalysis.Completion.Providers
{
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Concurrent;
using System.Collections.Immutable;
using Roslyn.Utilities;
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using Roslyn.Utilities;
......
......@@ -28,7 +28,7 @@ public SourceWithMarkedNodes(string markedSource, Func<string, SyntaxTree> parse
SpansAndKindsAndIds = ImmutableArray.CreateRange(GetSpansRecursive(markedSource, 0, getSyntaxKind));
}
private static IEnumerable<ValueTuple<TextSpan, int, int>> GetSpansRecursive(string markedSource, int offset, Func<string, int> getSyntaxKind)
private static IEnumerable<(TextSpan, int, int)> GetSpansRecursive(string markedSource, int offset, Func<string, int> getSyntaxKind)
{
foreach (var match in s_markerPattern.Matches(markedSource).ToEnumerable())
{
......@@ -38,7 +38,7 @@ public SourceWithMarkedNodes(string markedSource, Func<string, SyntaxTree> parse
var parsedKind = string.IsNullOrEmpty(syntaxKindOpt) ? 0 : getSyntaxKind(syntaxKindOpt);
int absoluteOffset = offset + markedSyntax.Index;
yield return ValueTuple.Create(new TextSpan(absoluteOffset, markedSyntax.Length), parsedKind, id);
yield return (new TextSpan(absoluteOffset, markedSyntax.Length), parsedKind, id);
foreach (var nestedSpan in GetSpansRecursive(markedSyntax.Value, absoluteOffset, getSyntaxKind))
{
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Diagnostics;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Composition;
using Microsoft.CodeAnalysis.CSharp.Syntax;
......@@ -204,7 +205,7 @@ private void AddBlockIndentationOperation(List<IndentBlockOperation> list, Synta
AddIndentBlockOperation(list, bracePair.Item1.GetNextToken(includeZeroWidth: true), bracePair.Item2.GetPreviousToken(includeZeroWidth: true));
}
private void AddAlignmentBlockOperationRelativeToFirstTokenOnBaseTokenLine(List<IndentBlockOperation> list, Roslyn.Utilities.ValueTuple<SyntaxToken, SyntaxToken> bracePair)
private void AddAlignmentBlockOperationRelativeToFirstTokenOnBaseTokenLine(List<IndentBlockOperation> list, ValueTuple<SyntaxToken, SyntaxToken> bracePair)
{
var option = IndentBlockOption.RelativeToFirstTokenOnBaseTokenLine;
SetAlignmentBlockOperation(list, bracePair.Item1, bracePair.Item1.GetNextToken(includeZeroWidth: true), bracePair.Item2, option);
......
......@@ -74,7 +74,7 @@ public override void AddSuppressOperations(List<SuppressOperation> list, SyntaxN
private void AddSpecificNodesSuppressOperations(List<SuppressOperation> list, SyntaxNode node)
{
var tokens = GetSpecificNodeSuppressionTokenRange(node);
if (tokens != default(ValueTuple<SyntaxToken, SyntaxToken>))
if (!tokens.Equals(default(ValueTuple<SyntaxToken, SyntaxToken>)))
{
AddSuppressWrappingIfOnSingleLineOperation(list, tokens.Item1, tokens.Item2);
}
......@@ -106,7 +106,7 @@ private void RemoveSuppressOperationForStatementMethodDeclaration(List<SuppressO
}
var tokens = GetSpecificNodeSuppressionTokenRange(node);
if (tokens != default(ValueTuple<SyntaxToken, SyntaxToken>))
if (!tokens.Equals(default(ValueTuple<SyntaxToken, SyntaxToken>)))
{
RemoveSuppressOperation(list, tokens.Item1, tokens.Item2);
}
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.CodeAnalysis;
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Threading;
using Microsoft.CodeAnalysis.Internal.Log;
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Immutable;
using System.Linq;
using Microsoft.CodeAnalysis;
......
......@@ -165,15 +165,6 @@
<Compile Include="..\..\..\Compilers\Core\Portable\InternalUtilities\TextChangeRangeExtensions.cs">
<Link>InternalUtilities\TextChangeRangeExtensions.cs</Link>
</Compile>
<Compile Include="..\..\..\Compilers\Core\Portable\InternalUtilities\ValueTuple.cs">
<Link>InternalUtilities\ValueTuple.cs</Link>
</Compile>
<Compile Include="..\..\..\Compilers\Core\Portable\InternalUtilities\ValueTuple`2.cs">
<Link>InternalUtilities\ValueTuple`2.cs</Link>
</Compile>
<Compile Include="..\..\..\Compilers\Core\Portable\InternalUtilities\ValueTuple`3.cs">
<Link>InternalUtilities\ValueTuple`3.cs</Link>
</Compile>
<Compile Include="..\..\..\Compilers\Core\Portable\InternalUtilities\WeakReferenceExtensions.cs">
<Link>InternalUtilities\WeakReferenceExtensions.cs</Link>
</Compile>
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册