Closed DamianEdwards closed 8 months ago
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 RETURNING *
npgsql? presumably that's the same as OUTPUT inserted.*
on SQL Server?
Yep 👍
@DamianEdwards are we doing the same thing in parallel? https://github.com/aspnet/Benchmarks/pull/1930
Ah! No, I was updating benchmarks on Nanorm 😁
@DamianEdwards ah, k; tip: you might also want to try using the [CacheCommand]
hint - may reduce allocs a little
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: