Giter Site home page Giter Site logo

extensions.configuration.object's Introduction

Hi there ๐Ÿ‘‹

lawrence-laz's GitHub stats

extensions.configuration.object's People

Contributors

lawrence-laz avatar nicolaspierre1990 avatar runemoennike avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

extensions.configuration.object's Issues

Enums are loaded as value, but should be loaded as name

When IOptions are loaded from Configuration they can read enum settings, but they need to be entered by name, rather than by value. Current implementation loads it as value, which results in all enum values defaulting to first one.

StackOverflowException in LoadRecursively when serialising a Record

C# Records have a compiler generated Type EqualityContract property, once they get compiled into classes. When loading such a class, LoadRecursively fails with a StackOverflowException.

The property should not be loaded, I would say, but currently only fields are ignored when they have the CompilerGenerated attribute. I propose to check properties in the same way, and I will make a PR with this implemented.

For reference, here is a new unit test case that fails in the current implementation:

    public class RecordObjectTest
    {
        internal record MyConfiguration
        {
            public SubRecordConfiguration SubRecord;
            public string MyKey;
        }

        internal record SubRecordConfiguration
        {
            public string Title;
            public string Name;
            public int Age;
        }

        [Fact]
        public void AddObject_WithClassObject_ShouldLoadFieldsIntoConfiguration()
        {
            var configuration = new ConfigurationBuilder()
                .AddObject(new MyConfiguration
                {
                    SubRecord = new SubRecordConfiguration
                    {
                        Title = "Editor",
                        Name = "Joe Smith",
                        Age = 33
                    },
                    MyKey = "My appsettings.json Value",
                })
                .Build();

            configuration["SubRecord:Title"].Should().Be("Editor");
            configuration["SubRecord:Name"].Should().Be("Joe Smith");
            configuration["SubRecord:Age"].Should().Be("33");
            configuration["MyKey"].Should().Be("My appsettings.json Value");
        }
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.