question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support target-type new expressions.

See original GitHub issue

Right now this fails to parse:

        internal static class EnumFormatters
        {
            public static readonly EnumFormatter<AnalysisKind> AnalysisKind = new(value => (int)value, value => (AnalysisKind)value);
        }

failing at the = new( bit. I think this is the relevant piece of syntax.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
initramcommented, Sep 25, 2020

The new without a type is a new C# 9 feature called target-type new expressions. This is the issue for it: https://github.com/dotnet/csharplang/issues/100

So it is simply a new feature, not really a bug in the current syntax.

0reactions
initramcommented, Oct 5, 2020

I think this issue can be closed now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Target-typed new expressions - C# 9.0 draft specifications
This feature specification describes the enhancements to 'new' where the target type can be inferred from the variable declaration.
Read more >
C# 9.0: Target-typed New Expressions – Make Your ...
Target-typed means that an expression gets the type from the context it is used in. With C# 9.0 the new expression gets the...
Read more >
Target-typed new() expressions in C# 9 - Vahid Farahmandian
We all know that when we want to create a new object we need to use 'new' keyword plus specifying the target type...
Read more >
Target-typed new Expressions In C# 9.0 You Should Know...
Want to Learn about C# 9.0 Target-typed new Expressions ? Today I am sharing exactly what Target-typed new Expressions In C# 9.0 are...
Read more >
Generalized Target-Type Inference in Java - Baeldung
The Target-Type of an expression is the data type that the Java Compiler expects depending on where the expression appears. Java 8 supports...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found