Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

461
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda