Skip to content

Bazel: fix more managed assembly diffs#49

Merged
agocke merged 4 commits intobazelfrom
bazel-more-libs-match
Mar 9, 2026
Merged

Bazel: fix more managed assembly diffs#49
agocke merged 4 commits intobazelfrom
bazel-more-libs-match

Conversation

@agocke
Copy link
Owner

@agocke agocke commented Mar 8, 2026

  • Add gen_pnse_source rule and GenNotSupportedSource tool to generate
    .notsupported.cs stubs from ref assembly sources, matching MSBuild's
    GeneratePlatformNotSupportedAssemblyMessage behavior.

  • Fix PNSE assemblies (Microsoft.Win32.Registry, System.IO.Pipes.AccessControl,
    System.Threading.AccessControl, System.Runtime.InteropServices.JavaScript):
    Replace System.Void.cs with generated .notsupported.cs stubs and add
    resx_file for SR resource strings.

  • System shim: Convert deps from ref_ to impl_ assemblies, matching
    MSBuild's CompileUsingReferenceAssemblies=false behavior. Add
    impl_System.Private.Uri and ref_System.Private.CoreLib. This avoids
    the CS0433 conflict that occurred when mixing ref_System.Runtime
    (which declares Uri stubs) with impl_System.Private.Uri (which has
    actual Uri types). The impl_System.Runtime only has type forwards,
    so no conflict.

  • CoreLib: Add omit_getresourcestring support to gen_resx_source rule
    and GenerateResxSource tool. Set resource_class_name=System.SR and
    omit_getresourcestring=True on CoreLib, matching MSBuild's
    GenerateResxSourceOmitGetResourceString=true. The generated SR.cs
    now contains only property accessors (no GetResourceString method),
    which merges cleanly with Common/src/System/SR.cs as a partial class.

agocke and others added 4 commits March 8, 2026 11:29
- Add gen_pnse_source rule and GenNotSupportedSource tool to generate
  .notsupported.cs stubs from ref assembly sources, matching MSBuild's
  GeneratePlatformNotSupportedAssemblyMessage behavior.

- Fix PNSE assemblies (Microsoft.Win32.Registry, System.IO.Pipes.AccessControl,
  System.Threading.AccessControl, System.Runtime.InteropServices.JavaScript):
  Replace System.Void.cs with generated .notsupported.cs stubs and add
  resx_file for SR resource strings.

- Fix System.Runtime.Serialization.Formatters: Replace 30 Binary Formatter
  impl files with BinaryFormatter.Removed.cs stub, matching MSBuild's
  NetCoreAppCurrent behavior (FunctioningBinaryFormatter=false).

- Add resource_class_name plumbing through csharp_library (defs.bzl) and
  netcoreapp_impl_assembly (src/libraries/defs.bzl) for future use.

- Add pnse_message/pnse_ref_srcs parameters to netcoreapp_impl_assembly
  for declarative PNSE stub generation.

- Update managed-assembly-manifest.txt comments and docs/bazel.md to
  reflect current state.

Remaining diffs (not addressed):
- System: needs System.Private.Uri dep but causes CS0433 with ref_System.Runtime
- System.Private.CoreLib: SR.cs class name conflict with Common/SR.cs
- System.Net.Quic: needs full Linux impl (~86 source files)
- 14 non-archive assemblies: differ by design (precise deps vs targeting pack)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Move GenFacades, GenNotSupportedSource, GenerateResxSource, ResGen, and
test_proj2bazel into src/tools/bazel/ to consolidate all Bazel-specific
tooling in one location alongside BuildEquivalenceCheck.

Update all label references in defs.bzl and src/libraries/defs.bzl.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
System shim: Convert deps from ref_ to impl_ assemblies, matching
MSBuild's CompileUsingReferenceAssemblies=false behavior. Add
impl_System.Private.Uri and ref_System.Private.CoreLib. This avoids
the CS0433 conflict that occurred when mixing ref_System.Runtime
(which declares Uri stubs) with impl_System.Private.Uri (which has
actual Uri types). The impl_System.Runtime only has type forwards,
so no conflict.

CoreLib: Add omit_getresourcestring support to gen_resx_source rule
and GenerateResxSource tool. Set resource_class_name=System.SR and
omit_getresourcestring=True on CoreLib, matching MSBuild's
GenerateResxSourceOmitGetResourceString=true. The generated SR.cs
now contains only property accessors (no GetResourceString method),
which merges cleanly with Common/src/System/SR.cs as a partial class.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Set EnableUnsafeBinaryFormatterSerialization to false in the test
runtimeconfig, matching MSBuild behavior. With BinaryFormatter.Removed.cs
in the runtime, tests using BinaryFormatter are now properly skipped
via PlatformDetection.IsBinaryFormatterSupported instead of failing
with PlatformNotSupportedException.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@agocke agocke merged commit 46a6116 into bazel Mar 9, 2026
8 of 10 checks passed
@agocke agocke deleted the bazel-more-libs-match branch March 9, 2026 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant