Repository: dotnet/aspnetcore
File: src/Tools/Extensions.ApiDescription.Client/test/GetOpenApiReferenceMetadataTest.cs (C#)

Code before:
                {
                    "SerializedMetadata",
                    $"Identity={identity}|FirstForGenerator=true|" +
                    $"CodeGenerator=NSwagCSharp|OutputPath={outputPath}|Namespace={@namespace}|" +
                    $"OriginalItemSpec={identity}|ClassName=NSwagClient"
                },
            };

        // Act
        var result = task.Execute();

        // Assert
        Assert.True(result);
        Assert.False(task.Log.HasLoggedErrors);
        var output = Assert.Single(task.Outputs);
        Assert.Equal(identity, output.ItemSpec);
        var metadata = Assert.IsAssignableFrom<IDictionary<string, string>>(output.CloneCustomMetadata());

        // The dictionary CloneCustomMetadata returns doesn't provide a useful KeyValuePair enumerator.
        var orderedMetadata = new SortedDictionary<string, string>(StringComparer.Ordinal);
        foreach (var key in metadata.Keys)
        {
            orderedMetadata.Add(key, metadata[key]);
        }

       expectedMetadata["SerializedMetadata"] = string.Join("|", expectedMetadata["SerializedMetadata"].Split('|').OrderBy(s => s));
       orderedMetadata["SerializedMetadata"] = string.Join("|", orderedMetadata["SerializedMetadata"].Split('|').OrderBy(s => s));
       Assert.Equal(expectedMetadata, orderedMetadata);
    }

    [Fact]
    public void Execute_DoesNotOverrideClassName()
    {
        // Arrange
        var identity = Path.Combine("TestProjects", "files", "NSwag.json");
        var className = "ThisIsClassy";
        var @namespace = "Console.Client";
        var outputPath = Path.Combine("obj", $"NSwagClient.cs");
        var inputMetadata = new Dictionary<string, string>
            {
                { "CodeGenerator", "NSwagCSharp" },
                { "ClassName", className },
            };

        var task = new GetOpenApiReferenceMetadata
        {
            Extension = ".cs",
            Inputs = new[] { new TaskItem(identity, inputMetadata) },
            Namespace = @namespace,
            OutputDirectory = "obj",
        };

Review comment (suggestion):
It's not clear to me why we need to make this mutation to the `SerializedMetadata` field on S390X targets. Can you provide an example of what the current metadata output looks like? The logs you shared appear to be truncated and don't show the actual comparison of the `SerializedMetadata` field.

Code after:
                { "CodeGenerator", "NSwagCSharp" },
                { "FirstForGenerator", "true" },
                { "Namespace", @namespace },
                { "OriginalItemSpec", identity },
                { "OutputPath", outputPath },
                {
                    "SerializedMetadata",
                    $"Identity={identity}|FirstForGenerator=true|" +
                    $"CodeGenerator=NSwagCSharp|OutputPath={outputPath}|Namespace={@namespace}|" +
                    $"OriginalItemSpec={identity}|ClassName=NSwagClient"
                },
            };

        // Act
        var result = task.Execute();

        // Assert
        Assert.True(result);
        Assert.False(task.Log.HasLoggedErrors);
        var output = Assert.Single(task.Outputs);
        Assert.Equal(identity, output.ItemSpec);
        var metadata = Assert.IsAssignableFrom<IDictionary<string, string>>(output.CloneCustomMetadata());

        // The dictionary CloneCustomMetadata returns doesn't provide a useful KeyValuePair enumerator.
        var orderedMetadata = new SortedDictionary<string, string>(StringComparer.Ordinal);
        foreach (var key in metadata.Keys)
        {
            orderedMetadata.Add(key, metadata[key]);
        }

        expectedMetadata["SerializedMetadata"] = SortMetadata(expectedMetadata["SerializedMetadata"]); 
        orderedMetadata["SerializedMetadata"] = SortMetadata(orderedMetadata["SerializedMetadata"]);
        Assert.Equal(expectedMetadata, orderedMetadata);
    }

    [Fact]
    public void Execute_DoesNotOverrideClassName()
    {
        // Arrange
        var identity = Path.Combine("TestProjects", "files", "NSwag.json");
        var className = "ThisIsClassy";
        var @namespace = "Console.Client";
        var outputPath = Path.Combine("obj", $"NSwagClient.cs");
        var inputMetadata = new Dictionary<string, string>
            {
                { "CodeGenerator", "NSwagCSharp" },
                { "ClassName", className },
            };

        var task = new GetOpenApiReferenceMetadata
        {