mirror of
				https://github.com/MindWorkAI/AI-Studio.git
				synced 2025-11-04 02:40:20 +00:00 
			
		
		
		
	Added handling for default values for methods
This commit is contained in:
		
							parent
							
								
									37562d37f6
								
							
						
					
					
						commit
						a45649d3d1
					
				@ -46,6 +46,9 @@ public sealed class EmptyStringAnalyzer : DiagnosticAnalyzer
 | 
			
		||||
        if (IsInConstContext(stringLiteral))
 | 
			
		||||
            return;
 | 
			
		||||
        
 | 
			
		||||
        if (IsInParameterDefaultValue(stringLiteral))
 | 
			
		||||
            return;
 | 
			
		||||
        
 | 
			
		||||
        var diagnostic = Diagnostic.Create(RULE, stringLiteral.GetLocation());
 | 
			
		||||
        context.ReportDiagnostic(diagnostic);
 | 
			
		||||
    }
 | 
			
		||||
@ -65,4 +68,21 @@ public sealed class EmptyStringAnalyzer : DiagnosticAnalyzer
 | 
			
		||||
            _ => false
 | 
			
		||||
        };
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    private static bool IsInParameterDefaultValue(LiteralExpressionSyntax stringLiteral)
 | 
			
		||||
    {
 | 
			
		||||
        // Prüfen, ob das String-Literal Teil eines Parameter-Defaults ist
 | 
			
		||||
        var parameter = stringLiteral.FirstAncestorOrSelf<ParameterSyntax>();
 | 
			
		||||
        if (parameter is null)
 | 
			
		||||
            return false;
 | 
			
		||||
        
 | 
			
		||||
        // Überprüfen, ob das String-Literal im Default-Wert des Parameters verwendet wird
 | 
			
		||||
        if (parameter.Default is not null && 
 | 
			
		||||
            parameter.Default.Value == stringLiteral)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
    
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user