-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
Generated code results in compile error for types that have required properties #71
Comments
great catch! fixing, but temporary workaround (edit: not required if you update to 1.0.8): // don't erase the default .ctor
public SomeType() {}
// tell Dapper to use a custom .ctor
[ExplicitConstructor, System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
internal SomeType(string title)
{
this.Title = title;
} we then use deferred construction: int value0 = default;
string? value1 = default;
bool value2 = default;
foreach (var token in tokens)
{
// actual parse logic not shown here
}
return new global::SomeType(value1)
{
Id = value0,
IsComplete = value2,
}; |
output from 1.0.8: int value0 = default;
string? value1 = default;
bool value2 = default;
foreach (var token in tokens)
{
// actual parse logic not shown here
}
return new global::SomeType
{
Id = value0,
Title = value1,
IsComplete = value2,
}; |
@DamianEdwards entirely unrelated, but: is that |
Yep 👍 |
@DamianEdwards are we doing the same thing in parallel? aspnet/Benchmarks#1930 |
Ah! No, I was updating benchmarks on Nanorm 😁 |
@DamianEdwards ah, k; tip: you might also want to try using the |
Describe the bug
If I have a type like:
And a method like:
I get a compile error:
CS9035 Required member 'Todo.Title' must be set in the object initializer or attribute constructor.
Snippet of generated code that causes the error:
The text was updated successfully, but these errors were encountered: