public static SourceText From( ITextBufferCloneService?textBufferCloneService, ITextSnapshot editorSnapshot ) { if (editorSnapshot == null) { throw new ArgumentNullException(nameof(editorSnapshot)); } if (!s_textSnapshotMap.TryGetValue(editorSnapshot, out var snapshot)) { // Explicitly obtain the TextBufferContainer before calling GetValue to avoid reentrancy in // ConditionalWeakTable. https://github.com/dotnet/roslyn/issues/28256 var container = TextBufferContainer.From(editorSnapshot.TextBuffer); // Avoid capturing `textBufferCloneServiceOpt` on the fast path var tempTextBufferCloneService = textBufferCloneService; snapshot = s_textSnapshotMap.GetValue( editorSnapshot, s => new SnapshotSourceText(tempTextBufferCloneService, s, container) ); } return(snapshot); }
private SnapshotSourceText(ITextSnapshot editorSnapshot) { Contract.ThrowIfNull(editorSnapshot); this.EditorSnapshot = editorSnapshot; _containerOpt = TextBufferContainer.From(editorSnapshot.TextBuffer); _reiteratedVersion = editorSnapshot.Version.ReiteratedVersionNumber; }
private SnapshotSourceText(ITextSnapshot editorSnapshot, Encoding encodingOpt) { Contract.ThrowIfNull(editorSnapshot); this.RoslynSnapshot = TextBufferMapper.ToRoslyn(editorSnapshot); _containerOpt = TextBufferContainer.From(editorSnapshot.TextBuffer); _reiteratedVersion = editorSnapshot.Version.ReiteratedVersionNumber; _encodingOpt = encodingOpt; }
private SnapshotSourceText(ITextBufferCloneService textBufferCloneServiceOpt, ITextSnapshot editorSnapshot) : this(textBufferCloneServiceOpt, editorSnapshot, TextBufferContainer.From(editorSnapshot.TextBuffer)) { }
public static SourceTextContainer AsTextContainer(this ITextBuffer buffer) => TextBufferContainer.From(buffer);
public static SourceTextContainer AsTextContainer(this ITextBuffer buffer) { return(TextBufferContainer.From(buffer)); }
private SnapshotSourceText(ITextSnapshot editorSnapshot) : this(editorSnapshot, TextBufferContainer.From(editorSnapshot.TextBuffer)) { }