提交 dcfe4e87 编写于 作者: C Cyrus Najmabadi

Use implicit object creation in Editor Features layer.

上级 439a9d94
......@@ -22,9 +22,9 @@ private VSTypeScriptBreakpointResolutionResultWrapper(BreakpointResolutionResult
public bool IsLineBreakpoint => UnderlyingObject.IsLineBreakpoint;
public static VSTypeScriptBreakpointResolutionResultWrapper CreateSpanResult(Document document, TextSpan textSpan, string? locationNameOpt = null)
=> new VSTypeScriptBreakpointResolutionResultWrapper(BreakpointResolutionResult.CreateSpanResult(document, textSpan, locationNameOpt));
=> new(BreakpointResolutionResult.CreateSpanResult(document, textSpan, locationNameOpt));
public static VSTypeScriptBreakpointResolutionResultWrapper CreateLineResult(Document document, string? locationNameOpt = null)
=> new VSTypeScriptBreakpointResolutionResultWrapper(BreakpointResolutionResult.CreateLineResult(document, locationNameOpt));
=> new(BreakpointResolutionResult.CreateLineResult(document, locationNameOpt));
}
}
......@@ -20,7 +20,7 @@ private VSTypeScriptEditorFormattingServiceWrapper(IEditorFormattingService unde
=> _underlyingObject = underlyingObject;
public static VSTypeScriptEditorFormattingServiceWrapper Create(Document document)
=> new VSTypeScriptEditorFormattingServiceWrapper(document.Project.LanguageServices.GetRequiredService<IEditorFormattingService>());
=> new(document.Project.LanguageServices.GetRequiredService<IEditorFormattingService>());
public Task<IList<TextChange>> GetFormattingChangesAsync(Document document, TextSpan? textSpan, CancellationToken cancellationToken)
=> _underlyingObject.GetFormattingChangesAsync(document, textSpan, cancellationToken);
......
......@@ -20,7 +20,7 @@ private VSTypeScriptIndentationServiceWrapper(IIndentationService underlyingObje
=> _underlyingObject = underlyingObject;
public static VSTypeScriptIndentationServiceWrapper Create(Document document)
=> new VSTypeScriptIndentationServiceWrapper(document.Project.LanguageServices.GetRequiredService<IIndentationService>());
=> new(document.Project.LanguageServices.GetRequiredService<IIndentationService>());
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "External access API.")]
public async Task<VSTypeScriptIndentationResultWrapper?> GetDesiredIndentation(Document document, int lineNumber, CancellationToken cancellationToken)
......
......@@ -25,8 +25,8 @@ internal abstract partial class AbstractFindUsagesService
private class DefinitionTrackingContext : IFindUsagesContext
{
private readonly IFindUsagesContext _underlyingContext;
private readonly object _gate = new object();
private readonly List<DefinitionItem> _definitions = new List<DefinitionItem>();
private readonly object _gate = new();
private readonly List<DefinitionItem> _definitions = new();
public DefinitionTrackingContext(IFindUsagesContext underlyingContext)
=> _underlyingContext = underlyingContext;
......
......@@ -65,9 +65,9 @@ private class FindReferencesProgressAdapter : IStreamingFindReferencesProgress
/// all future callbacks.
/// </summary>
private readonly Dictionary<ISymbol, DefinitionItem> _definitionToItem =
new Dictionary<ISymbol, DefinitionItem>(MetadataUnifyingEquivalenceComparer.Instance);
new(MetadataUnifyingEquivalenceComparer.Instance);
private readonly SemaphoreSlim _gate = new SemaphoreSlim(initialCount: 1);
private readonly SemaphoreSlim _gate = new(initialCount: 1);
public IStreamingProgressTracker ProgressTracker
=> _context.ProgressTracker;
......
......@@ -60,7 +60,7 @@ private static SymbolDisplayFormat GetFormat(ISymbol definition)
}
private static readonly SymbolDisplayFormat s_definitionFormat =
new SymbolDisplayFormat(
new(
typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameOnly,
genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters,
parameterOptions: SymbolDisplayParameterOptions.IncludeType,
......
......@@ -52,7 +52,7 @@ public DefaultDefinitionsAndReferencesFactory()
internal static class DefinitionItemExtensions
{
private static readonly SymbolDisplayFormat s_namePartsFormat = new SymbolDisplayFormat(
private static readonly SymbolDisplayFormat s_namePartsFormat = new(
memberOptions: SymbolDisplayMemberOptions.IncludeContainingType);
public static DefinitionItem ToNonClassifiedDefinitionItem(
......
......@@ -16,7 +16,7 @@ namespace Microsoft.CodeAnalysis.Editor.FindUsages
/// </summary>
internal class SimpleFindUsagesContext : FindUsagesContext
{
private readonly object _gate = new object();
private readonly object _gate = new();
private readonly ImmutableArray<DefinitionItem>.Builder _definitionItems =
ImmutableArray.CreateBuilder<DefinitionItem>();
......
......@@ -12,9 +12,9 @@ namespace Microsoft.CodeAnalysis.Editor.GoToDefinition
{
internal class GoToSymbolContext
{
private readonly object _gate = new object();
private readonly object _gate = new();
private readonly MultiDictionary<string, DefinitionItem> _items = new MultiDictionary<string, DefinitionItem>();
private readonly MultiDictionary<string, DefinitionItem> _items = new();
public GoToSymbolContext(Document document, int position, CancellationToken cancellationToken)
{
......
......@@ -8,8 +8,8 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.BraceMatching
{
internal class BraceHighlightTag : TextMarkerTag
{
public static readonly BraceHighlightTag StartTag = new BraceHighlightTag(navigateToStart: true);
public static readonly BraceHighlightTag EndTag = new BraceHighlightTag(navigateToStart: false);
public static readonly BraceHighlightTag StartTag = new(navigateToStart: true);
public static readonly BraceHighlightTag EndTag = new(navigateToStart: false);
public bool NavigateToStart { get; }
......
......@@ -15,7 +15,7 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.Classification
{
internal static class ClassificationUtilities
{
private static readonly ConcurrentQueue<List<ClassifiedSpan>> s_spanCache = new ConcurrentQueue<List<ClassifiedSpan>>();
private static readonly ConcurrentQueue<List<ClassifiedSpan>> s_spanCache = new();
public static List<ClassifiedSpan> GetOrCreateClassifiedSpanList()
{
......
......@@ -36,7 +36,7 @@ internal static class SemanticClassificationUtilities
/// actually transitioned to a loaded state.
/// </summary>
private static readonly ConditionalWeakTable<Workspace, Task> s_workspaceToFullyLoadedStateTask =
new ConditionalWeakTable<Workspace, Task>();
new();
public static async Task ProduceTagsAsync(
TaggerContext<IClassificationTag> context,
......
......@@ -20,7 +20,7 @@ private class LastLineCache
// this helper class is primarily to improve active typing perf. don't bother to cache
// something very big.
private const int MaxClassificationNumber = 32;
private readonly object _gate = new object();
private readonly object _gate = new();
// mutating state
private SnapshotSpan _span;
......
......@@ -56,7 +56,7 @@ internal partial class TagComputer
// Note: we cache this data once we've retrieved the actual syntax tree for a document. This
// way, when we call into the actual classification service, it should be very quick for the
// it to get the tree if it needs it.
private readonly object _gate = new object();
private readonly object _gate = new();
private ITextSnapshot _lastProcessedSnapshot;
private Document _lastProcessedDocument;
......
......@@ -27,7 +27,7 @@ internal partial class SyntacticClassificationTaggerProvider : ITaggerProvider
private readonly IAsynchronousOperationListener _listener;
private readonly ClassificationTypeMap _typeMap;
private readonly ConditionalWeakTable<ITextBuffer, TagComputer> _tagComputers = new ConditionalWeakTable<ITextBuffer, TagComputer>();
private readonly ConditionalWeakTable<ITextBuffer, TagComputer> _tagComputers = new();
[ImportingConstructor]
[SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
......
......@@ -38,7 +38,7 @@ namespace Microsoft.CodeAnalysis.CodeFixes
internal partial class CodeFixService : ForegroundThreadAffinitizedObject, ICodeFixService
{
private static readonly Comparison<DiagnosticData> s_diagnosticDataComparisonById =
new Comparison<DiagnosticData>((d1, d2) => DiagnosticId.CompareOrdinal(d1.Id, d2.Id));
new((d1, d2) => DiagnosticId.CompareOrdinal(d1.Id, d2.Id));
private readonly IDiagnosticAnalyzerService _diagnosticService;
......
......@@ -29,7 +29,7 @@ internal abstract class AbstractToggleBlockCommentBase :
ICommandHandler<ToggleBlockCommentCommandArgs>
{
private static readonly CommentSelectionResult s_emptyCommentSelectionResult =
new CommentSelectionResult(new List<TextChange>(), new List<CommentTrackingSpan>(), Operation.Uncomment);
new(new List<TextChange>(), new List<CommentTrackingSpan>(), Operation.Uncomment);
private readonly ITextStructureNavigatorSelectorService _navigatorSelectorService;
......
......@@ -34,7 +34,7 @@ internal class ToggleLineCommentCommandHandler :
ICommandHandler<ToggleLineCommentCommandArgs>
{
private static readonly CommentSelectionResult s_emptyCommentSelectionResult =
new CommentSelectionResult(new List<TextChange>(), new List<CommentTrackingSpan>(), Operation.Uncomment);
new(new List<TextChange>(), new List<CommentTrackingSpan>(), Operation.Uncomment);
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
......
......@@ -52,7 +52,7 @@ internal abstract partial class AbstractDiagnosticsTaggerProvider<TTag> : Asynch
/// we're tagging.
/// </summary>
private static readonly ConditionalWeakTable<object, ITextSnapshot> _diagnosticIdToTextSnapshot =
new ConditionalWeakTable<object, ITextSnapshot>();
new();
protected AbstractDiagnosticsTaggerProvider(
IThreadingContext threadingContext,
......
......@@ -12,7 +12,7 @@ internal sealed class ActiveStatementTag : TextMarkerTag
{
internal const string TagId = "RoslynActiveStatementTag";
public static readonly ActiveStatementTag Instance = new ActiveStatementTag();
public static readonly ActiveStatementTag Instance = new();
private ActiveStatementTag()
: base(TagId)
......
......@@ -250,18 +250,18 @@ public PendingWork(int minimumRunPointInMS, Func<bool> work, IAsyncToken asyncTo
}
public PendingWork UpdateToCurrentTime()
=> new PendingWork(Environment.TickCount, DoWorkAction, DoWorkFunc, AsyncToken, CancellationToken);
=> new(Environment.TickCount, DoWorkAction, DoWorkFunc, AsyncToken, CancellationToken);
}
private class PriorityQueue
{
// use pool to share linked list nodes rather than re-create them every time
private static readonly ObjectPool<LinkedListNode<PendingWork>> s_pool =
new ObjectPool<LinkedListNode<PendingWork>>(() => new LinkedListNode<PendingWork>(default), 100);
new(() => new LinkedListNode<PendingWork>(default), 100);
private readonly object _gate = new object();
private readonly LinkedList<PendingWork> _list = new LinkedList<PendingWork>();
private readonly SemaphoreSlim _hasItemsGate = new SemaphoreSlim(initialCount: 0);
private readonly object _gate = new();
private readonly LinkedList<PendingWork> _list = new();
private readonly SemaphoreSlim _hasItemsGate = new(initialCount: 0);
public Task WaitForItemsAsync()
{
......
......@@ -188,6 +188,6 @@ public void ExecuteReturnOrTypeCommand(EditorCommandArgs args, Action nextHandle
}
private CaretPreservingEditTransaction CreateEditTransaction(ITextView view, string description)
=> new CaretPreservingEditTransaction(description, view, _undoHistoryRegistry, _editorOperationsFactoryService);
=> new(description, view, _undoHistoryRegistry, _editorOperationsFactoryService);
}
}
......@@ -8,7 +8,7 @@ namespace Microsoft.CodeAnalysis
{
internal class AsyncCompletionLogger
{
private static readonly LogAggregator s_logAggregator = new LogAggregator();
private static readonly LogAggregator s_logAggregator = new();
internal enum ActionInfo
{
......
......@@ -27,7 +27,7 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.AsyncComplet
internal sealed class CommitManager : ForegroundThreadAffinitizedObject, IAsyncCompletionCommitManager
{
private static readonly AsyncCompletionData.CommitResult CommitResultUnhandled =
new AsyncCompletionData.CommitResult(isHandled: false, AsyncCompletionData.CommitBehavior.None);
new(isHandled: false, AsyncCompletionData.CommitBehavior.None);
private readonly RecentItemsManager _recentItemsManager;
private readonly ITextView _textView;
......
......@@ -52,11 +52,11 @@ internal sealed class CompletionSource : ForegroundThreadAffinitizedObject, IAsy
private static readonly ImmutableArray<ImageElement> s_WarningImageAttributeImagesArray =
ImmutableArray.Create(new ImageElement(Glyph.CompletionWarning.GetImageId(), EditorFeaturesResources.Warning_image_element));
private static readonly EditorOptionKey<bool> NonBlockingCompletionEditorOption = new EditorOptionKey<bool>(NonBlockingCompletion);
private static readonly EditorOptionKey<bool> NonBlockingCompletionEditorOption = new(NonBlockingCompletion);
// Use CWT to cache data needed to create VSCompletionItem, so the table would be cleared when Roslyn completion item cache is cleared.
private static readonly ConditionalWeakTable<RoslynCompletionItem, StrongBox<VSCompletionItemData>> s_roslynItemToVsItemData =
new ConditionalWeakTable<RoslynCompletionItem, StrongBox<VSCompletionItemData>>();
new();
private readonly ITextView _textView;
private readonly bool _isDebuggerTextView;
......
......@@ -38,7 +38,7 @@ internal class ItemManager : IAsyncCompletionItemManager
/// <summary>
/// For telemetry.
/// </summary>
private readonly object _targetTypeCompletionFilterChosenMarker = new object();
private readonly object _targetTypeCompletionFilterChosenMarker = new();
internal ItemManager(RecentItemsManager recentItemsManager)
{
......
......@@ -17,7 +17,7 @@ internal class RecentItemsManager
/// <summary>
/// Guard for <see cref="RecentItems"/>
/// </summary>
private readonly object _mruUpdateLock = new object();
private readonly object _mruUpdateLock = new();
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
......
......@@ -15,7 +15,7 @@ internal class PrioritizedTaskScheduler : TaskScheduler
public static readonly TaskScheduler AboveNormalInstance = new PrioritizedTaskScheduler(ThreadPriority.AboveNormal);
private readonly Thread _thread;
private readonly BlockingCollection<Task> _tasks = new BlockingCollection<Task>();
private readonly BlockingCollection<Task> _tasks = new();
private PrioritizedTaskScheduler(ThreadPriority priority)
{
......
......@@ -27,7 +27,7 @@ internal partial class Controller :
IChainedCommandHandler<TypeCharCommandArgs>,
IChainedCommandHandler<InvokeSignatureHelpCommandArgs>
{
private static readonly object s_controllerPropertyKey = new object();
private static readonly object s_controllerPropertyKey = new();
private readonly IAsyncCompletionBroker _completionBroker;
private readonly IList<Lazy<ISignatureHelpProvider, OrderableLanguageMetadata>> _allProviders;
......
......@@ -20,8 +20,8 @@ internal class Parameter : IParameter
public string Documentation => _documentation ?? (_documentation = _parameter.DocumentationFactory(CancellationToken.None).GetFullText());
public string Name => _parameter.Name;
public Span Locus => new Span(_index, _contentLength);
public Span PrettyPrintedLocus => new Span(_prettyPrintedIndex, _contentLength);
public Span Locus => new(_index, _contentLength);
public Span PrettyPrintedLocus => new(_prettyPrintedIndex, _contentLength);
public ISignature Signature { get; }
public Parameter(
......
......@@ -19,7 +19,7 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.SignatureHel
[ContentType(ContentTypeNames.RoslynContentType)]
internal partial class SignatureHelpPresenter : ForegroundThreadAffinitizedObject, IIntelliSensePresenter<ISignatureHelpPresenterSession, ISignatureHelpSession>, ISignatureHelpSourceProvider
{
private static readonly object s_augmentSessionKey = new object();
private static readonly object s_augmentSessionKey = new();
private readonly ISignatureHelpBroker _sigHelpBroker;
......
......@@ -19,7 +19,7 @@ namespace Microsoft.CodeAnalysis.Editor.Completion.FileSystem
internal sealed class GlobalAssemblyCacheCompletionHelper
{
private static readonly Lazy<List<string>> s_lazyAssemblySimpleNames =
new Lazy<List<string>>(() => GlobalAssemblyCache.Instance.GetAssemblySimpleNames().ToList());
new(() => GlobalAssemblyCache.Instance.GetAssemblySimpleNames().ToList());
private readonly CompletionItemRules _itemRules;
......
......@@ -23,8 +23,8 @@ protected sealed override void AddHighlightsForNode(SyntaxNode node, List<TextSp
internal abstract class AbstractKeywordHighlighter : IHighlighter
{
private static readonly ObjectPool<List<TextSpan>> s_textSpanListPool = new ObjectPool<List<TextSpan>>(() => new List<TextSpan>());
private static readonly ObjectPool<List<SyntaxToken>> s_tokenListPool = new ObjectPool<List<SyntaxToken>>(() => new List<SyntaxToken>());
private static readonly ObjectPool<List<TextSpan>> s_textSpanListPool = new(() => new List<TextSpan>());
private static readonly ObjectPool<List<SyntaxToken>> s_tokenListPool = new(() => new List<SyntaxToken>());
protected abstract bool IsHighlightableNode(SyntaxNode node);
......@@ -72,7 +72,7 @@ private static bool AnyIntersects(int position, List<TextSpan> highlights)
protected abstract void AddHighlightsForNode(SyntaxNode node, List<TextSpan> highlights, CancellationToken cancellationToken);
protected static TextSpan EmptySpan(int position)
=> new TextSpan(position, 0);
=> new(position, 0);
internal static void AddTouchingTokens(SyntaxNode root, int position, List<SyntaxToken> tokens)
{
......
......@@ -31,7 +31,7 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.Highlighting
internal class HighlighterViewTaggerProvider : AsynchronousViewTaggerProvider<KeywordHighlightTag>
{
private readonly IHighlightingService _highlightingService;
private static readonly PooledObjects.ObjectPool<List<TextSpan>> s_listPool = new PooledObjects.ObjectPool<List<TextSpan>>(() => new List<TextSpan>());
private static readonly PooledObjects.ObjectPool<List<TextSpan>> s_listPool = new(() => new List<TextSpan>());
// Whenever an edit happens, clear all highlights. When moving the caret, preserve
// highlights if the caret stays within an existing tag.
......
......@@ -17,7 +17,7 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.Highlighting
internal class HighlightingService : IHighlightingService
{
private readonly List<Lazy<IHighlighter, LanguageMetadata>> _highlighters;
private static readonly PooledObjects.ObjectPool<List<TextSpan>> s_listPool = new PooledObjects.ObjectPool<List<TextSpan>>(() => new List<TextSpan>());
private static readonly PooledObjects.ObjectPool<List<TextSpan>> s_listPool = new(() => new List<TextSpan>());
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
......
......@@ -10,7 +10,7 @@ internal class KeywordHighlightTag : NavigableHighlightTag
{
internal const string TagId = "MarkerFormatDefinition/HighlightedReference";
public static readonly KeywordHighlightTag Instance = new KeywordHighlightTag();
public static readonly KeywordHighlightTag Instance = new();
private KeywordHighlightTag()
: base(TagId)
......
......@@ -24,7 +24,7 @@ internal partial class NavigationBarController
/// </summary>
private Task<NavigationBarModel> _modelTask;
private NavigationBarModel _lastCompletedModel;
private CancellationTokenSource _modelTaskCancellationSource = new CancellationTokenSource();
private CancellationTokenSource _modelTaskCancellationSource = new();
/// <summary>
/// Starts a new task to compute the model based on the current text.
......@@ -100,7 +100,7 @@ private async Task<NavigationBarModel> ComputeModelAsync(Document document, ITex
}
private Task<NavigationBarSelectedTypeAndMember> _selectedItemInfoTask;
private CancellationTokenSource _selectedItemInfoTaskCancellationSource = new CancellationTokenSource();
private CancellationTokenSource _selectedItemInfoTaskCancellationSource = new();
/// <summary>
/// Starts a new task to compute what item should be selected.
......
......@@ -17,7 +17,7 @@ namespace Microsoft.CodeAnalysis.PasteTracking
internal class PasteTrackingService : IPasteTrackingService
{
private readonly IThreadingContext _threadingContext;
private readonly object _pastedTextSpanKey = new object();
private readonly object _pastedTextSpanKey = new();
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
......
......@@ -10,7 +10,7 @@ internal class RenameTrackingTag : TextMarkerTag
{
internal const string TagId = "RenameTrackingTag";
public static readonly RenameTrackingTag Instance = new RenameTrackingTag();
public static readonly RenameTrackingTag Instance = new();
private RenameTrackingTag()
: base(TagId)
......
......@@ -43,7 +43,7 @@ public IndentationResult(int basePosition, int offset) : this()
}
public static implicit operator Indentation.IndentationResult(IndentationResult result)
=> new Indentation.IndentationResult(result.BasePosition, result.Offset);
=> new(result.BasePosition, result.Offset);
}
// Removal of this interface tracked with https://github.com/dotnet/roslyn/issues/35872
......
......@@ -24,12 +24,12 @@ namespace Microsoft.CodeAnalysis.Editor
internal class TextBufferAssociatedViewService : ITextViewConnectionListener, ITextBufferAssociatedViewService
{
#if DEBUG
private static readonly HashSet<ITextView> s_registeredViews = new HashSet<ITextView>();
private static readonly HashSet<ITextView> s_registeredViews = new();
#endif
private static readonly object s_gate = new object();
private static readonly object s_gate = new();
private static readonly ConditionalWeakTable<ITextBuffer, HashSet<ITextView>> s_map =
new ConditionalWeakTable<ITextBuffer, HashSet<ITextView>>();
new();
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
......
......@@ -34,7 +34,7 @@ internal abstract partial class AbstractTextStructureNavigatorProvider : ITextSt
protected abstract bool IsWithinNaturalLanguage(SyntaxToken token, int position);
protected virtual TextExtent GetExtentOfWordFromToken(SyntaxToken token, SnapshotPoint position)
=> new TextExtent(token.Span.ToSnapshotSpan(position.Snapshot), isSignificant: true);
=> new(token.Span.ToSnapshotSpan(position.Snapshot), isSignificant: true);
public ITextStructureNavigator CreateTextStructureNavigator(ITextBuffer subjectBuffer)
{
......
......@@ -19,7 +19,7 @@ namespace Microsoft.CodeAnalysis.Editor.NavigableSymbols
[ContentType(ContentTypeNames.RoslynContentType)]
internal partial class NavigableSymbolService : INavigableSymbolSourceProvider
{
private static readonly object s_key = new object();
private static readonly object s_key = new();
private readonly IWaitIndicator _waitIndicator;
private readonly IThreadingContext _threadingContext;
private readonly IStreamingFindUsagesPresenter _streamingPresenter;
......
......@@ -16,7 +16,7 @@ namespace Microsoft.CodeAnalysis.Editor.Options
internal static class BraceCompletionOptions
{
// This is serialized by the Visual Studio-specific LanguageSettingsPersister
public static readonly PerLanguageOption<bool> Enable = new PerLanguageOption<bool>(nameof(BraceCompletionOptions), nameof(Enable), defaultValue: true);
public static readonly PerLanguageOption<bool> Enable = new(nameof(BraceCompletionOptions), nameof(Enable), defaultValue: true);
}
[ExportOptionProvider, Shared]
......
......@@ -16,12 +16,12 @@ internal static class ColorSchemeOptions
{
internal const string ColorSchemeSettingKey = "TextEditor.Roslyn.ColorScheme";
public static readonly Option2<SchemeName> ColorScheme = new Option2<SchemeName>(nameof(ColorSchemeOptions),
public static readonly Option2<SchemeName> ColorScheme = new(nameof(ColorSchemeOptions),
nameof(ColorScheme),
defaultValue: SchemeName.VisualStudio2019,
storageLocations: new RoamingProfileStorageLocation(ColorSchemeSettingKey));
public static readonly Option2<UseEnhancedColors> LegacyUseEnhancedColors = new Option2<UseEnhancedColors>(nameof(ColorSchemeOptions),
public static readonly Option2<UseEnhancedColors> LegacyUseEnhancedColors = new(nameof(ColorSchemeOptions),
nameof(LegacyUseEnhancedColors),
defaultValue: UseEnhancedColors.Default,
storageLocations: new RoamingProfileStorageLocation("WindowManagement.Options.UseEnhancedColorsForManagedLanguages"));
......
......@@ -13,7 +13,7 @@ namespace Microsoft.CodeAnalysis.Editor.Options
{
internal partial class ExtensionManagerOptions
{
public static readonly Option<bool> DisableCrashingExtensions = new Option<bool>(nameof(ExtensionManagerOptions), nameof(DisableCrashingExtensions), defaultValue: true);
public static readonly Option<bool> DisableCrashingExtensions = new(nameof(ExtensionManagerOptions), nameof(DisableCrashingExtensions), defaultValue: true);
}
[ExportOptionProvider, Shared]
......
......@@ -15,7 +15,7 @@ namespace Microsoft.CodeAnalysis.Editor.Options
{
internal static class NavigationBarOptions
{
public static readonly PerLanguageOption<bool> ShowNavigationBar = new PerLanguageOption<bool>(nameof(NavigationBarOptions), nameof(ShowNavigationBar), defaultValue: true);
public static readonly PerLanguageOption<bool> ShowNavigationBar = new(nameof(NavigationBarOptions), nameof(ShowNavigationBar), defaultValue: true);
}
[ExportOptionProvider, Shared]
......
......@@ -15,7 +15,7 @@ namespace Microsoft.CodeAnalysis.Editor.Options
{
internal static class SignatureHelpOptions
{
public static readonly PerLanguageOption2<bool> ShowSignatureHelp = new PerLanguageOption2<bool>(nameof(SignatureHelpOptions), nameof(ShowSignatureHelp), defaultValue: true);
public static readonly PerLanguageOption2<bool> ShowSignatureHelp = new(nameof(SignatureHelpOptions), nameof(ShowSignatureHelp), defaultValue: true);
}
[ExportOptionProvider, Shared]
......
......@@ -10,7 +10,7 @@ internal class DefinitionHighlightTag : NavigableHighlightTag
{
public const string TagId = "MarkerFormatDefinition/HighlightedDefinition";
public static readonly DefinitionHighlightTag Instance = new DefinitionHighlightTag();
public static readonly DefinitionHighlightTag Instance = new();
private DefinitionHighlightTag()
: base(TagId)
......
......@@ -10,7 +10,7 @@ internal class ReferenceHighlightTag : NavigableHighlightTag
{
internal const string TagId = "MarkerFormatDefinition/HighlightedReference";
public static readonly ReferenceHighlightTag Instance = new ReferenceHighlightTag();
public static readonly ReferenceHighlightTag Instance = new();
private ReferenceHighlightTag()
: base(TagId)
......
......@@ -10,7 +10,7 @@ internal class WrittenReferenceHighlightTag : NavigableHighlightTag
{
internal const string TagId = "MarkerFormatDefinition/HighlightedWrittenReference";
public static readonly WrittenReferenceHighlightTag Instance = new WrittenReferenceHighlightTag();
public static readonly WrittenReferenceHighlightTag Instance = new();
private WrittenReferenceHighlightTag()
: base(TagId)
......
......@@ -18,7 +18,7 @@ internal static class GlyphExtensions
private static readonly Guid ImageCatalogGuid = Guid.Parse("ae27a6b0-e345-4288-96df-5eaf394ee369");
public static ImageId GetImageCatalogImageId(int imageId)
=> new ImageId(ImageCatalogGuid, imageId);
=> new(ImageCatalogGuid, imageId);
public static ImageId GetImageId(this Glyph glyph)
{
......
......@@ -41,7 +41,7 @@ internal static class HostWorkspaceServicesExtensions
/// A cache of host services -> (language name -> content type name).
/// </summary>
private static readonly ConditionalWeakTable<HostWorkspaceServices, Dictionary<string, string>> s_hostServicesToContentTypeMap
= new ConditionalWeakTable<HostWorkspaceServices, Dictionary<string, string>>();
= new();
private static string GetDefaultContentTypeName(HostWorkspaceServices workspaceServices, string language)
{
......
......@@ -14,7 +14,7 @@ internal static partial class ITextViewExtensions
private class AutoClosingViewProperty<TProperty, TTextView> where TTextView : ITextView
{
private readonly TTextView _textView;
private readonly Dictionary<object, TProperty> _map = new Dictionary<object, TProperty>();
private readonly Dictionary<object, TProperty> _map = new();
public static bool GetOrCreateValue(
TTextView textView,
......
......@@ -18,11 +18,11 @@ internal static partial class ITextViewExtensions
private class PerSubjectBufferProperty<TProperty, TTextView> where TTextView : ITextView
{
private readonly TTextView _textView;
private readonly Dictionary<ITextBuffer, Dictionary<object, TProperty>> _subjectBufferMap = new Dictionary<ITextBuffer, Dictionary<object, TProperty>>();
private readonly Dictionary<ITextBuffer, Dictionary<object, TProperty>> _subjectBufferMap = new();
// Some other VS components (e.g. Razor) will temporarily disconnect out ITextBuffer from the ITextView. When listening to
// BufferGraph.GraphBuffersChanged, we should allow buffers we previously knew about to be re-attached.
private readonly ConditionalWeakTable<ITextBuffer, Dictionary<object, TProperty>> _buffersRemovedFromTextViewBufferGraph = new ConditionalWeakTable<ITextBuffer, Dictionary<object, TProperty>>();
private readonly ConditionalWeakTable<ITextBuffer, Dictionary<object, TProperty>> _buffersRemovedFromTextViewBufferGraph = new();
public static bool GetOrCreateValue(
TTextView textView,
......
......@@ -18,7 +18,7 @@ internal static class SpanExtensions
/// <param name="span"></param>
/// <returns></returns>
public static TextSpan ToTextSpan(this Span span)
=> new TextSpan(span.Start, span.Length);
=> new(span.Start, span.Length);
public static bool IntersectsWith(this Span span, int position)
=> position >= span.Start && position <= span.End;
......
......@@ -10,6 +10,6 @@ namespace Microsoft.CodeAnalysis.Editor.Shared.Extensions
internal static class TextChangeExtensions
{
public static TextChangeRange ToTextChangeRange(this ITextChange textChange)
=> new TextChangeRange(textChange.OldSpan.ToTextSpan(), textChange.NewLength);
=> new(textChange.OldSpan.ToTextSpan(), textChange.NewLength);
}
}
......@@ -18,16 +18,16 @@ internal static class EditorComponentOnOffOptions
{
private const string LocalRegistryPath = @"Roslyn\Internal\OnOff\Components\";
public static readonly Option2<bool> Adornment = new Option2<bool>(nameof(EditorComponentOnOffOptions), nameof(Adornment), defaultValue: true,
public static readonly Option2<bool> Adornment = new(nameof(EditorComponentOnOffOptions), nameof(Adornment), defaultValue: true,
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Adornment"));
public static readonly Option2<bool> Tagger = new Option2<bool>(nameof(EditorComponentOnOffOptions), nameof(Tagger), defaultValue: true,
public static readonly Option2<bool> Tagger = new(nameof(EditorComponentOnOffOptions), nameof(Tagger), defaultValue: true,
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Tagger"));
public static readonly Option2<bool> CodeRefactorings = new Option2<bool>(nameof(EditorComponentOnOffOptions), nameof(CodeRefactorings), defaultValue: true,
public static readonly Option2<bool> CodeRefactorings = new(nameof(EditorComponentOnOffOptions), nameof(CodeRefactorings), defaultValue: true,
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Code Refactorings"));
public static readonly Option2<bool> ShowCodeRefactoringsWhenQueriedForCodeFixes = new Option2<bool>(
public static readonly Option2<bool> ShowCodeRefactoringsWhenQueriedForCodeFixes = new(
nameof(EditorComponentOnOffOptions), nameof(ShowCodeRefactoringsWhenQueriedForCodeFixes), defaultValue: false,
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + nameof(ShowCodeRefactoringsWhenQueriedForCodeFixes)));
}
......
......@@ -15,53 +15,53 @@ namespace Microsoft.CodeAnalysis.Editor.Shared.Options
{
internal static class FeatureOnOffOptions
{
public static readonly PerLanguageOption2<bool> EndConstruct = new PerLanguageOption2<bool>(nameof(FeatureOnOffOptions), nameof(EndConstruct), defaultValue: true,
public static readonly PerLanguageOption2<bool> EndConstruct = new(nameof(FeatureOnOffOptions), nameof(EndConstruct), defaultValue: true,
storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.AutoEndInsert"));
// This value is only used by Visual Basic, and so is using the old serialization name that was used by VB.
public static readonly PerLanguageOption2<bool> AutomaticInsertionOfAbstractOrInterfaceMembers = new PerLanguageOption2<bool>(nameof(FeatureOnOffOptions), nameof(AutomaticInsertionOfAbstractOrInterfaceMembers), defaultValue: true,
public static readonly PerLanguageOption2<bool> AutomaticInsertionOfAbstractOrInterfaceMembers = new(nameof(FeatureOnOffOptions), nameof(AutomaticInsertionOfAbstractOrInterfaceMembers), defaultValue: true,
storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.AutoRequiredMemberInsert"));
public static readonly PerLanguageOption2<bool> LineSeparator = new PerLanguageOption2<bool>(nameof(FeatureOnOffOptions), nameof(LineSeparator), defaultValue: false,
public static readonly PerLanguageOption2<bool> LineSeparator = new(nameof(FeatureOnOffOptions), nameof(LineSeparator), defaultValue: false,
storageLocations: new RoamingProfileStorageLocation(language => language == LanguageNames.VisualBasic ? "TextEditor.%LANGUAGE%.Specific.DisplayLineSeparators" : "TextEditor.%LANGUAGE%.Specific.Line Separator"));
public static readonly PerLanguageOption2<bool> Outlining = new PerLanguageOption2<bool>(nameof(FeatureOnOffOptions), nameof(Outlining), defaultValue: true,
public static readonly PerLanguageOption2<bool> Outlining = new(nameof(FeatureOnOffOptions), nameof(Outlining), defaultValue: true,
storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.Outlining"));
public static readonly PerLanguageOption2<bool> KeywordHighlighting = new PerLanguageOption2<bool>(nameof(FeatureOnOffOptions), nameof(KeywordHighlighting), defaultValue: true,
public static readonly PerLanguageOption2<bool> KeywordHighlighting = new(nameof(FeatureOnOffOptions), nameof(KeywordHighlighting), defaultValue: true,
storageLocations: new RoamingProfileStorageLocation(language => language == LanguageNames.VisualBasic ? "TextEditor.%LANGUAGE%.Specific.EnableHighlightRelatedKeywords" : "TextEditor.%LANGUAGE%.Specific.Keyword Highlighting"));
public static readonly PerLanguageOption2<bool> ReferenceHighlighting = new PerLanguageOption2<bool>(nameof(FeatureOnOffOptions), nameof(ReferenceHighlighting), defaultValue: true,
public static readonly PerLanguageOption2<bool> ReferenceHighlighting = new(nameof(FeatureOnOffOptions), nameof(ReferenceHighlighting), defaultValue: true,
storageLocations: new RoamingProfileStorageLocation(language => language == LanguageNames.VisualBasic ? "TextEditor.%LANGUAGE%.Specific.EnableHighlightReferences" : "TextEditor.%LANGUAGE%.Specific.Reference Highlighting"));
public static readonly PerLanguageOption2<bool> FormatOnPaste = new PerLanguageOption2<bool>(nameof(FeatureOnOffOptions), nameof(FormatOnPaste), defaultValue: true,
public static readonly PerLanguageOption2<bool> FormatOnPaste = new(nameof(FeatureOnOffOptions), nameof(FormatOnPaste), defaultValue: true,
storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.FormatOnPaste"));
public static readonly PerLanguageOption2<bool> AutoXmlDocCommentGeneration = new PerLanguageOption2<bool>(nameof(FeatureOnOffOptions), nameof(AutoXmlDocCommentGeneration), defaultValue: true,
public static readonly PerLanguageOption2<bool> AutoXmlDocCommentGeneration = new(nameof(FeatureOnOffOptions), nameof(AutoXmlDocCommentGeneration), defaultValue: true,
storageLocations: new RoamingProfileStorageLocation(language => language == LanguageNames.VisualBasic ? "TextEditor.%LANGUAGE%.Specific.AutoComment" : "TextEditor.%LANGUAGE%.Specific.Automatic XML Doc Comment Generation"));
public static readonly PerLanguageOption2<bool> AutoInsertBlockCommentStartString = new PerLanguageOption2<bool>(nameof(FeatureOnOffOptions), nameof(AutoInsertBlockCommentStartString), defaultValue: true,
public static readonly PerLanguageOption2<bool> AutoInsertBlockCommentStartString = new(nameof(FeatureOnOffOptions), nameof(AutoInsertBlockCommentStartString), defaultValue: true,
storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.Auto Insert Block Comment Start String"));
public static readonly PerLanguageOption2<bool> PrettyListing = new PerLanguageOption2<bool>(nameof(FeatureOnOffOptions), nameof(PrettyListing), defaultValue: true,
public static readonly PerLanguageOption2<bool> PrettyListing = new(nameof(FeatureOnOffOptions), nameof(PrettyListing), defaultValue: true,
storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.PrettyListing"));
public static readonly PerLanguageOption2<bool> InlineParameterNameHints = new PerLanguageOption2<bool>(nameof(FeatureOnOffOptions), nameof(InlineParameterNameHints), defaultValue: false,
public static readonly PerLanguageOption2<bool> InlineParameterNameHints = new(nameof(FeatureOnOffOptions), nameof(InlineParameterNameHints), defaultValue: false,
storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.InlineParameterNameHints"));
public static readonly PerLanguageOption2<bool> AutoFormattingOnTyping = new PerLanguageOption2<bool>(
public static readonly PerLanguageOption2<bool> AutoFormattingOnTyping = new(
nameof(FeatureOnOffOptions), nameof(AutoFormattingOnTyping), defaultValue: true,
storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.Auto Formatting On Typing"));
public static readonly PerLanguageOption2<bool> AutoFormattingOnCloseBrace = new PerLanguageOption2<bool>(
public static readonly PerLanguageOption2<bool> AutoFormattingOnCloseBrace = new(
nameof(FeatureOnOffOptions), nameof(AutoFormattingOnCloseBrace), defaultValue: true,
storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.Auto Formatting On Close Brace"));
public static readonly PerLanguageOption2<bool> AutoFormattingOnSemicolon = new PerLanguageOption2<bool>(
public static readonly PerLanguageOption2<bool> AutoFormattingOnSemicolon = new(
nameof(FeatureOnOffOptions), nameof(AutoFormattingOnSemicolon), defaultValue: true,
storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.Auto Formatting On Semicolon"));
public static readonly PerLanguageOption2<bool> RenameTrackingPreview = new PerLanguageOption2<bool>(nameof(FeatureOnOffOptions), nameof(RenameTrackingPreview), defaultValue: true,
public static readonly PerLanguageOption2<bool> RenameTrackingPreview = new(nameof(FeatureOnOffOptions), nameof(RenameTrackingPreview), defaultValue: true,
storageLocations: new RoamingProfileStorageLocation(language => language == LanguageNames.VisualBasic ? "TextEditor.%LANGUAGE%.Specific.RenameTrackingPreview" : "TextEditor.%LANGUAGE%.Specific.Rename Tracking Preview"));
/// <summary>
......@@ -70,7 +70,7 @@ internal static class FeatureOnOffOptions
/// maintain any customized value for this setting, even through versions that have not
/// implemented this feature yet.
/// </summary>
public static readonly PerLanguageOption2<bool> RenameTracking = new PerLanguageOption2<bool>(nameof(FeatureOnOffOptions), nameof(RenameTracking), defaultValue: true);
public static readonly PerLanguageOption2<bool> RenameTracking = new(nameof(FeatureOnOffOptions), nameof(RenameTracking), defaultValue: true);
/// <summary>
/// This option is currently used by Roslyn, but we might want to implement it in the
......@@ -78,17 +78,17 @@ internal static class FeatureOnOffOptions
/// maintain any customized value for this setting, even through versions that have not
/// implemented this feature yet.
/// </summary>
public static readonly PerLanguageOption2<bool> RefactoringVerification = new PerLanguageOption2<bool>(
public static readonly PerLanguageOption2<bool> RefactoringVerification = new(
nameof(FeatureOnOffOptions), nameof(RefactoringVerification), defaultValue: false);
public static readonly PerLanguageOption2<bool> StreamingGoToImplementation = new PerLanguageOption2<bool>(
public static readonly PerLanguageOption2<bool> StreamingGoToImplementation = new(
nameof(FeatureOnOffOptions), nameof(StreamingGoToImplementation), defaultValue: true);
public static readonly Option2<bool> NavigateToDecompiledSources = new Option2<bool>(
public static readonly Option2<bool> NavigateToDecompiledSources = new(
nameof(FeatureOnOffOptions), nameof(NavigateToDecompiledSources), defaultValue: false,
storageLocations: new RoamingProfileStorageLocation($"TextEditor.{nameof(NavigateToDecompiledSources)}"));
public static readonly Option2<int> UseEnhancedColors = new Option2<int>(
public static readonly Option2<int> UseEnhancedColors = new(
nameof(FeatureOnOffOptions), nameof(UseEnhancedColors), defaultValue: 1,
storageLocations: new RoamingProfileStorageLocation("WindowManagement.Options.UseEnhancedColorsForManagedLanguages"));
}
......
......@@ -16,63 +16,63 @@ internal static class InternalFeatureOnOffOptions
{
internal const string LocalRegistryPath = StorageOptions.LocalRegistryPath;
public static readonly Option2<bool> BraceMatching = new Option2<bool>(nameof(InternalFeatureOnOffOptions), nameof(BraceMatching), defaultValue: true,
public static readonly Option2<bool> BraceMatching = new(nameof(InternalFeatureOnOffOptions), nameof(BraceMatching), defaultValue: true,
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Brace Matching"));
public static readonly Option2<bool> Classification = new Option2<bool>(nameof(InternalFeatureOnOffOptions), nameof(Classification), defaultValue: true,
public static readonly Option2<bool> Classification = new(nameof(InternalFeatureOnOffOptions), nameof(Classification), defaultValue: true,
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Classification"));
public static readonly Option2<bool> SemanticColorizer = new Option2<bool>(nameof(InternalFeatureOnOffOptions), nameof(SemanticColorizer), defaultValue: true,
public static readonly Option2<bool> SemanticColorizer = new(nameof(InternalFeatureOnOffOptions), nameof(SemanticColorizer), defaultValue: true,
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Semantic Colorizer"));
public static readonly Option2<bool> SyntacticColorizer = new Option2<bool>(nameof(InternalFeatureOnOffOptions), nameof(SyntacticColorizer), defaultValue: true,
public static readonly Option2<bool> SyntacticColorizer = new(nameof(InternalFeatureOnOffOptions), nameof(SyntacticColorizer), defaultValue: true,
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Syntactic Colorizer"));
public static readonly Option2<bool> AutomaticPairCompletion = new Option2<bool>(nameof(InternalFeatureOnOffOptions), nameof(AutomaticPairCompletion), defaultValue: true,
public static readonly Option2<bool> AutomaticPairCompletion = new(nameof(InternalFeatureOnOffOptions), nameof(AutomaticPairCompletion), defaultValue: true,
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Automatic Pair Completion"));
public static readonly Option2<bool> AutomaticLineEnder = new Option2<bool>(nameof(InternalFeatureOnOffOptions), nameof(AutomaticLineEnder), defaultValue: true,
public static readonly Option2<bool> AutomaticLineEnder = new(nameof(InternalFeatureOnOffOptions), nameof(AutomaticLineEnder), defaultValue: true,
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Automatic Line Ender"));
public static readonly Option2<bool> SmartIndenter = new Option2<bool>(nameof(InternalFeatureOnOffOptions), nameof(SmartIndenter), defaultValue: true,
public static readonly Option2<bool> SmartIndenter = new(nameof(InternalFeatureOnOffOptions), nameof(SmartIndenter), defaultValue: true,
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Smart Indenter"));
public static readonly Option2<bool> CompletionSet = new Option2<bool>(nameof(InternalFeatureOnOffOptions), nameof(CompletionSet), defaultValue: true,
public static readonly Option2<bool> CompletionSet = new(nameof(InternalFeatureOnOffOptions), nameof(CompletionSet), defaultValue: true,
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Completion Set"));
public static readonly Option2<bool> KeywordHighlight = new Option2<bool>(nameof(InternalFeatureOnOffOptions), nameof(KeywordHighlight), defaultValue: true,
public static readonly Option2<bool> KeywordHighlight = new(nameof(InternalFeatureOnOffOptions), nameof(KeywordHighlight), defaultValue: true,
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Keyword Highlight"));
public static readonly Option2<bool> QuickInfo = new Option2<bool>(nameof(InternalFeatureOnOffOptions), nameof(QuickInfo), defaultValue: true,
public static readonly Option2<bool> QuickInfo = new(nameof(InternalFeatureOnOffOptions), nameof(QuickInfo), defaultValue: true,
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Quick Info"));
public static readonly Option2<bool> Squiggles = new Option2<bool>(nameof(InternalFeatureOnOffOptions), nameof(Squiggles), defaultValue: true,
public static readonly Option2<bool> Squiggles = new(nameof(InternalFeatureOnOffOptions), nameof(Squiggles), defaultValue: true,
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Squiggles"));
public static readonly Option2<bool> FormatOnSave = new Option2<bool>(nameof(InternalFeatureOnOffOptions), nameof(FormatOnSave), defaultValue: true,
public static readonly Option2<bool> FormatOnSave = new(nameof(InternalFeatureOnOffOptions), nameof(FormatOnSave), defaultValue: true,
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "FormatOnSave"));
public static readonly Option2<bool> RenameTracking = new Option2<bool>(nameof(InternalFeatureOnOffOptions), nameof(RenameTracking), defaultValue: true,
public static readonly Option2<bool> RenameTracking = new(nameof(InternalFeatureOnOffOptions), nameof(RenameTracking), defaultValue: true,
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Rename Tracking"));
public static readonly Option2<bool> EventHookup = new Option2<bool>(nameof(InternalFeatureOnOffOptions), nameof(EventHookup), defaultValue: true,
public static readonly Option2<bool> EventHookup = new(nameof(InternalFeatureOnOffOptions), nameof(EventHookup), defaultValue: true,
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Event Hookup"));
/// Due to https://github.com/dotnet/roslyn/issues/5393, the name "Snippets" is unusable for serialization.
/// (Summary: Some builds incorrectly set it without providing a way to clear it so it exists in many registries.)
public static readonly Option2<bool> Snippets = new Option2<bool>(nameof(InternalFeatureOnOffOptions), nameof(Snippets), defaultValue: true,
public static readonly Option2<bool> Snippets = new(nameof(InternalFeatureOnOffOptions), nameof(Snippets), defaultValue: true,
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Snippets2"));
public static readonly Option2<bool> TodoComments = new Option2<bool>(nameof(InternalFeatureOnOffOptions), nameof(TodoComments), defaultValue: true,
public static readonly Option2<bool> TodoComments = new(nameof(InternalFeatureOnOffOptions), nameof(TodoComments), defaultValue: true,
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Todo Comments"));
public static readonly Option2<bool> DesignerAttributes = new Option2<bool>(nameof(InternalFeatureOnOffOptions), nameof(DesignerAttributes), defaultValue: true,
public static readonly Option2<bool> DesignerAttributes = new(nameof(InternalFeatureOnOffOptions), nameof(DesignerAttributes), defaultValue: true,
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Designer Attribute"));
public static readonly Option2<bool> BackgroundAnalysisMemoryMonitor = new Option2<bool>(nameof(InternalFeatureOnOffOptions), "FullSolutionAnalysisMemoryMonitor", defaultValue: true,
public static readonly Option2<bool> BackgroundAnalysisMemoryMonitor = new(nameof(InternalFeatureOnOffOptions), "FullSolutionAnalysisMemoryMonitor", defaultValue: true,
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Full Solution Analysis Memory Monitor"));
public static readonly Option2<bool> ProjectReferenceConversion = new Option2<bool>(nameof(InternalFeatureOnOffOptions), nameof(ProjectReferenceConversion), defaultValue: true,
public static readonly Option2<bool> ProjectReferenceConversion = new(nameof(InternalFeatureOnOffOptions), nameof(ProjectReferenceConversion), defaultValue: true,
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Project Reference Conversion"));
}
......
......@@ -6,12 +6,12 @@ namespace Microsoft.CodeAnalysis.Editor.Shared.Preview
{
internal static class PredefinedPreviewTaggerKeys
{
public static readonly object DefinitionHighlightingSpansKey = new object();
public static readonly object ReferenceHighlightingSpansKey = new object();
public static readonly object WrittenReferenceHighlightingSpansKey = new object();
public static readonly object ConflictSpansKey = new object();
public static readonly object WarningSpansKey = new object();
public static readonly object SuppressDiagnosticsSpansKey = new object();
public static readonly object StaticClassificationSpansKey = new object();
public static readonly object DefinitionHighlightingSpansKey = new();
public static readonly object ReferenceHighlightingSpansKey = new();
public static readonly object WrittenReferenceHighlightingSpansKey = new();
public static readonly object ConflictSpansKey = new();
public static readonly object WarningSpansKey = new();
public static readonly object SuppressDiagnosticsSpansKey = new();
public static readonly object StaticClassificationSpansKey = new();
}
}
......@@ -18,7 +18,7 @@ internal partial class TaggerEventSources
private class CompletionClosedEventSource : AbstractTaggerEventSource
{
private readonly IIntellisenseSessionStack _sessionStack;
private readonly HashSet<ICompletionSession> _trackedSessions = new HashSet<ICompletionSession>();
private readonly HashSet<ICompletionSession> _trackedSessions = new();
public CompletionClosedEventSource(
IIntellisenseSessionStack sessionStack,
......
......@@ -10,7 +10,7 @@ internal class ConflictTag : TextMarkerTag
{
public const string TagId = "RoslynConflictTag";
public static readonly ConflictTag Instance = new ConflictTag();
public static readonly ConflictTag Instance = new();
private ConflictTag()
: base(TagId)
......
......@@ -10,7 +10,7 @@ internal class PreviewWarningTag : TextMarkerTag
{
public const string TagId = "RoslynPreviewWarningTag";
public static readonly PreviewWarningTag Instance = new PreviewWarningTag();
public static readonly PreviewWarningTag Instance = new();
private PreviewWarningTag()
: base(TagId)
......
......@@ -32,14 +32,14 @@ internal class AsynchronousSerialWorkQueue : ForegroundThreadAffinitizedObject
private readonly IAsynchronousOperationListener _asyncListener;
// Lock for serializing access to these objects.
private readonly object _gate = new object();
private readonly object _gate = new();
// The current task we are executing on the background. Kept around so we can serialize
// background tasks by continually calling 'SafeContinueWith' on this task.
private Task _currentBackgroundTask;
// The cancellation source for the current chain of work.
private CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource();
private CancellationTokenSource _cancellationTokenSource = new();
#endregion
......
......@@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Editor.Shared.Utilities
/// </summary>
internal class AutomaticCodeChangeMergePolicy : IMergeTextUndoTransactionPolicy
{
public static readonly AutomaticCodeChangeMergePolicy Instance = new AutomaticCodeChangeMergePolicy();
public static readonly AutomaticCodeChangeMergePolicy Instance = new();
public bool CanMerge(ITextUndoTransaction newerTransaction, ITextUndoTransaction olderTransaction)
{
......
......@@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Editor.Shared.Utilities
{
internal class LinkedEditsTracker
{
private static readonly object s_propagateSpansEditTag = new object();
private static readonly object s_propagateSpansEditTag = new();
private readonly ITextBuffer _subjectBuffer;
......
......@@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Editor.Shared.Utilities
{
internal class ResettableDelay
{
public static readonly ResettableDelay CompletedDelay = new ResettableDelay();
public static readonly ResettableDelay CompletedDelay = new();
private readonly int _delayInMilliseconds;
private readonly IExpeditableDelaySource _expeditableDelaySource;
......
......@@ -25,7 +25,7 @@ namespace Microsoft.CodeAnalysis.Editor.Shared.Utilities
[Shared]
internal sealed class ThreadingContext : IThreadingContext, IDisposable
{
private readonly CancellationTokenSource _disposalTokenSource = new CancellationTokenSource();
private readonly CancellationTokenSource _disposalTokenSource = new();
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
......
......@@ -33,7 +33,7 @@ public DeltaInput(byte* pBuf_, int cbBuf_, bool editable_) : this()
editable = editable_;
}
public static DeltaInput Empty = new DeltaInput();
public static DeltaInput Empty = new();
}
[StructLayout(LayoutKind.Sequential)]
......
......@@ -42,7 +42,7 @@ internal partial class SymbolSearchUpdateEngine
private const int AddReferenceDatabaseTextFileFormatVersion = 1;
private readonly ConcurrentDictionary<string, object> _sourceToUpdateSentinel =
new ConcurrentDictionary<string, object>();
new();
// Interfaces that abstract out the external functionality we need. Used so we can easily
// mock behavior during tests.
......
......@@ -28,7 +28,7 @@ namespace Microsoft.CodeAnalysis.SymbolSearch
internal partial class SymbolSearchUpdateEngine : ISymbolSearchUpdateEngine
{
private readonly ConcurrentDictionary<string, IAddReferenceDatabaseWrapper> _sourceToDatabase =
new ConcurrentDictionary<string, IAddReferenceDatabaseWrapper>();
new();
/// <summary>
/// Don't call directly. Use <see cref="SymbolSearchUpdateEngineFactory"/> instead.
......
......@@ -48,7 +48,7 @@ private class BatchChangeNotifier : ForegroundThreadAffinitizedObject
// a list that will be updated all at once the timer actually runs.
private bool _notificationRequestEnqueued;
private readonly SortedDictionary<int, NormalizedSnapshotSpanCollection> _snapshotVersionToSpansMap =
new SortedDictionary<int, NormalizedSnapshotSpanCollection>();
new();
/// <summary>
/// True if we are currently suppressing UI updates. While suppressed we still continue
......
......@@ -87,7 +87,7 @@ private sealed partial class TagSource : ForegroundThreadAffinitizedObject
/// if our ref count actually reaches 0. Otherwise, we always try to compute the initial
/// set of tags for our view/buffer.
/// </summary>
private readonly CancellationTokenSource _initialComputationCancellationTokenSource = new CancellationTokenSource();
private readonly CancellationTokenSource _initialComputationCancellationTokenSource = new();
public TaggerDelay AddedTagNotificationDelay => _dataSource.AddedTagNotificationDelay;
public TaggerDelay RemovedTagNotificationDelay => _dataSource.RemovedTagNotificationDelay;
......
......@@ -27,7 +27,7 @@ namespace Microsoft.CodeAnalysis.Editor.Tagging
/// </summary>
internal abstract partial class AbstractAsynchronousTaggerProvider<TTag> : ForegroundThreadAffinitizedObject where TTag : ITag
{
private readonly object _uniqueKey = new object();
private readonly object _uniqueKey = new();
private readonly IForegroundNotificationService _notificationService;
protected readonly IAsynchronousOperationListener AsyncListener;
......@@ -243,7 +243,7 @@ protected virtual void ProduceTagsSynchronously(TaggerContext<TTag> context, Doc
}
internal TestAccessor GetTestAccessor()
=> new TestAccessor(this);
=> new(this);
private struct DiffResult
{
......
......@@ -16,7 +16,7 @@ namespace Microsoft.CodeAnalysis.Editor.Undo
[ExportWorkspaceService(typeof(ISourceTextUndoService), ServiceLayer.Editor), Shared]
internal sealed class EditorSourceTextUndoService : ISourceTextUndoService
{
private readonly Dictionary<SourceText, SourceTextUndoTransaction> _transactions = new Dictionary<SourceText, SourceTextUndoTransaction>();
private readonly Dictionary<SourceText, SourceTextUndoTransaction> _transactions = new();
private readonly ITextUndoHistoryRegistry _undoHistoryRegistry;
......
......@@ -17,7 +17,7 @@ internal class NoOpGlobalUndoServiceFactory : IWorkspaceServiceFactory
{
public static readonly IWorkspaceGlobalUndoTransaction Transaction = new NoOpUndoTransaction();
private readonly NoOpGlobalUndoService _singleton = new NoOpGlobalUndoService();
private readonly NoOpGlobalUndoService _singleton = new();
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册