Open drewnoakes opened 4 years ago
apart from the obvious
ReferenceEquals(type, typeThatIsntDerivedOrBaseOfOtherType)
would this also apply to value types? Given
ReferenceEquals(someStruct, someStruct)
will always be false currently because they are boxed to different instances. Although, if boxing pooling happened, this could change
would this also apply to value types?
That now exists: https://github.com/dotnet/roslyn-analyzers/blob/master/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DoNotUseReferenceEqualsWithValueTypes.cs
cc: @bartonjs
@stephentoub do we usually keep issues like this open here or do we usually move them to roslyn repo?
@joperezr Analyzer proposals for BCL API live in this repository, so we can review them like API proposals.
But this one was already implemented, as #33766.
I thought the one you pointed at (also @stephentoub pointed at) was only for value types, and this issue was for both that and reference types. Should we reopen to track that part?
Oh, right, yeah. That made sense to me at the time, too. Today, however, I got confused.
Similar to #33770.
Warn if use of
ReferenceEquals
would provably always be false based upon the types of the arguments.Category: Reliability