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.

Implicit cast converts null to object

See original GitHub issue

In ServiceOverride.cs L82 the implicit cast converts a ServiceOverride of null into an object. This took me a while to figure out because it is behavior I never saw before. Is this intended?

public static implicit operator Dependency(ServiceOverride item)
{
    return new Dependency(item);
}

I would have expected the cast like this:

public static implicit operator Dependency(ServiceOverride item)
{
    return item == null ? null : new Dependency(item);
}

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
Toxantroncommented, Mar 26, 2016

I am gonna do it tonight and open a PR. Alright?

0reactions
Toxantroncommented, Apr 6, 2016

Thanks. I will try if I am now able to work on the code. Would love to contribute.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Implicit conversion from null
My question: It works fine, if I pass an actual object, mapping it to an Maybe, but if I pass NULL, I still...
Read more >
Nullable<T>.Implicit(T to Nullable<T>) Operator (System)
In C# and Visual Basic, an implicit conversion from a null or Nothing literal to Nullable<T> produces a Nullable<T> value whose HasValue property...
Read more >
C#: Implicit conversion from null to struct (and more)
When an implicit cast of null to the struct is required, having no other logical options, the compiler assumes that "null" is a...
Read more >
Error in implicit conversion. Cannot convert null object - Help
Hi Developer, i found issue regarding write range activities. Write Range: Error in implicit conversion. Cannot convert null object
Read more >
566 – Implicit Conversions to Nullable Types
A nullable type represents a type whose value can be either a particular value type or can be the null value. You can...
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