-
-
Notifications
You must be signed in to change notification settings - Fork 837
Open
xunit/xunit.analyzers
#203Labels
Analyzershttps://github.com/xunit/xunit.analyzershttps://github.com/xunit/xunit.analyzersFeatureA request for a new featureA request for a new featurehelp wantedA community-provided PR would be welcomedA community-provided PR would be welcomed
Description
The XUnit code below has a warning that _someClass doesn't have a value set, however the value is set in the InitializerAsync() method.
public class XUnitTests : IAsyncLifetime
{
private SomeClass _someClass; // CS8618 warning
public Task DisposeAsync()
{
return Task.CompletedTask;
}
public Task InitializeAsync()
{
_someClass = new() { SomeProperty = "Hello World" };
return Task.CompletedTask;
}
[Fact]
public void Test1()
{
var x = 2;
}
}NUnit has the NUnit3002 analyser that suppresses CS8618 warnings when the class member is set in the Setup() method, so I was wondering if XUnit could implement something similar?
NUnit code:
public class NUnitTests
{
private SomeClass _someClass; // no warning
[SetUp]
public async Task Setup()
{
_someClass = new() { SomeProperty = "SomeValue" };
}
[Test]
public void Test1()
{
Assert.Pass();
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Analyzershttps://github.com/xunit/xunit.analyzershttps://github.com/xunit/xunit.analyzersFeatureA request for a new featureA request for a new featurehelp wantedA community-provided PR would be welcomedA community-provided PR would be welcomed