Update AutoMapper to 16.1.1 and add LoggerFactory support#4468
Conversation
Upgraded AutoMapper to version 16.1.1 across all projects. Updated all MapperConfiguration instantiations to include a LoggerFactory as required by the new version. Added Microsoft.Extensions.Logging imports where necessary. No changes to mapping logic; these updates ensure compatibility and proper logging configuration with the latest AutoMapper API.
WalkthroughUpdated AutoMapper dependency to v16.1.1 and modified numerous MapperConfiguration constructions to pass a LoggerFactory (NullLoggerFactory.Instance); added Microsoft.Extensions.Logging.Abstractions using directives. No public APIs or mapping targets were changed. Changes
Sequence Diagram(s)(omitted — changes are logging/config adjustments across many files, not a new multi-component control flow) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@Ginger/GingerCoreNET/ActionsLib/UI/ActSwitchWindow.cs`:
- Line 164: The code instantiates a new disposable LoggerFactory for every
AutoMapper configuration (mapConfig = new AutoMapper.MapperConfiguration(...,
new LoggerFactory())), causing repeated allocations; replace the per-call new
LoggerFactory() with a shared singleton logger factory (e.g.,
Microsoft.Extensions.Logging.Abstractions.NullLoggerFactory.Instance) or an
injected ILoggerFactory field, and update the AutoMapper.MapperConfiguration
invocation in ActSwitchWindow (the GetNewAction()/mapConfig creation spot) to
use that shared instance instead.
In `@Ginger/GingerCoreNET/ActionsLib/UI/Legacy/ActCheckbox.cs`:
- Line 142: The AutoMapper.MapperConfiguration invocation in ActCheckbox.cs is
missing a space after the comma; update the call to match other files (e.g.,
ActLabel.cs) by adding a space between the closing brace and new LoggerFactory()
so the line reads like AutoMapper.MapperConfiguration(cfg => {
cfg.CreateMap<Act, ActUIElement>(); }, new LoggerFactory()); — look for the
AutoMapper.MapperConfiguration and LoggerFactory usage in ActCheckbox.cs and
adjust spacing to be consistent.
In `@Ginger/GingerCoreNET/ActionsLib/UI/Legacy/ActPassword.cs`:
- Line 24: The code currently constructs a LoggerFactory (new LoggerFactory())
when building the MapperConfiguration in ActPassword (or wherever
MapperConfiguration is instantiated), which yields a silent no-op logger;
replace that with NullLoggerFactory.Instance to explicitly indicate no logging,
or wire in a configured factory via LoggerFactory.Create(...) (e.g., add
providers) or, preferably, accept/inject an ILoggerFactory from DI and pass that
into MapperConfiguration; update the MapperConfiguration constructor call to use
NullLoggerFactory.Instance or the injected ILoggerFactory and remove the direct
new LoggerFactory() usage.
In `@Ginger/GingerCoreNET/DiameterLib/DiameterUtils.cs`:
- Around line 198-199: Replace the per-call new LoggerFactory() allocations used
when constructing AutoMapper.MapperConfiguration with a shared static
ILoggerFactory on the DiameterUtils type: add a static readonly ILoggerFactory
(e.g., SharedLoggerFactory) to DiameterUtils and use that instance in both
locations where MapperConfiguration(cfg =>
cfg.AddProfile<DiameterAutoMapperProfile>(), new LoggerFactory()) is called (the
occurrences around the mapperConfig/CreateMapper calls), ensuring the factory is
reused across calls and not recreated per call; leave disposal to application
shutdown or provide a single centralized dispose path for the static factory.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 5b88e5ca-1111-4792-899d-e438476cd528
📒 Files selected for processing (29)
Ginger/Ginger/Actions/ActionEditPages/WebServices/ActDiameterEditPage.xaml.csGinger/Ginger/Ginger.csprojGinger/GingerCore/Actions/ActLowLevelClicks.csGinger/GingerCore/Actions/ActMenuItem.csGinger/GingerCore/Actions/ActTableElement.csGinger/GingerCore/GingerCore.csprojGinger/GingerCoreNET/ActionsLib/ActASCFControl.csGinger/GingerCoreNET/ActionsLib/ActWindow.csGinger/GingerCoreNET/ActionsLib/Java/ActJavaElement.csGinger/GingerCoreNET/ActionsLib/UI/ActSwitchWindow.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActButton.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActCheckbox.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActDropDownList.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActGenElement.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActGotoURL.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActHandleBrowserAlert.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActLabel.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActLink.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActPassword.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActSubmit.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActTextBox.csGinger/GingerCoreNET/ActionsLib/Webservices/ActREST.csGinger/GingerCoreNET/ActionsLib/Webservices/ActWebService.csGinger/GingerCoreNET/Application Models/Learn/APIModels/ApiActionConversionUtils.csGinger/GingerCoreNET/Application Models/Learn/APIModels/LearnAPIModelsUtils.csGinger/GingerCoreNET/DiameterLib/DiameterUtils.csGinger/GingerCoreNET/GeneralLib/AutomapData.csGinger/GingerCoreNET/GingerCoreNET.csprojGinger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportApiHandler.cs
| { | ||
| bool uIElementTypeAssigned = false; | ||
| AutoMapper.MapperConfiguration mapConfig = new AutoMapper.MapperConfiguration(cfg => { cfg.CreateMap<Act, ActUIElement>(); }); | ||
| AutoMapper.MapperConfiguration mapConfig = new AutoMapper.MapperConfiguration(cfg => { cfg.CreateMap<Act, ActUIElement>(); },new LoggerFactory()); |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Minor formatting inconsistency.
The line is missing a space after the comma compared to other files in this PR (e.g., }, new LoggerFactory() in ActLabel.cs).
🧹 Suggested fix for consistent formatting
- AutoMapper.MapperConfiguration mapConfig = new AutoMapper.MapperConfiguration(cfg => { cfg.CreateMap<Act, ActUIElement>(); },new LoggerFactory());
+ AutoMapper.MapperConfiguration mapConfig = new AutoMapper.MapperConfiguration(cfg => { cfg.CreateMap<Act, ActUIElement>(); }, new LoggerFactory());📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| AutoMapper.MapperConfiguration mapConfig = new AutoMapper.MapperConfiguration(cfg => { cfg.CreateMap<Act, ActUIElement>(); },new LoggerFactory()); | |
| AutoMapper.MapperConfiguration mapConfig = new AutoMapper.MapperConfiguration(cfg => { cfg.CreateMap<Act, ActUIElement>(); }, new LoggerFactory()); |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@Ginger/GingerCoreNET/ActionsLib/UI/Legacy/ActCheckbox.cs` at line 142, The
AutoMapper.MapperConfiguration invocation in ActCheckbox.cs is missing a space
after the comma; update the call to match other files (e.g., ActLabel.cs) by
adding a space between the closing brace and new LoggerFactory() so the line
reads like AutoMapper.MapperConfiguration(cfg => { cfg.CreateMap<Act,
ActUIElement>(); }, new LoggerFactory()); — look for the
AutoMapper.MapperConfiguration and LoggerFactory usage in ActCheckbox.cs and
adjust spacing to be consistent.
Replaced new LoggerFactory() with NullLoggerFactory.Instance in AutoMapper.MapperConfiguration across multiple files. Added Microsoft.Extensions.Logging.Abstractions where needed. This disables logging for AutoMapper configuration, reducing log output and potential overhead. No functional changes to mapping logic.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@Ginger/GingerCoreNET/ActionsLib/UI/Legacy/ActGenElement.cs`:
- Around line 170-171: Local variable name mapConfigBrowserElementt has a typo;
rename it to mapConfigBrowserElement (or another clear name) where it's declared
as an AutoMapper.MapperConfiguration and where it's used to call
CreateMapper().Map<Act, ActBrowserElement>(this) so the declaration and usage
(AutoMapper.MapperConfiguration mapConfigBrowserElementt and the Map call) stay
consistent and improve readability in the Act -> ActBrowserElement conversion.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: b837e9ac-9e90-4e7d-a389-27bbc4fb610d
📒 Files selected for processing (26)
Ginger/Ginger/Actions/ActionEditPages/WebServices/ActDiameterEditPage.xaml.csGinger/GingerCore/Actions/ActLowLevelClicks.csGinger/GingerCore/Actions/ActMenuItem.csGinger/GingerCore/Actions/ActTableElement.csGinger/GingerCoreNET/ActionsLib/ActASCFControl.csGinger/GingerCoreNET/ActionsLib/ActWindow.csGinger/GingerCoreNET/ActionsLib/Java/ActJavaElement.csGinger/GingerCoreNET/ActionsLib/UI/ActSwitchWindow.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActButton.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActCheckbox.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActDropDownList.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActGenElement.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActGotoURL.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActHandleBrowserAlert.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActLabel.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActLink.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActPassword.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActSubmit.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActTextBox.csGinger/GingerCoreNET/ActionsLib/Webservices/ActREST.csGinger/GingerCoreNET/ActionsLib/Webservices/ActWebService.csGinger/GingerCoreNET/Application Models/Learn/APIModels/ApiActionConversionUtils.csGinger/GingerCoreNET/Application Models/Learn/APIModels/LearnAPIModelsUtils.csGinger/GingerCoreNET/DiameterLib/DiameterUtils.csGinger/GingerCoreNET/GeneralLib/AutomapData.csGinger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportApiHandler.cs
Removed all using statements for Microsoft.Extensions.Logging across multiple files. No other code changes were made; this commit eliminates unused logging framework references.
There was a problem hiding this comment.
♻️ Duplicate comments (1)
Ginger/GingerCoreNET/ActionsLib/UI/Legacy/ActGenElement.cs (1)
169-170: 🧹 Nitpick | 🔵 TrivialTypo in variable name:
mapConfigBrowserElementthas an extra 't'.This affects readability. Consider renaming to
mapConfigBrowserElement.✏️ Proposed fix
- AutoMapper.MapperConfiguration mapConfigBrowserElementt = new AutoMapper.MapperConfiguration(cfg => { cfg.CreateMap<Act, ActBrowserElement>(); }, NullLoggerFactory.Instance); - ActBrowserElement NewActBrowserElement = mapConfigBrowserElementt.CreateMapper().Map<Act, ActBrowserElement>(this); + AutoMapper.MapperConfiguration mapConfigBrowserElement = new AutoMapper.MapperConfiguration(cfg => { cfg.CreateMap<Act, ActBrowserElement>(); }, NullLoggerFactory.Instance); + ActBrowserElement NewActBrowserElement = mapConfigBrowserElement.CreateMapper().Map<Act, ActBrowserElement>(this);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@Ginger/GingerCoreNET/ActionsLib/UI/Legacy/ActGenElement.cs` around lines 169 - 170, Rename the misspelled local variable mapConfigBrowserElementt to mapConfigBrowserElement to improve readability and consistency; update both its declaration (AutoMapper.MapperConfiguration mapConfigBrowserElementt = ...) and the subsequent usage (mapConfigBrowserElementt.CreateMapper().Map<Act, ActBrowserElement>(this)) so the variable name matches in the ActGenElement.cs method that constructs the ActBrowserElement mapping.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@Ginger/GingerCoreNET/ActionsLib/UI/Legacy/ActGenElement.cs`:
- Around line 169-170: Rename the misspelled local variable
mapConfigBrowserElementt to mapConfigBrowserElement to improve readability and
consistency; update both its declaration (AutoMapper.MapperConfiguration
mapConfigBrowserElementt = ...) and the subsequent usage
(mapConfigBrowserElementt.CreateMapper().Map<Act, ActBrowserElement>(this)) so
the variable name matches in the ActGenElement.cs method that constructs the
ActBrowserElement mapping.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: e68d60b4-8796-41f3-8fe1-013a5c830121
📒 Files selected for processing (26)
Ginger/Ginger/Actions/ActionEditPages/WebServices/ActDiameterEditPage.xaml.csGinger/GingerCore/Actions/ActLowLevelClicks.csGinger/GingerCore/Actions/ActMenuItem.csGinger/GingerCore/Actions/ActTableElement.csGinger/GingerCoreNET/ActionsLib/ActASCFControl.csGinger/GingerCoreNET/ActionsLib/ActWindow.csGinger/GingerCoreNET/ActionsLib/Java/ActJavaElement.csGinger/GingerCoreNET/ActionsLib/UI/ActSwitchWindow.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActButton.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActCheckbox.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActDropDownList.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActGenElement.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActGotoURL.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActHandleBrowserAlert.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActLabel.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActLink.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActPassword.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActSubmit.csGinger/GingerCoreNET/ActionsLib/UI/Legacy/ActTextBox.csGinger/GingerCoreNET/ActionsLib/Webservices/ActREST.csGinger/GingerCoreNET/ActionsLib/Webservices/ActWebService.csGinger/GingerCoreNET/Application Models/Learn/APIModels/ApiActionConversionUtils.csGinger/GingerCoreNET/Application Models/Learn/APIModels/LearnAPIModelsUtils.csGinger/GingerCoreNET/DiameterLib/DiameterUtils.csGinger/GingerCoreNET/GeneralLib/AutomapData.csGinger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportApiHandler.cs
Upgraded AutoMapper to version 16.1.1 across all projects. Updated all MapperConfiguration instantiations to include a LoggerFactory as required by the new version. Added Microsoft.Extensions.Logging imports where necessary. No changes to mapping logic; these updates ensure compatibility and proper logging configuration with the latest AutoMapper API.
Description
Type of Change
Checklist
[IsSerializedForLocalRepository]where neededReporter.ToLog()patternSummary by CodeRabbit