提交 63c48cad 编写于 作者: A Ankita Khera

Added threading assertions

上级 42cf7632
......@@ -6,6 +6,7 @@
using System;
using System.Collections.Generic;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Classification;
using Microsoft.VisualStudio.Text.Editor;
......@@ -38,12 +39,14 @@ internal sealed class InlineParameterNameHintsTagger : ITagger<IntraTextAdornmen
private readonly IClassificationFormatMap _formatMap;
private TextFormattingRunProperties? _format;
private readonly IClassificationType _hint;
private readonly ForegroundThreadAffinitizedObject _threadAffinitizedObject;
public event EventHandler<SnapshotSpanEventArgs>? TagsChanged;
public InlineParameterNameHintsTagger(InlineParameterNameHintsTaggerProvider taggerProvider, ITextView textView, ITextBuffer buffer, ITagAggregator<InlineParameterNameHintDataTag> tagAggregator)
{
_cache = new List<ITagSpan<IntraTextAdornmentTag>>();
_threadAffinitizedObject = new ForegroundThreadAffinitizedObject(taggerProvider.ThreadingContext);
_textView = textView;
_buffer = buffer;
_tagAggregator = tagAggregator;
......@@ -55,6 +58,7 @@ public InlineParameterNameHintsTagger(InlineParameterNameHintsTaggerProvider tag
private void OnClassificationFormatMappingChanged(object sender, EventArgs e)
{
_threadAffinitizedObject.AssertIsForeground();
if (_format != null)
{
_format = null;
......@@ -76,8 +80,8 @@ private TextFormattingRunProperties Format
{
get
{
_threadAffinitizedObject.AssertIsForeground();
_format ??= _formatMap.GetTextProperties(_hint);
return _format;
}
}
......
......@@ -4,6 +4,7 @@
using System;
using System.ComponentModel.Composition;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Classification;
......@@ -26,18 +27,22 @@ internal class InlineParameterNameHintsTaggerProvider : IViewTaggerProvider
private readonly IBufferTagAggregatorFactoryService _bufferTagAggregatorFactoryService;
public readonly IClassificationFormatMapService ClassificationFormatMapService;
public readonly IClassificationTypeRegistryService ClassificationTypeRegistryService;
public readonly IThreadingContext ThreadingContext;
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public InlineParameterNameHintsTaggerProvider(IBufferTagAggregatorFactoryService bufferTagAggregatorFactoryService,
IClassificationFormatMapService classificationFormatMapService,
IClassificationTypeRegistryService classificationTypeRegistryService)
IClassificationFormatMapService classificationFormatMapService,
IClassificationTypeRegistryService classificationTypeRegistryService,
IThreadingContext threadingContext)
{
_bufferTagAggregatorFactoryService = bufferTagAggregatorFactoryService;
this.ClassificationFormatMapService = classificationFormatMapService;
this.ClassificationTypeRegistryService = classificationTypeRegistryService;
this.ThreadingContext = threadingContext;
}
public ITagger<T> CreateTagger<T>(ITextView textView, ITextBuffer buffer) where T : ITag
{
var tagAggregator = _bufferTagAggregatorFactoryService.CreateTagAggregator<InlineParameterNameHintDataTag>(buffer);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册