提交 ccefeced 编写于 作者: M mattwar

Change usages of ImmutableList to ImmutableArray. (changeset 1248518)

上级 88705735
......@@ -306,8 +306,9 @@ private static ObjectReaderData GetDefaultObjectReaderData()
return defaultObjectReaderData;
}
private static ImmutableList<object> serializationData;
private static ImmutableList<object> GetSerializationData()
private static IEnumerable<object> serializationData;
private static IEnumerable<object> GetSerializationData()
{
if (serializationData == null)
{
......@@ -357,7 +358,7 @@ private static ImmutableList<object> GetSerializationData()
"offset",
"width",
})
.ToImmutableList();
.ToImmutableArray();
System.Threading.Interlocked.CompareExchange(ref serializationData, data, null);
}
......
......@@ -235,6 +235,7 @@
<Compile Include="InternalUtilities\EnumUtilties.cs" />
<Compile Include="InternalUtilities\ExceptionUtilities.cs" />
<Compile Include="InternalUtilities\HashFunctions.cs" />
<Compile Include="InternalUtilities\ImmutableArrayExtensions.cs" />
<Compile Include="InternalUtilities\ImmutableListExtensions.cs" />
<Compile Include="InternalUtilities\ImmutableSetWithInsertionOrder`1.cs" />
<Compile Include="InternalUtilities\ISetExtensions.cs" />
......
......@@ -27,7 +27,7 @@ internal sealed class SimpleDiagnostic : Diagnostic, ISerializable
private readonly int warningLevel;
private readonly bool isWarningAsError;
private readonly Location location;
private readonly ImmutableList<Location> additionalLocations;
private readonly IReadOnlyList<Location> additionalLocations;
internal SimpleDiagnostic(string id, string category, string message, DiagnosticSeverity severity, bool isEnabledByDefault,
int warningLevel, bool isWarningAsError, Location location,
......@@ -52,7 +52,7 @@ internal sealed class SimpleDiagnostic : Diagnostic, ISerializable
this.warningLevel = warningLevel;
this.isWarningAsError = isWarningAsError;
this.location = location;
this.additionalLocations = additionalLocations.ToImmutableListOrEmpty();
this.additionalLocations = additionalLocations == null ? SpecializedCollections.EmptyReadOnlyList<Location>() : additionalLocations.ToImmutableArray();
}
private SimpleDiagnostic(SerializationInfo info, StreamingContext context)
......@@ -65,7 +65,7 @@ private SimpleDiagnostic(SerializationInfo info, StreamingContext context)
this.warningLevel = info.GetInt32("warningLevel");
this.isWarningAsError = info.GetBoolean("isWarningAsError");
this.location = (Location)info.GetValue("location", typeof(Location));
this.additionalLocations = ((Location[])info.GetValue("additionalLocations", typeof(Location[]))).ToImmutableListOrEmpty();
this.additionalLocations = ((Location[])info.GetValue("additionalLocations", typeof(Location[]))).ToImmutableArrayOrEmpty();
}
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
......
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Collections.Immutable;
namespace Roslyn.Utilities
{
internal static class ImmutableArrayExtensions
{
internal static ImmutableArray<T> ToImmutableArrayOrEmpty<T>(this T[] items)
{
if (items == null)
{
return ImmutableArray.Create<T>();
}
return ImmutableArray.Create<T>(items);
}
internal static ImmutableArray<T> ToImmutableArrayOrEmpty<T>(this IEnumerable<T> items)
{
if (items == null)
{
return ImmutableArray.Create<T>();
}
return ImmutableArray.CreateRange<T>(items);
}
internal static ImmutableArray<T> ToImmutableArrayOrEmpty<T>(this ImmutableArray<T> items)
{
if (items.IsDefault)
{
return ImmutableArray.Create<T>();
}
return items;
}
}
}
\ No newline at end of file
......@@ -128,7 +128,7 @@ public override IReadOnlyList<TextChangeRange> GetChangeRanges(SourceText oldTex
}
else
{
return ImmutableList.Create(new TextChangeRange(new TextSpan(0, oldText.Length), newText.Length));
return ImmutableArray.Create(new TextChangeRange(new TextSpan(0, oldText.Length), newText.Length));
}
}
}
......
......@@ -316,7 +316,7 @@ public virtual IReadOnlyList<TextChangeRange> GetChangeRanges(SourceText oldText
}
else
{
return ImmutableList.Create(new TextChangeRange(new TextSpan(0, oldText.Length), this.Length));
return ImmutableArray.Create(new TextChangeRange(new TextSpan(0, oldText.Length), this.Length));
}
}
......@@ -353,7 +353,7 @@ public virtual IReadOnlyList<TextChange> GetTextChanges(SourceText oldText)
newPosDelta += range.NewLength - range.Span.Length;
}
return textChanges.ToImmutableListOrEmpty();
return textChanges.ToImmutableArrayOrEmpty();
}
#endregion
......
......@@ -28,7 +28,7 @@ public TextChangeEventArgs(SourceText oldText, SourceText newText, IEnumerable<T
this.OldText = oldText;
this.NewText = newText;
this.Changes = changes.ToImmutableList();
this.Changes = changes.ToImmutableArray();
}
/// <summary>
......
......@@ -209,9 +209,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Return _defaultObjectWriterData
End Function
Private Shared ReadOnly _serializationData As ImmutableList(Of Object)
Private Shared Function GetSerializationData() As ImmutableList(Of Object)
Return New Object() {
Private Shared ReadOnly _serializationData As IEnumerable(Of Object)
Private Shared Function GetSerializationData() As IEnumerable(Of Object)
Dim data = New Object() {
GetType(Object).Assembly.FullName,
GetType(Microsoft.CodeAnalysis.DiagnosticInfo).Assembly.FullName,
GetType(Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxNode).Assembly.FullName,
......@@ -238,7 +238,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
} _
.Concat(InternalSyntax.SyntaxFactory.NodeTypes) _
.Concat(InternalSyntax.SyntaxFactory.GetWellKnownTrivia()) _
.ToImmutableList()
.ToImmutableArray()
Interlocked.CompareExchange(_serializationData, data, Nothing)
Return _serializationData
End Function
#End Region
......
......@@ -75,7 +75,7 @@ public override void AnalyzeSymbol(INamedTypeSymbol symbol, Compilation compilat
return;
}
IImmutableList<IFieldSymbol> zeroValuedFields = GetZeroValuedFields(symbol).ToImmutableList();
var zeroValuedFields = GetZeroValuedFields(symbol).ToImmutableArray();
bool hasFlagsAttribute = symbol.GetAttributes().Any(a => a.AttributeClass == flagsAttribute);
if (hasFlagsAttribute)
......@@ -88,9 +88,9 @@ public override void AnalyzeSymbol(INamedTypeSymbol symbol, Compilation compilat
}
}
private void CheckFlags(INamedTypeSymbol namedType, IImmutableList<IFieldSymbol> zeroValuedFields, Action<Diagnostic> addDiagnostic)
private void CheckFlags(INamedTypeSymbol namedType, ImmutableArray<IFieldSymbol> zeroValuedFields, Action<Diagnostic> addDiagnostic)
{
switch (zeroValuedFields.Count)
switch (zeroValuedFields.Length)
{
case 0:
break;
......@@ -114,9 +114,9 @@ private void CheckFlags(INamedTypeSymbol namedType, IImmutableList<IFieldSymbol>
}
}
private void CheckNonFlags(INamedTypeSymbol namedType, IImmutableList<IFieldSymbol> zeroValuedFields, Action<Diagnostic> addDiagnostic)
private void CheckNonFlags(INamedTypeSymbol namedType, ImmutableArray<IFieldSymbol> zeroValuedFields, Action<Diagnostic> addDiagnostic)
{
if (zeroValuedFields.Count == 0)
if (zeroValuedFields.Length == 0)
{
// Add a member to {0} that has a value of zero with a suggested name of 'None'.
addDiagnostic(namedType.CreateDiagnostic(RuleNoZero, namedType.Name));
......
......@@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.CSharp.Classification
internal static class SyntaxClassifier
{
public static readonly IEnumerable<ISyntaxClassifier> DefaultSyntaxClassifiers =
ImmutableList.Create<ISyntaxClassifier>(
ImmutableArray.Create<ISyntaxClassifier>(
new NameSyntaxClassifier(),
new SyntaxTokenClassifier(),
new UsingDirectiveSyntaxClassifier());
......
......@@ -9,13 +9,13 @@ namespace Microsoft.CodeAnalysis.CSharp.CodeCleanup
{
internal class CSharpCodeCleanerService : AbstractCodeCleanerService
{
private static readonly IList<ICodeCleanupProvider> defaultProviders;
private static readonly IEnumerable<ICodeCleanupProvider> defaultProviders;
static CSharpCodeCleanerService()
{
// TODO : move it down to service and add this - GetService<IOrganizingService>(LanguageNames.VisualBasic)
defaultProviders = ImmutableList.Create<ICodeCleanupProvider>(
defaultProviders = ImmutableArray.Create<ICodeCleanupProvider>(
new SimplificationCodeCleanupProvider(),
new FormatCodeCleanupProvider());
}
......
......@@ -32,7 +32,7 @@ public CSharpSyntaxFormattingService([ImportMany] IEnumerable<Lazy<IFormattingRu
.Where(x => x.Metadata.Language == LanguageNames.CSharp)
.Select(x => x.Value)
.Concat(new DefaultOperationProvider())
.ToImmutableList());
.ToImmutableArray());
}
public override IEnumerable<IFormattingRule> GetDefaultFormattingRules()
......@@ -47,7 +47,7 @@ public override IEnumerable<IFormattingRule> GetDefaultFormattingRules()
new IndentUserSettingsFormattingRule()
};
return spaceFormattingRules.Concat(rules).ToImmutableList();
return spaceFormattingRules.Concat(rules).ToImmutableArray();
}
protected override IFormattingResult CreateAggregatedFormattingResult(SyntaxNode node, IList<AbstractFormattingResult> results, SimpleIntervalTree<TextSpan> formattingSpans = null)
......
......@@ -23,7 +23,7 @@ private class PathSyntaxReference : SyntaxReference
private readonly SyntaxTree tree;
private readonly SyntaxKind kind;
private readonly TextSpan textSpan;
private readonly ImmutableList<int> pathFromRoot;
private readonly ImmutableArray<int> pathFromRoot;
public PathSyntaxReference(SyntaxNode node)
{
......@@ -49,7 +49,7 @@ public override TextSpan Span
}
}
private ImmutableList<int> ComputePathFromRoot(SyntaxNode node)
private ImmutableArray<int> ComputePathFromRoot(SyntaxNode node)
{
var path = new List<int>();
var root = tree.GetRoot();
......@@ -80,7 +80,7 @@ private ImmutableList<int> ComputePathFromRoot(SyntaxNode node)
}
path.Reverse();
return path.ToImmutableList();
return path.ToImmutableArray();
}
private int GetChildIndex(SyntaxNodeOrToken child)
......@@ -155,7 +155,7 @@ public async override Task<SyntaxNode> GetSyntaxAsync(CancellationToken cancella
private SyntaxNode GetNode(SyntaxNode root)
{
var node = root;
for (int i = 0, n = this.pathFromRoot.Count; i < n; i++)
for (int i = 0, n = this.pathFromRoot.Length; i < n; i++)
{
var child = node.ChildNodesAndTokens()[this.pathFromRoot[i]];
......
......@@ -93,7 +93,7 @@ private ProjectFileInfo CreateProjectFileInfo(CSharpCompilerInputs compilerInput
var docs = compilerInputs.Sources
.Where(s => !Path.GetFileName(s.ItemSpec).StartsWith("TemporaryGeneratedFile_"))
.Select(s => MakeDocumentFileInfo(projectDirectory, s))
.ToImmutableList();
.ToImmutableArray();
var metadataRefs = compilerInputs.References.SelectMany(r => MakeMetadataInfo(r));
......
......@@ -18,7 +18,7 @@ internal partial class FindReferencesSearchEngine
{
private readonly Solution solution;
private readonly IImmutableSet<Document> documents;
private readonly ImmutableList<IReferenceFinder> finders;
private readonly ImmutableArray<IReferenceFinder> finders;
private readonly IFindReferencesProgress progress;
private readonly CancellationToken cancellationToken;
private readonly ProjectDependencyGraph dependencyGraph;
......@@ -40,7 +40,7 @@ internal partial class FindReferencesSearchEngine
public FindReferencesSearchEngine(
Solution solution,
IImmutableSet<Document> documents,
ImmutableList<IReferenceFinder> finders,
ImmutableArray<IReferenceFinder> finders,
IFindReferencesProgress progress,
CancellationToken cancellationToken)
{
......@@ -70,7 +70,7 @@ public async Task<IEnumerable<ReferencedSymbol>> FindReferencesAsync(ISymbol sym
progress.OnCompleted();
}
return this.foundReferences.Select(kvp => new ReferencedSymbol(kvp.Key, kvp.Value.ToImmutableList())).ToImmutableList();
return this.foundReferences.Select(kvp => new ReferencedSymbol(kvp.Key, kvp.Value.ToImmutableArray())).ToImmutableArray();
}
private async Task ProcessAsync(
......
......@@ -30,14 +30,14 @@ internal static class ReferenceFinders
/// <summary>
/// The list of common reference finders.
/// </summary>
public static readonly IEnumerable<IReferenceFinder> DefaultReferenceFinders;
public static readonly ImmutableArray<IReferenceFinder> DefaultReferenceFinders;
// Rename does not need to include base/this constructor initializer calls
internal static readonly ImmutableList<IReferenceFinder> DefaultRenameReferenceFinders;
internal static readonly ImmutableArray<IReferenceFinder> DefaultRenameReferenceFinders;
static ReferenceFinders()
{
DefaultRenameReferenceFinders = ImmutableList.Create(
DefaultRenameReferenceFinders = ImmutableArray.Create(
Constructor,
Destructor,
Event,
......
......@@ -62,7 +62,7 @@ public static partial class SymbolFinder
{
var finders = ReferenceFinders.DefaultReferenceFinders;
progress = progress ?? FindReferencesProgress.Instance;
var engine = new FindReferencesSearchEngine(solution, documents, finders.ToImmutableListOrEmpty(), progress, cancellationToken);
var engine = new FindReferencesSearchEngine(solution, documents, finders, progress, cancellationToken);
return await engine.FindReferencesAsync(symbol).ConfigureAwait(false);
}
}
......
......@@ -50,7 +50,7 @@ public override GlobalOperationRegistration Start(string operation)
protected virtual Task RaiseGlobalOperationStarted()
{
var handlers = this.eventMap.GetEventHandlers<EventHandler>(GlobalOperationStartedEventName);
if (handlers != null)
if (handlers.Length > 0)
{
return this.eventQueue.ScheduleTask(() =>
{
......@@ -67,7 +67,7 @@ protected virtual Task RaiseGlobalOperationStarted()
protected virtual Task RaiseGlobalOperationStopped(IReadOnlyList<string> operations, bool cancelled)
{
var handlers = this.eventMap.GetEventHandlers<EventHandler<GlobalOperationEventArgs>>(GlobalOperationStoppedEventName);
if (handlers != null)
if (handlers.Length > 0)
{
var args = new GlobalOperationEventArgs(operations, cancelled);
......
......@@ -17,8 +17,8 @@ namespace Microsoft.CodeAnalysis.Options
internal class OptionService : IOptionService
{
private readonly Lazy<HashSet<IOption>> options;
private readonly ImmutableDictionary<string, ImmutableList<Lazy<IOptionSerializer, OptionSerializerMetadata>>> featureNameToOptionSerializers =
ImmutableDictionary.Create<string, ImmutableList<Lazy<IOptionSerializer, OptionSerializerMetadata>>>();
private readonly ImmutableDictionary<string, ImmutableArray<Lazy<IOptionSerializer, OptionSerializerMetadata>>> featureNameToOptionSerializers =
ImmutableDictionary.Create<string, ImmutableArray<Lazy<IOptionSerializer, OptionSerializerMetadata>>>();
private readonly object gate = new object();
private ImmutableDictionary<OptionKey, object> currentValues;
......@@ -50,10 +50,10 @@ internal class OptionService : IOptionService
{
foreach (var featureName in optionSerializerAndMetadata.Metadata.Features)
{
ImmutableList<Lazy<IOptionSerializer, OptionSerializerMetadata>> existingSerializers;
ImmutableArray<Lazy<IOptionSerializer, OptionSerializerMetadata>> existingSerializers;
if (!featureNameToOptionSerializers.TryGetValue(featureName, out existingSerializers))
{
existingSerializers = ImmutableList.Create<Lazy<IOptionSerializer, OptionSerializerMetadata>>();
existingSerializers = ImmutableArray.Create<Lazy<IOptionSerializer, OptionSerializerMetadata>>();
}
this.featureNameToOptionSerializers = this.featureNameToOptionSerializers.SetItem(featureName, existingSerializers.Add(optionSerializerAndMetadata));
......@@ -67,7 +67,7 @@ private object LoadOptionFromSerializerOrGetDefault(OptionKey optionKey)
{
lock (gate)
{
ImmutableList<Lazy<IOptionSerializer, OptionSerializerMetadata>> optionSerializers;
ImmutableArray<Lazy<IOptionSerializer, OptionSerializerMetadata>> optionSerializers;
if (featureNameToOptionSerializers.TryGetValue(optionKey.Option.Feature, out optionSerializers))
{
foreach (var serializer in optionSerializers)
......@@ -160,7 +160,7 @@ public void SetOptions(OptionSet optionSet)
currentValues = currentValues.SetItem(optionKey, setValue);
ImmutableList<Lazy<IOptionSerializer, OptionSerializerMetadata>> optionSerializers;
ImmutableArray<Lazy<IOptionSerializer, OptionSerializerMetadata>> optionSerializers;
if (featureNameToOptionSerializers.TryGetValue(optionKey.Option.Feature, out optionSerializers))
{
foreach (var serializer in optionSerializers)
......
......@@ -22,7 +22,7 @@ public void AddEventHandler<TEventHandler>(string eventName, TEventHandler event
using (this.guard.DisposableWait())
{
var handlers = GetEvents_NoLock<TEventHandler>(eventName);
var newHandlers = (handlers ?? ImmutableList.Create<TEventHandler>()).Add(eventHandler);
var newHandlers = handlers.Add(eventHandler);
SetEvents_NoLock(eventName, newHandlers);
}
}
......@@ -32,18 +32,15 @@ public void RemoveEventHandler<TEventHandler>(string eventName, TEventHandler ev
using (this.guard.DisposableWait())
{
var handlers = GetEvents_NoLock<TEventHandler>(eventName);
if (handlers != null)
var newHandlers = handlers.Remove(eventHandler);
if (newHandlers != handlers)
{
var newHandlers = handlers.Remove(eventHandler);
if (newHandlers != handlers)
{
SetEvents_NoLock(eventName, newHandlers);
}
SetEvents_NoLock(eventName, newHandlers);
}
}
}
public IEnumerable<TEventHandler> GetEventHandlers<TEventHandler>(string eventName)
public ImmutableArray<TEventHandler> GetEventHandlers<TEventHandler>(string eventName)
{
using (this.guard.DisposableWait())
{
......@@ -64,20 +61,20 @@ public void RaiseEvent<TEventArgs>(string eventName, object sender, TEventArgs a
}
}
private ImmutableList<TEventHandler> GetEvents_NoLock<TEventHandler>(string eventName)
private ImmutableArray<TEventHandler> GetEvents_NoLock<TEventHandler>(string eventName)
{
this.guard.AssertHasLock();
object handlers;
if (this.eventNameToHandlers.TryGetValue(eventName, out handlers))
{
return (ImmutableList<TEventHandler>)handlers;
return (ImmutableArray<TEventHandler>)handlers;
}
return null;
return ImmutableArray.Create<TEventHandler>();
}
private void SetEvents_NoLock<TEventHandler>(string name, ImmutableList<TEventHandler> events)
private void SetEvents_NoLock<TEventHandler>(string name, ImmutableArray<TEventHandler> events)
{
this.guard.AssertHasLock();
......
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Collections.Immutable;
namespace Roslyn.Utilities
{
internal static class ImmutableArrayExtensions
{
internal static ImmutableArray<T> ToImmutableArrayOrEmpty<T>(this T[] items)
{
if (items == null)
{
return ImmutableArray.Create<T>();
}
return ImmutableArray.Create<T>(items);
}
internal static ImmutableArray<T> ToImmutableArrayOrEmpty<T>(this IEnumerable<T> items)
{
if (items == null)
{
return ImmutableArray.Create<T>();
}
return ImmutableArray.CreateRange<T>(items);
}
internal static ImmutableArray<T> ToImmutableArrayOrEmpty<T>(this ImmutableArray<T> items)
{
if (items.IsDefault)
{
return ImmutableArray.Create<T>();
}
return items;
}
internal static IReadOnlyList<T> ToImmutableReadOnlyListOrEmpty<T>(this IEnumerable<T> items)
{
if (items is ImmutableArray<T> && !((ImmutableArray<T>)items).IsDefault)
{
return (IReadOnlyList<T>)items;
}
else
{
return items.ToImmutableArrayOrEmpty();
}
}
}
}
\ No newline at end of file
......@@ -148,11 +148,11 @@ private static IList<string> GetFolders(string path)
var directory = Path.GetDirectoryName(path);
if (string.IsNullOrEmpty(directory))
{
return ImmutableList.Create<string>();
return ImmutableArray.Create<string>();
}
else
{
return directory.Split(folderSplitters, StringSplitOptions.RemoveEmptyEntries).ToImmutableList();
return directory.Split(folderSplitters, StringSplitOptions.RemoveEmptyEntries).ToImmutableArray();
}
}
......
......@@ -61,16 +61,16 @@ protected internal override HostWorkspaceServices CreateWorkspaceServices(Worksp
return new MefWorkspaceServices(this, workspace);
}
private ImmutableList<string> languages;
private IEnumerable<string> languages;
private ImmutableList<string> GetSupportedLanguages()
private IEnumerable<string> GetSupportedLanguages()
{
if (this.languages == null)
{
var list = this.GetExports<ILanguageService, LanguageServiceMetadata>().Select(lz => lz.Metadata.Language).Concat(
this.GetExports<ILanguageServiceFactory, LanguageServiceMetadata>().Select(lz => lz.Metadata.Language))
.Distinct()
.ToImmutableList();
.ToImmutableArray();
Interlocked.CompareExchange(ref this.languages, list, null);
}
......@@ -212,8 +212,8 @@ private class MefLanguageServices : HostLanguageServices
{
private readonly MefWorkspaceServices workspaceServices;
private readonly string language;
private readonly ImmutableList<Lazy<ILanguageService, LanguageServiceMetadata>> services;
private readonly ImmutableList<Lazy<ILanguageServiceFactory, LanguageServiceMetadata>> factories;
private readonly ImmutableArray<Lazy<ILanguageService, LanguageServiceMetadata>> services;
private readonly ImmutableArray<Lazy<ILanguageServiceFactory, LanguageServiceMetadata>> factories;
private ImmutableDictionary<string, ILanguageService> serviceMap = ImmutableDictionary<string, ILanguageService>.Empty;
......@@ -224,8 +224,8 @@ private class MefLanguageServices : HostLanguageServices
this.workspaceServices = workspaceServices;
this.language = language;
var hostServices = (MefHostServices)workspaceServices.HostServices;
this.services = hostServices.GetExports<ILanguageService, LanguageServiceMetadata>().Where(lz => lz.Metadata.Language == language).ToImmutableList();
this.factories = hostServices.GetExports<ILanguageServiceFactory, LanguageServiceMetadata>().Where(lz => lz.Metadata.Language == language).ToImmutableList();
this.services = hostServices.GetExports<ILanguageService, LanguageServiceMetadata>().Where(lz => lz.Metadata.Language == language).ToImmutableArray();
this.factories = hostServices.GetExports<ILanguageServiceFactory, LanguageServiceMetadata>().Where(lz => lz.Metadata.Language == language).ToImmutableArray();
}
public override HostWorkspaceServices WorkspaceServices
......@@ -240,7 +240,7 @@ public override string Language
public bool HasServices
{
get { return this.services.Count > 0 || this.factories.Count > 0; }
get { return this.services.Length > 0 || this.factories.Length > 0; }
}
public override TLanguageService GetService<TLanguageService>()
......@@ -323,7 +323,7 @@ private ILanguageService PickLanguageService(IEnumerable<KeyValuePair<string, Fu
if (!this.exportsMap.TryGetValue(key, out exports))
{
exports = ImmutableInterlocked.GetOrAdd(ref this.exportsMap, key, _ =>
this.exportProvider.GetExports<TExtension, TMetadata>().ToImmutableList());
this.exportProvider.GetExports<TExtension, TMetadata>().ToImmutableArray());
}
return (IEnumerable<Lazy<TExtension, TMetadata>>)exports;
......@@ -339,7 +339,7 @@ public IEnumerable<Lazy<TExtension>> GetExports<TExtension>()
if (!this.exportsMap.TryGetValue(key, out exports))
{
exports = ImmutableInterlocked.GetOrAdd(ref this.exportsMap, key, _ =>
this.exportProvider.GetExports<TExtension>().ToImmutableList());
this.exportProvider.GetExports<TExtension>().ToImmutableArray());
}
return (IEnumerable<Lazy<TExtension>>)exports;
......@@ -393,21 +393,21 @@ public static MefHostServices DefaultHost
}
}
private static ImmutableList<Assembly> defaultAssemblies;
public static ImmutableList<Assembly> DefaultAssemblies
private static ImmutableArray<Assembly> defaultAssemblies;
public static ImmutableArray<Assembly> DefaultAssemblies
{
get
{
if (defaultAssemblies == null)
if (defaultAssemblies.IsDefault)
{
Interlocked.CompareExchange(ref defaultAssemblies, LoadDefaultAssemblies(), null);
ImmutableInterlocked.InterlockedInitialize(ref defaultAssemblies, LoadDefaultAssemblies());
}
return defaultAssemblies;
}
}
private static ImmutableList<Assembly> LoadDefaultAssemblies()
private static ImmutableArray<Assembly> LoadDefaultAssemblies()
{
// build a MEF composition using this assembly and the known VisualBasic/CSharp workspace assemblies.
var assemblies = new List<Assembly>();
......@@ -425,7 +425,7 @@ private static ImmutableList<Assembly> LoadDefaultAssemblies()
LoadAssembly(assemblies,
string.Format("Microsoft.CodeAnalysis.VisualBasic.Workspaces, Version={0}, Culture=neutral, PublicKeyToken={1}", assemblyVersion, publicKeyToken));
return assemblies.ToImmutableList();
return assemblies.ToImmutableArray();
}
private static void LoadAssembly(List<Assembly> assemblies, string assemblyName)
......
......@@ -398,7 +398,7 @@ private async Task<ProjectId> LoadProjectAsync(string projectFilePath, IProjectF
}
// Documents
var docFileInfos = projectFileInfo.Documents.ToImmutableListOrEmpty();
var docFileInfos = projectFileInfo.Documents.ToImmutableArrayOrEmpty();
CheckDocuments(docFileInfos, projectFilePath, projectId);
var docs = new List<DocumentInfo>();
......@@ -449,9 +449,9 @@ private async Task<ProjectId> LoadProjectAsync(string projectFilePath, IProjectF
outputFilePath,
projectFileInfo.CompilationOptions,
projectFileInfo.ParseOptions,
docs.ToImmutableListOrEmpty(),
resolvedReferences.ProjectReferences.ToImmutableListOrEmpty(),
metadataReferences.ToImmutableListOrEmpty(),
docs,
resolvedReferences.ProjectReferences,
metadataReferences,
analyzerReferences: projectFileInfo.AnalyzerReferences,
isSubmission: false,
hostObjectType: null));
......@@ -468,16 +468,16 @@ private async Task<ProjectId> LoadProjectAsync(string projectFilePath, IProjectF
private static readonly char[] DirectorySplitChars = new char[] { Path.DirectorySeparatorChar };
private static ImmutableList<string> GetDocumentFolders(string logicalPath)
private static ImmutableArray<string> GetDocumentFolders(string logicalPath)
{
var logicalDirectory = Path.GetDirectoryName(logicalPath);
if (!string.IsNullOrEmpty(logicalDirectory))
{
return logicalDirectory.Split(DirectorySplitChars, StringSplitOptions.None).ToImmutableList();
return logicalDirectory.Split(DirectorySplitChars, StringSplitOptions.None).ToImmutableArray();
}
return ImmutableList.Create<string>();
return ImmutableArray.Create<string>();
}
private void CheckDocuments(IEnumerable<DocumentFileInfo> docs, string projectFilePath, ProjectId projectId)
......
......@@ -79,10 +79,10 @@ internal sealed class ProjectFileInfo
this.AssemblyName = assemblyName;
this.CompilationOptions = compilationOptions;
this.ParseOptions = parseOptions;
this.Documents = documents.ToImmutableListOrEmpty();
this.ProjectReferences = projectReferences.ToImmutableListOrEmpty();
this.MetadataReferences = metadataReferences.ToImmutableListOrEmpty();
this.AnalyzerReferences = analyzerReferences.ToImmutableListOrEmpty();
this.Documents = documents.ToImmutableReadOnlyListOrEmpty();
this.ProjectReferences = projectReferences.ToImmutableReadOnlyListOrEmpty();
this.MetadataReferences = metadataReferences.ToImmutableReadOnlyListOrEmpty();
this.AnalyzerReferences = analyzerReferences.ToImmutableReadOnlyListOrEmpty();
this.AppConfigPath = appConfigPath;
}
}
......
......@@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using System.Threading;
......
......@@ -76,7 +76,7 @@ public sealed class DocumentInfo
this.Id = id;
this.Name = name;
this.Folders = folders.ToImmutableListOrEmpty();
this.Folders = folders.ToImmutableReadOnlyListOrEmpty();
this.SourceCodeKind = sourceCodeKind;
this.TextLoader = loader;
this.FilePath = filePath;
......@@ -97,7 +97,7 @@ public sealed class DocumentInfo
private DocumentInfo With(
DocumentId id = null,
string name = null,
Optional<IEnumerable<string>> folders = default(Optional<IEnumerable<string>>),
IEnumerable<string> folders = null,
Optional<SourceCodeKind> sourceCodeKind = default(Optional<SourceCodeKind>),
Optional<TextAndVersion> textAndVersion = default(Optional<TextAndVersion>),
Optional<TextLoader> loader = default(Optional<TextLoader>),
......@@ -105,7 +105,7 @@ public sealed class DocumentInfo
{
var newId = id ?? this.Id;
var newName = name ?? this.Name;
var newFolders = folders.HasValue ? folders.Value : this.Folders;
var newFolders = folders ?? this.Folders;
var newSourceCodeKind = sourceCodeKind.HasValue ? sourceCodeKind.Value : this.SourceCodeKind;
var newLoader = loader.HasValue ? loader.Value : this.TextLoader;
var newFilePath = filePath.HasValue ? filePath.Value : this.FilePath;
......@@ -125,7 +125,7 @@ public sealed class DocumentInfo
public DocumentInfo WithFolders(IEnumerable<string> folders)
{
return this.With(folders: new Optional<IEnumerable<string>>(folders));
return this.With(folders: folders.ToImmutableReadOnlyListOrEmpty());
}
public DocumentInfo WithSourceCodeKind(SourceCodeKind kind)
......
......@@ -292,7 +292,7 @@ public DocumentState UpdateFolders(IList<string> folders)
return new DocumentState(
this.languageServices,
this.solutionServices,
this.info.WithFolders(folders.ToImmutableListOrEmpty()),
this.info.WithFolders(folders),
this.options,
this.textSource,
this.treeSource);
......
......@@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using System.Threading;
......
......@@ -16,7 +16,7 @@ namespace Microsoft.CodeAnalysis
/// </summary>
public class ProjectDependencyGraph
{
private readonly ImmutableList<ProjectId> projectIds;
private readonly ImmutableArray<ProjectId> projectIds;
private readonly ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> referencesMap;
// guards lazy computed data
......@@ -24,19 +24,19 @@ public class ProjectDependencyGraph
// these are computed fully on demand
private ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> lazyReverseReferencesMap;
private ImmutableList<ProjectId> lazyTopologicallySortedProjects;
private ImmutableList<IEnumerable<ProjectId>> lazyDependencySets;
private ImmutableArray<ProjectId> lazyTopologicallySortedProjects;
private ImmutableArray<IEnumerable<ProjectId>> lazyDependencySets;
// these accumulate results on demand
private ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> transitiveReferencesMap = ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>>.Empty;
private ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> reverseTransitiveReferencesMap = ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>>.Empty;
internal static readonly ProjectDependencyGraph Empty = new ProjectDependencyGraph(
ImmutableList<ProjectId>.Empty,
ImmutableArray.Create<ProjectId>(),
ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>>.Empty);
internal ProjectDependencyGraph(
ImmutableList<ProjectId> projectIds,
ImmutableArray<ProjectId> projectIds,
ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> referencesMap)
{
this.projectIds = projectIds;
......@@ -270,7 +270,7 @@ private IEnumerable<ProjectId> GetTopologicallySortedProjects_NoLock(Cancellatio
using (var resultList = SharedPools.Default<List<ProjectId>>().GetPooledObject())
{
this.TopologicalSort(this.projectIds, cancellationToken, seenProjects.Object, resultList.Object);
this.lazyTopologicallySortedProjects = resultList.Object.ToImmutableList();
this.lazyTopologicallySortedProjects = resultList.Object.ToImmutableArray();
}
}
......@@ -327,7 +327,7 @@ private IEnumerable<IEnumerable<ProjectId>> GetDependencySets_NoLock(Cancellatio
using (var results = SharedPools.Default<List<IEnumerable<ProjectId>>>().GetPooledObject())
{
this.ComputeDependencySets(seenProjects.Object, results.Object, cancellationToken);
this.lazyDependencySets = results.Object.ToImmutableList();
this.lazyDependencySets = results.Object.ToImmutableArray();
}
}
......@@ -354,7 +354,7 @@ private void ComputeDependencySets(HashSet<ProjectId> seenProjects, List<IEnumer
using (var sortedProjects = SharedPools.Default<List<ProjectId>>().GetPooledObject())
{
this.TopologicalSort(dependencySet.Object, cancellationToken, topologicallySeenProjects.Object, sortedProjects.Object);
results.Add(sortedProjects.Object.ToImmutableList());
results.Add(sortedProjects.Object.ToImmutableArrayOrEmpty());
}
}
}
......
......@@ -135,10 +135,10 @@ public sealed class ProjectInfo
this.OutputFilePath = outputFilePath;
this.CompilationOptions = compilationOptions;
this.ParseOptions = parseOptions;
this.Documents = documents.ToImmutableListOrEmpty();
this.ProjectReferences = projectReferences.ToImmutableListOrEmpty();
this.MetadataReferences = metadataReferences.ToImmutableListOrEmpty();
this.AnalyzerReferences = analyzerReferences.ToImmutableListOrEmpty();
this.Documents = documents.ToImmutableReadOnlyListOrEmpty();
this.ProjectReferences = projectReferences.ToImmutableReadOnlyListOrEmpty();
this.MetadataReferences = metadataReferences.ToImmutableReadOnlyListOrEmpty();
this.AnalyzerReferences = analyzerReferences.ToImmutableReadOnlyListOrEmpty();
this.IsSubmission = isSubmission;
this.HostObjectType = hostObjectType;
}
......@@ -253,7 +253,7 @@ public sealed class ProjectInfo
public ProjectInfo WithDocuments(IEnumerable<DocumentInfo> documents)
{
return this.With(documents: documents);
return this.With(documents: documents.ToImmutableReadOnlyListOrEmpty());
}
public ProjectInfo WithVersion(VersionStamp version)
......@@ -283,17 +283,17 @@ public ProjectInfo WithParseOptions(ParseOptions parseOptions)
public ProjectInfo WithProjectReferences(IEnumerable<ProjectReference> projectReferences)
{
return this.With(projectReferences: projectReferences);
return this.With(projectReferences: projectReferences.ToImmutableReadOnlyListOrEmpty());
}
public ProjectInfo WithMetadataReferences(IEnumerable<MetadataReference> metadataReferences)
{
return this.With(metadataReferences: metadataReferences);
return this.With(metadataReferences: metadataReferences.ToImmutableReadOnlyListOrEmpty());
}
public ProjectInfo WithAnalyzerReferences(IEnumerable<AnalyzerReference> analyzerReferences)
{
return this.With(analyzerReferences: analyzerReferences);
return this.With(analyzerReferences: analyzerReferences.ToImmutableReadOnlyListOrEmpty());
}
}
}
\ No newline at end of file
......@@ -20,7 +20,7 @@ internal partial class ProjectState
private readonly HostLanguageServices languageServices;
private readonly SolutionServices solutionServices;
private readonly ImmutableDictionary<DocumentId, DocumentState> documentStates;
private readonly ImmutableList<DocumentId> documentIds;
private readonly IReadOnlyList<DocumentId> documentIds;
private readonly AsyncLazy<VersionStamp> lazyLatestDocumentVersion;
private readonly AsyncLazy<VersionStamp> lazyLatestDocumentTopLevelChangeVersion;
......@@ -28,7 +28,7 @@ internal partial class ProjectState
ProjectInfo projectInfo,
HostLanguageServices languageServices,
SolutionServices solutionServices,
ImmutableList<DocumentId> documentIds,
IEnumerable<DocumentId> documentIds,
ImmutableDictionary<DocumentId, DocumentState> documentStates,
AsyncLazy<VersionStamp> lazyLatestDocumentVersion,
AsyncLazy<VersionStamp> lazyLatestDocumentTopLevelChangeVersion)
......@@ -36,7 +36,7 @@ internal partial class ProjectState
this.projectInfo = projectInfo;
this.solutionServices = solutionServices;
this.languageServices = languageServices;
this.documentIds = documentIds;
this.documentIds = documentIds.ToImmutableReadOnlyListOrEmpty();
this.documentStates = documentStates;
this.lazyLatestDocumentVersion = lazyLatestDocumentVersion;
this.lazyLatestDocumentTopLevelChangeVersion = lazyLatestDocumentTopLevelChangeVersion;
......@@ -53,7 +53,7 @@ internal ProjectState(ProjectInfo projectInfo, HostLanguageServices languageServ
this.projectInfo = FixProjectInfo(projectInfo);
this.documentIds = this.projectInfo.Documents.Select(d => d.Id).ToImmutableList();
this.documentIds = this.projectInfo.Documents.Select(d => d.Id).ToImmutableArray();
var docStates = ImmutableDictionary.CreateRange<DocumentId, DocumentState>(
this.projectInfo.Documents.Select(d =>
......@@ -235,21 +235,21 @@ public ParseOptions ParseOptions
}
[DebuggerBrowsable(DebuggerBrowsableState.Collapsed)]
public ImmutableList<MetadataReference> MetadataReferences
public IReadOnlyList<MetadataReference> MetadataReferences
{
get { return (ImmutableList<MetadataReference>)this.ProjectInfo.MetadataReferences; }
get { return this.ProjectInfo.MetadataReferences; }
}
[DebuggerBrowsable(DebuggerBrowsableState.Collapsed)]
public ImmutableList<AnalyzerReference> AnalyzerReferences
public IReadOnlyList<AnalyzerReference> AnalyzerReferences
{
get { return (ImmutableList<AnalyzerReference>)this.ProjectInfo.AnalyzerReferences; }
get { return this.ProjectInfo.AnalyzerReferences; }
}
[DebuggerBrowsable(DebuggerBrowsableState.Collapsed)]
public ImmutableList<ProjectReference> ProjectReferences
public IReadOnlyList<ProjectReference> ProjectReferences
{
get { return (ImmutableList<ProjectReference>)this.ProjectInfo.ProjectReferences; }
get { return this.ProjectInfo.ProjectReferences; }
}
[DebuggerBrowsable(DebuggerBrowsableState.Collapsed)]
......@@ -265,7 +265,7 @@ public IEnumerable<DocumentState> OrderedDocumentStates
}
[DebuggerBrowsable(DebuggerBrowsableState.Collapsed)]
public ImmutableList<DocumentId> DocumentIds
public IReadOnlyList<DocumentId> DocumentIds
{
get { return this.documentIds; }
}
......@@ -290,7 +290,7 @@ public DocumentState GetDocumentState(DocumentId documentId)
private ProjectState With(
ProjectInfo projectInfo = null,
ImmutableList<DocumentId> documentIds = null,
ImmutableArray<DocumentId> documentIds = default(ImmutableArray<DocumentId>),
ImmutableDictionary<DocumentId, DocumentState> documentStates = null,
AsyncLazy<VersionStamp> latestDocumentVersion = null,
AsyncLazy<VersionStamp> latestDocumentTopLevelChangeVersion = null)
......@@ -299,7 +299,7 @@ public DocumentState GetDocumentState(DocumentId documentId)
projectInfo ?? this.projectInfo,
this.languageServices,
this.solutionServices,
documentIds ?? this.documentIds,
documentIds.IsDefault ? this.documentIds : documentIds,
documentStates ?? this.documentStates,
latestDocumentVersion ?? this.lazyLatestDocumentVersion,
latestDocumentTopLevelChangeVersion ?? this.lazyLatestDocumentTopLevelChangeVersion);
......@@ -367,7 +367,7 @@ public ProjectState AddProjectReference(ProjectReference projectReference)
Contract.Requires(!this.ProjectReferences.Contains(projectReference));
return this.With(
projectInfo: this.ProjectInfo.WithProjectReferences(this.ProjectReferences.Add(projectReference)).WithVersion(this.Version.GetNewerVersion()));
projectInfo: this.ProjectInfo.WithProjectReferences(this.ProjectReferences.ToImmutableArray().Add(projectReference)).WithVersion(this.Version.GetNewerVersion()));
}
public ProjectState RemoveProjectReference(ProjectReference projectReference)
......@@ -375,7 +375,7 @@ public ProjectState RemoveProjectReference(ProjectReference projectReference)
Contract.Requires(this.ProjectReferences.Contains(projectReference));
return this.With(
projectInfo: this.ProjectInfo.WithProjectReferences(this.ProjectReferences.Remove(projectReference)).WithVersion(this.Version.GetNewerVersion()));
projectInfo: this.ProjectInfo.WithProjectReferences(this.ProjectReferences.ToImmutableArray().Remove(projectReference)).WithVersion(this.Version.GetNewerVersion()));
}
public ProjectState AddProjectReferences(IEnumerable<ProjectReference> projectReferences)
......@@ -384,7 +384,7 @@ public ProjectState AddProjectReferences(IEnumerable<ProjectReference> projectRe
foreach (var projectReference in projectReferences)
{
Contract.Requires(!newProjectRefs.Contains(projectReference));
newProjectRefs = newProjectRefs.Add(projectReference);
newProjectRefs = newProjectRefs.ToImmutableArray().Add(projectReference);
}
return this.With(
......@@ -394,7 +394,7 @@ public ProjectState AddProjectReferences(IEnumerable<ProjectReference> projectRe
public ProjectState WithProjectReferences(IEnumerable<ProjectReference> projectReferences)
{
return this.With(
projectInfo: this.ProjectInfo.WithProjectReferences(projectReferences.ToImmutableListOrEmpty()).WithVersion(this.Version.GetNewerVersion()));
projectInfo: this.ProjectInfo.WithProjectReferences(projectReferences).WithVersion(this.Version.GetNewerVersion()));
}
public ProjectState AddMetadataReference(MetadataReference toMetadata)
......@@ -402,7 +402,7 @@ public ProjectState AddMetadataReference(MetadataReference toMetadata)
Contract.Requires(!this.MetadataReferences.Contains(toMetadata));
return this.With(
projectInfo: this.ProjectInfo.WithMetadataReferences(this.MetadataReferences.Add(toMetadata)).WithVersion(this.Version.GetNewerVersion()));
projectInfo: this.ProjectInfo.WithMetadataReferences(this.MetadataReferences.ToImmutableArray().Add(toMetadata)).WithVersion(this.Version.GetNewerVersion()));
}
public ProjectState RemoveMetadataReference(MetadataReference toMetadata)
......@@ -410,7 +410,7 @@ public ProjectState RemoveMetadataReference(MetadataReference toMetadata)
Contract.Requires(this.MetadataReferences.Contains(toMetadata));
return this.With(
projectInfo: this.ProjectInfo.WithMetadataReferences(this.MetadataReferences.Remove(toMetadata)).WithVersion(this.Version.GetNewerVersion()));
projectInfo: this.ProjectInfo.WithMetadataReferences(this.MetadataReferences.ToImmutableArray().Remove(toMetadata)).WithVersion(this.Version.GetNewerVersion()));
}
public ProjectState AddMetadataReferences(IEnumerable<MetadataReference> metadataReferences)
......@@ -419,7 +419,7 @@ public ProjectState AddMetadataReferences(IEnumerable<MetadataReference> metadat
foreach (var metadataReference in metadataReferences)
{
Contract.Requires(!newMetaRefs.Contains(metadataReference));
newMetaRefs = newMetaRefs.Add(metadataReference);
newMetaRefs = newMetaRefs.ToImmutableArray().Add(metadataReference);
}
return this.With(
......@@ -429,7 +429,7 @@ public ProjectState AddMetadataReferences(IEnumerable<MetadataReference> metadat
public ProjectState WithMetadataReferences(IEnumerable<MetadataReference> metadataReferences)
{
return this.With(
projectInfo: this.ProjectInfo.WithMetadataReferences(metadataReferences.ToImmutableListOrEmpty()).WithVersion(this.Version.GetNewerVersion()));
projectInfo: this.ProjectInfo.WithMetadataReferences(metadataReferences).WithVersion(this.Version.GetNewerVersion()));
}
public ProjectState AddAnalyzerReference(AnalyzerReference analyzerReference)
......@@ -437,7 +437,7 @@ public ProjectState AddAnalyzerReference(AnalyzerReference analyzerReference)
Contract.Requires(!this.AnalyzerReferences.Contains(analyzerReference));
return this.With(
projectInfo: this.ProjectInfo.WithAnalyzerReferences(this.AnalyzerReferences.Add(analyzerReference)).WithVersion(this.Version.GetNewerVersion()));
projectInfo: this.ProjectInfo.WithAnalyzerReferences(this.AnalyzerReferences.ToImmutableArray().Add(analyzerReference)).WithVersion(this.Version.GetNewerVersion()));
}
public ProjectState RemoveAnalyzerReference(AnalyzerReference analyzerReference)
......@@ -445,7 +445,7 @@ public ProjectState RemoveAnalyzerReference(AnalyzerReference analyzerReference)
Contract.Requires(this.AnalyzerReferences.Contains(analyzerReference));
return this.With(
projectInfo: this.ProjectInfo.WithAnalyzerReferences(this.AnalyzerReferences.Remove(analyzerReference)).WithVersion(this.Version.GetNewerVersion()));
projectInfo: this.ProjectInfo.WithAnalyzerReferences(this.AnalyzerReferences.ToImmutableArray().Remove(analyzerReference)).WithVersion(this.Version.GetNewerVersion()));
}
public ProjectState AddAnalyzerReferences(IEnumerable<AnalyzerReference> analyzerReferences)
......@@ -454,7 +454,7 @@ public ProjectState AddAnalyzerReferences(IEnumerable<AnalyzerReference> analyze
foreach (var analyzerReference in analyzerReferences)
{
Contract.Requires(!newAnalyzerReferences.Contains(analyzerReference));
newAnalyzerReferences = newAnalyzerReferences.Add(analyzerReference);
newAnalyzerReferences = newAnalyzerReferences.ToImmutableArray().Add(analyzerReference);
}
return this.With(
......@@ -464,7 +464,7 @@ public ProjectState AddAnalyzerReferences(IEnumerable<AnalyzerReference> analyze
public ProjectState WithAnalyzerReferences(IEnumerable<AnalyzerReference> analyzerReferences)
{
return this.With(
projectInfo: this.ProjectInfo.WithAnalyzerReferences(analyzerReferences.ToImmutableListOrEmpty()).WithVersion(this.Version.GetNewerVersion()));
projectInfo: this.ProjectInfo.WithAnalyzerReferences(analyzerReferences).WithVersion(this.Version.GetNewerVersion()));
}
public ProjectState AddDocument(DocumentState document)
......@@ -473,7 +473,7 @@ public ProjectState AddDocument(DocumentState document)
return this.With(
projectInfo: this.ProjectInfo.WithVersion(this.Version.GetNewerVersion()).WithDocuments(this.ProjectInfo.Documents.Concat(document.Info)),
documentIds: this.DocumentIds.Add(document.Id),
documentIds: this.DocumentIds.ToImmutableArray().Add(document.Id),
documentStates: this.DocumentStates.Add(document.Id, document));
}
......@@ -483,7 +483,7 @@ public ProjectState RemoveDocument(DocumentId documentId)
return this.With(
projectInfo: this.ProjectInfo.WithVersion(this.Version.GetNewerVersion()).WithDocuments(this.ProjectInfo.Documents.Where(info => info.Id != documentId)),
documentIds: this.DocumentIds.Remove(documentId),
documentIds: this.DocumentIds.ToImmutableArray().Remove(documentId),
documentStates: this.DocumentStates.Remove(documentId));
}
......@@ -491,7 +491,7 @@ public ProjectState RemoveAllDocuments()
{
return this.With(
projectInfo: this.ProjectInfo.WithVersion(this.Version.GetNewerVersion()).WithDocuments(SpecializedCollections.EmptyEnumerable<DocumentInfo>()),
documentIds: ImmutableList<DocumentId>.Empty,
documentIds: ImmutableArray.Create<DocumentId>(),
documentStates: ImmutableDictionary<DocumentId, DocumentState>.Empty);
}
......
......@@ -58,15 +58,15 @@ protected State(ValueSource<Compilation> compilation, Compilation declarationOnl
public static State Create(
ValueSource<Compilation> compilationSource,
ImmutableList<ValueTuple<ProjectState, CompilationTranslationAction>> intermediateProjects)
ImmutableArray<ValueTuple<ProjectState, CompilationTranslationAction>> intermediateProjects)
{
Contract.ThrowIfNull(compilationSource);
Contract.ThrowIfNull(compilationSource.GetValue());
Contract.ThrowIfNull(intermediateProjects);
Contract.ThrowIfTrue(intermediateProjects.IsDefault);
// If we don't have any intermediate projects to process, just initialize our
// DeclarationState now.
return intermediateProjects.Count == 0
return intermediateProjects.Length == 0
? (State)new FullDeclarationState(compilationSource)
: (State)new InProgressState(compilationSource, intermediateProjects);
}
......@@ -76,17 +76,17 @@ protected State(ValueSource<Compilation> compilation, Compilation declarationOnl
// DeclarationCompilation from by iteratively processing IntermediateProjects
private sealed class InProgressState : State
{
public ImmutableList<ValueTuple<ProjectState, CompilationTranslationAction>> IntermediateProjects { get; private set; }
public ImmutableArray<ValueTuple<ProjectState, CompilationTranslationAction>> IntermediateProjects { get; private set; }
public InProgressState(
ValueSource<Compilation> inProgressCompilationSource,
ImmutableList<ValueTuple<ProjectState, CompilationTranslationAction>> intermediateProjects)
ImmutableArray<ValueTuple<ProjectState, CompilationTranslationAction>> intermediateProjects)
: base(inProgressCompilationSource)
{
Contract.ThrowIfNull(inProgressCompilationSource);
Contract.ThrowIfNull(inProgressCompilationSource.GetValue());
Contract.ThrowIfNull(intermediateProjects);
Contract.ThrowIfFalse(intermediateProjects.Count > 0);
Contract.ThrowIfTrue(intermediateProjects.IsDefault);
Contract.ThrowIfFalse(intermediateProjects.Length > 0);
this.IntermediateProjects = intermediateProjects;
}
......
......@@ -111,7 +111,7 @@ public bool HasCompilation
var intermediateProjects = state is InProgressState
? ((InProgressState)state).IntermediateProjects
: ImmutableList.Create<ValueTuple<ProjectState, CompilationTranslationAction>>();
: ImmutableArray.Create<ValueTuple<ProjectState, CompilationTranslationAction>>();
var newIntermediateProjects = translate == null
? intermediateProjects
......@@ -132,7 +132,7 @@ public bool HasCompilation
: (ValueSource<Compilation>)new ConstantValueSource<Compilation>(declarationOnlyCompilation);
var intermediateProjects =
ImmutableList.Create<ValueTuple<ProjectState, CompilationTranslationAction>>(ValueTuple.Create(this.ProjectState, translate));
ImmutableArray.Create<ValueTuple<ProjectState, CompilationTranslationAction>>(ValueTuple.Create(this.ProjectState, translate));
return new CompilationTracker(newProject, new InProgressState(compilationSource, intermediateProjects));
}
......@@ -231,7 +231,7 @@ public CompilationTracker FreezePartialStateWithTree(Solution solution, Document
}
// first remove all project from the project and compilation.
inProgressProject = inProgressProject.WithProjectReferences(ImmutableList.Create<ProjectReference>());
inProgressProject = inProgressProject.WithProjectReferences(ImmutableArray.Create<ProjectReference>());
// Now add in back a consistent set of project references. For project references
// try to get either a CompilationReference or a SkeletonReference. This ensures
......@@ -501,7 +501,7 @@ private Compilation CreateEmptyCompilation(Solution solution)
Contract.Requires(inProgressCompilation != null);
var intermediateProjects = state.IntermediateProjects;
while (intermediateProjects.Count > 0)
while (intermediateProjects.Length > 0)
{
cancellationToken.ThrowIfCancellationRequested();
......
......@@ -32,9 +32,9 @@ public partial class Solution
private readonly SolutionServices solutionServices;
private readonly SolutionId id;
private readonly string filePath;
private readonly ImmutableList<ProjectId> projectIds;
private readonly IReadOnlyList<ProjectId> projectIds;
private readonly ImmutableDictionary<ProjectId, ProjectState> projectIdToProjectStateMap;
private readonly ImmutableDictionary<string, ImmutableList<DocumentId>> linkedFilesMap;
private readonly ImmutableDictionary<string, ImmutableArray<DocumentId>> linkedFilesMap;
private readonly VersionStamp version;
private readonly Lazy<VersionStamp> lazyLatestProjectVersion;
private readonly ProjectDependencyGraph dependencyGraph;
......@@ -49,10 +49,10 @@ public partial class Solution
SolutionServices solutionServices,
SolutionId id,
string filePath,
ImmutableList<ProjectId> projectIds,
IEnumerable<ProjectId> projectIds,
ImmutableDictionary<ProjectId, ProjectState> idToProjectStateMap,
ImmutableDictionary<ProjectId, CompilationTracker> projectIdToTrackerMap,
ImmutableDictionary<string, ImmutableList<DocumentId>> linkedFilesMap,
ImmutableDictionary<string, ImmutableArray<DocumentId>> linkedFilesMap,
ProjectDependencyGraph dependencyGraph,
VersionStamp version,
Lazy<VersionStamp> lazyLatestProjectVersion)
......@@ -62,7 +62,7 @@ public partial class Solution
this.id = id;
this.filePath = filePath;
this.solutionServices = solutionServices;
this.projectIds = projectIds;
this.projectIds = projectIds.ToImmutableReadOnlyListOrEmpty();
this.projectIdToProjectStateMap = idToProjectStateMap;
this.projectIdToTrackerMap = projectIdToTrackerMap;
this.linkedFilesMap = linkedFilesMap;
......@@ -84,10 +84,10 @@ public partial class Solution
id: info.Id,
filePath: info.FilePath,
version: info.Version,
projectIds: ImmutableList.Create<ProjectId>(),
projectIds: null,
idToProjectStateMap: ImmutableDictionary<ProjectId, ProjectState>.Empty,
projectIdToTrackerMap: ImmutableDictionary<ProjectId, CompilationTracker>.Empty,
linkedFilesMap: ImmutableDictionary.Create<string, ImmutableList<DocumentId>>(StringComparer.OrdinalIgnoreCase),
linkedFilesMap: ImmutableDictionary.Create<string, ImmutableArray<DocumentId>>(StringComparer.OrdinalIgnoreCase),
dependencyGraph: ProjectDependencyGraph.Empty,
lazyLatestProjectVersion: null)
{
......@@ -202,10 +202,10 @@ private void CheckInvariants()
}
private Solution Branch(
ImmutableList<ProjectId> projectIds = null,
IEnumerable<ProjectId> projectIds = null,
ImmutableDictionary<ProjectId, ProjectState> idToProjectStateMap = null,
ImmutableDictionary<ProjectId, CompilationTracker> projectIdToTrackerMap = null,
ImmutableDictionary<string, ImmutableList<DocumentId>> linkedFilesMap = null,
ImmutableDictionary<string, ImmutableArray<DocumentId>> linkedFilesMap = null,
ProjectDependencyGraph dependencyGraph = null,
VersionStamp? version = default(VersionStamp?),
Lazy<VersionStamp> lazyLatestProjectVersion = null)
......@@ -502,7 +502,7 @@ private CompilationTracker GetCompilationTracker(ProjectId projectId)
private Solution AddProject(ProjectId projectId, ProjectState projectState)
{
var newProjectIds = this.projectIds.Add(projectId);
var newProjectIds = this.projectIds.ToImmutableArray().Add(projectId);
var newStateMap = this.projectIdToProjectStateMap.Add(projectId, projectState);
var newDependencyGraph = CreateDependencyGraph(newProjectIds, newStateMap);
var newTrackerMap = CreateCompilationTrackerMap(projectId, newDependencyGraph);
......@@ -573,12 +573,12 @@ public Solution AddProject(ProjectInfo projectInfo)
return this.AddProject(newProject.Id, newProject);
}
private ImmutableDictionary<string, ImmutableList<DocumentId>> CreateLinkedFilesMapWithAddedProject(ProjectState projectState)
private ImmutableDictionary<string, ImmutableArray<DocumentId>> CreateLinkedFilesMapWithAddedProject(ProjectState projectState)
{
return CreateLinkedFilesMapWithAddedDocuments(projectState, projectState.DocumentIds);
}
private ImmutableDictionary<string, ImmutableList<DocumentId>> CreateLinkedFilesMapWithAddedDocuments(ProjectState projectState, ImmutableList<DocumentId> documentIds)
private ImmutableDictionary<string, ImmutableArray<DocumentId>> CreateLinkedFilesMapWithAddedDocuments(ProjectState projectState, IReadOnlyList<DocumentId> documentIds)
{
var builder = this.linkedFilesMap.ToBuilder();
......@@ -591,10 +591,10 @@ public Solution AddProject(ProjectInfo projectInfo)
continue;
}
ImmutableList<DocumentId> documentIdsWithPath;
ImmutableArray<DocumentId> documentIdsWithPath;
builder[filePath] = builder.TryGetValue(filePath, out documentIdsWithPath)
? documentIdsWithPath.Add(documentId)
: ImmutableList.Create(documentId);
: ImmutableArray.Create(documentId);
}
return builder.ToImmutable();
......@@ -612,7 +612,7 @@ public Solution RemoveProject(ProjectId projectId)
CheckContainsProject(projectId);
var newProjectIds = this.projectIds.Remove(projectId);
var newProjectIds = this.projectIds.ToImmutableArray().Remove(projectId);
var newStateMap = this.projectIdToProjectStateMap.Remove(projectId);
var newDependencyGraph = CreateDependencyGraph(newProjectIds, newStateMap);
var newTrackerMap = CreateCompilationTrackerMap(projectId, newDependencyGraph);
......@@ -627,14 +627,14 @@ public Solution RemoveProject(ProjectId projectId)
version: this.Version.GetNewerVersion()); // changed project list, so increment version
}
private ImmutableDictionary<string, ImmutableList<DocumentId>> CreateLinkedFilesMapWithRemovedProject(ProjectState projectState)
private ImmutableDictionary<string, ImmutableArray<DocumentId>> CreateLinkedFilesMapWithRemovedProject(ProjectState projectState)
{
return CreateLinkedFilesMapWithRemovedDocuments(projectState, projectState.DocumentIds);
}
private ImmutableDictionary<string, ImmutableList<DocumentId>> CreateLinkedFilesMapWithRemovedDocuments(
private ImmutableDictionary<string, ImmutableArray<DocumentId>> CreateLinkedFilesMapWithRemovedDocuments(
ProjectState projectState,
ImmutableList<DocumentId> documentIds)
IReadOnlyList<DocumentId> documentIds)
{
var builder = this.linkedFilesMap.ToBuilder();
......@@ -647,13 +647,13 @@ public Solution RemoveProject(ProjectId projectId)
continue;
}
ImmutableList<DocumentId> documentIdsWithPath;
ImmutableArray<DocumentId> documentIdsWithPath;
if (!builder.TryGetValue(filePath, out documentIdsWithPath) || !documentIdsWithPath.Contains(documentId))
{
throw new ArgumentException("The given documentId was not found in the linkedFilesMap.");
}
if (documentIdsWithPath.Count == 1)
if (documentIdsWithPath.Length == 1)
{
builder.Remove(filePath);
}
......@@ -1476,12 +1476,12 @@ private Solution TouchDocument(DocumentId documentId, Func<ProjectState, Project
lazyLatestProjectVersion: newLatestProjectVersion);
}
private ImmutableDictionary<string, ImmutableList<DocumentId>> CreateLinkedFilesMapWithChangedProject(ProjectState oldProjectState, ProjectState newProjectState)
private ImmutableDictionary<string, ImmutableArray<DocumentId>> CreateLinkedFilesMapWithChangedProject(ProjectState oldProjectState, ProjectState newProjectState)
{
var oldDocumentIds = oldProjectState.DocumentIds;
var newDocumentIds = newProjectState.DocumentIds;
var addedDocumentIds = newDocumentIds.RemoveRange(oldDocumentIds);
var removedDocumentIds = oldDocumentIds.RemoveRange(newDocumentIds);
var addedDocumentIds = newDocumentIds.ToImmutableArray().RemoveRange(oldDocumentIds);
var removedDocumentIds = oldDocumentIds.ToImmutableArray().RemoveRange(newDocumentIds);
Debug.Assert(addedDocumentIds.Any() || removedDocumentIds.Any(), "The solution's linkedFilesMap should only be recalculated if its files changed.");
......@@ -1494,21 +1494,21 @@ private Solution TouchDocument(DocumentId documentId, Func<ProjectState, Project
/// <summary>
/// Gets the set of documents in the current solution with the given file path.
/// </summary>
internal ImmutableList<DocumentId> GetDocumentIdsWithFilePath(string filePath)
internal ImmutableArray<DocumentId> GetDocumentIdsWithFilePath(string filePath)
{
if (string.IsNullOrWhiteSpace(filePath))
{
return ImmutableList<DocumentId>.Empty;
return ImmutableArray.Create<DocumentId>();
}
ImmutableList<DocumentId> documentIds;
ImmutableArray<DocumentId> documentIds;
return this.linkedFilesMap.TryGetValue(filePath, out documentIds)
? documentIds
: ImmutableList<DocumentId>.Empty;
: ImmutableArray.Create<DocumentId>();
}
private static ProjectDependencyGraph CreateDependencyGraph(
ImmutableList<ProjectId> projectIds,
IReadOnlyList<ProjectId> projectIds,
ImmutableDictionary<ProjectId, ProjectState> projectStates)
{
var map = projectStates.Values.Select(state => new KeyValuePair<ProjectId, ImmutableHashSet<ProjectId>>(
......@@ -1516,7 +1516,7 @@ internal ImmutableList<DocumentId> GetDocumentIdsWithFilePath(string filePath)
state.ProjectReferences.Where(pr => projectStates.ContainsKey(pr.ProjectId)).Select(pr => pr.ProjectId).ToImmutableHashSet()))
.ToImmutableDictionary();
return new ProjectDependencyGraph(projectIds, map);
return new ProjectDependencyGraph(projectIds.ToImmutableArray(), map);
}
private ImmutableDictionary<ProjectId, CompilationTracker> CreateCompilationTrackerMap(ProjectId projectId, ProjectDependencyGraph dependencyGraph)
......
......@@ -45,7 +45,7 @@ public sealed class SolutionInfo
this.Id = id;
this.Version = version;
this.FilePath = filePath;
this.Projects = projects.ToImmutableListOrEmpty();
this.Projects = projects.ToImmutableReadOnlyListOrEmpty();
}
/// <summary>
......
......@@ -20,7 +20,7 @@ public abstract partial class Workspace
// text buffer maps
private readonly Dictionary<SourceTextContainer, DocumentId> bufferToDocumentInCurrentContextMap = new Dictionary<SourceTextContainer, DocumentId>();
private readonly Dictionary<SourceTextContainer, ImmutableList<DocumentId>> bufferToDocumentIdMap = new Dictionary<SourceTextContainer, ImmutableList<DocumentId>>();
private readonly Dictionary<SourceTextContainer, ImmutableArray<DocumentId>> bufferToDocumentIdMap = new Dictionary<SourceTextContainer, ImmutableArray<DocumentId>>();
private readonly Dictionary<DocumentId, TextTracker> textTrackers = new Dictionary<DocumentId, TextTracker>();
/// <summary>
......@@ -200,7 +200,7 @@ public virtual IEnumerable<DocumentId> GetOpenDocumentIds(ProjectId projectId =
return SpecializedCollections.EmptyEnumerable<DocumentId>();
}
return this.projectToOpenDocumentsMap.SelectMany(kvp => kvp.Value).ToImmutableList();
return this.projectToOpenDocumentsMap.SelectMany(kvp => kvp.Value).ToImmutableArray();
}
}
......@@ -221,16 +221,16 @@ public virtual IEnumerable<DocumentId> GetRelatedDocumentIds(SourceTextContainer
}
}
private IEnumerable<DocumentId> GetRelatedDocumentIds_NoLock(SourceTextContainer container)
private ImmutableArray<DocumentId> GetRelatedDocumentIds_NoLock(SourceTextContainer container)
{
ImmutableList<DocumentId> docIds;
ImmutableArray<DocumentId> docIds;
if (this.bufferToDocumentIdMap.TryGetValue(container, out docIds))
{
return docIds;
}
else
{
return SpecializedCollections.EmptyEnumerable<DocumentId>();
return ImmutableArray.Create<DocumentId>();
}
}
......@@ -438,14 +438,14 @@ protected internal void OnDocumentClosed(DocumentId documentId, TextLoader reloa
private void AddTextToDocumentIdMapping_NoLock(SourceTextContainer textContainer, DocumentId id, bool isCurrentContext)
{
ImmutableList<DocumentId> docIds;
ImmutableArray<DocumentId> docIds;
if (this.bufferToDocumentIdMap.TryGetValue(textContainer, out docIds))
{
this.bufferToDocumentIdMap[textContainer] = docIds.Add(id);
}
else
{
this.bufferToDocumentIdMap[textContainer] = ImmutableList.Create(id);
this.bufferToDocumentIdMap[textContainer] = ImmutableArray.Create(id);
}
if (isCurrentContext || !bufferToDocumentInCurrentContextMap.ContainsKey(textContainer))
......@@ -457,11 +457,11 @@ private void AddTextToDocumentIdMapping_NoLock(SourceTextContainer textContainer
/// <returns>The DocumentId of the current context document attached to the textContainer, if any.</returns>
private DocumentId RemoveTextToDocumentIdMapping_NoLock(SourceTextContainer textContainer, DocumentId id)
{
ImmutableList<DocumentId> docIds;
ImmutableArray<DocumentId> docIds;
if (this.bufferToDocumentIdMap.TryGetValue(textContainer, out docIds))
{
docIds = docIds.Remove(id);
if (docIds.Count > 0)
if (docIds.Length > 0)
{
this.bufferToDocumentIdMap[textContainer] = docIds;
......
......@@ -44,7 +44,7 @@ protected Task RaiseWorkspaceChangedEventAsync(WorkspaceChangeKind kind, Solutio
}
var handlers = this.eventMap.GetEventHandlers<EventHandler<WorkspaceChangeEventArgs>>(WorkspaceChangeEventName);
if (handlers != null)
if (handlers.Length > 0)
{
return this.ScheduleTask(() =>
{
......@@ -81,7 +81,7 @@ protected Task RaiseWorkspaceChangedEventAsync(WorkspaceChangeKind kind, Solutio
private Task RaiseWorkspaceFailedEventAsync(WorkspaceDiagnostic diagnostic)
{
var handlers = this.eventMap.GetEventHandlers<EventHandler<WorkspaceDiagnosticEventArgs>>(WorkspaceFailedEventName);
if (handlers != null)
if (handlers.Length > 0)
{
return this.ScheduleTask(() =>
{
......@@ -122,7 +122,7 @@ protected internal virtual void OnWorkspaceFailed(WorkspaceDiagnostic diagnostic
protected Task RaiseDocumentOpenedEventAsync(Document document)
{
var handlers = this.eventMap.GetEventHandlers<EventHandler<DocumentEventArgs>>(DocumentOpenedEventName);
if (handlers != null)
if (handlers.Length > 0)
{
return this.ScheduleTask(() =>
{
......@@ -158,7 +158,7 @@ protected Task RaiseDocumentOpenedEventAsync(Document document)
protected Task RaiseDocumentClosedEventAsync(Document document)
{
var handlers = this.eventMap.GetEventHandlers<EventHandler<DocumentEventArgs>>(DocumentClosedEventName);
if (handlers != null)
if (handlers.Length > 0)
{
return this.ScheduleTask(() =>
{
......@@ -195,7 +195,7 @@ protected Task RaiseDocumentClosedEventAsync(Document document)
protected Task RaiseDocumentActiveContextChangedEventAsync(Document document)
{
var handlers = this.eventMap.GetEventHandlers<EventHandler<DocumentEventArgs>>(DocumentActiveContextChangedName);
if (handlers != null)
if (handlers.Length > 0)
{
return this.ScheduleTask(() =>
{
......
......@@ -485,6 +485,7 @@
<Compile Include="GeneratedCodeRecognition\GeneratedCodeRecognitionServiceFactory.cs" />
<Compile Include="GeneratedCodeRecognition\IGeneratedCodeRecognitionService.cs" />
<Compile Include="IOrderableMetadata.cs" />
<Compile Include="Utilities\ImmutableArrayExtensions.cs" />
<Compile Include="Utilities\ObjectPools\PooledObject.cs" />
<Compile Include="Workspace\Host\Mef\ServiceLayer.cs" />
<Compile Include="Workspace\Host\SyntaxTreeFactory\AbstractSyntaxTreeFactoryService.AbstractRecoverableSyntaxRoot.cs" />
......
......@@ -7,7 +7,7 @@ Imports Microsoft.CodeAnalysis.VisualBasic.Classification.Classifiers
Namespace Microsoft.CodeAnalysis.VisualBasic.Classification
Friend Module SyntaxClassifier
Public ReadOnly DefaultSyntaxClassifiers As IEnumerable(Of ISyntaxClassifier) =
ImmutableList.Create(Of ISyntaxClassifier)(
ImmutableArray.Create(Of ISyntaxClassifier)(
New NameSyntaxClassifier(),
New AliasImportsClauseSyntaxClassifier()
)
......
......@@ -8,10 +8,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeCleanup
Partial Friend Class VisualBasicCodeCleanerService
Inherits AbstractCodeCleanerService
Private Shared ReadOnly defaultProviders As IList(Of ICodeCleanupProvider)
Private Shared ReadOnly defaultProviders As IEnumerable(Of ICodeCleanupProvider)
Shared Sub New()
defaultProviders = ImmutableList.Create(Of ICodeCleanupProvider)(
defaultProviders = ImmutableArray.Create(Of ICodeCleanupProvider)(
New AddMissingTokensCodeCleanupProvider(),
New FixIncorrectTokensCodeCleanupProvider(),
New ReduceTokensCodeCleanupProvider(),
......
......@@ -25,7 +25,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Formatting
Sub New(<ImportMany> rules As IEnumerable(Of Lazy(Of IFormattingRule, OrderableLanguageMetadata)))
Me.lazyExportedRules = New Lazy(Of IEnumerable(Of IFormattingRule))(
Function()
Return ExtensionOrderer.Order(rules).Where(Function(x) x.Metadata.Language = LanguageNames.VisualBasic).Select(Function(x) x.Value).Concat(New DefaultOperationProvider()).ToImmutableList()
Return ExtensionOrderer.Order(rules).Where(Function(x) x.Metadata.Language = LanguageNames.VisualBasic).Select(Function(x) x.Value).Concat(New DefaultOperationProvider()).ToImmutableArray()
End Function)
End Sub
......
......@@ -34,7 +34,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Private ReadOnly _span As TextSpan
Private ReadOnly pathFromRoot As ImmutableList(Of Integer)
Private ReadOnly pathFromRoot As ImmutableArray(Of Integer)
Public Sub New(tree As SyntaxTree, node As SyntaxNode)
Me.tree = tree
......@@ -55,7 +55,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End Get
End Property
Private Function ComputePathFromRoot(node As SyntaxNode) As ImmutableList(Of Integer)
Private Function ComputePathFromRoot(node As SyntaxNode) As ImmutableArray(Of Integer)
Dim path = New List(Of Integer)()
Dim root = tree.GetRoot()
While node IsNot root
......@@ -79,7 +79,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End While
path.Reverse()
Return path.ToImmutableList()
Return path.ToImmutableArray()
End Function
Private Function GetChildIndex(child As SyntaxNodeOrToken) As Integer
......
......@@ -97,7 +97,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Return compilerInputs.Sources _
.Where(Function(s) Not System.IO.Path.GetFileName(s.ItemSpec).StartsWith("TemporaryGeneratedFile_")) _
.Select(Function(s) New DocumentFileInfo(GetDocumentFilePath(s), GetDocumentLogicalPath(s, projectDirectory), IsDocumentLinked(s), IsDocumentGenerated(s))).ToImmutableList()
.Select(Function(s) New DocumentFileInfo(GetDocumentFilePath(s), GetDocumentLogicalPath(s, projectDirectory), IsDocumentLinked(s), IsDocumentGenerated(s))).ToImmutableArray()
End Function
Private Function GetMetadataReferences(compilerInputs As VisualBasicCompilerInputs) As IEnumerable(Of MetadataInfo)
......@@ -142,7 +142,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
refs.Add(New MetadataInfo(systemPath))
End If
Return refs.ToImmutableList()
Return refs.ToImmutableArray()
End Function
Private Function GetAnalyzerReferences(compilerInputs As VisualBasicCompilerInputs) As IEnumerable(Of AnalyzerReference)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册