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
Unit test fixes for Windows #1804
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
|
@@ -86,21 +87,26 @@ void M() | |
|
||
int count = 5; | ||
|
||
|
||
count = 6; | ||
|
||
} | ||
|
||
} | ||
"; | ||
|
||
var expectedCode = @" | ||
// Hack for Windows: StyleCop uses the Environment NewLine for its replacement, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tagging @sharwell to comment on this. |
||
// so we have take care of it | ||
var expectedCode = @$" | ||
class C | ||
{ | ||
{{ | ||
void M() | ||
{ | ||
{{ | ||
object obj = new object(); | ||
|
||
int count = 5; | ||
} | ||
} | ||
{Environment.NewLine} int count = 5; | ||
{Environment.NewLine} count = 6; | ||
}} | ||
}} | ||
"; | ||
|
||
var editorConfig = new Dictionary<string, string>() | ||
|
@@ -163,6 +169,9 @@ void M() | |
|
||
// Prefer using. IDISP017 | ||
["dotnet_diagnostic.IDISP017.severity"] = "error", | ||
|
||
// We expect new line as end_of_line in this test | ||
["end_of_line"] = EndOfLineFormatter.GetEndOfLineOption("\n"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❔ Why was this added? |
||
}; | ||
|
||
await AssertCodeChangedAsync(testCode, expectedCode, editorConfig, fixCategory: FixCategory.Analyzers, analyzerReferences: analyzerReferences); | ||
|
@@ -210,6 +219,9 @@ void M() | |
|
||
// Prefer using. IDISP017 | ||
["dotnet_diagnostic.IDISP017.severity"] = "error", | ||
|
||
// We expect new line as end_of_line in this test | ||
["end_of_line"] = EndOfLineFormatter.GetEndOfLineOption("\n"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❔ Why was this added? This test has |
||
}; | ||
|
||
await AssertCodeChangedAsync(testCode, expectedCode, editorConfig, fixCategory: FixCategory.Analyzers, analyzerReferences: analyzerReferences); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -587,9 +587,13 @@ public async Task GeneratorSolution_NoDiagnosticsReported_WhenNotIncludingGenera | |
[MSBuildFact] | ||
public async Task GeneratorSolution_AdditionalDocumentsUpdated_WhenIncludingGenerated() | ||
{ | ||
const string ExpectedPublicApi = @"Greeter | ||
Greeter.Greet() -> void | ||
Greeter.Greeter() -> void"; | ||
var sb = new System.Text.StringBuilder(); | ||
sb.Append("Greeter"); | ||
sb.Append(Environment.NewLine); | ||
sb.Append("Greeter.Greet() -> void"); | ||
sb.Append(Environment.NewLine); | ||
sb.Append("Greeter.Greeter() -> void"); | ||
var expectedPublicApi = sb.ToString(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❔ Why was this changed? |
||
|
||
// Copy solution to temp folder so we can write changes to disk. | ||
var solutionPath = CopyToTempFolder(s_generatorSolutionPath); | ||
|
@@ -617,7 +621,7 @@ public async Task GeneratorSolution_AdditionalDocumentsUpdated_WhenIncludingGene | |
|
||
// Verify that changes were persisted to disk. | ||
var unshippedPublicApi = File.ReadAllText(Path.Combine(solutionPath, "console_app", "PublicAPI.Unshipped.txt")); | ||
Assert.Equal(ExpectedPublicApi, unshippedPublicApi); | ||
Assert.Equal(expectedPublicApi, unshippedPublicApi); | ||
} | ||
finally | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,7 @@ class C | |
|
||
var editorConfig = new Dictionary<string, string>() | ||
{ | ||
["end_of_line"] = EndOfLineFormatter.GetEndOfLineOption(Environment.NewLine), | ||
["end_of_line"] = EndOfLineFormatter.GetEndOfLineOption("\n"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❔ Why was this changed? Applies to all instances of this in the file. |
||
["dotnet_sort_system_directives_first"] = "false", | ||
["dotnet_separate_import_directive_groups"] = "false" | ||
}; | ||
|
@@ -72,7 +72,7 @@ class C | |
|
||
var editorConfig = new Dictionary<string, string>() | ||
{ | ||
["end_of_line"] = EndOfLineFormatter.GetEndOfLineOption(Environment.NewLine), | ||
["end_of_line"] = EndOfLineFormatter.GetEndOfLineOption("\n"), | ||
["dotnet_sort_system_directives_first"] = "true", | ||
["dotnet_separate_import_directive_groups"] = "false" | ||
}; | ||
|
@@ -104,7 +104,7 @@ class C | |
|
||
var editorConfig = new Dictionary<string, string>() | ||
{ | ||
["end_of_line"] = EndOfLineFormatter.GetEndOfLineOption(Environment.NewLine), | ||
["end_of_line"] = EndOfLineFormatter.GetEndOfLineOption("\n"), | ||
["dotnet_sort_system_directives_first"] = "false", | ||
["dotnet_separate_import_directive_groups"] = "true" | ||
}; | ||
|
@@ -136,7 +136,7 @@ class C | |
|
||
var editorConfig = new Dictionary<string, string>() | ||
{ | ||
["end_of_line"] = EndOfLineFormatter.GetEndOfLineOption(Environment.NewLine), | ||
["end_of_line"] = EndOfLineFormatter.GetEndOfLineOption("\n"), | ||
["dotnet_sort_system_directives_first"] = "true", | ||
["dotnet_separate_import_directive_groups"] = "true" | ||
}; | ||
|
@@ -158,7 +158,7 @@ class C | |
|
||
var editorConfig = new Dictionary<string, string>() | ||
{ | ||
["end_of_line"] = EndOfLineFormatter.GetEndOfLineOption(Environment.NewLine) | ||
["end_of_line"] = EndOfLineFormatter.GetEndOfLineOption("\n") | ||
}; | ||
|
||
await AssertCodeUnchangedAsync(code, editorConfig); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❔ Why was this added?