Skip to content
This repository has been archived by the owner on May 12, 2023. It is now read-only.

Commit

Permalink
Implemented fix for Dynalon#27
Browse files Browse the repository at this point in the history
  • Loading branch information
nefarius committed Feb 5, 2020
1 parent dcbf835 commit d64cbc4
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ packages/
/.vs/JsonConfig/v15/sqlite3
/.vs/JsonConfig/v15/Server/sqlite3
/.tmp/Nuke.MSBuildLocator
/.vs/JsonConfig
14 changes: 14 additions & 0 deletions JsonConfig.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonConfig", "JsonConfig\Js
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JsonConfig.Tests", "JsonConfig.Tests\JsonConfig.Tests.csproj", "{402F5791-B95A-4226-A3B1-5961B24AED2D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApp", "TestApp\TestApp.csproj", "{582166F9-F35C-47F9-AC6B-A408635BA076}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -40,6 +42,18 @@ Global
{402F5791-B95A-4226-A3B1-5961B24AED2D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{402F5791-B95A-4226-A3B1-5961B24AED2D}.Release|x86.ActiveCfg = Release|Any CPU
{402F5791-B95A-4226-A3B1-5961B24AED2D}.Release|x86.Build.0 = Release|Any CPU
{582166F9-F35C-47F9-AC6B-A408635BA076}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{582166F9-F35C-47F9-AC6B-A408635BA076}.Debug|Any CPU.Build.0 = Debug|Any CPU
{582166F9-F35C-47F9-AC6B-A408635BA076}.Debug|x86.ActiveCfg = Debug|Any CPU
{582166F9-F35C-47F9-AC6B-A408635BA076}.Debug|x86.Build.0 = Debug|Any CPU
{582166F9-F35C-47F9-AC6B-A408635BA076}.Default|Any CPU.ActiveCfg = Debug|Any CPU
{582166F9-F35C-47F9-AC6B-A408635BA076}.Default|Any CPU.Build.0 = Debug|Any CPU
{582166F9-F35C-47F9-AC6B-A408635BA076}.Default|x86.ActiveCfg = Debug|Any CPU
{582166F9-F35C-47F9-AC6B-A408635BA076}.Default|x86.Build.0 = Debug|Any CPU
{582166F9-F35C-47F9-AC6B-A408635BA076}.Release|Any CPU.ActiveCfg = Release|Any CPU
{582166F9-F35C-47F9-AC6B-A408635BA076}.Release|Any CPU.Build.0 = Release|Any CPU
{582166F9-F35C-47F9-AC6B-A408635BA076}.Release|x86.ActiveCfg = Release|Any CPU
{582166F9-F35C-47F9-AC6B-A408635BA076}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
18 changes: 18 additions & 0 deletions JsonConfig/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Linq;

namespace JsonConfig.Extensions
{
public static class StringExtensions
{
public static string FirstCharToUpper(this string input)
{
return input switch
{
null => throw new ArgumentNullException(nameof(input)),
"" => throw new ArgumentException($"{nameof(input)} cannot be empty", nameof(input)),
_ => input.First().ToString().ToUpper() + input.Substring(1)
};
}
}
}
1 change: 1 addition & 0 deletions JsonConfig/JsonConfig.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<LangVersion>8.0</LangVersion>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
<PropertyGroup>
Expand Down
3 changes: 2 additions & 1 deletion JsonConfig/JsonNetAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using JsonConfig.Extensions;

namespace JsonConfig
{
Expand All @@ -15,7 +16,7 @@ public static ExpandoObject Transform(ExpandoObject data)
var edict = (IDictionary<string, object>) newExpando;

foreach (var kvp in data)
edict[kvp.Key] = TransformByType(kvp.Value);
edict[kvp.Key.FirstCharToUpper()] = TransformByType(kvp.Value);

return newExpando;
}
Expand Down
17 changes: 17 additions & 0 deletions TestApp/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using JsonConfig;

namespace TestApp
{
/// <summary>
/// This is here because the NUnit project is legacy and broken at the moment :(
/// </summary>

class Program
{
static void Main(string[] args)
{
Console.WriteLine(Config.Global.Foo);
}
}
}
18 changes: 18 additions & 0 deletions TestApp/TestApp.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\JsonConfig\JsonConfig.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
3 changes: 3 additions & 0 deletions TestApp/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"foo": "bar"
}

0 comments on commit d64cbc4

Please sign in to comment.