Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Targeting IDE projects to .NET 6 #66655

Merged
merged 11 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private InfoCache(INamedTypeSymbol rangeType, INamedTypeSymbol stringType, IName
{
var substringMethod = stringType.GetMembers(nameof(string.Substring))
.OfType<IMethodSymbol>()
.FirstOrDefault(m => IsTwoArgumentSliceLikeMethod(m));
.First(m => IsTwoArgumentSliceLikeMethod(m));
genlu marked this conversation as resolved.
Show resolved Hide resolved

_methodToMemberInfo[substringMethod] = ComputeMemberInfo(substringMethod, requireRangeMember: false);
}
Expand All @@ -65,7 +65,7 @@ public static bool TryCreate(Compilation compilation, [NotNullWhen(true)] out In
return true;
}

private static IMethodSymbol GetSliceLikeMethod(INamedTypeSymbol namedType)
private static IMethodSymbol? GetSliceLikeMethod(INamedTypeSymbol namedType)
=> namedType.GetMembers()
.OfType<IMethodSymbol>()
.Where(m => IsTwoArgumentSliceLikeMethod(m))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ internal static class Helpers
/// <summary>
/// Find an `int MyType.Count` or `int MyType.Length` property.
/// </summary>
public static IPropertySymbol TryGetLengthOrCountProperty(ITypeSymbol namedType)
public static IPropertySymbol? TryGetLengthOrCountProperty(ITypeSymbol namedType)
=> TryGetNoArgInt32Property(namedType, nameof(string.Length)) ??
TryGetNoArgInt32Property(namedType, nameof(ICollection.Count));

/// <summary>
/// Tried to find a public, non-static, int-returning property in the given type with the
/// specified <paramref name="name"/>.
/// </summary>
public static IPropertySymbol TryGetNoArgInt32Property(ITypeSymbol type, string name)
public static IPropertySymbol? TryGetNoArgInt32Property(ITypeSymbol type, string name)
=> type.GetMembers(name)
.OfType<IPropertySymbol>()
.Where(p => IsPublicInstance(p) &&
Expand Down Expand Up @@ -124,7 +124,7 @@ private static bool IsSliceSecondParameter(IParameterSymbol parameter)
/// provided <paramref name="parameterType"/> and must return the provided <paramref
/// name="returnType"/>.
/// </summary>
public static IPropertySymbol GetIndexer(ITypeSymbol type, ITypeSymbol parameterType, ITypeSymbol returnType)
public static IPropertySymbol? GetIndexer(ITypeSymbol type, ITypeSymbol parameterType, ITypeSymbol returnType)
=> type.GetMembers(WellKnownMemberNames.Indexer)
.OfType<IPropertySymbol>()
.Where(p => p.IsIndexer &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
{
var diagnostic = context.Diagnostics.First();
var serializedNamingStyle = diagnostic.Properties[nameof(NamingStyle)];
Contract.ThrowIfNull(serializedNamingStyle);

var style = NamingStyle.FromXElement(XElement.Parse(serializedNamingStyle));

var document = context.Document;
Expand Down
3 changes: 3 additions & 0 deletions src/Compilers/Core/MSBuildTask/RCWForCurrentContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ private void CleanupComObject()
_shouldReleaseRCW &&
Marshal.IsComObject(_rcwForCurrentCtx))
{
#if NETCOREAPP
Debug.Assert(OperatingSystem.IsWindows());
#endif
Marshal.ReleaseComObject(_rcwForCurrentCtx);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Copied from:
// https://github.com/dotnet/runtime/blob/fdd104ec5e1d0d2aa24a6723995a98d0124f724b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/CompilerFeatureRequiredAttribute.cs

#if !NET6_0_OR_GREATER
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would #if NETSTANDARD be better, so that it is not updated every time we bump version?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems this type is not in .net 6 either, only in net 7

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's the runtime PR addign those types
dotnet/runtime#64287

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to change this directive (now or in the future). net7.0 falls under NET6_0_OR_GREATER.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the problem is we are compiled for .NET6, which would exclude this from code, but the type only available in .NET7

#if !NET7_0_OR_GREATER

namespace System.Runtime.CompilerServices
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System;
using System.IO;
using System.Runtime.Versioning;

namespace Roslyn.Utilities
{
Expand All @@ -14,7 +15,11 @@ namespace Roslyn.Utilities
/// </summary>
internal static class PlatformInformation
{
#if NET5_0_OR_GREATER
[SupportedOSPlatformGuard("windows")]
#endif
public static bool IsWindows => Path.DirectorySeparatorChar == '\\';

public static bool IsUnix => Path.DirectorySeparatorChar == '/';
public static bool IsRunningOnMono
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Copied from:
// https://github.com/dotnet/runtime/blob/fdd104ec5e1d0d2aa24a6723995a98d0124f724b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RequiredMemberAttribute.cs

#if !NET6_0_OR_GREATER
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would #if NETSTANDARD be better, so that it is not updated every time we bump version?

#if !NET7_0_OR_GREATER

namespace System.Runtime.CompilerServices
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Copied from:
// https://github.com/dotnet/runtime/blob/fdd104ec5e1d0d2aa24a6723995a98d0124f724b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/SetsRequiredMembersAttribute.cs

#if !NET6_0_OR_GREATER
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would #if NETSTANDARD be better, so that it is not updated every time we bump version?

#if !NET7_0_OR_GREATER

namespace System.Diagnostics.CodeAnalysis
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,17 @@ internal sealed class GacFileResolver : IEquatable<GacFileResolver>
/// Returns true if GAC is available on the current platform.
/// </summary>
public static bool IsAvailable
// Since mscorlib may not be loaded from the GAC on Mono, also check if the platform is Mono which supports a GAC.
=> typeof(object).Assembly.GlobalAssemblyCache || PlatformInformation.IsRunningOnMono;
{
get
{
// Since mscorlib may not be loaded from the GAC on Mono, also check if the platform is Mono which supports a GAC.
return
#if !NETCOREAPP
typeof(object).Assembly.GlobalAssemblyCache ||
#endif
PlatformInformation.IsRunningOnMono;
}
}

/// <summary>
/// Architecture filter used when resolving assembly references.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>Microsoft.CodeAnalysis.Editor.CSharp</RootNamespace>
<TargetFrameworks>netcoreapp3.1;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ApplyNgenOptimization Condition="'$(TargetFramework)' == 'netstandard2.0'">full</ApplyNgenOptimization>
<!-- NuGet -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Microsoft.CodeAnalysis.Editor.EditorConfigSettings.Updater;
using Microsoft.CodeAnalysis.EditorConfig;
using Microsoft.CodeAnalysis.Shared.Extensions;
using RoslynEnumerableExtensions = Microsoft.CodeAnalysis.Editor.EditorConfigSettings.Extensions.EnumerableExtensions;

namespace Microsoft.CodeAnalysis.Editor.EditorConfigSettings.DataProvider.Analyzer
{
Expand All @@ -28,7 +29,7 @@ public AnalyzerSettingsProvider(string fileName, AnalyzerSettingsUpdater setting

protected override void UpdateOptions(TieredAnalyzerConfigOptions options, ImmutableArray<Project> projectsInScope)
{
var analyzerReferences = projectsInScope.SelectMany(p => p.AnalyzerReferences).DistinctBy(a => a.Id).ToImmutableArray();
var analyzerReferences = RoslynEnumerableExtensions.DistinctBy(projectsInScope.SelectMany(p => p.AnalyzerReferences), a => a.Id).ToImmutableArray();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually need the extension method?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can unify them to BCL implementation, but I'd keep the original logic in this PR

foreach (var analyzerReference in analyzerReferences)
{
var configSettings = GetSettings(analyzerReference, options.EditorConfigOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Microsoft.CodeAnalysis.Editor.EditorConfigSettings.Extensions;
using Microsoft.CodeAnalysis.Editor.EditorConfigSettings.Updater;
using Microsoft.CodeAnalysis.Options;
using RoslynEnumerableExtensions = Microsoft.CodeAnalysis.Editor.EditorConfigSettings.Extensions.EnumerableExtensions;

namespace Microsoft.CodeAnalysis.Editor.EditorConfigSettings.DataProvider.NamingStyles
{
Expand All @@ -29,7 +30,7 @@ protected override void UpdateOptions(TieredAnalyzerConfigOptions options, Immut

var fileName = (location.LocationKind != LocationKind.VisualStudio) ? options.EditorConfigFileName : null;
var namingRules = namingPreferences.NamingRules.Select(r => r.GetRule(namingPreferences));
var allStyles = namingPreferences.NamingStyles.DistinctBy(s => s.Name).ToArray();
var allStyles = RoslynEnumerableExtensions.DistinctBy(namingPreferences.NamingStyles, s => s.Name).ToArray();
var namingStyles = namingRules.Select(namingRule => new NamingStyleSetting(namingRule, allStyles, SettingsUpdater, fileName));

AddRange(namingStyles);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ protected SettingsProviderBase(string fileName, TOptionsUpdater settingsUpdater,
protected void Update()
{
var givenFolder = new DirectoryInfo(FileName).Parent;
if (givenFolder is null)
{
return;
}

var solution = Workspace.CurrentSolution;
var projects = solution.GetProjectsUnderEditorConfigFile(FileName);
var project = projects.FirstOrDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Text;
using static Microsoft.CodeAnalysis.EditorConfig.Parsing.NamingStyles.EditorConfigNamingStylesParser;
using RoslynEnumerableExtensions = Microsoft.CodeAnalysis.Editor.EditorConfigSettings.Extensions.EnumerableExtensions;

namespace Microsoft.CodeAnalysis.Editor.EditorConfigSettings.Updater
{
Expand Down Expand Up @@ -59,7 +60,7 @@ public NamingStyleSettingsUpdater(Workspace workspace, IGlobalOptionService glob
{
var allCurrentStyles = result.Rules.Select(x => x.NamingScheme).Distinct().Select(x => (x, style: x.AsNamingStyle()));
var styleParseResult = TryGetStyleParseResult(prevStyle, allCurrentStyles);
var allDistinctStyles = allCurrentStyles.Select(x => x.style).DistinctBy(x => x.Name).ToArray();
var allDistinctStyles = RoslynEnumerableExtensions.DistinctBy(allCurrentStyles.Select(x => x.style), x => x.Name).ToArray();
if (styleParseResult is (NamingScheme namingScheme, NamingStyle style))
{
var newLine = $"dotnet_naming_rule.{parseResult.RuleName.Value}.style = {namingScheme.OptionName.Value}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async Task QueueUpdateAsync()
}
}

public async Task<SourceText?> GetChangedEditorConfigAsync(AnalyzerConfigDocument analyzerConfigDocument, CancellationToken token)
public async Task<SourceText?> GetChangedEditorConfigAsync(AnalyzerConfigDocument? analyzerConfigDocument, CancellationToken token)
{
if (analyzerConfigDocument is null)
return null;
Expand Down Expand Up @@ -81,7 +81,7 @@ async Task QueueUpdateAsync()
return null;
}

var originalText = await analyzerConfigDocument.GetTextAsync(token).ConfigureAwait(false);
var originalText = await analyzerConfigDocument!.GetTextAsync(token).ConfigureAwait(false);
return newText.GetTextChanges(originalText);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public ServiceWrapper(IVSTypeScriptGoToDefinitionService service)
public async Task<IEnumerable<INavigableItem>?> FindDefinitionsAsync(Document document, int position, CancellationToken cancellationToken)
{
var items = await _service.FindDefinitionsAsync(document, position, cancellationToken).ConfigureAwait(false);
return items.Select(item => new VSTypeScriptNavigableItemWrapper(item));
return items?.Select(item => new VSTypeScriptNavigableItemWrapper(item));
}

public bool TryGoToDefinition(Document document, int position, CancellationToken cancellationToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>Microsoft.CodeAnalysis</RootNamespace>
<TargetFrameworks>netcoreapp3.1;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>$(DefineConstants);EDITOR_FEATURES</DefineConstants>
<ApplyNgenOptimization Condition="'$(TargetFramework)' == 'netstandard2.0'">full</ApplyNgenOptimization>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.VisualStudio.Text.Classification;
using Roslyn.Utilities;
using ReferenceEqualityComparer = Roslyn.Utilities.ReferenceEqualityComparer;

namespace Microsoft.CodeAnalysis.Editor.Shared.Utilities
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>Microsoft.CodeAnalysis.Text</RootNamespace>
<TargetFrameworks>netcoreapp3.1;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks>
<ApplyNgenOptimization Condition="'$(TargetFramework)' == 'netstandard2.0'">full</ApplyNgenOptimization>

<!-- NuGet -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFrameworks>netcoreapp3.1;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks>
<RootNamespace></RootNamespace>
<ApplyNgenOptimization Condition="'$(TargetFramework)' == 'netstandard2.0'">full</ApplyNgenOptimization>
<!-- NuGet -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// 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;
using System.Collections.Immutable;
using System.Composition;
using System.Diagnostics.CodeAnalysis;
Expand All @@ -15,8 +14,6 @@
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Editing;
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
Expand Down Expand Up @@ -100,7 +97,8 @@ protected override async Task FixAllAsync(
var root = (CompilationUnitSyntax)await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
var options = await document.GetCSharpCodeFixOptionsProviderAsync(optionsProvider, cancellationToken).ConfigureAwait(false);
var namespaceDecl = root.DescendantNodes().OfType<BaseNamespaceDeclarationSyntax>().FirstOrDefault();
if (!CanOfferRefactoring(namespaceDecl, root, options, out var info)
if (namespaceDecl is null
|| !CanOfferRefactoring(namespaceDecl, root, options, out var info)
genlu marked this conversation as resolved.
Show resolved Hide resolved
|| info.Value.equivalenceKey != equivalenceKey)
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>Microsoft.CodeAnalysis.CSharp</RootNamespace>
<TargetFrameworks>netcoreapp3.1;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks>
<ApplyNgenOptimization Condition="'$(TargetFramework)' == 'netstandard2.0'">full</ApplyNgenOptimization>

<!-- NuGet -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private static string GetIndentation(Document document, SyntaxNode node, SyntaxF
protected override async Task<Document> AddIndentationToDocumentAsync(Document document, int position, ISyntaxFacts syntaxFacts, CancellationToken cancellationToken)
{
var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
var snippet = root.GetAnnotatedNodes(_findSnippetAnnotation).FirstOrDefault();
var snippet = root.GetAnnotatedNodes(_findSnippetAnnotation).First();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI @akhera99 for snippet related change

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't trust this at all. @akhera99 how do you know you will absolutely find the node here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured it would given that, when we annotate the added snippet, we throw if the added snippet can't be found. I think it's safer to keep it as FirstOrDefault, but I believe we bail out earlier in case it's not found.


var syntaxFormattingOptions = await document.GetSyntaxFormattingOptionsAsync(fallbackOptions: null, cancellationToken).ConfigureAwait(false);
var indentationString = GetIndentation(document, snippet, syntaxFormattingOptions, cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private static string GetIndentationString(Document document, ElseClauseSyntax e
protected override async Task<Document> AddIndentationToDocumentAsync(Document document, int position, ISyntaxFacts syntaxFacts, CancellationToken cancellationToken)
{
var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
var snippet = root.GetAnnotatedNodes(_findSnippetAnnotation).FirstOrDefault();
var snippet = root.GetAnnotatedNodes(_findSnippetAnnotation).First();
genlu marked this conversation as resolved.
Show resolved Hide resolved
var elseClauseSyntax = (ElseClauseSyntax)snippet;

var syntaxFormattingOptions = await document.GetSyntaxFormattingOptionsAsync(fallbackOptions: null, cancellationToken).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private static string GetIndentation(Document document, SyntaxNode node, SyntaxF
protected override async Task<Document> AddIndentationToDocumentAsync(Document document, int position, ISyntaxFacts syntaxFacts, CancellationToken cancellationToken)
{
var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
var snippet = root.GetAnnotatedNodes(_findSnippetAnnotation).FirstOrDefault();
var snippet = root.GetAnnotatedNodes(_findSnippetAnnotation).First();

var syntaxFormattingOptions = await document.GetSyntaxFormattingOptionsAsync(fallbackOptions: null, cancellationToken).ConfigureAwait(false);
var indentationString = GetIndentation(document, snippet, syntaxFormattingOptions, cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private static string GetIndentation(Document document, SyntaxNode node, SyntaxF
protected override async Task<Document> AddIndentationToDocumentAsync(Document document, int position, ISyntaxFacts syntaxFacts, CancellationToken cancellationToken)
{
var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
var snippet = root.GetAnnotatedNodes(_findSnippetAnnotation).FirstOrDefault();
var snippet = root.GetAnnotatedNodes(_findSnippetAnnotation).First();

var syntaxFormattingOptions = await document.GetSyntaxFormattingOptionsAsync(fallbackOptions: null, cancellationToken).ConfigureAwait(false);
var indentationString = GetIndentation(document, snippet, syntaxFormattingOptions, cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private static string GetIndentation(Document document, SyntaxNode node, SyntaxF
protected override async Task<Document> AddIndentationToDocumentAsync(Document document, int position, ISyntaxFacts syntaxFacts, CancellationToken cancellationToken)
{
var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
var snippet = root.GetAnnotatedNodes(_findSnippetAnnotation).FirstOrDefault();
var snippet = root.GetAnnotatedNodes(_findSnippetAnnotation).First();

var syntaxFormattingOptions = await document.GetSyntaxFormattingOptionsAsync(fallbackOptions: null, cancellationToken).ConfigureAwait(false);
var indentationString = GetIndentation(document, snippet, syntaxFormattingOptions, cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private static string GetIndentation(Document document, SyntaxNode node, SyntaxF
protected override async Task<Document> AddIndentationToDocumentAsync(Document document, int position, ISyntaxFacts syntaxFacts, CancellationToken cancellationToken)
{
var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
var snippet = root.GetAnnotatedNodes(_findSnippetAnnotation).FirstOrDefault();
var snippet = root.GetAnnotatedNodes(_findSnippetAnnotation).First();

var syntaxFormattingOptions = await document.GetSyntaxFormattingOptionsAsync(fallbackOptions: null, cancellationToken).ConfigureAwait(false);
var indentationString = GetIndentation(document, snippet, syntaxFormattingOptions, cancellationToken);
Expand Down
Loading