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

Fix issues found by Roslynator #1899

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from
Open

Conversation

sungam3r
Copy link
Contributor

@sungam3r sungam3r commented May 1, 2023

No description provided.

@@ -21,7 +21,7 @@ static class Padding
/// <summary>
/// Writes the provided value to the output, applying direction-based padding when <paramref name="alignment"/> is provided.
/// </summary>
public static void Apply(TextWriter output, string value, in Alignment? alignment)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Is making Alignment readonly a suitable alternative? (The in keyword was added here thanks to advice from a competing analyzer, IIRC 🤷 )

Copy link
Contributor Author

@sungam3r sungam3r May 21, 2023

Choose a reason for hiding this comment

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

Is making Alignment readonly a suitable alternative?

Alignment is already a readonly struct.

# Conflicts:
#	src/Serilog/Capturing/PropertyValueConverter.cs
@SimonCropp
Copy link
Contributor

my personal preference is to avoid roslyn analysers. been burned too many times with poor performance and bugs.

when i do use them i only enable them for build. so disable realtime checking

Copy link
Member

@nblumhardt nblumhardt left a comment

Choose a reason for hiding this comment

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

I like some of the fixes/suggestions in here, but like @SimonCropp I'd lean towards keeping the solution lighter (and not having to potentially suppress another set of false-positives/unnecessary hints); Roslynator is installable as an IDE extension so perhaps that's enough, in this case?

/// <summary>
/// Construct a <see cref="LoggingFailedException"/> to communicate a logging failure.
/// </summary>
public LoggingFailedException()
Copy link
Member

Choose a reason for hiding this comment

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

Default exception constructors usually set a default message.

Copy link
Contributor

Choose a reason for hiding this comment

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

why does an exception need a default constructor?

Copy link
Member

Choose a reason for hiding this comment

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

@@ -21,7 +21,7 @@ static class Padding
/// <summary>
/// Writes the provided value to the output, applying direction-based padding when <paramref name="alignment"/> is provided.
/// </summary>
public static void Apply(TextWriter output, string value, in Alignment? alignment)
Copy link
Member

Choose a reason for hiding this comment

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

Is making Alignment readonly a suitable alternative? (The in keyword was added here thanks to advice from a competing analyzer, IIRC 🤷 )

@@ -830,7 +832,7 @@ namespace Serilog.Parsing
}
public sealed class PropertyToken : Serilog.Parsing.MessageTemplateToken
{
public PropertyToken(string propertyName, string rawText, string? format = null, in Serilog.Parsing.Alignment? alignment = null, Serilog.Parsing.Destructuring destructuring = 0) { }
Copy link
Member

Choose a reason for hiding this comment

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

Ditto here.

Copy link
Contributor Author

@sungam3r sungam3r May 3, 2023

Choose a reason for hiding this comment

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

Alignment is a readonly struct and works well with in but Nullable<Alignment> is not a readonly struct so in creates defensive copy as I understand.

The in keyword was added here thanks to advice from a competing analyzer, IIRC

No, I added in myself when making struct readonly.

@sungam3r sungam3r changed the title Introduce Roslynator Fix issues found by Roslynator May 3, 2023
@sungam3r
Copy link
Contributor Author

rebased on dev

@sungam3r
Copy link
Contributor Author

rebased on dev

@sungam3r
Copy link
Contributor Author

Rebased on dev. @nblumhardt Anything else to do here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants