Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

458
Views
Vs2019.9.2 Raise runtime errors when using Property Pattern for undefined variable and fail compilation and it's expected compilation error

Using Vs 2019.9.2 (or v 2019.9.0):

Create a console net5 application. Add the next class:

class Class1
    {
        public void Test1()
        {
           if (shape is Circle { Radius: >= 100 })  //variable shape is un defined, cause many errors by vs 2019.9.2
            {
                // this is a huge circle
            }
        }
    }
    public class Circle
    {
        public double Radius { get; init; }
    }

You get many error messages (without compilation) at the upper screen under the menu with these common errors:

Feature 'Diagnostic analyzer runner' is currently unavailable due to an internal error. Show Stack Trace 
Feature 'CodeLens references' is currently unavailable due to an internal error. Show Stack Trace 
Feature 'Semantic classification cache' is currently unavailable due to an internal error. Show Stack Trace 

The common error message in Stack Trace:

RPC server exception:
System.InvalidOperationException: Operation is not valid due to the current state of the object.

as shown in the next figure:

vs2019 error

and you can't remove these errors, then vs2019 raise the compilation error:

Error   MSB6006 "csc.exe" exited with code -2146232797. Vs2019Bug   C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets  71  

The line ( with undefined variable shape)

if (shape is Circle { Radius: >= 100 })

cause these errors, and it's expected that vs 2019 raise a compilation error.

Remove the Property Patten check and replace the above line with the next one:

if (shape is Circle ) //cause compilation error as expected

What I missed to avoid the VS2019 runtime error?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I have posted the issue to the Roslyn Project here

It was reported as a bug and the issue is resolved by Roslyn Team in the next version of Vs 2019.

Thanks to Roslyn team.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!