/
githubmirror
/
roslyn
Обзор
Документация
Войти
/
githubmirror
/
roslyn
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/EditorFeatures/Text/Shared/Extensions/TextSpanExtensions.cs
33 строки
1 KB
Cyrus Najmabadi
Use implicit object creation expressions
13 сен 2025, 01:48
13 сен 2025, 01:48
4c6a36a
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Diagnostics; using Microsoft.VisualStudio.Text; namespace Microsoft.CodeAnalysis.Text.Shared.Extensions; internal static class TextSpanExtensions { /// <summary> /// Convert a <see cref="TextSpan"/> instance to a <see cref="TextSpan"/>. /// </summary> public static Span ToSpan(this TextSpan textSpan) => new(textSpan.Start, textSpan.Length); /// <summary> /// Add an offset to a <see cref="TextSpan"/>. /// </summary> public static TextSpan MoveTo(this TextSpan textSpan, int offset) => new(textSpan.Start + offset, textSpan.Length); /// <summary> /// Convert a <see cref="TextSpan"/> to a <see cref="SnapshotSpan"/> on the given <see cref="ITextSnapshot"/> instance /// </summary> public static SnapshotSpan ToSnapshotSpan(this TextSpan textSpan, ITextSnapshot snapshot) { Debug.Assert(snapshot != null); var span = textSpan.ToSpan(); return new SnapshotSpan(snapshot, span); } }