Skip to content

Commit

Permalink
Merge branch 'syncPerfTests' into syncLess
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi committed Apr 9, 2024
2 parents 67dd1ac + ba4b563 commit e603563
Show file tree
Hide file tree
Showing 126 changed files with 851 additions and 705 deletions.
2 changes: 1 addition & 1 deletion eng/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
<PackageVersion Include="Microsoft.VisualStudio.RemoteControl" Version="16.3.52" />
<PackageVersion Include="Microsoft.VisualStudio.RpcContracts" Version="17.10.3-preview" />
<PackageVersion Include="Microsoft.VisualStudio.Shell.15.0" Version="17.10.234-preview.1" />
<PackageVersion Include="Microsoft.VisualStudio.Telemetry" Version="17.9.102" />
<PackageVersion Include="Microsoft.VisualStudio.Telemetry" Version="17.11.3" />
<PackageVersion Include="Microsoft.VisualStudio.Text.Data" Version="$(MicrosoftVisualStudioCoreVersion)" />
<PackageVersion Include="Microsoft.VisualStudio.Text.Logic" Version="$(MicrosoftVisualStudioCoreVersion)" />
<PackageVersion Include="Microsoft.VisualStudio.Text.UI" Version="$(MicrosoftVisualStudioCoreVersion)" />
Expand Down
12 changes: 6 additions & 6 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="8.0.0-beta.24179.4">
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="8.0.0-beta.24204.3">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>fc2b7849b25c4a21457feb6da5fc7c9806a80976</Sha>
<Sha>188340e12c0a372b1681ad6a5e72c608021efdba</Sha>
</Dependency>
<!-- Intermediate is necessary for source build. -->
<Dependency Name="Microsoft.SourceBuild.Intermediate.arcade" Version="8.0.0-beta.24179.4">
<Dependency Name="Microsoft.SourceBuild.Intermediate.arcade" Version="8.0.0-beta.24204.3">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>fc2b7849b25c4a21457feb6da5fc7c9806a80976</Sha>
<Sha>188340e12c0a372b1681ad6a5e72c608021efdba</Sha>
<SourceBuild RepoName="arcade" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.DotNet.XliffTasks" Version="1.0.0-beta.23475.1" CoherentParentDependency="Microsoft.DotNet.Arcade.Sdk">
Expand All @@ -144,9 +144,9 @@
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>5d10d428050c0d6afef30a072c4ae68776621877</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="8.0.0-beta.24179.4">
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="8.0.0-beta.24204.3">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>fc2b7849b25c4a21457feb6da5fc7c9806a80976</Sha>
<Sha>188340e12c0a372b1681ad6a5e72c608021efdba</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0-preview.23468.1">
<Uri>https://github.com/dotnet/roslyn-analyzers</Uri>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ parameters:

steps:
- ${{ if eq(parameters.disableComponentGovernance, 'true') }}:
- script: "echo ##vso[task.setvariable variable=skipComponentGovernanceDetection]true"
- script: echo "##vso[task.setvariable variable=skipComponentGovernanceDetection]true"
displayName: Set skipComponentGovernanceDetection variable
- ${{ if ne(parameters.disableComponentGovernance, 'true') }}:
- task: ComponentGovernanceComponentDetection@0
Expand Down
2 changes: 1 addition & 1 deletion eng/common/templates/steps/component-governance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ parameters:

steps:
- ${{ if eq(parameters.disableComponentGovernance, 'true') }}:
- script: "echo ##vso[task.setvariable variable=skipComponentGovernanceDetection]true"
- script: echo "##vso[task.setvariable variable=skipComponentGovernanceDetection]true"
displayName: Set skipComponentGovernanceDetection variable
- ${{ if ne(parameters.disableComponentGovernance, 'true') }}:
- task: ComponentGovernanceComponentDetection@0
Expand Down
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"xcopy-msbuild": "17.8.1-2"
},
"msbuild-sdks": {
"Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.24179.4",
"Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.24179.4",
"Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.24204.3",
"Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.24204.3",
"Microsoft.Build.Traversal": "3.4.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

namespace Microsoft.CodeAnalysis.CSharp.UseCollectionExpression;

using static CSharpSyntaxTokens;
using static SyntaxFactory;

internal static class UseCollectionExpressionHelpers
Expand Down Expand Up @@ -690,10 +691,10 @@ public static CollectionExpressionSyntax ConvertInitializerToCollectionExpressio
InitializerExpressionSyntax initializer, bool wasOnSingleLine)
{
// if the initializer is already on multiple lines, keep it that way. otherwise, squash from `{ 1, 2, 3 }` to `[1, 2, 3]`
var openBracket = Token(SyntaxKind.OpenBracketToken).WithTriviaFrom(initializer.OpenBraceToken);
var openBracket = OpenBracketToken.WithTriviaFrom(initializer.OpenBraceToken);
var elements = initializer.Expressions.GetWithSeparators().SelectAsArray(
i => i.IsToken ? i : ExpressionElement((ExpressionSyntax)i.AsNode()!));
var closeBracket = Token(SyntaxKind.CloseBracketToken).WithTriviaFrom(initializer.CloseBraceToken);
var closeBracket = CloseBracketToken.WithTriviaFrom(initializer.CloseBraceToken);

// If it was on a single line to begin with, then remove the inner spaces on the `{ ... }` to create `[...]`. If
// it was multiline, leave alone as we want the brackets to just replace the existing braces exactly as they are.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

namespace Microsoft.CodeAnalysis.CSharp.UseExpressionBody;

using static CSharpSyntaxTokens;
using static SyntaxFactory;

/// <summary>
Expand Down Expand Up @@ -181,7 +182,7 @@ public bool CanOfferUseBlockBody(

expressionBody = GetExpressionBody(declaration);
if (expressionBody?.TryConvertToBlock(
Token(SyntaxKind.SemicolonToken), false, block: out _) != true)
SemicolonToken, false, block: out _) != true)
{
fixesError = false;
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,23 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Composition;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading;
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;
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.LanguageService;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;

namespace Microsoft.CodeAnalysis.CSharp.CodeFixes.AddInheritdoc;

using static CSharpSyntaxTokens;

[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.AddInheritdoc), Shared]
internal sealed class AddInheritdocCodeFixProvider : SyntaxEditorBasedCodeFixProvider
{
Expand Down Expand Up @@ -107,9 +100,9 @@ protected override async Task FixAllAsync(Document document, ImmutableArray<Diag
// We can safely assume, that there is no leading doc comment, because that is what CS1591 is telling us.
// So we create a new /// <inheritdoc/> comment.
var xmlSpaceAfterTripleSlash = Token(leading: [DocumentationCommentExterior("///")], SyntaxKind.XmlTextLiteralToken, text: " ", valueText: " ", trailing: default);
var lessThanToken = Token(SyntaxKind.LessThanToken).WithoutTrivia();
var lessThanToken = LessThanToken.WithoutTrivia();
var inheritdocTagName = XmlName("inheritdoc").WithoutTrivia();
var slashGreaterThanToken = Token(SyntaxKind.SlashGreaterThanToken).WithoutTrivia();
var slashGreaterThanToken = SlashGreaterThanToken.WithoutTrivia();
var xmlNewLineToken = Token(leading: default, SyntaxKind.XmlTextLiteralNewLineToken, text: newLine, valueText: newLine, trailing: default);

var singleLineInheritdocComment = DocumentationCommentTrivia(
Expand All @@ -120,7 +113,7 @@ protected override async Task FixAllAsync(Document document, ImmutableArray<Diag
XmlEmptyElement(lessThanToken, inheritdocTagName, attributes: default, slashGreaterThanToken),
XmlText(xmlNewLineToken),
],
endOfComment: Token(SyntaxKind.EndOfDocumentationCommentToken).WithoutTrivia());
endOfComment: EndOfDocumentationCommentToken.WithoutTrivia());

sourceText ??= await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
var indentation = sourceText.GetLeadingWhitespaceOfLineAtPosition(node.FullSpan.Start);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

namespace Microsoft.CodeAnalysis.CSharp.ConditionalExpressionInStringInterpolation;

using static CSharpSyntaxTokens;

[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.AddParenthesesAroundConditionalExpressionInInterpolatedString), Shared]
internal class CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider : CodeFixProvider
{
Expand Down Expand Up @@ -119,7 +121,7 @@ private static async Task<Document> InsertCloseParenthesisAsync(
}

var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
var newCloseParen = SyntaxFactory.Token(SyntaxKind.CloseParenToken).WithTriviaFrom(parenthesizedExpression.CloseParenToken);
var newCloseParen = CloseParenToken.WithTriviaFrom(parenthesizedExpression.CloseParenToken);
var parenthesizedExpressionWithClosingParen = parenthesizedExpression.WithCloseParenToken(newCloseParen);
var newRoot = root.ReplaceNode(parenthesizedExpression, parenthesizedExpressionWithClosingParen);
return document.WithSyntaxRoot(newRoot);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

namespace Microsoft.CodeAnalysis.CSharp.ConvertNamespace;

using static CSharpSyntaxTokens;
using static SyntaxFactory;

internal static class ConvertNamespaceTransform
Expand Down Expand Up @@ -322,7 +323,7 @@ private static bool HasLeadingBlankLine(
private static FileScopedNamespaceDeclarationSyntax ConvertNamespaceDeclaration(NamespaceDeclarationSyntax namespaceDeclaration)
{
// If the open-brace token has any special trivia, then move them to after the semicolon.
var semiColon = Token(SyntaxKind.SemicolonToken)
var semiColon = SemicolonToken
.WithoutTrivia()
.WithTrailingTrivia(namespaceDeclaration.Name.GetTrailingTrivia())
.WithAppendedTrailingTrivia(namespaceDeclaration.OpenBraceToken.LeadingTrivia);
Expand Down Expand Up @@ -382,15 +383,15 @@ private static NamespaceDeclarationSyntax ConvertFileScopedNamespace(ParsedDocum
{
var nameSyntax = fileScopedNamespace.Name.WithAppendedTrailingTrivia(fileScopedNamespace.SemicolonToken.LeadingTrivia)
.WithAppendedTrailingTrivia(newLinePlacement.HasFlag(NewLinePlacement.BeforeOpenBraceInTypes) ? EndOfLine(lineEnding) : Space);
var openBraceToken = Token(SyntaxKind.OpenBraceToken).WithoutLeadingTrivia().WithTrailingTrivia(fileScopedNamespace.SemicolonToken.TrailingTrivia);
var openBraceToken = OpenBraceToken.WithoutLeadingTrivia().WithTrailingTrivia(fileScopedNamespace.SemicolonToken.TrailingTrivia);

if (openBraceToken.TrailingTrivia is not [.., SyntaxTrivia(SyntaxKind.EndOfLineTrivia)])
{
openBraceToken = openBraceToken.WithAppendedTrailingTrivia(EndOfLine(lineEnding));
}

FileScopedNamespaceDeclarationSyntax adjustedFileScopedNamespace;
var closeBraceToken = Token(SyntaxKind.CloseBraceToken).WithoutLeadingTrivia().WithoutTrailingTrivia();
var closeBraceToken = CloseBraceToken.WithoutLeadingTrivia().WithoutTrailingTrivia();

// Normally the block scoped namespace will have a newline after the closing brace. The only exception to
// this occurs when there are no tokens after the closing brace and the document with a file scoped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace Microsoft.CodeAnalysis.CSharp.ConvertSwitchStatementToExpression;

using static ConvertSwitchStatementToExpressionHelpers;
using static CSharpSyntaxTokens;
using static SyntaxFactory;

internal sealed partial class ConvertSwitchStatementToExpressionCodeFixProvider
Expand Down Expand Up @@ -73,12 +74,12 @@ private StatementSyntax GetFinalStatement(
return ReturnStatement(
Token(leadingTrivia, SyntaxKind.ReturnKeyword, trailing: default),
switchExpression,
Token(SyntaxKind.SemicolonToken));
SemicolonToken);
case SyntaxKind.ThrowStatement:
return ThrowStatement(
Token(leadingTrivia, SyntaxKind.ThrowKeyword, trailing: default),
switchExpression,
Token(SyntaxKind.SemicolonToken));
SemicolonToken);
}

Debug.Assert(SyntaxFacts.IsAssignmentExpression(nodeToGenerate));
Expand Down Expand Up @@ -250,8 +251,8 @@ private ExpressionSyntax RewriteSwitchStatement(
Token(leading: default, SyntaxKind.OpenBraceToken, node.OpenBraceToken.TrailingTrivia),
SeparatedList(
switchArms.Select(t => t.armExpression.WithLeadingTrivia(t.tokensForLeadingTrivia.GetTrivia().FilterComments(addElasticMarker: false))),
switchArms.Select(t => Token(SyntaxKind.CommaToken).WithTrailingTrivia(t.tokensForTrailingTrivia.GetTrivia().FilterComments(addElasticMarker: true)))),
Token(SyntaxKind.CloseBraceToken));
switchArms.Select(t => CommaToken.WithTrailingTrivia(t.tokensForTrailingTrivia.GetTrivia().FilterComments(addElasticMarker: true)))),
CloseBraceToken);
}

