-
-
Notifications
You must be signed in to change notification settings - Fork 491
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
Support IReadOnlyCollection #1008
Comments
Can you share some example code and yaml that you’re trying to deserialize? I think, may be wrong, but we may already support read only collections. Can’t entirely remember |
public record Extends(string Template, object Parameters)
{
public Extends() : this(default!, default!) { }
}
public record Parameter(string Name, string DisplayName, string Type, string Default)
{
public Parameter() : this(default!, default!, default!, default!) { }
}
#pragma warning disable CA1724 // "Resources" is correct
public record Resources(RepositoryItem[] Repositories)
{
public Resources() : this([]) { }
}
#pragma warning restore CA1724
public record RepositoryItem(string Repository, string Type, string Name, string Ref)
{
public RepositoryItem() : this(default!, default!, default!, default!) { }
}
public record Trigger(bool Batch, Branches Branches)
{
public Trigger() : this(default!, default!) { }
}
public record Branches(string[] Include)
{
public Branches() : this([]) { }
}
public record Pipeline(Trigger Trigger, Resources Resources, Parameter[] Parameters, Extends Extends)
{
public Pipeline() : this(default!, default!, default!, default!) { }
public static Pipeline Parse(string yaml)
{
var deserializer = new DeserializerBuilder()
.WithNamingConvention(CamelCaseNamingConvention.Instance)
.IgnoreUnmatchedProperties()
.Build();
return deserializer.Deserialize<Pipeline>(yaml);
}
} You can see here that I had to replace |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Properties should not return arraysCA1819
The recommended solution is
IReadOnlyCollection
, especially if the intent is to have an immutable record.The text was updated successfully, but these errors were encountered: