dotnet / dotnet/roslyn

Provide line numbers for exceptions in object initializer expressions

Open
#83,240 1 comment 1 reaction 1 assignee Claimed by @tmat View on GitHub
Area-Interactive Interactive-Debugging
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

When using object initializers, like above, all exception stack traces point to the main statement

```
var myObject = new MyClass
{
Property1 = F(),
Property2 = G(),
}
```

This is very suboptimal from an error handling exception, making it so we don't use non-trivial object initializers where I work.

Could this be improved so we get real sequence points between each initialization?

I have seen #5477, which is similar, but relates to anonymous types, so I think this suggestion is slightly different (without knowing the details about lowering, I hope each assignment is its own statement

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.