dotnet / roslyn-analyzers

MIT License
1.6k stars 468 forks source link

PointsToAnalysis treats String.Empty as NullAbstractValue.MaybeNull #2115

Open dotpaul opened 5 years ago

dotpaul commented 5 years ago

Expected: PointsToAnalysis treats String.Empty as NullAbstractValue.NotNull, with a singleton location.

Actual: PointsToAnalysis treats String.Empty as NullAbstractValue.MaybeNull.

mavasani commented 5 years ago

Potentially can be moved to https://github.com/dotnet/roslyn-analyzers/issues/1547, which tracks bunch of other enhancements for string content analysis. I thought we already handle string.Empty though: https://github.com/dotnet/roslyn-analyzers/blob/features/dataflow/src/Utilities/FlowAnalysis/Analysis/ValueContentAnalysis/ValueContentAnalysis.ValueContentDataFlowOperationVisitor.cs#L216 and unit test here

mavasani commented 5 years ago

Ah this is about PointsToAnalysis, not value content. Just need to add a similar special handling to its operation visitor. Makes sense to track it with this issue as the this is about PointsTo analysis and #1547 is about value content.

dotpaul commented 5 years ago

I don't have any scenario at the moment yet, just noticed it while testing.