Skip to content

UpgradeToRegexGeneratorAnalyzerTests fail on some Mono runtimes #69823

@joperezr

Description

@joperezr

When running the unit tests in some Mono runtimes the tests are failing with:

  Discovering: System.Text.RegularExpressions.Unit.Tests (method display = ClassAndMethod, method display options = None)
  Discovered:  System.Text.RegularExpressions.Unit.Tests (found 32 test cases)
  Starting:    System.Text.RegularExpressions.Unit.Tests (parallel test collections = on, max threads = 6)
    System.Text.RegularExpressions.Unit.Tests.UpgradeToRegexGeneratorAnalyzerTests.DiagnosticNotEmittedForVariablePattern(test: "using System.Text;\nusing System.Text.RegularExpre"...) [FAIL]
      System.MethodAccessException : Method `Microsoft.CodeAnalysis.Testing.AnalyzerInfo+CustomAnalysisContext..ctor()' is inaccessible from method `CustomAnalysisContextImpl..ctor()'
      Stack Trace:
           at CustomAnalysisContextImpl..ctor()
        /_/src/mono/System.Private.CoreLib/src/System/RuntimeType.Mono.cs(1638,0): at System.RuntimeType.CreateInstanceMono(Boolean nonPublic, Boolean wrapExceptions)
        /_/src/mono/System.Private.CoreLib/src/System/RuntimeType.Mono.cs(1514,0): at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
        /_/src/libraries/System.Private.CoreLib/src/System/Activator.RuntimeType.cs(98,0): at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
        /_/src/libraries/System.Private.CoreLib/src/System/Activator.RuntimeType.cs(89,0): at System.Activator.CreateInstance(Type type, Boolean nonPublic)
        /_/src/libraries/System.Private.CoreLib/src/System/Activator.cs(41,0): at System.Activator.CreateInstance(Type type)
        /_/src/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing/AnalyzerInfo.cs(56,0): at Microsoft.CodeAnalysis.Testing.AnalyzerInfo.CreateAnalysisContext()
        /_/src/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing/AnalyzerInfo.cs(38,0): at Microsoft.CodeAnalysis.Testing.AnalyzerInfo.HasConfiguredGeneratedCodeAnalysis(DiagnosticAnalyz

Seems like the way the Roslyn test infrastructure is designed isn't very compatible with the Mono runtime. For now, we mostly care that the tests run against coreclr and .NET Framework since those are the platforms the compiler targets, so we are disabling the tests for now. This issue is to track the work of re-enabling them for Mono in case that is what is decided.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions