Skip to content

Commit

Permalink
Merge pull request #33421 from dotnet/merges/master-to-features/reado…
Browse files Browse the repository at this point in the history
…nly-members

Merge master to features/readonly-members
  • Loading branch information
dotnet-automerge-bot authored Feb 15, 2019
2 parents 7f6f687 + b4a4a98 commit d733674
Show file tree
Hide file tree
Showing 8 changed files with 308 additions and 14 deletions.
9 changes: 5 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# EditorConfig is awesome:http://EditorConfig.org
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true
Expand All @@ -14,19 +14,20 @@ indent_size = 4
insert_final_newline = true
charset = utf-8-bom

# Xml project files
# XML project files
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
indent_size = 2

# Xml config files
# XML config files
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
indent_size = 2

# JSON files
[*.json]
indent_size = 2

[*.{sh}]
# Shell script files
[*.sh]
end_of_line = lf
indent_size = 2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ The Test.cmd script will run our unit test on already built binaries. It can be
2. Navigate to the directory of your Git clone.
3. Run `msbuild /v:m /m /nodereuse:false BuildAndTest.proj` in the command prompt.

You can more precisely control how the tests are run by running the eng/build.ps1 script directly with the relevant options. For example passing in the `-test` switch will run the tests on .Net Framework, whilst passing in the `-testCoreClr` switch will run the tests on .Net Core.

The results of the tests can be viewed in the artifacts/TestResults directory.

### Test Explorer

Tests can be run and debugged from the Test Explorer window. For best performance, we recommend the following:
Expand Down
21 changes: 14 additions & 7 deletions eng/config/PublishData.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,44 @@
"nuget": [ "https://dotnet.myget.org/F/roslyn/api/v2/package" ],
"vsix": [ "https://dotnet.myget.org/F/roslyn/vsix/upload" ],
"channels": [ "dev15.9"],
"vsBranch": "rel/d15.9"
"vsBranch": "rel/d15.9",
"vsMajorVersion": 15
},
"dev16.0-preview3-vs-deps": {
"nugetKind": ["Shipping", "NonShipping"],
"version": "3.0.*",
"nuget": [ "https://dotnet.myget.org/F/roslyn/api/v2/package" ],
"vsix": [ "https://dotnet.myget.org/F/roslyn/vsix/upload" ],
"channels": [ "dev16.0p3" ],
"vsBranch": "lab/d16.0stg"
"vsBranch": "lab/d16.0stg",
"vsMajorVersion": 16
},
"dev16.0-vs-deps": {
"nugetKind": ["Shipping", "NonShipping"],
"version": "3.0.*",
"nuget": [ "https://dotnet.myget.org/F/roslyn/api/v2/package" ],
"vsix": [ "https://dotnet.myget.org/F/roslyn/vsix/upload" ],
"channels": [ "dev16.0", "dev16.0p4" ],
"vsBranch": "rel/d16.0"
"vsBranch": "rel/d16.0",
"vsMajorVersion": 16
},
"master-vs-deps": {
"nugetKind": ["Shipping", "NonShipping"],
"version": "3.1.*",
"nuget": [ "https://dotnet.myget.org/F/roslyn/api/v2/package" ],
"vsix": [ "https://dotnet.myget.org/F/roslyn/vsix/upload" ],
"channels": [ "dev16.1", "dev16.1p1" ],
"vsBranch": "lab/ml"
"vsBranch": "master",
"vsMajorVersion": 16
},
"features/NullableReferenceTypes": {
"nugetKind": "PerBuildPreRelease",
"version": "2.6.*",
"nuget": [ "https://dotnet.myget.org/F/roslyn-nonnull/api/v2/package" ],
"vsix": [ "https://dotnet.myget.org/F/roslyn-nonnull/vsix/upload" ],
"channels": [ "nonnull" ],
"vsBranch": "lab/ml",
"vsBranch": "master",
"vsMajorVersion": 16,
"ibcSourceBranch": "master-vs-deps"
},
"features/dataflow": {
Expand All @@ -47,7 +52,8 @@
"nuget": [ "https://dotnet.myget.org/F/roslyn/api/v2/package" ],
"vsix": [ "https://dotnet.myget.org/F/roslyn/vsix/upload" ],
"channels": [ "dataflow" ],
"vsBranch": "lab/ml",
"vsBranch": "master",
"vsMajorVersion": 16,
"ibcSourceBranch": "master-vs-deps"
},
"features/editorconfig-in-compiler": {
Expand All @@ -56,7 +62,8 @@
"nuget": [ "https://dotnet.myget.org/F/roslyn/api/v2/package" ],
"vsix": [ "https://dotnet.myget.org/F/roslyn/vsix/upload" ],
"channels": [ "editorconfig" ],
"vsBranch": "lab/ml",
"vsBranch": "master",
"vsMajorVersion": 16,
"ibcSourceBranch": "master-vs-deps"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1172,5 +1172,216 @@ void Foo()
await TestMoveTypeToNewFileAsync(
code, codeAfterMove, expectedDocumentName, destinationDocumentText);
}

