dotnet / dotnet/roslyn

IL2026, IL3050 show up in Error List, then disappear

Open
#79,965 3 comments 0 reactions 1 assignee Claimed by @JoeRobich View on GitHub
Area-IDE
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

**Version Used**: Visual Studio 2022 Update 14 (Dev17.14)

**Diagnostic Id**: IL2026, IL3050

> **IL3050** Using member 'StreamJsonRpc.JsonRpc.Attach()' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. This code generates IL at runtime and executes it.
> **IL2026** Using member 'StreamJsonRpc.JsonRpc.Attach()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. This code generates IL at runtime and executes it.

**Repro steps**:

```
git clone https://github.com/microsoft/vs-streamjsonrpc.git
cd vs-streamjsonrpc
git checkout 835ae62576a8d7f60c186a9a1a79dbc7e547857d
.\init.ps1
StreamJsonRpc.slnx
```

Open some code files that are _not_ in the `NativeAOTCompatibility.Test` project.

**Expected Behavior**:

No warnings appear in the error list, consistent with build/publish at the CLI.

**Actual Behavior**:

While working in StreamJsonRpc, I frequently see this:

Image

But when I double-click on them to see the source code, they vanish.
The linker does not produce any such warnings. So it seems these roslyn analyzers are defective.
I have "Entire Solution" set for both "Background code analysis" and "Show compiler errors and warnings for", BTW.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.