Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into tests-out-of-repo
Browse files Browse the repository at this point in the history
  • Loading branch information
radical committed Jul 11, 2024
2 parents ef3158b + 9421fc8 commit e23cd4c
Show file tree
Hide file tree
Showing 5 changed files with 340 additions and 53 deletions.
32 changes: 16 additions & 16 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,42 +121,42 @@
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="8.0.0-beta.24359.3">
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="8.0.0-beta.24360.5">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>db87887481d4110c09a1004191002482fdd7e4f2</Sha>
<Sha>c9efa535175049eb9cba06cae1f8c3d5dbe768a9</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Build.Tasks.Installers" Version="8.0.0-beta.24359.3">
<Dependency Name="Microsoft.DotNet.Build.Tasks.Installers" Version="8.0.0-beta.24360.5">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>db87887481d4110c09a1004191002482fdd7e4f2</Sha>
<Sha>c9efa535175049eb9cba06cae1f8c3d5dbe768a9</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Build.Tasks.Workloads" Version="8.0.0-beta.24359.3">
<Dependency Name="Microsoft.DotNet.Build.Tasks.Workloads" Version="8.0.0-beta.24360.5">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>db87887481d4110c09a1004191002482fdd7e4f2</Sha>
<Sha>c9efa535175049eb9cba06cae1f8c3d5dbe768a9</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="8.0.0-beta.24359.3">
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="8.0.0-beta.24360.5">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>db87887481d4110c09a1004191002482fdd7e4f2</Sha>
<Sha>c9efa535175049eb9cba06cae1f8c3d5dbe768a9</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.SharedFramework.Sdk" Version="8.0.0-beta.24359.3">
<Dependency Name="Microsoft.DotNet.SharedFramework.Sdk" Version="8.0.0-beta.24360.5">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>db87887481d4110c09a1004191002482fdd7e4f2</Sha>
<Sha>c9efa535175049eb9cba06cae1f8c3d5dbe768a9</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.RemoteExecutor" Version="8.0.0-beta.24359.3">
<Dependency Name="Microsoft.DotNet.RemoteExecutor" Version="8.0.0-beta.24360.5">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>db87887481d4110c09a1004191002482fdd7e4f2</Sha>
<Sha>c9efa535175049eb9cba06cae1f8c3d5dbe768a9</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.XUnitExtensions" Version="8.0.0-beta.24359.3">
<Dependency Name="Microsoft.DotNet.XUnitExtensions" Version="8.0.0-beta.24360.5">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>db87887481d4110c09a1004191002482fdd7e4f2</Sha>
<Sha>c9efa535175049eb9cba06cae1f8c3d5dbe768a9</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.XliffTasks" Version="1.0.0-beta.23475.1" CoherentParentDependency="Microsoft.DotNet.Arcade.Sdk">
<Uri>https://github.com/dotnet/xliff-tasks</Uri>
<Sha>73f0850939d96131c28cf6ea6ee5aacb4da0083a</Sha>
</Dependency>
<!-- Intermediate is necessary for source build. -->
<Dependency Name="Microsoft.SourceBuild.Intermediate.arcade" Version="8.0.0-beta.24359.3">
<Dependency Name="Microsoft.SourceBuild.Intermediate.arcade" Version="8.0.0-beta.24360.5">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>db87887481d4110c09a1004191002482fdd7e4f2</Sha>
<Sha>c9efa535175049eb9cba06cae1f8c3d5dbe768a9</Sha>
<SourceBuild RepoName="arcade" ManagedOnly="true" />
</Dependency>
<!-- Intermediate is necessary for source build. -->
Expand Down
8 changes: 4 additions & 4 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
<MicrosoftDeveloperControlPlanewindowsamd64PackageVersion>0.5.7</MicrosoftDeveloperControlPlanewindowsamd64PackageVersion>
<MicrosoftDeveloperControlPlanewindowsarm64PackageVersion>0.5.7</MicrosoftDeveloperControlPlanewindowsarm64PackageVersion>
<!-- Other -->
<MicrosoftDotNetRemoteExecutorPackageVersion>8.0.0-beta.24359.3</MicrosoftDotNetRemoteExecutorPackageVersion>
<MicrosoftDotNetXUnitExtensionsPackageVersion>8.0.0-beta.24359.3</MicrosoftDotNetXUnitExtensionsPackageVersion>
<MicrosoftDotNetBuildTasksInstallersPackageVersion>8.0.0-beta.24359.3</MicrosoftDotNetBuildTasksInstallersPackageVersion>
<MicrosoftDotNetBuildTasksWorkloadsPackageVersion>8.0.0-beta.24359.3</MicrosoftDotNetBuildTasksWorkloadsPackageVersion>
<MicrosoftDotNetRemoteExecutorPackageVersion>8.0.0-beta.24360.5</MicrosoftDotNetRemoteExecutorPackageVersion>
<MicrosoftDotNetXUnitExtensionsPackageVersion>8.0.0-beta.24360.5</MicrosoftDotNetXUnitExtensionsPackageVersion>
<MicrosoftDotNetBuildTasksInstallersPackageVersion>8.0.0-beta.24360.5</MicrosoftDotNetBuildTasksInstallersPackageVersion>
<MicrosoftDotNetBuildTasksWorkloadsPackageVersion>8.0.0-beta.24360.5</MicrosoftDotNetBuildTasksWorkloadsPackageVersion>
<MicrosoftExtensionsHttpResiliencePackageVersion>8.6.0</MicrosoftExtensionsHttpResiliencePackageVersion>
<MicrosoftExtensionsDiagnosticsTestingPackageVersion>8.6.0</MicrosoftExtensionsDiagnosticsTestingPackageVersion>
<MicrosoftExtensionsConfigurationAbstractionsPackageVersion>8.0.0</MicrosoftExtensionsConfigurationAbstractionsPackageVersion>
Expand Down
10 changes: 5 additions & 5 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"sdk": {
"version": "8.0.200",
"version": "8.0.303",
"rollForward": "major",
"allowPrerelease": true
},
"tools": {
"dotnet": "8.0.200"
"dotnet": "8.0.303"
},
"msbuild-sdks": {
"Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.24359.3",
"Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.24359.3",
"Microsoft.DotNet.SharedFramework.Sdk": "8.0.0-beta.24359.3",
"Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.24360.5",
"Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.24360.5",
"Microsoft.DotNet.SharedFramework.Sdk": "8.0.0-beta.24360.5",
"Microsoft.Build.NoTargets": "3.7.0"
}
}
70 changes: 50 additions & 20 deletions src/Tools/ConfigurationSchemaGenerator/ConfigSchemaEmitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ internal sealed partial class ConfigSchemaEmitter(SchemaGenerationSpec spec, Com
{
internal const string RootPathPrefix = "--empty--";
private static readonly string[] s_lineBreaks = ["\r\n", "\r", "\n"];
private static readonly JsonNodeOptions s_ignoreCaseNodeOptions = new() { PropertyNameCaseInsensitive = true };

private static readonly JsonSerializerOptions s_serializerOptions = new()
{
Expand Down Expand Up @@ -55,12 +56,12 @@ private void GenerateLogCategories(JsonObject parent)
return;
}

var propertiesNode = new JsonObject();
var propertiesNode = new JsonObject(s_ignoreCaseNodeOptions);
for (var i = 0; i < categories.Count; i++)
{
var catObj = new JsonObject();
catObj["$ref"] = "#/definitions/logLevelThreshold";
propertiesNode.Add(categories[i], catObj);
var categoryNode = new JsonObject();
categoryNode["$ref"] = "#/definitions/logLevelThreshold";
propertiesNode[categories[i]] = categoryNode;
}

parent["definitions"] = new JsonObject
Expand Down Expand Up @@ -105,6 +106,8 @@ private bool GeneratePathSegment(JsonObject currentNode, TypeSpec type, Queue<st
}

var pathSegment = pathSegments.Dequeue();
var isAsterisk = pathSegment == "*";
var propertiesName = isAsterisk ? "additionalProperties" : "properties";

// While descending into the node tree, a container node is created or an existing one is reused, which is then passed to the subtree generator.
// Each generator is responsible for reverting to the original state of its children and return false, in case there's nothing to generate.
Expand All @@ -117,19 +120,42 @@ private bool GeneratePathSegment(JsonObject currentNode, TypeSpec type, Queue<st
currentNode["type"] = "object";

var ownsProperties = false;
if (currentNode["properties"] is not JsonObject propertiesNode)
if (currentNode[propertiesName] is not JsonObject propertiesNode)
{
propertiesNode = new JsonObject();
currentNode["properties"] = propertiesNode;
propertiesNode = new JsonObject(s_ignoreCaseNodeOptions);
currentNode[propertiesName] = propertiesNode;
ownsProperties = true;
}

var ownsPathSegment = false;
string? backupCasingOfPathSegmentName = null;
if (propertiesNode[pathSegment] is not JsonObject pathSegmentNode)
{
pathSegmentNode = new JsonObject();
propertiesNode[pathSegment] = pathSegmentNode;
ownsPathSegment = true;
if (isAsterisk)
{
pathSegmentNode = propertiesNode;
}
else
{
pathSegmentNode = new JsonObject();
propertiesNode[pathSegment] = pathSegmentNode;
ownsPathSegment = true;
}
}
else
{
backupCasingOfPathSegmentName = propertiesNode[pathSegment].GetPropertyName();

if (backupCasingOfPathSegmentName != pathSegment)
{
// Re-add existing node, so the new casing of pathSegment is used.
propertiesNode.Remove(pathSegment);
propertiesNode[pathSegment] = pathSegmentNode;
}
else
{
backupCasingOfPathSegmentName = null;
}
}

var hasGenerated = GeneratePathSegment(pathSegmentNode, type, pathSegments);
Expand All @@ -139,12 +165,19 @@ private bool GeneratePathSegment(JsonObject currentNode, TypeSpec type, Queue<st

if (ownsProperties)
{
currentNode.Remove("properties");
currentNode.Remove(propertiesName);
}
else if (ownsPathSegment)
{
propertiesNode.Remove(pathSegment);
}
else if (backupCasingOfPathSegmentName != null)
{
// Revert casing change of pathSegment.
var existingValue = propertiesNode[pathSegment];
propertiesNode.Remove(pathSegment);
propertiesNode[backupCasingOfPathSegmentName] = existingValue;
}
}

return hasGenerated;
Expand Down Expand Up @@ -458,18 +491,15 @@ internal static string FormatDescription(XElement element)
.Trim('\n');
}

private void GenerateDescriptionForType(JsonObject? currentNode, TypeSpec type)
private void GenerateDescriptionForType(JsonObject currentNode, TypeSpec type)
{
if (currentNode is not null && currentNode["description"] is null)
var typeSymbol = _compilation.GetBestTypeByMetadataName(type.FullName);
if (typeSymbol is not null)
{
var typeSymbol = _compilation.GetBestTypeByMetadataName(type.FullName);
if (typeSymbol is not null)
var docComment = GetDocComment(typeSymbol);
if (!string.IsNullOrEmpty(docComment))
{
var docComment = GetDocComment(typeSymbol);
if (!string.IsNullOrEmpty(docComment))
{
GenerateDescriptionFromDocComment(currentNode, docComment);
}
GenerateDescriptionFromDocComment(currentNode, docComment);
}
}
}
Expand Down
Loading

0 comments on commit e23cd4c

Please sign in to comment.