RicoSuter / Namotion.Reflection

.NET library with advanced reflection APIs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incorrect nullability for nested class containing an async method in the parent class

PhilipAlexanderWallin opened this issue · comments

I noticed "Unknown" nullability was given for a nested class when the parent class contains an async method. The use case I have is I have an async unit test which use a nested test class for the unit tests of a factory method. The following is a minimal example of the problem, given the method "Test" in run in a nullable context, note that it works as expected if the async "Test" method is removed:

static void Main(string[] args)
{
	// Gives Nullability: NotNullable
	var data = typeof(StringData).GetProperties().First().ToContextualProperty();
	
	// Gives Nullability: Unknown
	var dataInner = typeof(Outer.StringDataInner).GetProperties().First().ToContextualProperty();
}

public class Outer
{
	public async Task Test()
	{
		await Task.Delay(1);
	}

	public class StringDataInner
	{
		public string Text { get; } = string.Empty;
	}
}

public class StringData
{
	public string Text { get; } = string.Empty;
}