private SwitchStatementSyntax AddCastIfNecessary(SwitchStatementSyntax node)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

namespace Microsoft.CodeAnalysis.CSharp.ConvertToRecord;

using static CSharpSyntaxTokens;
using static SyntaxFactory;

internal static class ConvertToRecordEngine
Expand Down Expand Up @@ -127,7 +128,7 @@ await RefactorInitializersAsync(type, solutionEditor, propertiesToAssign, cancel
documentEditor.ReplaceNode(property, property
.WithInitializer(
EqualsValueClause(IdentifierName(property.Identifier.WithoutTrivia())))
.WithSemicolonToken(Token(SyntaxKind.SemicolonToken)));
.WithSemicolonToken(SemicolonToken));
}
else
{
Expand Down Expand Up @@ -266,7 +267,7 @@ await RefactorInitializersAsync(type, solutionEditor, propertiesToAssign, cancel

// if we have a class, move trivia from class keyword to record keyword
// if struct, split trivia and leading goes to record keyword, trailing goes to struct keyword
var recordKeyword = Token(SyntaxKind.RecordKeyword);
var recordKeyword = RecordKeyword;
recordKeyword = type.TypeKind == TypeKind.Class
? recordKeyword.WithTriviaFrom(typeDeclaration.Keyword)
: recordKeyword.WithLeadingTrivia(typeDeclaration.Keyword.LeadingTrivia);
Expand Down Expand Up @@ -391,16 +392,16 @@ private static RecordDeclarationSyntax CreateRecordDeclaration(
openBrace = default;
closeBrace = default;
semicolon = typeDeclaration.SemicolonToken == default
? Token(SyntaxKind.SemicolonToken)
? SemicolonToken
: typeDeclaration.SemicolonToken;
}
else
{
openBrace = typeDeclaration.OpenBraceToken == default
? Token(SyntaxKind.OpenBraceToken)
? OpenBraceToken
: typeDeclaration.OpenBraceToken;
closeBrace = typeDeclaration.CloseBraceToken == default
? Token(SyntaxKind.CloseBraceToken)
? CloseBraceToken
: typeDeclaration.CloseBraceToken;
semicolon = default;

Expand Down Expand Up @@ -459,7 +460,7 @@ private static SyntaxList<AttributeListSyntax> GetModifiedAttributeListsForPrope
{
// convert attributes attached to the property with no target into "property :" targeted attributes
return attributeList
.WithTarget(AttributeTargetSpecifier(Token(SyntaxKind.PropertyKeyword)))
.WithTarget(AttributeTargetSpecifier(PropertyKeyword))
.WithoutTrivia();
}
else
Expand Down Expand Up @@ -657,7 +658,7 @@ [.. propertyParamComments.Skip(1)
.WithLeadingTrivia(DocumentationCommentExterior("/**"))
.WithTrailingTrivia(exteriorTrivia)))
.Append(XmlText(XmlTextNewLine(lineFormattingOptions.NewLine, continueXmlDocumentationComment: false)))],
Token(SyntaxKind.EndOfDocumentationCommentToken)
EndOfDocumentationCommentToken
.WithTrailingTrivia(DocumentationCommentExterior("*/"), ElasticCarriageReturnLineFeed));
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
// See the LICENSE file in the project root for more information.

