Area-IDEFeature - IDE0059help wanted
仓库指标
- 星标
- (20,414 个星标)
- PR 合并指标
- (平均合并 6天 17小时) (30 天内合并 256 个 PR)
描述
Brief description: The following two variable declarations are equivalent and only vary based on coding style:
a? ret;
if(Condition){
ret = new a(){ ... };
} else {
ret = new a(){ ... };
}
AND
var ret = default(a?);
if(Condition){
ret = new a(){ ... };
} else {
ret = new a(){ ... };
}
Today, IDE0059 triggers if a variable is initialized with any value and then later reassigned. I suggest updating IDE0059 to trigger only if a variable is initialized to a non-default value and then later reassigned.
Languages applicable: C# any maybe VB.
Code example that the analyzer SHOULD report: Needlessly initializing to a non-default value.
Code example that the analyzer not report: See above