To Reproduce
Create a test with this code:
var code =
"""
using Rocks.Runtime;
using System.Diagnostics.CodeAnalysis;
[assembly: Rock(typeof(RequiredConstructor), BuildType.Create | BuildType.Make)]
#nullable enable
public class RequiredConstructor
{
[SetsRequiredMembers]
public RequiredConstructor() { }
public virtual object GetValue() => new();
}
""";
Expected behavior
Mock code is generated with no issues.
Actual behavior
Errors occur:
error CS9039: This constructor must add 'SetsRequiredMembers' because it chains to a constructor that has that attribute.
Additional context
Note that the RequiredConstructor type doesn't actually have any required properties, but it's OK to put this attribute on the constructor in this case. If it had required properties, Rocks will automatically put [SetsRequiredMembers] on the constructor. However, it also needs to do it if it exists on the base type's constructor as well.
This was found on Elastic.Clients.Elasticsearch.Sql.QueryResponse, version 9.0.1
To Reproduce
Create a test with this code:
Expected behavior
Mock code is generated with no issues.
Actual behavior
Errors occur:
Additional context
Note that the
RequiredConstructortype doesn't actually have anyrequiredproperties, but it's OK to put this attribute on the constructor in this case. If it hadrequiredproperties, Rocks will automatically put[SetsRequiredMembers]on the constructor. However, it also needs to do it if it exists on the base type's constructor as well.This was found on
Elastic.Clients.Elasticsearch.Sql.QueryResponse, version 9.0.1