using System.Linq;
using System.Threading.Tasks;
using System.Threading;
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CSharp.LanguageService;
using Microsoft.CodeAnalysis.CSharp.OrderModifiers;
using Microsoft.CodeAnalysis.OrderModifiers;
using Roslyn.Utilities;
using Microsoft.CodeAnalysis.CSharp.LanguageService;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.CodeActions;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.CSharp.CodeFixes.HideBase;

using static CSharpSyntaxTokens;

internal partial class HideBaseCodeFixProvider
{
private class AddNewKeywordAction(Document document, SyntaxNode node, CodeActionOptionsProvider fallbackOptions) : CodeAction
Expand All @@ -41,7 +41,7 @@ private static SyntaxNode GetNewNode(SyntaxNode node, string preferredModifierOr
{
var syntaxFacts = CSharpSyntaxFacts.Instance;
var modifiers = syntaxFacts.GetModifiers(node);
var newModifiers = modifiers.Add(SyntaxFactory.Token(SyntaxKind.NewKeyword));
var newModifiers = modifiers.Add(NewKeyword);

if (!CSharpOrderModifiersHelper.Instance.TryGetOrComputePreferredOrder(preferredModifierOrder, out var preferredOrder) ||
!AbstractOrderModifiersHelpers.IsOrdered(preferredOrder, modifiers))
Expand Down
Loading

0 comments on commit e603563

Please sign in to comment.