Probably a bug with CS8302
See original GitHub issueSteps to Reproduce:
Use #error version:7.1
with LangVersion set to 7.1
Expected Behavior:
No diagnostic
Actual Behavior:
error CS8302: Feature 'version' is not available in C# 7.1. Please use language version 7.1 or greater.
The error message looks very strange.
The problem lies in DirectiveParser.cs
, more specifically, this part of code:
if (this.Options.LanguageVersion != LanguageVersion.Preview &&
errorText.StartsWith(versionMarker, StringComparison.Ordinal) &&
LanguageVersionFacts.TryParse(errorText.Substring(versionMarker.Length), out var languageVersion))
{
ErrorCode error = this.Options.LanguageVersion.GetErrorCode();
eod = this.AddError(eod, triviaOffset, triviaWidth, error, "version", new CSharpRequiredLanguageVersion(languageVersion));
}
I think the if condition needs to compare the parsed languageVersion
with this.Options.LanguageVersion
or this.Options.SpecifiedLanguageVersion
(not sure what’s the difference between them, hope someone can clear this up for me).
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Feature 'using declarations' is not available in C# 7.3. ...
When using Visual Studio Enterprise 16.3.7 on two separate machines, one builds fine and the other machine throws the error: Feature 'using ...
Read more >World's First Computer Bug
On September 9, 1947, a team of computer scientists reported the world's first computer bug—a moth trapped in their computer at Harvard ...
Read more >Software bug
A software bug is an error, flaw or fault in the design, development, or operation of computer software that causes it to produce...
Read more >Moth in the machine: Debugging the origins of 'bug'
Did Grace Hopper really invent the term 'bug' to describe software errors? Nope. Here's the real story.
Read more >Your favorite candy probably has bugs in it, and that's ...
Your favorite candy probably has bugs in it, and that's really okay - The Washington Post.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Since
#error version:<version>
is not meant for users, I don’t worry about the quality of the diagnostic message. I’ll go ahead and close this issue as by-design. ThanksI think it’s fine.