grpc / grpc/grpc-dotnet

AoT Linker Warning in Grpc.AspNetCore.Server.Reflection

Open
#2,605 0 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
C#
Stars
4.5k
Forks
836
Avg merge
6d 3h
Merged PRs (30d)
7

Description

### What version of gRPC and what language are you using?

### What operating system (Linux, Windows,...) and version?
All

### What runtime / compiler are you using (e.g. .NET Core SDK version `dotnet --info`)

```
dotnet --info
.NET SDK:
Version: 9.0.101
Commit: eedb237549
Workload version: 9.0.100-manifests.693890c1
MSBuild version: 17.12.12+1cce77968

Runtime Environment:
OS Name: Mac OS X
OS Version: 13.7
OS Platform: Darwin
RID: osx-arm64
Base Path: /usr/local/share/dotnet/sdk/9.0.101/

.NET workloads installed:
[wasi-experimental]
Installation Source: SDK 9.0.100
Manifest Version: 9.0.1/9.0.100
Manifest Path: /usr/local/share/dotnet/sdk-manifests/9.0.100/microsoft.net.workload.mono.toolchain.current/9.0.1/WorkloadManifest.json
Install Type: FileBased

[aspire]
Installation Source: SDK 9.0.100
Manifest Version: 8.2.2/8.0.100
Manifest Path: /usr/local/share/dotnet/sdk-manifests/8.0.100/microsoft.net.sdk.aspire/8.2.2/WorkloadManifest.json
Install Type: FileBased

Configured to use loose manifests when installing new manifests.

Host:
Version: 9.0.0
Architecture: arm64
Commit: 9d5a6a9aa4

.NET SDKs installed:
9.0.101 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
Microsoft.NETCore.App 9.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
None

Environment variables:
Not set

```

### What did you do?
If possible, provide a recipe for reproducing the error. Try being specific and include code snippets if helpful.

```C#
var builder = WebApplication.CreateSlimBuilder();
...
builder.Services.AddGrpcReflection();
...
var web = builder.Build();

web.MapGrpcReflectionService();
```
### What did you expect to see?

No IL Trim warnings

### What did you see instead?

```
/_/src/Grpc.AspNetCore.Server.Reflection/GrpcReflectionServiceExtensions.cs(129): Trim analysis warning IL2075: Microsoft.Extensions.DependencyInjection.GrpcReflectionServiceExtensions.GetDescriptorPropertyFallback(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperty(String,BindingFlags,Binder,Type,Type[],ParameterModifier[])'. The return value of method 'System.Reflection.MemberInfo.DeclaringType.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
```

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

See [TROUBLESHOOTING.md](https://github.com/grpc/grpc-dotnet/blob/master/TROUBLESHOOTING.md) for how to diagnose problems better.

### Anything else we should know about your project / environment?

Contributor guide

Open the contributing guide

Research direction

Start with Grpc.AspNetCore.Server.Reflection/GrpcReflectionServiceExtensions.cs at line 129 and reproduce the warning with the WebApplication.CreateSlimBuilder, AddGrpcReflection, and MapGrpcReflectionService setup from the issue. Trace the GetDescriptorPropertyFallback reflection call and verify the completed change produces no IL trim warnings under the reported .NET 9 SDK.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.