dotnet / dotnet/sdk

`dotnet format` emits spurious errors on references to source generated symbols

Open
#50,499 0 comments 0 reactions 1 assignee Claimed by @JoeRobich View on GitHub
Area-Format
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

SDK: 9.0.304, ubuntu-22.04

I have a blocked PR due to [3 new errors](https://dev.azure.com/azure-public/vside/_build/results?buildId=22038&view=logs&jobId=0da5d1d9-276d-5173-c4c4-9d4d4ed14fdb&j=0da5d1d9-276d-5173-c4c4-9d4d4ed14fdb&t=5b4cc83a-7bb0-5664-5bb1-588f7e4dc05b) from `dotnet format` due to the PR's added references to symbols that are produced by a source generator.

I suspect this means that `dotnet format` is not actually plugging in the source generator (which itself is one of the projects in this solution).

```
/home/vsts/work/1/s/src/StreamJsonRpc/Reflection/ProxyBase.cs(485,100): error CS0246: The type or namespace name 'Generated' could not be found (are you missing a using directive or an assembly reference?) [/home/vsts/work/1/s/src/StreamJsonRpc/StreamJsonRpc.csproj]
/home/vsts/work/1/s/src/StreamJsonRpc/Reflection/ProxyBase.cs(485,100): error CS0246: The type or namespace name 'Generated' could not be found (are you missing a using directive or an assembly reference?) [/home/vsts/work/1/s/src/StreamJsonRpc/StreamJsonRpc.csproj]
/home/vsts/work/1/s/src/StreamJsonRpc/Reflection/ProxyBase.cs(485,100): error CS0246: The type or namespace name 'Generated' could not be found (are you missing a using directive or an assembly reference?) [/home/vsts/work/1/s/src/StreamJsonRpc/StreamJsonRpc.csproj]
```

### To Reproduce

```
git clone https://github.com/microsoft/vs-streamjsonrpc.git
cd vs-streamjsonrpc
git fetch origin 1610f861dbeb1713d373f734e4d56273955af551
git checkout 1610f861dbeb1713d373f734e4d56273955af551
dotnet build -c release
dotnet format --verify-no-changes --exclude test/NativeAOTCompatibility.Test
```

Interestingly, building _debug_ configuration before running the `dotnet format` command avoids the problem.

### Further technical details
details of dotnet --info

OS Platform: Linux
RID: linux-x64
Base Path: /opt/hostedtoolcache/dotnet/sdk/9.0.304/

.NET workloads installed:
There are no installed workloads to display.
Configured to use loose manifests when installing new manifests.

Host:
Version: 9.0.8
Architecture: x64
Commit: aae90fa090

.NET SDKs installed:
9.0.304 [/opt/hostedtoolcache/dotnet/sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 9.0.8 [/opt/hostedtoolcache/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.19 [/opt/hostedtoolcache/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.8 [/opt/hostedtoolcache/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
None

Environment variables:
DOTNET_ROOT [/opt/hostedtoolcache/dotnet]

global.json file:
/home/vsts/work/1/s/global.json

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download
Mono JIT compiler version 6.12.0.200 (tarball Tue Jul 11 21:37:50 UTC 2023)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
Interpreter: yes
LLVM: yes(610)
Suspend: hybrid
GC: sgen (concurrent by default)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.