Skip to content

refactor: simplify InvokeGetter in PropertySetup#402

Merged
vbreuss merged 1 commit into
mainfrom
topic/remove-unnecessary-condition-in-propertysetup
Jan 25, 2026
Merged

refactor: simplify InvokeGetter in PropertySetup#402
vbreuss merged 1 commit into
mainfrom
topic/remove-unnecessary-condition-in-propertysetup

Conversation

@vbreuss
Copy link
Copy Markdown
Member

@vbreuss vbreuss commented Jan 25, 2026

The PR simplifies the InvokeGetter method in PropertySetup by removing redundant initialization logic that was previously handling type mismatches. The code now relies solely on the initialization that occurs in the if (factory is not null) block above.

Key Changes:

  • Removed fallback initialization logic from InvokeGetter that attempted to use defaultValueGenerator when _isInitialized was false
  • Removed corresponding test InitializeValue_NotMatchingTypes_ShouldUseDefault that validated the removed behavior

@vbreuss vbreuss self-assigned this Jan 25, 2026
Copilot AI review requested due to automatic review settings January 25, 2026 05:11
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

The PR simplifies the InvokeGetter method in PropertySetup by removing redundant initialization logic that was previously handling type mismatches. The code now relies solely on the initialization that occurs in the if (factory is not null) block above.

Changes:

  • Removed fallback initialization logic from InvokeGetter that attempted to use defaultValueGenerator when _isInitialized was false
  • Removed corresponding test InitializeValue_NotMatchingTypes_ShouldUseDefault that validated the removed behavior

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
Source/Mockolate/Setup/PropertySetup.cs Removed redundant initialization code path from InvokeGetter method
Tests/Mockolate.Tests/MockProperties/SetupPropertyTests.cs Removed test validating the removed initialization behavior

@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

Test Results

    21 files  ±0      21 suites  ±0   5m 58s ⏱️ -57s
 2 396 tests  - 1   2 395 ✅  - 1  1 💤 ±0  0 ❌ ±0 
16 065 runs   - 7  16 064 ✅  - 7  1 💤 ±0  0 ❌ ±0 

Results for commit fb6ad62. ± Comparison against base commit e8b8d93.

This pull request removes 1 test.
Mockolate.Tests.MockProperties.SetupPropertyTests ‑ InitializeValue_NotMatchingTypes_ShouldUseDefault

@github-actions
Copy link
Copy Markdown

🚀 Benchmark Results

Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.3 LTS (Noble Numbat)
AMD EPYC 7763 3.13GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.102
[Host] : .NET 10.0.2 (10.0.2, 10.0.225.61305), X64 RyuJIT x86-64-v3

Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15
LaunchCount=1 WarmupCount=10

Method Mean Error StdDev Gen0 Gen1 Allocated
Simple_Mockolate 1.667 μs 0.0303 μs 0.0283 μs 0.2270 - 3.73 KB
Simple_Moq 184.212 μs 0.8465 μs 0.7504 μs 0.4883 - 14.55 KB
Simple_NSubstitute 5.962 μs 0.0671 μs 0.0627 μs 0.5569 0.0076 9.14 KB
Simple_FakeItEasy 6.718 μs 0.0727 μs 0.0680 μs 0.4959 - 8.11 KB

@vbreuss vbreuss merged commit ae38745 into main Jan 25, 2026
12 checks passed
@vbreuss vbreuss deleted the topic/remove-unnecessary-condition-in-propertysetup branch January 25, 2026 06:18
@github-actions
Copy link
Copy Markdown

This is addressed in release v1.0.3.

@github-actions github-actions Bot added the state: released The issue is released label Jan 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants