Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConfigurationBuilder does not initialize an INI file #119

Open
tmontney opened this issue Sep 7, 2021 · 0 comments
Open

ConfigurationBuilder does not initialize an INI file #119

tmontney opened this issue Sep 7, 2021 · 0 comments

Comments

@tmontney
Copy link

tmontney commented Sep 7, 2021

Couldn't find anywhere else to post this.

When I run Build, I expect...

  1. Create the .ini file (relative path from executing directory or absolute path)
  2. Write settings with default values
  3. Optionally, write settings with no default value like "MySetting=". (Assuming this is valid for INI.)

When I run Build, I get...

  • No .ini file.
  • .ini file is only created if I set a value in code. Only the setting I set is inserted into the file.

IServerConfig.vb

Public Interface IServerConfig
    <[Option](DefaultValue:="127.0.0.1")>
    Property host As String
End Interface

Server.vb

Public Sub New()
        serverConfig = New ConfigurationBuilder(Of IServerConfig)().UseIniFile(GetConfigName()).Build()
End Sub

My ugly workaround

    Private Sub InitializeConfigNetFile(ByVal ConfigPath As String)
        For Each prop In GetType(IServerConfig).GetProperties()
            prop.SetValue(serverConfig, prop.GetValue(serverConfig))
        Next
    End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant