Skip to content

Report generator failures as DM0001, and make log and file names unique - #95

Merged
ipjohnson merged 1 commit into
mainfrom
fix/generator-failures-and-logs
Sep 24, 2026
Merged

ipjohnson merged 1 commit into
mainfrom
fix/generator-failures-and-logs

Conversation

@ipjohnson

Copy link
Copy Markdown
Owner

Closes #84. Closes #90. Closes #94.

An exception in any output of the generator is now reported as DM0001. Before this, four of the eight outputs had no handler. An exception there gave CS8785, and Roslyn removed all generated code. Log files no longer replace each other, and two modules can no longer get the same generated file name.

#94: file names

GetFileNameHint removes the root namespace, so App.Sub.FooModule and Sub.FooModule both got Sub.FooModule.Module.g.cs. A name outside the root namespace now starts with global-, for example global-Sub.FooModule.Module.g.cs. A namespace cannot contain -, so no shortened name can match it.

The names of types under the root namespace do not change. A type in the global namespace changes from global.X to global-X, because a type X in the namespace App.global also got global.X.

#90: log files

Each log file name now ends with 8 random hex characters after the time. The diagnostics output of each stage logs as <Stage>.Diagnostics. Thus the ServiceSourceGenerator log is again the one with the configuration, the modules and the services.

#84: DM0001 for every output

These outputs now run inside FileLogger.Wrap:

  • the module writer
  • ModuleEntryPointDiagnostics (DM0003, DM0017, DM0018)
  • AssemblyModuleAttributeDiagnostics (DM0016, DM0019)
  • TestAttributeDiagnostics (DM0021)

A new FileLogger.Wrap overload takes the SourceProductionContext and reports DM0001. The four outputs that already reported DM0001 use it too. The module writer catches per module, so a module that fails does not remove the code of the others. OperationCanceledException is not caught, because it is Roslyn stopping the run.

TestAttributeDiagnostics now reads the configuration to find the log folder, because a test project often declares no module to take it from. BaseSourceGenerator.CreateConfigurationValueProvider is internal static for this.

With #94 fixed, the repro in #84 no longer fails. The test for #84 gives the module writer a module whose name Roslyn refuses as a hint name.

Public API

Two members are added to the DependencyModules.SourceGenerator API: DependencyModuleDiagnostics.GeneratorFailureFrom(Exception) and the new FileLogger.Wrap overload. Nothing is removed.

Docs

The warnings for #84 and #90 are on docs-ste-rewrite, in troubleshooting.md and diagnostics.md. That branch is not on main, so this PR does not change them. They will be removed in one docs pass after the fixes.

Verified

  • The new tests fail on main (8 failures) and pass with this change.
  • The full suite passes on net8.0 and net10.0.
  • The Release build is clean, and dotnet csharpier check . is clean.
  • I did not run scripts/coverage.sh or scripts/verify-packages.sh locally. CI runs both.

🤖 Generated with Claude Code

GetFileNameHint removed the root namespace from every name, so App.Sub.FooModule and
Sub.FooModule both got Sub.FooModule.Module.g.cs. A name outside the root namespace now
starts with "global-". A namespace cannot contain '-', so no shortened name can match it.

A log file name was the stage name and the time in milliseconds. The two outputs of a
stage often finish in the same millisecond, so one log replaced the other. Each name now
ends with a random part, and the diagnostics output of a stage logs under its own name.

The module writer and the three outputs that only report diagnostics had no handler. An
exception there gave CS8785, and Roslyn then dropped every generated file. They now log the
exception and report DM0001. The module writer does this per module, so one failure does
not remove the code of the other modules. Cancellation is not reported as a failure.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@ipjohnson
ipjohnson merged commit 24dea64 into main Sep 24, 2026
2 checks passed
ipjohnson added a commit that referenced this pull request Sep 24, 2026
* Update the docs for the fixes to issues #63 to #94

The warnings and limits that described the defects are removed or corrected, and the pages now
describe the behavior of PRs #95 to #111. DM0023, DM0024 and DM0025 get entries in the
diagnostics reference. The package description of DependencyModules.SourceGenerator.Impl no
longer tells the reader to add CSharpAuthor.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* Describe Implementation decorators with generated factories, and retire DM0022

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Ian Johnson <ianjohnson@mac.mynetworksettings.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
ipjohnson added a commit that referenced this pull request Sep 24, 2026
…113)

* Rewrite the README and documentation in Simplified Technical English

The new text follows ASD-STE100 Issue 9. It was written from the source
code, not from the previous documentation. All C# samples compile, and
the samples that can run were run. A separate review checked each claim
against the source.

This removes the pages guide/scanning, guide/testing-registrations,
reference/conventions-api, and reference/interfaces. It adds
guide/testing-container-source and reference/api. The nine package
descriptions are also rewritten.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* Point .git-blame-ignore-revs at the CSharpier commit on main

79a2881 is not in the history of main. The squash merge of #62 made
d7a1a82, which is the reformat commit on main. With the old hash,
git blame still gave 53 lines of ModuleEnvironment.cs to the reformat.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* Update the docs for the fixes to issues #63 to #94 (#112)

* Update the docs for the fixes to issues #63 to #94

The warnings and limits that described the defects are removed or corrected, and the pages now
describe the behavior of PRs #95 to #111. DM0023, DM0024 and DM0025 get entries in the
diagnostics reference. The package description of DependencyModules.SourceGenerator.Impl no
longer tells the reader to add CSharpAuthor.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* Describe Implementation decorators with generated factories, and retire DM0022

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Ian Johnson <ianjohnson@mac.mynetworksettings.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* Document three service registration limits found during the fixes

A keyed factory method, TryEnumerable for a registration whose implementation is its service
type, and a class with only internal constructors all fail at run time with no diagnostic. No
issue tracks them yet.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* Restore the CSharpAuthor packing in DependencyModules.SourceGenerator.Impl

The merge of main took this branch's whole project file to keep its description, which
dropped what #103 added: GeneratePathProperty on CSharpAuthor and the items that pack its
sources. The project file now matches main except for the description.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Ian Johnson <ianjohnson@mac.mynetworksettings.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant