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 for Nullable reference types

See original GitHub issue

Hey there! This is such an awesome project, thanks a lot for creating it and choosing MIT for the license!

I just cloned and ran the console app against our backend and noticed value types are annotated with question marks in the generated types, i.e. they are nullable when the schema says they are.

I’d love to see the same type annotation in the C# types for reference types, thanks to C# 8.0 supporting that. This should probably be an option, as I’m sure not everyone wants to switch to C# 8 for their project just yet 😄 The generated output file should probably enclose the whole source with #nullable enable and #nullable restore - just in case a user is using C# 8 but not yet turning on nullable ref types for everything.

I am happy to raise a PR for this, but it will be a couple of weeks most likely until I can get to it.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
Husqvikcommented, Nov 6, 2019

Forgot the strings and other reference types. These should be marked with question mark in C# 8 to say explicitly they are nullable. I’ll fix that too. Of course with optional setting as it would break compilation for older compiler versions.

0reactions
bddckrcommented, Nov 6, 2019

I just updated and ran some of my queries without any problem! All input classes have the proper annotation and are wrapped in #nullable (enable, then disable).

Thanks a lot for the quick changes ❤️

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nullable reference types
Nullable reference types are a compile time feature. That means it's possible for callers to ignore warnings, intentionally use null as an ...
Read more >
Nullable reference types - C# reference
Nullable reference types aren't new class types, but rather annotations on existing reference types. The compiler uses those annotations to help ...
Read more >
Digging Into Nullable Reference Types in C#
Enabling Nullable Reference Types · PropertyGroup · OutputType · OutputType · TargetFramework · TargetFramework · ImplicitUsings · ImplicitUsings ...
Read more >
Nullable Reference types in C# – Best practices
Although using nullable reference types can introduce its own set of problems, I still think it's beneficial because it helps you find potential ......
Read more >
How to enable Nullable Reference Types feature of C# 8.0 ...
To enable Nullable Reference Types for all code in a project, add the following to its .csproj file:
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