Skip to content

JSON GetCurrentDictionary() fails on custom section handler #59

@chriswill

Description

@chriswill

We've written a custom section handler for the smtp section (SmtpSection) and are populating it's values from a json file in Sectional mode. A fully-populated, but empty file looks like this:

{
  "appSettings": {   
  },
  "connectionStrings": {    
  },
  "machineKey": {    
  },
  "smtp":{    
  }
}

However if we omit the smtp section of this file the Json source throws an error in the GetCurrentDictionary() method because _currentSection will be set to "smtp" and there is no "smtp" key value populated in _allSettings.
A better approach is to check to see if _allSettings contains that key before requesting access to that value.
I'm submitting a basic PR to address this issue. Without this fix all of our json configuration files have to contain smtp sections, even if we are not specifying values in this area.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions