Skip to content
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

[Code Style] Add some extra style checks focused on nullability. #17831

Merged
merged 5 commits into from
Jun 22, 2023

Commits on Mar 17, 2023

  1. [Code Style] Add some extra style checks focused on nullability.

    Added the following new checks:
    
    ```csharp
    // dotnet_style_coalesce_expression = true
    var v = x ?? y;
    
    // dotnet_style_coalesce_expression = false
    var v = x != null ? x : y; // or
    var v = x == null ? y : x;
    ```
    
    ```csharp
    // dotnet_style_null_propagation = true
    var v = o?.ToString();
    
    // dotnet_style_null_propagation = false
    var v = o == null ? null : o.ToString(); // or
    var v = o != null ? o.String() : null;
    ```
    
    ```csharp
    // dotnet_style_prefer_is_null_check_over_reference_equality_method = true
    if (value is null)
        return;
    
    // dotnet_style_prefer_is_null_check_over_reference_equality_method = false
    if (object.ReferenceEquals(value, null))
        return;
    
    // dotnet_style_prefer_is_null_check_over_reference_equality_method = false
    if ((object)o == null)
        return;
    ```
    mandel-macaque committed Mar 17, 2023
    Configuration menu
    Copy the full SHA
    3bfe8d6 View commit details
    Browse the repository at this point in the history
  2. Update .editorconfig

    mandel-macaque committed Mar 17, 2023
    Configuration menu
    Copy the full SHA
    7eed258 View commit details
    Browse the repository at this point in the history
  3. Update .editorconfig

    mandel-macaque committed Mar 17, 2023
    Configuration menu
    Copy the full SHA
    a22e639 View commit details
    Browse the repository at this point in the history

Commits on May 10, 2023

  1. Configuration menu
    Copy the full SHA
    878fbba View commit details
    Browse the repository at this point in the history

Commits on Jun 21, 2023

  1. Configuration menu
    Copy the full SHA
    4040fe9 View commit details
    Browse the repository at this point in the history