From 2ff6ad7e08d866be09283d903da2c9a7c023b676 Mon Sep 17 00:00:00 2001
From: "dotnet-maestro[bot]"
<42748379+dotnet-maestro[bot]@users.noreply.github.com>
Date: Sat, 26 Jun 2021 13:35:23 +0000
Subject: [PATCH 1/3] [main] Update dependencies from dotnet/source-build
(#54384)
[main] Update dependencies from dotnet/source-build
---
eng/Version.Details.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml
index b42d8c8d6b619..4c7abe65aeed9 100644
--- a/eng/Version.Details.xml
+++ b/eng/Version.Details.xml
@@ -6,9 +6,9 @@
7e80445ee82adbf9a8e6ae601ac5e239d982afaa
-
+
https://github.com/dotnet/source-build
- c35d744cbe24f85d2165a5edb1730355b8cb916f
+ 0655d162f86955d32d9e564024beb8abecc171d2
From e1b5629c70cb30be9b000013107e3155bdfd6901 Mon Sep 17 00:00:00 2001
From: Andrew Hall
Date: Sat, 26 Jun 2021 15:56:07 -0700
Subject: [PATCH 2/3] Fix move type for top level statements
---
.../MoveType/MoveTypeTests.MoveToNewFile.cs | 46 +++++++++++++++++++
.../MoveType/AbstractMoveTypeService.cs | 14 +++++-
2 files changed, 59 insertions(+), 1 deletion(-)
diff --git a/src/EditorFeatures/CSharpTest/CodeActions/MoveType/MoveTypeTests.MoveToNewFile.cs b/src/EditorFeatures/CSharpTest/CodeActions/MoveType/MoveTypeTests.MoveToNewFile.cs
index 2795b666bef30..c3a43618a02c9 100644
--- a/src/EditorFeatures/CSharpTest/CodeActions/MoveType/MoveTypeTests.MoveToNewFile.cs
+++ b/src/EditorFeatures/CSharpTest/CodeActions/MoveType/MoveTypeTests.MoveToNewFile.cs
@@ -1408,5 +1408,51 @@ record CacheContext(String Message);
await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText);
}
+
+ [WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)]
+ public async Task MoveClassInTopLevelStatements()
+ {
+ var code = @"
+using ConsoleApp1;
+using System;
+
+var c = new C();
+Console.WriteLine(c.Hello);
+
+class [||]C
+{
+ public string Hello => ""Hello"";
+}";
+
+ var codeAfterMove = @"
+using ConsoleApp1;
+using System;
+
+var c = new C();
+Console.WriteLine(c.Hello);
+";
+
+ var expectedDocumentName = "C.cs";
+ var destinationDocumentText = @"class C
+{
+ public string Hello => ""Hello"";
+}";
+
+ await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText);
+ }
+
+ [WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)]
+ public async Task MissingInTopLevelStatementsOnly()
+ {
+ var code = @"
+using ConsoleApp1;
+using System;
+
+var c = new object();
+[||]Console.WriteLine(c.ToString());
+";
+
+ await TestMissingAsync(code);
+ }
}
}
diff --git a/src/Features/Core/Portable/CodeRefactorings/MoveType/AbstractMoveTypeService.cs b/src/Features/Core/Portable/CodeRefactorings/MoveType/AbstractMoveTypeService.cs
index 139c4efddf2ec..56077d699a069 100644
--- a/src/Features/Core/Portable/CodeRefactorings/MoveType/AbstractMoveTypeService.cs
+++ b/src/Features/Core/Portable/CodeRefactorings/MoveType/AbstractMoveTypeService.cs
@@ -13,7 +13,9 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
+using Microsoft.CodeAnalysis.LanguageServices;
using Microsoft.CodeAnalysis.PooledObjects;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
@@ -107,6 +109,11 @@ private ImmutableArray CreateActions(State state, CancellationToken
var manyTypes = MultipleTopLevelTypeDeclarationInSourceDocument(state.SemanticDocument.Root);
var isNestedType = IsNestedType(state.TypeNode);
+ var syntaxFacts = state.SemanticDocument.Document.GetRequiredLanguageService();
+ var isClassNextToGlobalStatements = manyTypes
+ ? false
+ : ClassNextToGlobalStatements(state.SemanticDocument.Root, syntaxFacts);
+
var suggestedFileNames = GetSuggestedFileNames(
state.TypeNode,
isNestedType,
@@ -120,7 +127,9 @@ private ImmutableArray CreateActions(State state, CancellationToken
// case 2: This is a nested type, offer to move to new file.
// case 3: If there is a single type decl in current file, *do not* offer move to new file,
// rename actions are sufficient in this case.
- if (manyTypes || isNestedType)
+ // case 4: If there are top level statements(Global statements) offer to move even
+ // in cases where there are only one class in the file.
+ if (manyTypes || isNestedType || isClassNextToGlobalStatements)
{
foreach (var fileName in suggestedFileNames)
{
@@ -152,6 +161,9 @@ private ImmutableArray CreateActions(State state, CancellationToken
return actions.ToImmutable();
}
+ private static bool ClassNextToGlobalStatements(SyntaxNode root, ISyntaxFactsService syntaxFacts)
+ => syntaxFacts.ContainsGlobalStatement(root);
+
private CodeAction GetCodeAction(State state, string fileName, MoveTypeOperationKind operationKind) =>
new MoveTypeCodeAction((TService)this, state, operationKind, fileName);
From 7cf416262aae8f51a58ce49815f5af57beb39e5a Mon Sep 17 00:00:00 2001
From: Rikki Gibson
Date: Sat, 26 Jun 2021 21:42:14 -0700
Subject: [PATCH 3/3] Insertion depends on DARC publishing (#54420)
---
azure-pipelines-official.yml | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/azure-pipelines-official.yml b/azure-pipelines-official.yml
index 2133a429b3405..43fcf4cb37080 100644
--- a/azure-pipelines-official.yml
+++ b/azure-pipelines-official.yml
@@ -294,7 +294,9 @@ stages:
vmImage: vs2017-win2016
- stage: insert
- dependsOn: build
+ dependsOn:
+ - build
+ - publish_using_darc
displayName: Insert to VS
jobs: