- 
                Notifications
    
You must be signed in to change notification settings  - Fork 480
 
New constant expected analyzer #5766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
        
          
                src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Performance/ConstantExpectedTests.cs
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Performance/ConstantExpectedTests.cs
              
                Outdated
          
            Show resolved
            Hide resolved
        
      9ee7606    to
    c97c002      
    Compare
  
    
          Codecov Report
 
 Additional details and impacted files@@            Coverage Diff            @@
##             main    #5766     +/-   ##
=========================================
  Coverage   96.04%   96.05%             
=========================================
  Files        1360     1364      +4     
  Lines      312225   313686   +1461     
  Branches    10047    10125     +78     
=========================================
+ Hits       299890   301324   +1434     
- Misses       9928     9940     +12     
- Partials     2407     2422     +15      | 
    
3d61e3f    to
    02c9847      
    Compare
  
    38ac251    to
    9cf0495      
    Compare
  
    | 
           @wzchua Are you still working on this?  | 
    
| 
           Yea, it is effectively done but I'm sure I'm still missing something. Also, I'm not sure if the team wants the vb analyzer  | 
    
| 
           Can you please check if the analyzer works also on VB? dotnet/runtime#33771 (comment)  | 
    
| 
           It won't work, it depends on language specific syntax since there is no IOperation for attribute  | 
    
| 
           I'll do a rebase and mark it for review later in the day  | 
    
fix some typo
Add new warning for missing attribute from interface or base class
Fill in missing cases in tests.
84d6e4d    to
    5f8922f      
    Compare
  
    | 
           The test is still missing a reference assembly with the attribute  | 
    
        
          
                ...ers/Core/Microsoft.NetCore.Analyzers/Performance/ConstantExpectedAnalyzer.UnmanagedHelper.cs
          
            Show resolved
            Hide resolved
        
              
          
                ...etAnalyzers/CSharp/Microsoft.NetCore.Analyzers/Performance/CSharpConstantExpectedAnalyzer.cs
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                ...etAnalyzers/CSharp/Microsoft.NetCore.Analyzers/Performance/CSharpConstantExpectedAnalyzer.cs
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                ...ers/Core/Microsoft.NetCore.Analyzers/Performance/ConstantExpectedAnalyzer.UnmanagedHelper.cs
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                ...ers/Core/Microsoft.NetCore.Analyzers/Performance/ConstantExpectedAnalyzer.UnmanagedHelper.cs
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/ConstantExpectedAnalyzer.cs
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/ConstantExpectedAnalyzer.cs
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/ConstantExpectedAnalyzer.cs
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/ConstantExpectedAnalyzer.cs
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/ConstantExpectedAnalyzer.cs
              
                Outdated
          
            Show resolved
            Hide resolved
        
      Co-authored-by: Robin Lindner <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| 
           This isn't something I have the relevant expertise to review. It only impacts some of the APIs in my area as things that might use the analyzer. CC> @buyaa-n  | 
    
| 
           @tannergooding. From the test, you can view the behaviour of the analyzer. Let me know if the behaviour does not match what is expected.  | 
    
| 
           Thanks @wzchua, looks a few comments still not addressed yet, otherwise looks good  | 
    
| 
           I have resolved the remaining comments  | 
    
5369cc6    to
    4a752f7      
    Compare
  
    ConstantExpectedContext captures the INamedTypeSymbol and wrap methods related to checking with the ConstantExpected attribute
4a752f7    to
    865974c      
    Compare
  
    There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for your contribution @wzchua, I would simplify the perf test a bit
        
          
                src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/MicrosoftNetCoreAnalyzersResources.resx
              
                Outdated
          
            Show resolved
            Hide resolved
        
      | 
           FYI: @mavasani @jmarolf it is safe to merge this analyzer in 7.0 as it would not cause any warnings because the   | 
    
| 
           What's the status of this and is it ready to merge?  | 
    
          
 This is ready (except it got new merge conflicts), it can be merged into 7.0 if @jmarolf @mavasani OK with merging (It would not cause any warning as no any API attributed with ConstantExpectedAttribute in 7.0). Else I will merge it when the main branch will become for 8.0  | 
    
Resolves dotnet/runtime#33771
This is still a WIP and I'm using CA1860 and CA1861 as placeholder.
I believe the logic covers most of the general cases.
It is still not fully clear to me the rules for applying this attribute to a generic parameter.
I have added logic to handle some of it but not sure if this is how the team would like them.
@buyaa-n @tannergooding