Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3910 +/- ##
=======================================
Coverage 97.44% 97.44%
=======================================
Files 926 932 +6
Lines 110283 110380 +97
Branches 3319 3320 +1
=======================================
+ Hits 107467 107564 +97
Misses 1847 1847
Partials 969 969 🚀 New features to boost your workflow:
|
Collectionexpressions are detected as variable declarations and not as InitializerExpression - Filter based on the declared variables collectionexpressions out, and then check each element
6481cc1 to
d22f8a0
Compare
|
I don't think this is the correct way of handling this, since collection expressions can be used in other places besides declarations. This triggers the corresponding handling of initializer expressions: SyntaxKindEx contains CollectionExpression, but the Lightup folder in the analyzer project should also be updated to include support for collection expressions. This has not yet been added to the repo as far as I can see. @sharwell would need to do this, or at least describe what to do. This is to avoid the call to ChildNodes(), which seems to work fine, but is not the normal way of accessing syntax nodes in this repository. |
Issue URL: #3904
Collectionexpressions are detected as variable declarations and not as InitializerExpression.
Previously they where checked based on the declaration itself (so we only have 1 Item e.g.
var myVariable = [1,2,3]). Now, for collection initializations we get the SyntaxNode from the variable and then validate each item of the collection on its own.Since this is my first open source contribution feedback is very welcome.
I also found 2 points where I'm not sure how to proceed with:
Microsoft.CodeAnalysis.CSharpis installed with V.1.2.1 @Stylecop.Analyzers. V.4.7.0 introduced theCollectionExpressionSyntaxthat would simply myIsCollectionExpression()to just a type check basiclly. Also the "workaround" with that id could be removed so imo it would be way cleaner, due to beeing 3 Major Versions behind i didnt wanted to update, since i basiclly dont know the project and also what could be affected by that upgrade.