Skip to content

Csharp support#124

Merged
robmck1995 merged 32 commits intomainfrom
csharp
Feb 7, 2025
Merged

Csharp support#124
robmck1995 merged 32 commits intomainfrom
csharp

Conversation

@robmck1995
Copy link
Copy Markdown
Contributor

@robmck1995 robmck1995 commented Feb 6, 2025

CodeAnt-AI Description

  • Added support for C# language in the language server, including a new CSharpClient for handling C# processes.
  • Updated Dockerfiles to install and configure .NET SDK and csharp-ls tool.
  • Enhanced logging and message handling in the LSP client.
  • Added rules for identifying various C# constructs such as classes, enums, fields, interfaces, methods, and properties.
  • Updated language detection utilities to recognize C# file extensions and patterns.

Changes walkthrough

Relevant files
Enhancement
16 files
api_types.rs
Add CSharp to SupportedLanguages enum                                                   

lsproxy/src/api_types.rs

  • Added CSharp to the SupportedLanguages enum.
+2/-0     
health.rs
Include CSharp in health check supported languages                         

lsproxy/src/handlers/health.rs

  • Included CSharp in the health check supported languages list.
+1/-0     
client.rs
Enhance logging and message handling in LSP client                         

lsproxy/src/lsp/client.rs

  • Added info logging and modified debug messages.
  • Enhanced message handling with dynamic registration and response
    creation.
  • +29/-4   
    json_rpc.rs
    Implement success response creation in JSON-RPC                               

    lsproxy/src/lsp/json_rpc.rs

    • Implemented a method to create success responses in JSON-RPC.
    +10/-0   
    csharp.rs
    Introduce CSharpClient for C# language server handling                 

    lsproxy/src/lsp/languages/csharp.rs

  • Introduced a new CSharpClient for handling C# language server
    processes.
  • Implemented initialization and configuration methods for CSharpClient.

  • +88/-0   
    mod.rs
    Add CSharp module to language modules                                                   

    lsproxy/src/lsp/languages/mod.rs

    • Added CSharp module to the list of language modules.
    +2/-1     
    manager.rs
    Integrate CSharpClient into language server manager                       

    lsproxy/src/lsp/manager/manager.rs

  • Integrated CSharpClient into the language server manager.
  • Updated file pattern detection for C# files.
  • +14/-6   
    file_utils.rs
    Add C# extensions to language detection utility                               

    lsproxy/src/utils/file_utils.rs

    • Added C# extensions to the language detection utility.
    +3/-1     
    workspace_documents.rs
    Define C# root files and patterns for workspace documents           

    lsproxy/src/utils/workspace_documents.rs

    • Defined C# root files and file patterns for workspace documents.
    +4/-0     
    all-identifiers.yml
    Add rule for C# identifiers                                                                       

    lsproxy/src/ast_grep/identifier/rules/csharp/all-identifiers.yml

    • Added rule for identifying all identifiers in C#.
    +5/-0     
    class.yml
    Add rule for C# class declarations                                                         

    lsproxy/src/ast_grep/symbol/rules/csharp/class.yml

    • Added rule for identifying class declarations in C#.
    +8/-0     
    enum.yml
    Add rule for C# enum declarations                                                           

    lsproxy/src/ast_grep/symbol/rules/csharp/enum.yml

    • Added rule for identifying enum declarations in C#.
    +8/-0     
    field.yml
    Add rule for C# field declarations                                                         

    lsproxy/src/ast_grep/symbol/rules/csharp/field.yml

    • Added rule for identifying field declarations in C#.
    +18/-0   
    interface.yml
    Add rule for C# interface declarations                                                 

    lsproxy/src/ast_grep/symbol/rules/csharp/interface.yml

    • Added rule for identifying interface declarations in C#.
    +8/-0     
    method.yml
    Add rule for C# method declarations                                                       

    lsproxy/src/ast_grep/symbol/rules/csharp/method.yml

    • Added rule for identifying method declarations in C#.
    +8/-0     
    property.yml
    Add rule for C# property declarations                                                   

    lsproxy/src/ast_grep/symbol/rules/csharp/property.yml

    • Added rule for identifying property declarations in C#.
    +8/-0     
    Configuration changes
    2 files
    Dockerfile
    Install and configure .NET SDK and csharp-ls                                     

    lsproxy/Dockerfile

  • Installed .NET SDK and csharp-ls tool.
  • Configured environment for C# language server.
  • +25/-0   
    Dockerfile
    Configure .NET SDK and csharp-ls for release                                     

    release/Dockerfile

    • Installed .NET SDK and csharp-ls tool for release environment.
    +16/-0   

    🔍 Infra Scan Results:
    Failed Dockerfile Checks
    Check NameFile PathLines
    Ensure that APT isn't usedlsproxy/Dockerfile91-93
    Ensure that HEALTHCHECK instructions have been added to container imageslsproxy/Dockerfile1-142
    Ensure that a user for the container has been createdlsproxy/Dockerfile1-142
    Ensure that APT isn't usedrelease/Dockerfile163-165
    Ensure that HEALTHCHECK instructions have been added to container imagesrelease/Dockerfile1-211
    Ensure that a user for the container has been createdrelease/Dockerfile1-211
    💡 Usage Guide

    Checking Your Pull Request

    Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

    Talking to CodeAnt AI

    Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

    @codeant-ai ask: Your question here
    

    This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

    Retrigger review

    Ask CodeAnt AI to review the PR again, by typing:

    @codeant-ai: review
    

    Check Your Repository Health

    To analyze the health of your code repository, visit our dashboard at app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

    @codeant-ai codeant-ai Bot added the size:L This PR changes 100-499 lines, ignoring generated files label Feb 6, 2025
    @codeant-ai
    Copy link
    Copy Markdown
    Contributor

    codeant-ai Bot commented Feb 6, 2025

    Pull Request Feedback 🔍

    🔒 No security issues identified
    ⚡ Recommended areas for review

    Code Smell
    The commented-out block of code between lines 250-266 should be removed or uncommented if necessary. Leaving commented-out code can lead to confusion and clutter.

    Error Handling
    The error message for failing to start the CSharp language server process mistakenly refers to "ruby-lsp" instead of "csharp-ls". This should be corrected to avoid confusion.

    Comment thread lsproxy/src/lsp/client.rs

    async fn start_response_listener(&mut self) -> Result<(), Box<dyn Error + Send + Sync>> {
    let process = self.get_process().clone();
    let mut process = self.get_process().clone();
    Copy link
    Copy Markdown
    Contributor

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Suggestion: Re-evaluate the necessity of cloning process in start_response_listener to avoid unnecessary resource usage. [performance]

    Suggested change
    let mut process = self.get_process().clone();
    let process = self.get_process();

    Comment thread lsproxy/src/lsp/languages/csharp.rs Outdated
    .stderr(debug_file)
    .spawn()
    .map_err(|e| {
    eprintln!("Failed to start ruby-lsp process: {}", e);
    Copy link
    Copy Markdown
    Contributor

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Suggestion: Consider using a more descriptive error message when the csharp-ls process fails to start, to help with debugging. [enhancement]

    Suggested change
    eprintln!("Failed to start ruby-lsp process: {}", e);
    eprintln!("Failed to start csharp-ls process in directory {}: {}", root_path, e);

    Comment on lines +170 to +171
    CSharpClient::new(workspace_path, self.watch_events_sender.subscribe())
    .await
    Copy link
    Copy Markdown
    Contributor

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Suggestion: Ensure that the CSharpClient::new method handles potential initialization errors gracefully, especially if it involves network or file operations that might fail. [possible issue]

    Suggested change
    CSharpClient::new(workspace_path, self.watch_events_sender.subscribe())
    .await
    CSharpClient::new(workspace_path, self.watch_events_sender.subscribe()).await.map_err(|e| format!("CSharpClient initialization failed: {}", e))?

    pub const CPP_EXTENSIONS: &[&str] = &["cpp", "cc", "cxx", "h", "hpp", "hxx", "hh"];
    pub const C_AND_CPP_EXTENSIONS: &[&str] = &["cpp", "cc", "c", "cxx", "h", "hpp", "hxx", "hh"];

    pub const CSHARP_ROOT_FILES: &[&str] = &["*.sln"];
    Copy link
    Copy Markdown
    Contributor

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Suggestion: Consider adding common C# project and solution files like ".csproj" and ".vcxproj" to CSHARP_ROOT_FILES to ensure comprehensive detection of C# projects. [enhancement]

    Suggested change
    pub const CSHARP_ROOT_FILES: &[&str] = &["*.sln"];
    pub const CSHARP_ROOT_FILES: &[&str] = &["*.sln", "*.csproj", "*.vcxproj"];

    @robmck1995 robmck1995 merged commit 0dbd314 into main Feb 7, 2025
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Labels

    size:L This PR changes 100-499 lines, ignoring generated files

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    2 participants