You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
vartest4=awaitcontext.Images.Where(x =>x.Id==ImageId.CreateUnique()&&x.Created==DateTime.MaxValue).FirstOrDefaultAsync(cancellationToken)??thrownewException("This is an exception message");
Output:
vartest4=awaitcontext.Images.Where(x =>x.Id==ImageId.CreateUnique()&&x.Created==DateTime.MaxValue).FirstOrDefaultAsync(cancellationToken)??thrownewException("This is an exception message");
Expected behavior:
vartest4=awaitcontext.Images.Where(x =>x.Id==ImageId.CreateUnique()&&x.Created==DateTime.MaxValue).FirstOrDefaultAsync(cancellationToken)??thrownewException("This is an exception message");
On its own, this might seem fine, but when compared to a similar method where we modify different parts of the assignment, the inconsistency becomes apparent:
// Fully inline: short method chain and short exception message.vartest1=awaitcontext.Images.FirstAsync(cancellationToken)??thrownewException("This is an exception message");// Break after '=', everything else fits on one line.vartest2_1=awaitcontext.Images.FirstOrDefaultAsync(cancellationToken)??thrownewException("This is an exception message");// Similar to test2_1, slightly longer exception message but still contained in a single line.vartest2_2=awaitcontext.Images.FirstAsync(cancellationToken)??thrownewException("This is a little longer exception message");// Breaks after '=', and '??' is on a new line due to method length.vartest3_1=awaitcontext.Images.FirstOrDefaultAsync(x =>x.Id==ImageId.CreateUnique(),cancellationToken)??thrownewException("This is an exception message");// Similar to test3_1, but it wraps due to message length.vartest3_2=awaitcontext.Images.FirstAsync(cancellationToken)??thrownewException("This is a much longer exception message which should be long enough to wrap on its own");// Multiline formatting: Last part of method chain is short and the exception message is short, so '??' is not wrapped, inconsistent with others.vartest4=awaitcontext.Images.Where(x =>x.Id==ImageId.CreateUnique()&&x.Created==DateTime.MaxValue).FirstOrDefaultAsync(cancellationToken)??thrownewException("This is an exception message");// Multiline formatting: Last part of method chain is long, so '??' is wrapped.vartest5_1=awaitcontext.Images.Where(x =>x.Id==ImageId.CreateUnique()&&x.Created==DateTime.MaxValue).FirstOrDefaultAsync(x =>x.Id==ImageId.CreateUnique(),cancellationToken)??thrownewException("This is an exception message");// Multiline formatting: Exception message is long, so '??' is wrapped.vartest5_2=awaitcontext.Images.Where(x =>x.Id==ImageId.CreateUnique()&&x.Created==DateTime.MaxValue).FirstOrDefaultAsync(cancellationToken)??thrownewException("This is a much longer exception message which should be long enough to wrap on its own");
I also tried without assignment and swapped out throw for a static function with same results.
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
csharpier 0.30.6
Input:
Output:
Expected behavior:
On its own, this might seem fine, but when compared to a similar method where we modify different parts of the assignment, the inconsistency becomes apparent:
I also tried without assignment and swapped out
throw
for a static function with same results.The text was updated successfully, but these errors were encountered: