Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public class MyClass : IAsyncDisposable
public void MyTest()
{
}

public ValueTask DisposeAsync()
{
return ValueTask.CompletedTask;
Expand All @@ -152,4 +152,104 @@ public ValueTask DisposeAsync()
"""
);
}

[Test]
public async Task Property_Getter_Setter_No_Error()
{
await Verifier
.VerifyAnalyzerAsync(
"""
using TUnit.Core;

public class MyClass
{
[Test]
public void MyTest()
{
}

public string? Name { get; set; }

public int Age
{
get { return 0; }
set { }
}
}
"""
);
}

[Test]
public async Task Event_Accessors_No_Error()
{
await Verifier
.VerifyAnalyzerAsync(
"""
using System;
using TUnit.Core;

public class MyClass
{
[Test]
public void MyTest()
{
}

public event EventHandler MyEvent
{
add { }
remove { }
}
}
"""
);
}

[Test]
public async Task Override_Method_No_Error()
{
await Verifier
.VerifyAnalyzerAsync(
"""
using TUnit.Core;

public class MyClass
{
[Test]
public void MyTest()
{
}

public override string ToString()
{
return "test";
}
}
"""
);
}

[Test]
public async Task Static_Method_No_Error()
{
await Verifier
.VerifyAnalyzerAsync(
"""
using TUnit.Core;

public class MyClass
{
[Test]
public void MyTest()
{
}

public static void StaticHelper()
{
}
}
"""
);
}
}
3 changes: 3 additions & 0 deletions TUnit.Analyzers/PublicMethodMissingTestAttributeAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ private void AnalyzeSymbol(SymbolAnalysisContext context)
return;
}

// MethodKind.Ordinary excludes property accessors (PropertyGet/PropertySet),
// event accessors (EventAdd/EventRemove), constructors, destructors, operators,
// and other compiler-generated method kinds.
foreach (var method in methods
.Where(x => x.MethodKind == MethodKind.Ordinary)
.Where(x => !x.IsAbstract)
Expand Down
Loading