bazel-contrib / bazel-contrib/rules_dotnet
Issues loading types when mixing and matching net8.0 and netstandard2.1
- Dominant language
- Starlark
- Stars
- 209
- Forks
- 98
- Avg merge
- 3h 59m
- Merged PRs (30d)
- 14
Description
A binary:
```starlark
load("@rules_dotnet//dotnet:defs.bzl", "fsharp_binary")
fsharp_binary(
name = "app",
srcs = [
"Program.fs",
],
target_frameworks = [
"net8.0",
],
deps = [
"@paket.main//fsharp.core",
"@paket.main//awssdk.core",
"@paket.main//awssdk.s3",
"//utils",
],
treat_warnings_as_errors = True,
)
```
And a library:
```starlark
load("@rules_dotnet//dotnet:defs.bzl", "fsharp_library")
fsharp_library(
name = "utils",
srcs = [
"Utils.fs",
],
target_frameworks = [
"netstandard2.1",
],
deps = [
"@paket.main//fsharp.core",
"@paket.main//awssdk.core",
"@paket.main//awssdk.s3",
],
treat_warnings_as_errors = True,
visibility = [
"//visibility:public",
],
)
```
Leads to this runtime exception:
> Unhandled exception. System.TypeLoadException: Virtual static method 'CreateDefaultClientConfig' is not implemented on type 'Amazon.DynamoDBv2.AmazonDynamoDBClient' from assembly 'AWSSDK.DynamoDBv2, Version=4.0.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604'.
If the targets are aligned, then it will work:
```diff
load("@rules_dotnet//dotnet:defs.bzl", "fsharp_library")
fsharp_library(
name = "utils",
srcs = [
"Utils.fs",
],
target_frameworks = [
- "netstandard2.1",
+ "net8.0",
],
deps = [
"@paket.main//fsharp.core",
"@paket.main//awssdk.core",
"@paket.main//awssdk.s3",
],
treat_warnings_as_errors = True,
visibility = [
"//visibility:public",
],
)
```
Issue appears with `rules_dotnet` versions `0.20.5` and `0.21.5`.
Full repro here: https://github.com/njlr/rules_dotnet_aws_repro
Contributor guide
Research direction
Start with the linked full repro and compare rules_dotnet 0.20.5 and 0.21.5 using mixed net8.0/netstandard2.1 targets versus aligned net8.0 targets. Trace how the target_frameworks and AWS dependencies are loaded, then verify the mixed-target case no longer raises the reported TypeLoadException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, fsharp
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100