Skip to content

Release/v0.1.0 #61

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

Closed
wants to merge 17 commits into from
Closed

Release/v0.1.0 #61

wants to merge 17 commits into from

Conversation

rjmurillo
Copy link
Owner

No description provided.

Copy link

codacy-production bot commented Aug 19, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.00% (target: -1.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (e2b85da) 821 745 90.74%
Head commit (29add09) 821 (+0) 745 (+0) 90.74% (+0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#61) 0 0 ∅ (not applicable)

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

@rjmurillo rjmurillo added documentation Improvements or additions to documentation analyzers releasable labels Aug 19, 2024
rjmurillo and others added 17 commits August 19, 2024 13:19
Add [SquiggleCop](https://github.com/MattKotsenas/SquiggleCop) to
prevent unintended changes to Roslyn analyzers

---------

Signed-off-by: Richard Murillo <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Adds `.globalconfig` to enable pattern matching

Resolves #27
…trings (ECS0004) (#41)

This pull request introduces a new Roslyn analyzer and code fix to
enforce the use of interpolated strings instead of `string.Format`. This
change addresses the recommendations outlined in Effective C#: 50
Specific Ways to Improve your C#.

## Rule Details

### Rule ID: ECS0004
**Title:** Replace string.Format with interpolated string

**Category:** Style

**Description:** This rule identifies instances of `string.Format` and
suggests replacing them with C# interpolated strings for improved
readability and reduced error potential.
Related: BillWagner/EffectiveCSharpAnalyzers#7
Closes #32

The problem addressed by this rule is the use of methods that should
involve callback mechanisms without employing delegates for this
purpose. Specifically, methods are being invoked directly without the
use of delegate types such as `Predicate<T>`, `Action<T>`, or `Func<T>`,
which are designed to handle callbacks in a type-safe and consistent
manner.
Signed-off-by: Richard Murillo <[email protected]>
)

This pull request introduces a new analyzer rule, ECS0008, which is
designed to enforce the use of the null-conditional operator when
invoking event handlers in C#. This practice helps prevent potential
`NullReferenceExceptions`, improving the safety and robustness of the
code.

Key Features:
- **Detection of Potential Violations**: The rule identifies patterns
where an event handler is invoked without using the null-conditional
operator (`?.Invoke`), such as direct invocations or invocations within
an `if` statement checking for `null`.
- **Automatic Code Fixes**: The code fix provider automatically replaces
the identified pattern with the null-conditional operator, ensuring that
the event handler is only invoked when it has subscribers.
- **Comprehensive Coverage**: The rule handles cases where the event
handler is checked directly and cases where it is first assigned to a
local variable.

Example Violation:

```csharp
public class EventSource
{
    private EventHandler<int> Updated;
    private int counter;

    public void RaiseUpdates()
    {
        counter++;
        if (Updated != null)
            Updated(this, counter);
    }
}
```

Fixed code:

```csharp
public class EventSource
{
    private EventHandler<int> Updated;
    private int counter;

    public void RaiseUpdates()
    {
        counter++;
        Updated?.Invoke(this, counter);
    }
}
```
The ECS1000 analyzer for `Span<T>` is not part of Effective C# and is
removed
This pull request introduces a new Roslyn analyzer and associated code
fix provider to enforce best practices for culture-specific string
formatting in C#. The analyzer identifies cases where
`FormattableString` or `string.Create` should be used instead of string
for interpolated strings, depending on the target framework version. The
code fix provider automatically suggests the appropriate replacement.

## Changes

- Analyzer: `FormattableStringForCultureSpecificStringsAnalyzer`
- Detects culture-specific string usage and recommends either
`FormattableString`, `string.Create`, or `string.Format` based on the
.NET version.
- Code Fix Provider:
`FormattableStringForCultureSpecificStringsCodeFixProvider`
  - Provides automated fixes based on the analyzer's recommendations.
- Tests: Comprehensive unit tests covering various scenarios, including
different .NET versions and complex string interpolation cases.

This analyzer aligns modern C# and .NET practices, particularly Stephen
Toub's guidance on using `string.Create` in .NET 6+
Signed-off-by: Richard Murillo <[email protected]>
## Changes

- Update build matrix to use latest version of Ubuntu and Windows
- Update release workflow to trigger when releases are published,
edited, pre-released, or released
- Move performance baseline forward
- Update .NET SDK version to 8.0.400
- Move analyzer rules to shipped
- Update numbering of analyzer rules to leave room for sub rules
- Updated analyzer strings for title, message format, description to
`LocalizableString`
- Update `version.json` to use `0.1.0`
When a delegate is used but not combined or passed around, ECS0700 was
triggered. There is no problematic behavior. See #54 for details.

Resolves #54
Signed-off-by: Richard Murillo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzers documentation Improvements or additions to documentation releasable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant