fix: NRE when `reset_unmatched_scores` not present

json-serializing-nullable-fields-issue
Robert Dailey 9 months ago
parent f3f95b3cd6
commit 4d7a5f49c3

@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Fixed
- Crash when doing `recyclarr sync` with no `reset_unmatched_scores` present.
## [5.3.0] - 2023-08-21
### Added

@ -23,7 +23,8 @@ public class ConfigYamlMapperProfile : Profile
.ForMember(x => x.UpgradeAllowed, o => o.MapFrom(x => x.Upgrade!.Allowed))
.ForMember(x => x.UpgradeUntilQuality, o => o.MapFrom(x => x.Upgrade!.UntilQuality))
.ForMember(x => x.UpgradeUntilScore, o => o.MapFrom(x => x.Upgrade!.UntilScore))
.ForMember(x => x.QualitySort, o => o.NullSubstitute(QualitySortAlgorithm.Top));
.ForMember(x => x.QualitySort, o => o.NullSubstitute(QualitySortAlgorithm.Top))
.ForMember(x => x.ResetUnmatchedScores, o => o.UseDestinationValue());
CreateMap<ServiceConfigYaml, ServiceConfiguration>()
.ForMember(x => x.InstanceName, o => o.Ignore());

@ -11,6 +11,9 @@ public class AutoMapperConfigurationTest : CliIntegrationFixture
public void Automapper_config_is_valid()
{
var mapper = Resolve<MapperConfiguration>();
// Build an execution plan like:
// var plan = mapper.BuildExecutionPlan(typeof(QualityProfileConfigYaml), typeof(QualityProfileConfig));
// And do `plan.ToReadableString()` in the Debug Expressions/Watch
mapper.AssertConfigurationIsValid();
}
}

@ -41,4 +41,15 @@ public class ConfigYamlMapperProfileTest
result.QualitySort.Should().Be(QualitySortAlgorithm.Top);
}
[Test]
public void Non_null_reset_unmatched_scores_when_source_is_null()
{
var yaml = new QualityProfileConfigYaml();
var mapper = CreateMapper();
var result = mapper.Map<QualityProfileConfig>(yaml);
result.ResetUnmatchedScores.Should().BeEquivalentTo(new ResetUnmatchedScoresConfig());
}
}

Loading…
Cancel
Save