Skip to content

Add compiler log (.complog) support as a website generation input - #279

Open
jaredpar wants to merge 1 commit into
mainfrom
jaredpar-add-complog-support
Open

Add compiler log (.complog) support as a website generation input#279
jaredpar wants to merge 1 commit into
mainfrom
jaredpar-add-complog-support

Conversation

@jaredpar

Copy link
Copy Markdown
Member

Why

The indexer currently accepts MSBuild binlogs and .sln/.slnx files as inputs. Compiler logs (.complog, from jaredpar/complog) are a compact, self-contained format that captures a fully-resolved Roslyn compilation per project. Supporting them lets repos feed the source browser without needing MSBuild evaluation at index time.

Approach

A .complog behaves like a workspace-producing input (similar to .sln), not like the binlog invocation-extraction path, so it is routed through SolutionGenerator/the Roslyn workspace rather than IndexSolutionsAsync's binlog branch.

  • Workspace creation (SolutionGenerator): Basic.CompilerLog.Util.SolutionReader materializes a SolutionInfo directly. It is created with BasicAnalyzerKind.None so originally-generated files are added inline and analyzers/source generators are not re-run. The reader is kept alive for the duration of Pass1 because document source text is loaded lazily from it, and is disposed in Dispose().
  • Assembly names (Program.GetAssemblyNamesAsync): read via the lighter-weight CompilerLogReader (ReadCompilerCallData(cc).AssemblyFileName for Regular calls) instead of building a full solution.
  • Type forwards (Program.GetTypeForwards): a compiler log does not ship emitted binaries, so each project's assembly is re-emitted to memory (EmitToMemory(EmitFlags.MetadataOnly)) from the persisted compilation and the forwards are read from those bytes. TypeForwardReader gained a Stream overload for this, sharing the metadata walk with the existing file-based path.
  • Naming quirk: complog reports AssemblyName with the file extension (e.g. HelloLib.dll), unlike the binlog/Roslyn path. NormalizeCompilerLogAssemblyNames strips it so Pass1 output folders line up with the extension-less global assembly list.
  • Plumbing: CommandLineOptions.IsSupportedProject and the README accept/document .complog; index.proj discovers and indexes *.complog in the pipeline.

Notes for reviewers

  • During generation complog emits a benign first-chance IOException on its locks\*.lock files; it is handled internally and generation completes fine.
  • Microsoft.CodeAnalysis.SolutionInfo is referenced fully-qualified in a couple of spots on purpose: HtmlGenerator has its own Microsoft.SourceBrowser.HtmlGenerator.SolutionInfo type that otherwise makes the short name ambiguous.

Validation

  • HtmlGenerator builds clean; all 189 tests pass (including new assembly-name normalization tests).
  • Verified end-to-end: built a C# lib to a binlog, converted to .complog, ran HtmlGenerator on it. Source is indexed and the output structure matches the equivalent binlog run (extension-less HelloLib folder).

Compiler logs (.complog, from jaredpar/complog) carry a fully-resolved
Roslyn compilation per project, so they can drive the source browser the
same way .sln inputs do without any MSBuild evaluation. This wires them
in alongside the existing binlog/.sln inputs.

- HtmlGenerator: route .complog through the SolutionGenerator/workspace
  path via Basic.CompilerLog.Util.SolutionReader (BasicAnalyzerKind.None
  so generators/analyzers are not re-run); read assembly names with the
  lighter-weight CompilerLogReader; derive type forwards by emitting each
  project's assembly (metadata only) in memory instead of reading build
  outputs off disk.
- Normalize complog assembly names (strip extension) so output folders
  match the extension-less global assembly list.
- CommandLineOptions/README: accept and document .complog inputs.
- index.proj: discover and index *.complog in the pipeline.
- Tests: cover assembly-name normalization.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8ccbc0b2-2195-4ecb-b61c-372cddc4afe4
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