提交 3990b3c1 编写于 作者: J Jason Malinowski

Add [Fact]s where missing and make helper methods private

xunit.analyzers will flag public methods of types that have other
facts in them. Sometimes this catches things we missed [Fact] on, and
in other times was catching private test helpers. Make both of the
fixes.
上级 0e588a52
......@@ -3487,6 +3487,7 @@ namespace System.Runtime.CompilerServices { class AsyncMethodBuilderAttribute :
);
}
[Fact]
public void AsyncTasklikeBadAttributeArgument4()
{
var source = @"
......@@ -3851,7 +3852,7 @@ namespace System.Runtime.CompilerServices { class AsyncMethodBuilderAttribute :
}
// Should check constraints (see https://github.com/dotnet/roslyn/issues/12616).
//[Fact]
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/12616")]
public void AsyncTasklikeBuilderConstraints()
{
var source1 = @"
......
......@@ -2838,6 +2838,7 @@ static void Main()
);
}
[Fact]
[WorkItem(16947, "https://github.com/dotnet/roslyn/issues/16947")]
public void Dynamic001()
{
......@@ -2867,6 +2868,8 @@ public void M()
Diagnostic(ErrorCode.ERR_RefReturnLvalueExpected, "d.Length").WithLocation(14, 20)
);
}
[Fact]
[WorkItem(16947, "https://github.com/dotnet/roslyn/issues/16947")]
public void Dynamic002()
{
......@@ -2897,6 +2900,7 @@ public void M()
);
}
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/21079")]
[WorkItem(16947, "https://github.com/dotnet/roslyn/issues/16947")]
public void Dynamic003()
{
......
......@@ -81,6 +81,7 @@ .maxstack 1
");
}
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/21079")]
public void TestRethrowImplicit()
{
var source = @"
......@@ -121,6 +122,7 @@ .maxstack 1
");
}
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/21079")]
public void TestRethrowTyped()
{
var source = @"
......@@ -161,6 +163,7 @@ .maxstack 1
");
}
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/21079")]
public void TestRethrowNamed()
{
var source = @"
......@@ -201,6 +204,7 @@ .maxstack 1
");
}
[Fact]
public void TestRethrowModified()
{
var source = @"
......@@ -234,6 +238,7 @@ static void Main()
CompileAndVerify(source, expectedOutput: "B");
}
[Fact]
public void TestRethrowOverwritten()
{
var source = @"
......
......@@ -895,6 +895,7 @@ .maxstack 2
);
}
[Fact]
public void DegenerateSwitch007()
{
var text = @"using System;
......
......@@ -8493,6 +8493,7 @@ .locals init (pinned char*& V_0)
");
}
[Fact]
public void FixedBufferAndStatementWithFixedArrayElementAsInitializerExe()
{
var text = @"
......
......@@ -491,7 +491,7 @@ class C
Diagnostic(ErrorCode.ERR_ModuleEmitFailure).WithArguments("C"));
}
public void VerifyAssemblyReferences(AggregatedMetadataReader reader, string[] expected)
private void VerifyAssemblyReferences(AggregatedMetadataReader reader, string[] expected)
{
AssertEx.Equal(expected, reader.GetAssemblyReferences().Select(aref => $"{reader.GetString(aref.Name)}, {aref.Version}"));
}
......
......@@ -6795,6 +6795,7 @@ static void M()
#region Patterns
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/21079")]
public void SyntaxOffset_Pattern()
{
var source = @"class C { bool F(object o) => o is int i && o is 3 && o is bool; }";
......
......@@ -136,6 +136,7 @@ static void M1()
VerifyOperationTreeAndDiagnosticsForTest<InvocationExpressionSyntax>(source, expectedOperationTree, expectedDiagnostics);
}
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/21079")]
public void NamedArgumentInParameterOrderWithDefaultValue()
{
string source = @"
......
......@@ -22445,6 +22445,7 @@ static void Main(string[] args)
}
[WorkItem(543473, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543473")]
[Fact]
public void CS0815ERR_CannotAssignLambdaExpressionToAnImplicitlyTypedLocalVariable()
{
var text =
......
......@@ -1275,6 +1275,8 @@ public void TestNumericLiteralWithHugeNumberAndDecimal()
Assert.Equal(value, token.Value);
}
[Fact]
[Trait("Feature", "Literals")]
public void TestNumericLiteralWithHugeNumberAndHugeDecimal()
{
var value = 12332434234234234234234234324234234234.45623423423423423423423423423423423423;
......
......@@ -2013,7 +2013,7 @@ public void TestDelegateWithBuiltInReturnTypes()
TestDelegateWithBuiltInReturnType(SyntaxKind.ObjectKeyword);
}
public void TestDelegateWithBuiltInReturnType(SyntaxKind builtInType)
private void TestDelegateWithBuiltInReturnType(SyntaxKind builtInType)
{
var typeText = SyntaxFacts.GetText(builtInType);
var text = "delegate " + typeText + " b();";
......@@ -2059,7 +2059,7 @@ public void TestDelegateWithBuiltInParameterTypes()
TestDelegateWithBuiltInParameterType(SyntaxKind.ObjectKeyword);
}
public void TestDelegateWithBuiltInParameterType(SyntaxKind builtInType)
private void TestDelegateWithBuiltInParameterType(SyntaxKind builtInType)
{
var typeText = SyntaxFacts.GetText(builtInType);
var text = "delegate a b(" + typeText + " c);";
......@@ -2482,6 +2482,7 @@ public void TestClassMethodWithRefReturn()
Assert.Equal(SyntaxKind.None, ms.SemicolonToken.Kind());
}
[Fact]
public void TestClassMethodWithRef()
{
var text = "class a { ref }";
......@@ -2876,7 +2877,7 @@ public void TestClassMethodWithBuiltInReturnTypes()
TestClassMethodWithBuiltInReturnType(SyntaxKind.ObjectKeyword);
}
public void TestClassMethodWithBuiltInReturnType(SyntaxKind type)
private void TestClassMethodWithBuiltInReturnType(SyntaxKind type)
{
var typeText = SyntaxFacts.GetText(type);
var text = "class a { " + typeText + " M() { } }";
......@@ -2941,7 +2942,7 @@ public void TestClassMethodWithBuiltInParameterTypes()
TestClassMethodWithBuiltInParameterType(SyntaxKind.ObjectKeyword);
}
public void TestClassMethodWithBuiltInParameterType(SyntaxKind type)
private void TestClassMethodWithBuiltInParameterType(SyntaxKind type)
{
var typeText = SyntaxFacts.GetText(type);
var text = "class a { b X(" + typeText + " c) { } }";
......@@ -3299,7 +3300,7 @@ public void TestClassFieldWithBuiltInTypes()
TestClassFieldWithBuiltInType(SyntaxKind.ObjectKeyword);
}
public void TestClassFieldWithBuiltInType(SyntaxKind type)
private void TestClassFieldWithBuiltInType(SyntaxKind type)
{
var typeText = SyntaxFacts.GetText(type);
var text = "class a { " + typeText + " c; }";
......@@ -3873,7 +3874,7 @@ public void TestClassPropertyWithBuiltInTypes()
TestClassPropertyWithBuiltInType(SyntaxKind.ObjectKeyword);
}
public void TestClassPropertyWithBuiltInType(SyntaxKind type)
private void TestClassPropertyWithBuiltInType(SyntaxKind type)
{
var typeText = SyntaxFacts.GetText(type);
var text = "class a { " + typeText + " c { get; set; } }";
......@@ -4065,7 +4066,7 @@ public void TestClassPropertyOrEventWithValue()
TestClassEventWithValue(SyntaxKind.RemoveAccessorDeclaration, SyntaxKind.RemoveKeyword, SyntaxKind.IdentifierToken);
}
public void TestClassPropertyWithValue(SyntaxKind accessorKind, SyntaxKind accessorKeyword, SyntaxKind tokenKind)
private void TestClassPropertyWithValue(SyntaxKind accessorKind, SyntaxKind accessorKeyword, SyntaxKind tokenKind)
{
bool isEvent = accessorKeyword == SyntaxKind.AddKeyword || accessorKeyword == SyntaxKind.RemoveKeyword;
var text = "class a { " + (isEvent ? "event" : string.Empty) + " b c { " + SyntaxFacts.GetText(accessorKeyword) + " { x = value; } } }";
......@@ -4122,7 +4123,7 @@ public void TestClassPropertyWithValue(SyntaxKind accessorKind, SyntaxKind acces
Assert.Equal(tokenKind, ((IdentifierNameSyntax)bx.Right).Identifier.Kind());
}
public void TestClassEventWithValue(SyntaxKind accessorKind, SyntaxKind accessorKeyword, SyntaxKind tokenKind)
private void TestClassEventWithValue(SyntaxKind accessorKind, SyntaxKind accessorKeyword, SyntaxKind tokenKind)
{
var text = "class a { event b c { " + SyntaxFacts.GetText(accessorKeyword) + " { x = value; } } }";
var file = this.ParseFile(text);
......
......@@ -1852,6 +1852,7 @@ public void TestFromOrderByDescendingSelect()
Assert.Null(qs.Body.Continuation);
}
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/21079")]
public void TestFromGroupBy()
{
var text = "from a in A group b by c";
......@@ -1891,6 +1892,7 @@ public void TestFromGroupBy()
Assert.Null(qs.Body.Continuation);
}
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/21079")]
public void TestFromGroupByIntoSelect()
{
var text = "from a in A group b by c into d select e";
......
......@@ -4395,6 +4395,7 @@ void M()
Diagnostic(ErrorCode.ERR_InvalidExprTerm, "stackalloc").WithArguments("stackalloc").WithLocation(6, 24));
}
[Fact]
public void CS1674ERR_StackAllocInUsing1()
{
// Diff errors
......
......@@ -169,7 +169,7 @@ public void LexerTooManyBadTokens_LongUnicode()
#region "Helpers"
public static void ParseAndValidate(string text, params DiagnosticDescription[] expectedErrors)
private static void ParseAndValidate(string text, params DiagnosticDescription[] expectedErrors)
{
var parsedTree = ParseWithRoundTripCheck(text);
var actualErrors = parsedTree.GetDiagnostics();
......
......@@ -46,7 +46,7 @@ internal static void ParseAndRoundTripping(string text, CSharpParseOptions optio
ParentChecker.CheckParents(tree.GetCompilationUnitRoot(), tree);
}
public static void ParseAndCheckTerminalSpans(string text)
private static void ParseAndCheckTerminalSpans(string text)
{
var tree = SyntaxFactory.ParseSyntaxTree(text);
var toText = tree.GetCompilationUnitRoot().ToFullString();
......
......@@ -21,12 +21,12 @@ protected override SyntaxTree ParseTree(string text, CSharpParseOptions options)
return SyntaxFactory.ParseSyntaxTree(text, options: options ?? TestOptions.Script);
}
public void ParseAndValidate(string text, params ErrorDescription[] errors)
private void ParseAndValidate(string text, params ErrorDescription[] errors)
{
ParseAndValidate(text, null, errors);
}
public SyntaxTree ParseAndValidate(string text, CSharpParseOptions options, params ErrorDescription[] errors)
private SyntaxTree ParseAndValidate(string text, CSharpParseOptions options, params ErrorDescription[] errors)
{
var parsedTree = ParseTree(text, options);
var parsedText = parsedTree.GetCompilationUnitRoot();
......
......@@ -263,6 +263,7 @@ public void TestLocalDeclarationStatementWithTuple()
Assert.False(ds.SemicolonToken.IsMissing);
}
[Fact]
public void TestLocalDeclarationStatementWithNamedTuple()
{
var text = "(T x, (U k, V l, W m) y) a;";
......
......@@ -6,7 +6,7 @@
namespace Microsoft.CodeAnalysis.UnitTests.Collections
{
internal class ArrayBuilderTests
public class ArrayBuilderTests
{
[Fact]
public void RemoveDuplicates1()
......
......@@ -423,6 +423,7 @@ void Method()
}
}
[WpfFact, Trait(Traits.Feature, Traits.Features.AutomaticCompletion)]
public void Preprocessor2()
{
var code = @"class C
......@@ -440,6 +441,7 @@ void Method()
}
}
[WpfFact, Trait(Traits.Feature, Traits.Features.AutomaticCompletion)]
public void Preprocessor3()
{
var code = @"class C
......
......@@ -2602,6 +2602,7 @@ public override int foo
}
[WorkItem(8257, "https://github.com/dotnet/roslyn/issues/8257")]
[WpfFact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task NotImplementedQualifiedWhenSystemUsingNotPresent_Method()
{
var markupBeforeCommit = @"abstract class C
......
......@@ -29,6 +29,7 @@ public async Task SnippetsInEmptyFile()
await VerifyItemExistsAsync(@"$$", MockSnippetInfoService.SnippetShortcut, sourceCodeKind: SourceCodeKind.Regular);
}
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task SnippetDescriptions()
{
await VerifyItemExistsAsync(@"$$", MockSnippetInfoService.SnippetShortcut, MockSnippetInfoService.SnippetTitle + Environment.NewLine + MockSnippetInfoService.SnippetDescription, SourceCodeKind.Regular);
......
......@@ -334,7 +334,7 @@ enum Color
}");
}
[Trait(Traits.Feature, Traits.Features.CodeActionsGenerateEnumMember)]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateEnumMember)]
public async Task TestWithNonZeroInteger()
{
await TestInRegularAndScriptAsync(
......
......@@ -322,6 +322,7 @@ internal interface
", new TestParameters(options: InterfaceNamesStartWithI));
}
[Fact, Trait(Traits.Feature, Traits.Features.NamingStyle)]
[WorkItem(16562, "https://github.com/dotnet/roslyn/issues/16562")]
public async Task TestRefactorNotify()
{
......
......@@ -1591,7 +1591,7 @@ void M()
}
[WorkItem(7900, "https://github.com/dotnet/roslyn/issues/7900")]
[Trait(Traits.Feature, Traits.Features.Formatting)]
[WpfFact, Trait(Traits.Feature, Traits.Features.Formatting)]
public void FormatLockStatementWithEmbeddedStatementOnSemicolonDifferentLine()
{
var code = @"class C
......@@ -1616,7 +1616,7 @@ public void M()
}
[WorkItem(7900, "https://github.com/dotnet/roslyn/issues/7900")]
[Trait(Traits.Feature, Traits.Features.Formatting)]
[WpfFact, Trait(Traits.Feature, Traits.Features.Formatting)]
public void FormatLockStatementWithEmbeddedStatementOnSemicolonSameLine()
{
var code = @"class C
......
......@@ -91,7 +91,7 @@ public async Task TestGetCodeFixWithExceptionInGetFixAllProvider()
await GetAddedFixesAsync(new ErrorCases.ExceptionInGetFixAllProvider());
}
public async Task GetDefaultFixesAsync(CodeFixProvider codefix)
private async Task GetDefaultFixesAsync(CodeFixProvider codefix)
{
var tuple = ServiceSetup(codefix);
using (var workspace = tuple.Item1)
......@@ -103,7 +103,7 @@ public async Task GetDefaultFixesAsync(CodeFixProvider codefix)
}
}
public async Task GetAddedFixesAsync(CodeFixProvider codefix)
private async Task GetAddedFixesAsync(CodeFixProvider codefix)
{
var tuple = ServiceSetup(codefix);
using (var workspace = tuple.Item1)
......@@ -121,7 +121,7 @@ public async Task GetAddedFixesAsync(CodeFixProvider codefix)
}
}
public async Task GetFirstDiagnosticWithFixAsync(CodeFixProvider codefix)
private async Task GetFirstDiagnosticWithFixAsync(CodeFixProvider codefix)
{
var tuple = ServiceSetup(codefix);
using (var workspace = tuple.Item1)
......
......@@ -31,7 +31,7 @@ public async Task TestExceptionInComputeRefactoringsAsync()
await VerifyRefactoringDisabledAsync(new ErrorCases.ExceptionInComputeRefactoringsAsync());
}
public async Task VerifyRefactoringDisabledAsync(CodeRefactoringProvider codeRefactoring)
private async Task VerifyRefactoringDisabledAsync(CodeRefactoringProvider codeRefactoring)
{
var refactoringService = new CodeRefactorings.CodeRefactoringService(GetMetadata(codeRefactoring));
using (var workspace = TestWorkspace.CreateCSharp(@"class Program {}"))
......
......@@ -382,7 +382,7 @@ public async Task Document_Reanalyze()
}
}
[WorkItem(670335, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/670335")]
[Fact, WorkItem(670335, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/670335")]
public async Task Document_Change()
{
using (var workspace = new WorkCoordinatorWorkspace(SolutionCrawler))
......@@ -427,7 +427,7 @@ public async Task Document_AdditionalFileChange()
}
}
[WorkItem(670335, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/670335")]
[Fact, WorkItem(670335, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/670335")]
public async Task Document_Cancellation()
{
using (var workspace = new WorkCoordinatorWorkspace(SolutionCrawler))
......@@ -457,7 +457,7 @@ public async Task Document_Cancellation()
}
}
[WorkItem(670335, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/670335")]
[Fact, WorkItem(670335, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/670335")]
public async Task Document_Cancellation_MultipleTimes()
{
using (var workspace = new WorkCoordinatorWorkspace(SolutionCrawler))
......@@ -491,7 +491,7 @@ public async Task Document_Cancellation_MultipleTimes()
}
}
[WorkItem(670335, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/670335")]
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/21082"), WorkItem(670335, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/670335")]
public async Task Document_InvocationReasons()
{
using (var workspace = new WorkCoordinatorWorkspace(SolutionCrawler))
......
......@@ -12,10 +12,10 @@
namespace Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator.UnitTests
{
internal class AccessibilityTests : CSharpResultProviderTestBase
public class AccessibilityTests : CSharpResultProviderTestBase
{
[WorkItem(889710, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/889710")]
[Fact]
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/21084")]
public void HideNonPublicMembersBaseClass()
{
var sourceA =
......@@ -176,7 +176,7 @@ class C
}
[WorkItem(889710, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/889710")]
[Fact]
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/21084")]
public void HideNonPublicMembersDerivedClass()
{
var sourceA =
......
......@@ -118,14 +118,14 @@ public string ReadErrorOutputToEnd()
return ReadOutputToEnd(isError: true);
}
public void ClearOutput()
private void ClearOutput()
{
_outputReadPosition = new int[] { 0, 0 };
_synchronizedOutput.Clear();
_synchronizedErrorOutput.Clear();
}
public void RestartHost(string rspFile = null)
private void RestartHost(string rspFile = null)
{
ClearOutput();
......
......@@ -708,7 +708,7 @@ public void DebuggerProxy_FrameworkTypes_Lazy()
);
}
public void TaskMethod()
private void TaskMethod()
{
}
......
......@@ -32,7 +32,7 @@ private SyntaxTree GetTreeFromCode(string code)
return SyntaxFactory.ParseSyntaxTree(code);
}
public async Task GenerateBaseline()
private async Task GenerateBaseline()
{
Console.WriteLine(typeof(FactAttribute));
......
......@@ -7,7 +7,7 @@
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Interactive.Commands
{
internal class InteractiveCommandHandlerTests
public class InteractiveCommandHandlerTests
{
private const string Caret = "$$";
private const string ExampleCode1 = @"var x = 1;";
......
......@@ -400,7 +400,7 @@ private static RemoteHostService CreateService()
return new RemoteHostService(stream, new InProcRemoteHostClient.ServiceProvider(runCacheCleanup: false));
}
public static void SetEqual<T>(IEnumerable<T> expected, IEnumerable<T> actual)
private static void SetEqual<T>(IEnumerable<T> expected, IEnumerable<T> actual)
{
var expectedSet = new HashSet<T>(expected);
var result = expected.Count() == actual.Count() && expectedSet.SetEquals(actual);
......
......@@ -8,7 +8,7 @@ namespace Microsoft.CodeAnalysis.UnitTests.LinkedFileDiffMerging
{
public partial class LinkedFileDiffMergingTests
{
public void TestLinkedFileSet(string startText, List<string> updatedTexts, string expectedMergedText, string languageName)
private void TestLinkedFileSet(string startText, List<string> updatedTexts, string expectedMergedText, string languageName)
{
using (var workspace = new AdhocWorkspace())
{
......
......@@ -1116,6 +1116,7 @@ public void TestLoadProjectFromCommandLine()
Assert.Equal(@"C:\ProjectDirectory\subdir\bar.cs", barDoc.FilePath);
}
[Fact, Trait(Traits.Feature, Traits.Features.Workspace)]
public void TestCommandLineProjectWithRelativePathOutsideProjectCone()
{
string commandLine = @"..\foo.cs";
......
......@@ -77,6 +77,7 @@ public void EditDistance4()
VerifyEditDistance("XlmReade", "XmlReader", 2);
}
[Fact]
public void EditDistance5()
{
VerifyEditDistance("Zeil", "trials", 4);
......
......@@ -177,7 +177,7 @@ public void TestTemporaryStorageMemoryMappedFileManagement()
// We want to keep this test around, but not have it disabled/associated with a bug
// [Fact, Trait(Traits.Feature, Traits.Features.Workspace)]
public void TestTemporaryStorageScaling()
private void TestTemporaryStorageScaling()
{
// This will churn through 4GB of memory. It validates that we don't
// use up our address space in a 32 bit process.
......
......@@ -417,7 +417,7 @@ public async Task TestUpdatedDocumentTextIsObservablyConstantAsync()
await CheckUpdatedDocumentTextIsObservablyConstantAsync(CreateWorkspaceWithRecoverableTrees());
}
public async Task CheckUpdatedDocumentTextIsObservablyConstantAsync(AdhocWorkspace ws)
private async Task CheckUpdatedDocumentTextIsObservablyConstantAsync(AdhocWorkspace ws)
{
var pid = ProjectId.CreateNewId();
var text = SourceText.From("public class C { }");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册