Reflector .NET cannot correctly reflect the zero coalescence operator?

I wrote this piece of code:

private Queue<int> EnsureQueue() { return _queue ?? (_queue = new Queue<int>(10)); } 

and the reflector gives me:

 private Queue<int> EnsureQueue() { if (this._queue == null) { } return (this._queue = new Queue<int>(10)); } 

Obviously, this is not what the source code says. String (this._queue = new Queue<int>(10)); will always return new Queue<int>(10) instead of _queue if it is not null .

Is this a bug in .NET .NET Reflector or am I missing something? The program seems to behave correctly ...

EDIT -> See My Answer

+5
source share
1 answer

Here is what my Reflector copy of this method does:

 private Queue<int> EnsureQueue() { return (this._queue ?? (this._queue = new Queue<int>(10))); } 

Looks good. Version 8.5.0.179, be sure to update your version.

+3
source

All Articles