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

[CORELIB-182] Fix dotnet and rider warnings, remove StyleCop leftovers #750

Merged
merged 21 commits into from
Jan 22, 2025

Conversation

wojtek2288
Copy link
Contributor

No description provided.

Copy link

github-actions bot commented Jan 21, 2025

test: Run #2114

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Pending ⏳ Other ❓ Flaky 🍂 Duration ⏱️
747 746 0 1 0 0 0 198ms

🎉 All tests passed!

Github Test Reporter

🔄 This comment has been updated

@@ -49,6 +50,7 @@ public override ISession Session
set { }
}

[SuppressMessage("ReSharper", "VirtualMemberCallInConstructor")]
Copy link
Member

Choose a reason for hiding this comment

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

Just a question, does it have a problem with the properties set here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes setting it in constructor. https://www.jetbrains.com/help/rider/VirtualMemberCallInConstructor.html For example this might fail:

public class CustomContext : LocalCallContext
{
    private string prefix;

    public CustomContext(
        IServiceProvider requestServices,
        ClaimsPrincipal user,
        string? activityIdentifier,
        IHeaderDictionary? headers,
        CancellationToken cancellationToken
    )
        : base(requestServices, user, activityIdentifier, headers, cancellationToken)
    {
        prefix = "test_";
    }

    public override string TraceIdentifier
    {
        get => base.TraceIdentifier;
        set => base.TraceIdentifier = $"{prefix}{value}";
    }
}
var context = new CustomContext(
    requestServices: serviceProvider,
    user: user,
    activityIdentifier: "123",
    headers: null,
    cancellationToken: CancellationToken.None
);

Because base constructor runs first and calls overridden setter but CustomContext constructor has not run yet and prefix is not initialized so we might get something like Object reference not set to an instance of an object.

@wojtek2288 wojtek2288 merged commit 30f95fe into v9.0-preview Jan 22, 2025
6 checks passed
@wojtek2288 wojtek2288 deleted the fix/warnings branch January 22, 2025 09:10
Copy link

codecov bot commented Jan 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (305efc4) to head (fc23912).
Report is 22 commits behind head on v9.0-preview.

Additional details and impacted files
@@         Coverage Diff         @@
##   v9.0-preview   #750   +/-   ##
===================================
===================================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it 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.

3 participants