dotnet/roslyn

No syntax error when VB compiler generates skipped tokens for nullable ? syntax inside cref

Open

#2,196 创建于 2015年4月23日

在 GitHub 查看
 (0 评论) (0 反应) (1 负责人)C# (20,414 star) (4,257 fork)batch import
Area-CompilersBugConcept-APIhelp wanted

描述

When I type the below code and turn on xml doc comment generation in the project settings, I noticed that ? is actually parsed as a skipped token - which indicates that the syntax was erroneous. Yet the compiler gives me no warning (which means that the cref will not be emitted correctly).

capture3

capture

  • If I replace Integer? with Nullable(Of Integer), there is no longer any skipped tokens and no errors either. However, I am not sure whether this is legal - in C# we only allow unconstructed generic types in crefs (except when specifying parameter types) - so it is legal to say <see cref="Nullable{T}"/> but it is not legal to say <see cref="Nullable{Integer}"/>. In any case, if I inspect symbols for Nullable(Of Integer) and Integer using the syntax visualizer, I can see that both identifiers bind correctly (see screenshot below). So I guess this must be legal in VB.
  • But if this is legal in VB, then shouldn't using the short form syntax Integer? be legal too? Why does the parser skip the ? token? And why doesn't it produce any errors if this is illegal.

capture2

  • The specific reason I am logging this issue is that this inconsistent behavior makes detection of when we should offer to simplify Nullable(Of Something) to Something? within crefs in VB quite difficult. (Looks like VB is inconsistent with C# here + the VB compiler is also inconsistent with itself w.r.t interchangeability of short and long form syntax for nullables.) But this also feels like it would impact any tools / extensions that want to do analysis within crefs.

贡献者指南

No syntax error when VB compiler generates skipped tokens for nullable ? syntax inside cref · dotnet/roslyn#2196 | Good First Issue