Skip to content

Fix NRT errors and enable TreatWarningsAsErrors#46

Open
niemyjski wants to merge 3 commits intomainfrom
nrt/treat-warnings-as-errors
Open

Fix NRT errors and enable TreatWarningsAsErrors#46
niemyjski wants to merge 3 commits intomainfrom
nrt/treat-warnings-as-errors

Conversation

@niemyjski
Copy link
Copy Markdown
Member

Summary

  • Enabled <TreatWarningsAsErrors>true\ in build configuration
  • Fixed nullable reference annotations in Aliyun storage provider

Test plan

  • \dotnet build Foundatio.All.slnx\ — 0 warnings, 0 errors

- Enable TreatWarningsAsErrors in build

- Fix nullable reference annotations in Aliyun storage implementation
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the Aliyun storage provider and build configuration to support stricter compilation (warnings as errors) by addressing nullable-reference-type (NRT) warnings and aligning dependency versions.

Changes:

  • Bumped Foundatio / Foundatio.TestHarness package references to 13.0.0-beta3.35.
  • Adjusted Aliyun storage/provider option and connection-string builder nullability annotations.
  • Minor internal refactors related to nullability initialization.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/Directory.Build.props Updates Foundatio.TestHarness package version.
src/Foundatio.Aliyun/Foundatio.Aliyun.csproj Updates Foundatio package version.
src/Foundatio.Aliyun/Storage/AliyunFileStorageOptions.cs Changes ConnectionString nullability/initialization.
src/Foundatio.Aliyun/AliyunConnectionStringBuilder.cs Changes connection-string parts (Endpoint, AccessKey, SecretKey) nullability + ctor signature.
src/Foundatio.Aliyun/Storage/AliyunFileStorageConnectionStringBuilder.cs Changes _bucket init and ctor signature nullability.
src/Foundatio.Aliyun/Storage/AliyunFileStorage.cs Updates SearchCriteria.Prefix initialization for NRT.
Comments suppressed due to low confidence (1)

src/Foundatio.Aliyun/AliyunConnectionStringBuilder.cs:20

  • Changing the constructor parameter from string? to string is a source-breaking nullability change for any consumers/derivers that may currently pass null (even though it throws at runtime). If you want to preserve compatibility while still validating, consider keeping the string? signature (or adding an overload) and continuing to throw for null/empty input.
    protected AliyunConnectionStringBuilder() { }

    protected AliyunConnectionStringBuilder(string connectionString)
    {
        if (String.IsNullOrEmpty(connectionString))
            throw new ArgumentNullException(nameof(connectionString));
        Parse(connectionString);

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +8 to +12
public string Endpoint { get; set; } = null!;

public string? AccessKey { get; set; }
public string AccessKey { get; set; } = null!;

public string? SecretKey { get; set; }
public string SecretKey { get; set; } = null!;

This comment was marked as resolved.

This comment was marked as resolved.

public class AliyunFileStorageOptions : SharedOptions
{
public string? ConnectionString { get; set; }
public string ConnectionString { get; set; } = null!;

This comment was marked as resolved.

This comment was marked as resolved.

}

public AliyunFileStorageConnectionStringBuilder(string? connectionString) : base(connectionString)
public AliyunFileStorageConnectionStringBuilder(string connectionString) : base(connectionString)

This comment was marked as resolved.

This comment was marked as resolved.

Address PR review comments: properties annotated as non-nullable string were initialized with null!, making the nullability contract inaccurate. Initialize with string.Empty instead so the non-nullable annotation is truthful at runtime.
Copy link
Copy Markdown
Member Author

@niemyjski niemyjski left a comment

Choose a reason for hiding this comment

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

@copilot review

…ring.Empty

Tests assert null for unset properties. Using string.Empty changed the
semantic meaning of not-set from null to empty, breaking 3 tests.
Properly nullable properties preserve original behavior.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

_logger = options.LoggerFactory?.CreateLogger(GetType()) ?? NullLogger.Instance;

if (String.IsNullOrEmpty(options.ConnectionString))
throw new ArgumentException("ConnectionString is required.", nameof(options));
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

The ArgumentException uses nameof(options) as the parameter name, but the invalid value is options.ConnectionString. Using nameof(options.ConnectionString) will make the exception’s ParamName accurate and improve diagnosability.

Suggested change
throw new ArgumentException("ConnectionString is required.", nameof(options));
throw new ArgumentException("ConnectionString is required.", nameof(options.ConnectionString));

Copilot uses AI. Check for mistakes.
private class SearchCriteria
{
public string Prefix { get; set; } = String.Empty;
public string Prefix { get; set; } = null!;
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

Prefix is initialized with null!, which makes the non-nullable contract less truthful and can allow a null value if SearchCriteria is ever instantiated without setting Prefix. Initializing it to String.Empty (as before) avoids the null-forgiving operator and keeps it safe by default.

Suggested change
public string Prefix { get; set; } = null!;
public string Prefix { get; set; } = String.Empty;

Copilot uses AI. Check for mistakes.
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.

2 participants