Skip to content

Commit 7f925ad

Browse files
authored
Merge pull request #16 from beheshty/feature/ignore-setsharp-setting-section-in-poco-generation
Feature/ignore setsharp setting section in poco generation
2 parents d2cf491 + 90dd35d commit 7f925ad

3 files changed

Lines changed: 27 additions & 1 deletion

File tree

src/SetSharp/ModelBuilder/ConfigurationModelBuilder.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ private void ProcessObject(SettingClassInfo SettingClassInfo, Dictionary<string,
2020
{
2121
foreach (var item in obj)
2222
{
23+
if (string.Equals(item.Key, "SetSharp", StringComparison.OrdinalIgnoreCase))
24+
{
25+
continue;
26+
}
2327
var propertyModel = new SettingPropertyInfo
2428
{
2529
OriginalJsonKey = item.Key,

src/SetSharp/SetSharp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
1111

1212
<PackageId>SetSharp</PackageId>
13-
<Version>1.3.0</Version>
13+
<Version>1.3.2</Version>
1414
<PackageIcon>icon.png</PackageIcon>
1515
<Authors>Amirhossein Beheshti</Authors>
1616
<Description>Generates strongly typed settings classes from appsettings.json using Source Generators.</Description>

tests/SetSharp.Tests/ModelBuilder/ConfigurationModelBuilderTests.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,28 @@ public void BuildFrom_WithFlatPrimitives_ShouldCreateModelCorrectly()
3434
Assert.Equal("double", rootModel.Properties.First(p => p.PropertyName == "DefaultThreshold").PropertyType);
3535
}
3636

37+
[Fact]
38+
public void BuildFrom_WithSetSharpSection_ShouldIgnoreSetSharp()
39+
{
40+
// Arrange
41+
var builder = new ConfigurationModelBuilder();
42+
var root = new Dictionary<string, object>
43+
{
44+
{ "ConnectionString", "Server=.;Database=Test;"},
45+
{ "SetSharp", new Dictionary<string, object>() }
46+
};
47+
48+
// Act
49+
var result = builder.BuildFrom(root);
50+
51+
// Assert
52+
var rootModel = Assert.Single(result);
53+
Assert.Equal("RootOptions", rootModel.ClassName);
54+
Assert.Equal("", rootModel.SectionPath);
55+
56+
Assert.DoesNotContain(result, c => c.ClassName == "SetSharp");
57+
}
58+
3759
[Fact]
3860
public void BuildFrom_WithNestedObject_ShouldCreateSeparateClassModel()
3961
{

0 commit comments

Comments
 (0)