Skip to content

Commit

Permalink
Merge pull request #8365 from drewnoakes/fix-8360-docker-compose-laun…
Browse files Browse the repository at this point in the history
…ch-settings-17.4

[17.4] Fix launch profile JSON parsing
  • Loading branch information
drewnoakes authored Jul 29, 2022
2 parents 7dad9a7 + 3c54844 commit 30f69af
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ LaunchProfile ReadProfile(string name)
{
JsonToken.Boolean => (bool)reader.Value!,
JsonToken.Integer => checked((int)(long)reader.Value!),
JsonToken.StartObject => (jsonSerializer ??= JsonSerializer.CreateDefault()).Deserialize<Dictionary<string, string>>(reader),
JsonToken.StartObject => (jsonSerializer ??= JsonSerializer.CreateDefault()).Deserialize<Dictionary<string, object>>(reader),
JsonToken.String => (string)reader.Value!,
_ => null
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ public void RoundTripMultipleProfiles()
"ASPNET_ENVIRONMENT": "Development",
"ASPNET_APPLICATIONBASE": "c:\\Users\\billhie\\Documents\\projects\\WebApplication8\\src\\WebApplication8"
}
},
"Docker Compose": {
"commandName": "DockerCompose",
"commandVersion": "1.0",
"composeProfile": {
"includes": [
"web1"
]
}
}
},
"string": "hello",
Expand All @@ -66,7 +75,7 @@ public void RoundTripMultipleProfiles()

var (profiles, globalSettings) = LaunchSettingsJsonEncoding.FromJson(new StringReader(json), _providers);

Assert.Equal(4, profiles.Length);
Assert.Equal(5, profiles.Length);

var profile = profiles[0];
Assert.Equal("IIS Express", profile.Name);
Expand Down Expand Up @@ -112,6 +121,24 @@ public void RoundTripMultipleProfiles()
Assert.Equal(("ASPNET_APPLICATIONBASE", @"c:\Users\billhie\Documents\projects\WebApplication8\src\WebApplication8"), profile.EnvironmentVariables[1]);
Assert.False(profile.IsInMemoryObject());

profile = profiles[4];
Assert.Equal("Docker Compose", profile.Name);
Assert.Equal("DockerCompose", profile.CommandName);
Assert.Null(profile.WorkingDirectory);
Assert.Null(profile.ExecutablePath);
Assert.False(profile.LaunchBrowser);
Assert.Null(profile.LaunchUrl);
Assert.Empty(profile.EnvironmentVariables);
Assert.Equal(2, profile.OtherSettings.Length);
Assert.Equal("commandVersion", profile.OtherSettings[0].Key);
Assert.Equal("1.0", profile.OtherSettings[0].Value);
Assert.Equal("composeProfile", profile.OtherSettings[1].Key);
var composeProfiles = Assert.IsType<Dictionary<string, object>>(profile.OtherSettings[1].Value);
var includes = Assert.IsType<JArray>(composeProfiles["includes"]);
Assert.Single(includes);
Assert.Equal("web1", includes[0]);
Assert.False(profile.IsInMemoryObject());

Assert.Equal(5, globalSettings.Length);
Assert.Equal(("string", new JValue("hello")), globalSettings[0]);
Assert.Equal(("int", new JValue(123)), globalSettings[1]);
Expand Down

0 comments on commit 30f69af

Please sign in to comment.