This issue has been moved from a ticket on Developer Community.
Hello,
I am use Visual Studio 16.8.3 on netcoreapp3.1 project (besides, it's reproduce on more old versions of .net) and I get incorrect result (result with compilation error) from invocation of override snippet under type parameter in the example below:
#nullable enable
using System;
namespace ConsoleApp1
{
abstract class Test<TResult>
{
public abstract TResult? Get();
}
class G : Test<int>
{
public override int? Get()
{
throw new NotImplementedException();
}
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
#nullable enable
The code is incorrect because Get in G must return System.Int32, not Nullable<System.Int32> (Suppose that the compiler behavior under type parameter constraint in this case with nullable ref types – is another question that doesn't affect Visual Studio). Marking G as returning int makes result compiling.
P.S.
Just to be clear I was make this simple example based on CsharpSyntaxVisitor<T> from Roslyn source codes.:
|
public virtual TResult? Visit(SyntaxNode? node) |
In attachments you will find screenshots the result of override snippet and the metadata of CsharpSyntaxVisitor<T>
Original Comments
Feedback Bot on 2/4/2021, 10:01 PM:
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.
Feedback Bot on 2/5/2021, 00:19 PM:
Thank you for sharing your feedback! Our teams prioritize action on product issues with broad customer impact. See details at: https://docs.microsoft.com/en-us/visualstudio/ide/report-a-problem?view=vs-2019#faq. In case you need answers to common questions or need assisted support, be sure to use https://visualstudio.microsoft.com/vs/support/. We’ll keep you posted on any updates to this feedback.
Original Solutions
(no solutions)
This issue has been moved from a ticket on Developer Community.
Hello,
I am use Visual Studio 16.8.3 on netcoreapp3.1 project (besides, it's reproduce on more old versions of .net) and I get incorrect result (result with compilation error) from invocation of override snippet under type parameter in the example below:
The code is incorrect because
GetinGmust returnSystem.Int32, notNullable<System.Int32>(Suppose that the compiler behavior under type parameter constraint in this case with nullable ref types – is another question that doesn't affect Visual Studio). MarkingGas returningintmakes result compiling.P.S.
Just to be clear I was make this simple example based on
CsharpSyntaxVisitor<T>from Roslyn source codes.:roslyn/src/Compilers/CSharp/Portable/Syntax/CSharpSyntaxVisitor.cs
Line 17 in afd1030
In attachments you will find screenshots the result of override snippet and the metadata of
CsharpSyntaxVisitor<T>Original Comments
Feedback Bot on 2/4/2021, 10:01 PM:
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.
Feedback Bot on 2/5/2021, 00:19 PM:
Thank you for sharing your feedback! Our teams prioritize action on product issues with broad customer impact. See details at: https://docs.microsoft.com/en-us/visualstudio/ide/report-a-problem?view=vs-2019#faq. In case you need answers to common questions or need assisted support, be sure to use https://visualstudio.microsoft.com/vs/support/. We’ll keep you posted on any updates to this feedback.
Original Solutions
(no solutions)