Giter Site home page Giter Site logo

Comments (4)

josefpihrt avatar josefpihrt commented on June 12, 2024 1
        this.logger.LogError(
            "The tracking number '{TrackingNumber}' for the specified unit with the prefix '{SpecifiedUnitIdPrefix}' for bypassing did not match the expected pattern. ErrorCode: {ErrorCode}", 
            trackingNumber,
            specifiedUnitIdPrefix,
            ErrorCodes.BypassUnitTrackingNumberNotMatched);

Will be fixed.

    [LoggerMessage(EventId = EventIds.BypassTrackingNumberPrefixUnmatched, Level = LogLevel.Error, Message = "The tracking number '{TrackingNumber}' for the specified unit with the prefix '{SpecifiedUnitIdPrefix}' for bypassing did not match the expected pattern. ErrorCode: {ErrorCode}", )]
    private partial void LogUnitPrefixDidNotMatch(int trackingNumber, string specifiedUnitIdPrefix, int errorCode);

It would be best if the attribute could be kept single line, but if required could also be spread with one parameter per line.

Will be fixed (parameter with string literal must be on its own line).

        return new ErrorResult(
            ErrorCodes.BypassUnitTrackingNumberNotMatched,
            "The bypass tracking number did not match the expected pattern",
                $"Could not bypass. The prefix '{specifiedUnitIdPrefix}' of the specified unit associated with the tracking number '{trackingNumber}' did not match the expected pattern. Please verify your input",
            ProblemPageUrls.UnmatchedUnit);

Will be fixed (same as first case).

from roslynator.

josefpihrt avatar josefpihrt commented on June 12, 2024

Adding an option to prevent certain lines from being reported as too long is definitely possible.

Could you provide some examples of lines that should be skipped by RCS0056? Thanks.

from roslynator.

FreeYourMinds avatar FreeYourMinds commented on June 12, 2024

Sure.

Structured Logging

These kinds of templates would need an exclusion
(most of these messages are still inline, some of those have already been moved to usage with the LoggerMessageAttribute)

"The tracking number '{TrackingNumber}' for the specified unit with the prefix '{SpecifiedUnitIdPrefix}' for bypassing did not match the expected pattern. ErrorCode: {ErrorCode}", 

Full Code

        this.logger.LogError(
            "The tracking number '{TrackingNumber}' for the specified unit with the prefix '{SpecifiedUnitIdPrefix}' for bypassing did not match the expected pattern. ErrorCode: {ErrorCode}", 
            trackingNumber,
            specifiedUnitIdPrefix,
            ErrorCodes.BypassUnitTrackingNumberNotMatched);

with the LoggerMessageAttribute the code would look like this

    [LoggerMessage(EventId = EventIds.BypassTrackingNumberPrefixUnmatched, Level = LogLevel.Error, Message = "The tracking number '{TrackingNumber}' for the specified unit with the prefix '{SpecifiedUnitIdPrefix}' for bypassing did not match the expected pattern. ErrorCode: {ErrorCode}", )]
    private partial void LogUnitPrefixDidNotMatch(int trackingNumber, string specifiedUnitIdPrefix, int errorCode);

It would be best if the attribute could be kept single line, but if required could also be spread with one parameter per line.

Since all attribute usages are ascendant in the code, they are currently easily excluded with a #pragma warning disable statement and therefore are not so important to get an exclusion, but would be nice to have

UI Feedback

This is the associated message as an interpolated string which is used for user feedback in the UI, which also should be excludable

$"Could not bypass. The prefix '{specifiedUnitIdPrefix}' of the specified unit associated with the tracking number '{trackingNumber}' did not match the expected pattern. Please verify your input",

Full Code

        return new ErrorResult(
            ErrorCodes.BypassUnitTrackingNumberNotMatched,
            "The bypass tracking number did not match the expected pattern",
                $"Could not bypass. The prefix '{specifiedUnitIdPrefix}' of the specified unit associated with the tracking number '{trackingNumber}' did not match the expected pattern. Please verify your input",
            ProblemPageUrls.UnmatchedUnit);

I hope these examples are sufficient to clarify my scenario, let me know if you need additional information.
And already thanks for considering

from roslynator.

FreeYourMinds avatar FreeYourMinds commented on June 12, 2024

Perfekt! Thank you for the quick implementation.

...(parameter with string literal must be on its own line)

I already expected this to be a requirement 😜

from roslynator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.