Nucs / JsonSettings

This library simplifies creating configuration for your C# app/service by utilizing the serialization capabilities of Json.NET to serialize nested (custom) objects, dictionaries and lists as simply as by creating a POCO and inheriting JsonSettings class.
MIT License
76 stars 18 forks source link

Simplify WithVersioning Module #28

Closed ghost1372 closed 3 years ago

ghost1372 commented 3 years ago

Is it possible to change the version number only in the config class? Using

public virtual Version Version { get; set; } = new Version(1, 0, 0, 6);

.WithVersioning(VersioningResultAction.RenameAndLoadDefault)

instead of .WithVersioning("2.1.1.7", VersioningResultAction.RenameAndLoadDefault) In this case, the way to use the module is also easier and the possibility of mistakes in the version number is also reduced

Thank you

Nucs commented 3 years ago

The main challenge is that to get that default value, we'll have to allocate a new object to obtain it. Maybe a better option will be to use an attribute

[EnforcedVersion(new Version(...))] //or with string
public virtual Version Version { get; set; }

The value will be populated only if VersioningModule is attached.

ghost1372 commented 3 years ago

Attribute seems interesting I agree with you

Nucs commented 3 years ago

JsonSettings.Tests/VersioningModuleTests.cs has tests covering usage + support for inheritance. It is the same as I mentioned above. Will be out in next prerelease