Skip to content

[TrimmableTypeMap] Add typed logger interface - #11095

Merged
simonrozsival merged 1 commit into
mainfrom
dev/simonrozsival/trimmable-typed-logger
Apr 9, 2026
Merged

[TrimmableTypeMap] Add typed logger interface#11095
simonrozsival merged 1 commit into
mainfrom
dev/simonrozsival/trimmable-typed-logger

Conversation

@simonrozsival

@simonrozsivalsimonrozsival commented Apr 9, 2026

Copy link
Copy Markdown
Member

Summary

Replace Action<string> log callback with ITrimmableTypeMapLogger interface in TrimmableTypeMapGenerator. This enables structured logging with typed methods instead of free-form string messages, making it easier to extend with new log categories (e.g., warnings) in follow-up PRs.

No behavioral changes — pure refactoring.

Changes

  • ITrimmableTypeMapLogger — new interface with 8 typed log methods
  • TrimmableTypeMapGenerator — accept ITrimmableTypeMapLogger? instead of Action<string>
  • GenerateTrimmableTypeMap — add MSBuildTrimmableTypeMapLogger adapter class
  • Tests — add TestTrimmableTypeMapLogger test double

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors TrimmableTypeMap logging by replacing the Action<string> callback with a typed ITrimmableTypeMapLogger interface, enabling structured/typed log events for the typemap generator pipeline.

Changes:

  • Introduces ITrimmableTypeMapLogger with typed log methods for key generator events.
  • Updates TrimmableTypeMapGenerator to accept an optional ITrimmableTypeMapLogger.
  • Adds MSBuild and test adapters (MSBuildTrimmableTypeMapLogger, TestTrimmableTypeMapLogger).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

FileDescription
tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/Generator/TrimmableTypeMapGeneratorTests.csReplaces string callback logger with a typed test logger implementation.
src/Xamarin.Android.Build.Tasks/Tasks/GenerateTrimmableTypeMap.csAdds an MSBuild logger adapter implementing the new interface and wires it into the task.
src/Microsoft.Android.Sdk.TrimmableTypeMap/TrimmableTypeMapGenerator.csSwitches generator logging from Action<string> to ITrimmableTypeMapLogger? calls.
src/Microsoft.Android.Sdk.TrimmableTypeMap/ITrimmableTypeMapLogger.csAdds the new typed logging interface.

Comment on lines +12 to +16
readonly ITrimmableTypeMapLogger? logger;

public TrimmableTypeMapGenerator (Action<string> log)
public TrimmableTypeMapGenerator (ITrimmableTypeMapLogger? logger = null)
{
this.log = log ?? throw new ArgumentNullException (nameof (log));
this.logger = logger;

CopilotAIApr 9, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description says “No behavioral changes — pure refactoring”, but the TrimmableTypeMapGenerator constructor now accepts a null logger (and even defaults to null) instead of throwing on null as it did with the previous required Action parameter. This changes the API contract and runtime behavior for callers that pass null (they’ll now silently get no logging). If the intent is truly no behavior change, keep the parameter required/non-null and continue throwing on null; otherwise, update the PR description to reflect the contract change.

Copilot uses AI. Check for mistakes.
@simonrozsival
simonrozsivalforce-pushed the dev/simonrozsival/trimmable-typed-logger branch 3 times, most recently from 7443456 to 0342566CompareApril 9, 2026 08:30
Replace Action<string> log callback with ITrimmableTypeMapLogger interface
in TrimmableTypeMapGenerator. This enables structured logging with typed
methods instead of free-form string messages, making it easier to extend
with new log categories (e.g., warnings) in follow-up PRs.
No behavioral changes — pure refactoring.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@simonrozsival
simonrozsivalforce-pushed the dev/simonrozsival/trimmable-typed-logger branch from 0342566 to d68d7dfCompareApril 9, 2026 08:32
@simonrozsivalsimonrozsival added trimmable-type-map copilot `copilot-cli` or other AIs were used to author this labels Apr 9, 2026
@simonrozsival
simonrozsival enabled auto-merge (squash) April 9, 2026 13:05
@simonrozsival
simonrozsival merged commit 859db83 into mainApr 9, 2026
6 checks passed
@simonrozsival
simonrozsival deleted the dev/simonrozsival/trimmable-typed-logger branch April 9, 2026 14:29
@github-actionsgithub-actionsBot locked and limited conversation to collaborators May 10, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

copilot`copilot-cli` or other AIs were used to author thistrimmable-type-map

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@simonrozsival