Skip to content

Commit

Permalink
Merge pull request #74697 from CyrusNajmabadi/layering
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi authored Aug 14, 2024
2 parents bba7cea + e636ac2 commit 9d57657
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,7 @@ public static async Task MakeLocalFunctionStaticAsync(
}
}

#if CODE_STYLE
var info = new CSharpCodeGenerationContextInfo(
CodeGenerationContext.Default, CSharpCodeGenerationOptions.Default, new CSharpCodeGenerationService(document.Project.GetExtendedLanguageServices().LanguageServices), root.SyntaxTree.Options.LanguageVersion());
#else
var info = await document.GetCodeGenerationInfoAsync(CodeGenerationContext.Default, cancellationToken).ConfigureAwait(false);
#endif

// Updates the local function declaration with variables passed in as parameters
syntaxEditor.ReplaceNode(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.Formatting;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editing;
Expand Down Expand Up @@ -144,11 +145,8 @@ static async Task<SeparatedSyntaxList<ArgumentSyntax>> GetArgumentsAsync(
return default;

var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
#if CODE_STYLE
var formattingOptions = SyntaxFormattingOptions.CommonDefaults;
#else
var formattingOptions = await document.GetSyntaxFormattingOptionsAsync(cancellationToken).ConfigureAwait(false);
#endif
var formattingOptions = await document.GetSyntaxFormattingOptionsAsync(
CSharpSyntaxFormatting.Instance, cancellationToken).ConfigureAwait(false);

using var _ = ArrayBuilder<SyntaxNodeOrToken>.GetInstance(out var nodesAndTokens);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,8 @@ protected override async Task FixAllAsync(
.OrderBy(d => d.Location.SourceSpan.End)
.SelectAsArray(d => (ObjectCreationExpressionSyntax)d.AdditionalLocations[0].FindNode(getInnermostNodeForTie: true, cancellationToken));

#if CODE_STYLE
var options = CSharpSimplifierOptions.Default;
#else
var options = (CSharpSimplifierOptions)await document.GetSimplifierOptionsAsync(cancellationToken).ConfigureAwait(false);
#endif
var options = (CSharpSimplifierOptions)await document.GetSimplifierOptionsAsync(
CSharpSimplification.Instance, cancellationToken).ConfigureAwait(false);

// Bulk apply these, except at the expression level. One fix at the expression level may prevent another fix
// from being valid. For example: `new List<C> { new C() }`. If we apply the fix to the outer `List<C>`, we
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,7 @@ protected override async Task FixAllAsync(

if (languageVersion >= LanguageVersion.CSharp8)
{
#if CODE_STYLE
var info = new CSharpCodeGenerationContextInfo(
CodeGenerationContext.Default, CSharpCodeGenerationOptions.Default, new CSharpCodeGenerationService(document.Project.GetExtendedLanguageServices().LanguageServices), root.SyntaxTree.Options.LanguageVersion());
#else
var info = await document.GetCodeGenerationInfoAsync(CodeGenerationContext.Default, cancellationToken).ConfigureAwait(false);
#endif

var options = (CSharpCodeGenerationOptions)info.Options;
makeStaticIfPossible = options.PreferStaticLocalFunction.Value;
Expand Down

0 comments on commit 9d57657

Please sign in to comment.