bazel-contrib / bazel-contrib/rules_dotnet

`ImplicitUsings` is not handled

Open
#436 8 comments 4 reactions 0 assignees View on GitHub
Dominant language
Starlark
Stars
209
Forks
98
Avg merge
3h 59m
Merged PRs (30d)
14

Description

Since `rules_dotnet` doesn't run MSBuild, the `Using` directives added by the Task files in the .NET SDK are not handled, causing the build to fail unless the auto-generated `{Assembly}.GlobalUsings.g.cs` is included in `srcs`.

For the time being, I'm hand-maintaining the following file:

```c#
// NOTE: Keep this file in sync with the following Using directives
// whenever the .NET SDK version is updated:
//
// https://github.com/dotnet/sdk/blob/release/8.0.2xx/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.CSharp.props#L26
// https://github.com/dotnet/sdk/blob/release/8.0.2xx/src/WebSdk/Web/Targets/Sdk.Server.props#L64

global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;
global using global::System.Net.Http.Json;
global using global::Microsoft.AspNetCore.Builder;
global using global::Microsoft.AspNetCore.Hosting;
global using global::Microsoft.AspNetCore.Http;
global using global::Microsoft.AspNetCore.Routing;
global using global::Microsoft.Extensions.Configuration;
global using global::Microsoft.Extensions.DependencyInjection;
global using global::Microsoft.Extensions.Hosting;
global using global::Microsoft.Extensions.Logging;
```

But obviously this isn't very nice. Would there be anyway to generate this file through Bazel somehow?

Contributor guide

Open the contributing guide

Research direction

Start by comparing the hand-maintained global-usings file with the .NET SDK Using directives linked in the issue, then inspect how rules_dotnet handles srcs and generated C# files. Define completion as Bazel builds handling ImplicitUsings without manually adding {Assembly}.GlobalUsings.g.cs; the issue does not name a specific source file or test.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.