Proposal: Interprocedural analysis for NRT #2792
Replies: 5 comments
-
There is no interprocedural analysis in c# My recommendation would be to have OriginalMethod return the non-null value |
Beta Was this translation helpful? Give feedback.
-
@CyrusNajmabadi Is there any plan to support it? I think it can greatly improve the analysis ability of roslyn. |
Beta Was this translation helpful? Give feedback.
-
not that i know of. Def file over at dotnet/csharplang if you're interested in having this happen! |
Beta Was this translation helpful? Give feedback.
-
I've update the issue and made a proposal. Any update on it? |
Beta Was this translation helpful? Give feedback.
-
I think this would be a big problem. Consider the following code: class A
{
internal string? x = null;
private void OtherMethod()
{
x = "";
SomeOtherMethod();
}
private void Test()
{
OtherMethod();
var len = x.Length; // Dereference of a possible null value
}
} If SomeOtherMethod() is in metadata, what's the state of Even a slight change to your code: class A
{
private string? x = null;
private void Test()
{
OtherMethod();
var len = x.Length; // Dereference of a possible null value
}
private void OtherMethod()
{
x = "";
}
} This looks like it would at least double the time we need to analyze the class, since by the time we're analyzing |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Proposal
Interprocedural analysis for NRT
A sample code:
Currently compiler will throw "Dereference of a possible null value", however, with interprocedural analysis,
var len = x.Length
should not throw any NRT related issues.Beta Was this translation helpful? Give feedback.
All reactions