[WorkItem(31377, "https://github.com/dotnet/roslyn/issues/31377")]
[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)]
public async Task TestLeadingCommentInContainer()
{
var code =
@"// Banner Text
using System;
class Class1
// Leading comment
{
class [||]Class2
{
}
void Foo()
{
Console.WriteLine();
}
public int I() => 5;
}
";
var codeAfterMove = @"// Banner Text
using System;
partial class Class1
// Leading comment
{
void Foo()
{
Console.WriteLine();
}
public int I() => 5;
}
";

var expectedDocumentName = "Class2.cs";
var destinationDocumentText = @"// Banner Text
partial class Class1
{
class Class2
{
}
}
";

await TestMoveTypeToNewFileAsync(
code, codeAfterMove, expectedDocumentName, destinationDocumentText);
}

[WorkItem(31377, "https://github.com/dotnet/roslyn/issues/31377")]
[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)]
public async Task TestLeadingCommentInContainer2()
{
var code =
@"// Banner Text
using System;
class Class1
{ // Leading comment
class [||]Class2
{
}
void Foo()
{
Console.WriteLine();
}
public int I() => 5;
}
";
var codeAfterMove = @"// Banner Text
using System;
partial class Class1
{ // Leading comment
void Foo()
{
Console.WriteLine();
}
public int I() => 5;
}
";

var expectedDocumentName = "Class2.cs";
var destinationDocumentText = @"// Banner Text
partial class Class1
{
class Class2
{
}
}
";

await TestMoveTypeToNewFileAsync(
code, codeAfterMove, expectedDocumentName, destinationDocumentText);
}

[WorkItem(31377, "https://github.com/dotnet/roslyn/issues/31377")]
[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)]
public async Task TestTrailingCommentInContainer()
{
var code =
@"// Banner Text
using System;
class Class1
{
class [||]Class2
{
}
void Foo()
{
Console.WriteLine();
}
public int I() => 5;
// End of class document
}
";
var codeAfterMove = @"// Banner Text
using System;
partial class Class1
{
void Foo()
{
Console.WriteLine();
}
public int I() => 5;
// End of class document
}
";

var expectedDocumentName = "Class2.cs";
var destinationDocumentText = @"// Banner Text
partial class Class1
{
class Class2
{
}
}
";

await TestMoveTypeToNewFileAsync(
code, codeAfterMove, expectedDocumentName, destinationDocumentText);
}

[WorkItem(31377, "https://github.com/dotnet/roslyn/issues/31377")]
[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)]
public async Task TestTrailingCommentInContainer2()
{
var code =
@"// Banner Text
using System;
class Class1
{
class [||]Class2
{
}
void Foo()
{
Console.WriteLine();
}
public int I() => 5;
} // End of class document
";
var codeAfterMove = @"// Banner Text
using System;
partial class Class1
{
void Foo()
{
Console.WriteLine();
}
public int I() => 5;
} // End of class document
";

var expectedDocumentName = "Class2.cs";
var destinationDocumentText = @"// Banner Text
partial class Class1
{
class Class2
{
}
}";

await TestMoveTypeToNewFileAsync(
code, codeAfterMove, expectedDocumentName, destinationDocumentText);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4266,6 +4266,45 @@ internal override SyntaxNode RefExpression(SyntaxNode expression)
public override SyntaxNode TupleExpression(IEnumerable<SyntaxNode> arguments)
=> SyntaxFactory.TupleExpression(SyntaxFactory.SeparatedList(arguments.Select(AsArgument)));

internal override SyntaxNode RemoveAllComments(SyntaxNode node)
{
var modifiedNode = RemoveLeadingAndTrailingComments(node);

if (modifiedNode is TypeDeclarationSyntax declarationSyntax)
{
return declarationSyntax.WithOpenBraceToken(RemoveLeadingAndTrailingComments(declarationSyntax.OpenBraceToken))
.WithCloseBraceToken(RemoveLeadingAndTrailingComments(declarationSyntax.CloseBraceToken));
}

return modifiedNode;
}

internal override SyntaxTriviaList RemoveCommentLines(SyntaxTriviaList syntaxTriviaList)
{
IEnumerable<IEnumerable<SyntaxTrivia>> splitIntoLines(SyntaxTriviaList triviaList)
{
int index = 0;
for (int i = 0; i < triviaList.Count; i++)
{
if (triviaList[i].IsEndOfLine())
{
yield return triviaList.TakeRange(index, i);
index = i + 1;
}
}

if (index < triviaList.Count)
{
yield return triviaList.TakeRange(index, triviaList.Count - 1);
}
}

var syntaxWithoutComments = splitIntoLines(syntaxTriviaList)
.Where(trivia => !trivia.Any(t => t.IsRegularOrDocComment()))
.SelectMany(t => t);

return new SyntaxTriviaList(syntaxWithoutComments);
}
#endregion

#region Patterns
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,16 @@ public static IEnumerable<SyntaxTrivia> SkipInitialWhitespace(this SyntaxTriviaL
{
return triviaList.SkipWhile(t => t.Kind() == SyntaxKind.WhitespaceTrivia);
}

/// <summary>
/// Takes an INCLUSIVE range of trivia from the trivia list.
/// </summary>
public static IEnumerable<SyntaxTrivia> TakeRange(this SyntaxTriviaList triviaList, int start, int end)
{
while (start <= end)
{
yield return triviaList[start++];
}
}
}
}
Loading

0 comments on commit d733674

Please sign in to comment.