Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cdac] Update cdac-build-tool to omit type when it is empty #101825

Merged
merged 1 commit into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/coreclr/tools/cdac-build-tool/DataDescriptorModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,6 @@ public DataDescriptorModel Build()
var globals = new Dictionary<string, GlobalModel>();
foreach (var (globalName, globalBuilder) in _globals)
{
if (globalBuilder.Type == string.Empty)
{
throw new InvalidOperationException($"Type must be set for global {globalName}");
}
GlobalValue? v = globalBuilder.Value;
if (v == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public override DataDescriptorModel.FieldModel Read(ref Utf8JsonReader reader, T

public override void Write(Utf8JsonWriter writer, DataDescriptorModel.FieldModel value, JsonSerializerOptions options)
{
if (value.Type is null)
if (string.IsNullOrEmpty(value.Type))
{
writer.WriteNumberValue(value.Offset);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public override DataDescriptorModel.GlobalModel Read(ref Utf8JsonReader reader,

public override void Write(Utf8JsonWriter writer, DataDescriptorModel.GlobalModel value, JsonSerializerOptions options)
{
if (value.Type is null)
if (string.IsNullOrEmpty(value.Type))
{
// no type: just write 'value' or '[value]'
JsonSerializer.Serialize(writer, value.Value, options);
Expand Down
Loading