Skip to content

fix: Consistent null handling in BanImplicitDateTimeToDateTimeOffsetConversion#406

Closed
Copilot wants to merge 3 commits intobmichaelis/nullabilityfrom
copilot/sub-pr-401
Closed

fix: Consistent null handling in BanImplicitDateTimeToDateTimeOffsetConversion#406
Copilot wants to merge 3 commits intobmichaelis/nullabilityfrom
copilot/sub-pr-401

Conversation

Copy link
Contributor

Copilot AI commented Mar 9, 2026

AnalyzeObjectCreation threw InvalidOperationException when GetTypeByMetadataName returned null, while AnalyzeInvocation handled the same case gracefully via SymbolEqualityComparer.Default.Equals.

Changes

  • BanImplicitDateTimeToDateTimeOffsetConversion.cs: Changed AnalyzeObjectCreation to declare nullable INamedTypeSymbol? and return early on null, matching the graceful degradation pattern used throughout the codebase
// Before
INamedTypeSymbol dateTimeOffsetType = context.Compilation.GetTypeByMetadataName("System.DateTimeOffset")
    ?? throw new InvalidOperationException("Unable to find DateTimeOffset type");

// After
INamedTypeSymbol? dateTimeOffsetType = context.Compilation.GetTypeByMetadataName("System.DateTimeOffset");
INamedTypeSymbol? dateTimeType = context.Compilation.GetTypeByMetadataName("System.DateTime");
if (dateTimeOffsetType is null || dateTimeType is null)
{
    return;
}

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits March 9, 2026 23:14
…ffsetConversion

Co-authored-by: BenjaminMichaelis <22186029+BenjaminMichaelis@users.noreply.github.com>
…alyzeInvocation

Co-authored-by: BenjaminMichaelis <22186029+BenjaminMichaelis@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 9, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • pe3vsblobprodcus354.vsblob.vsassets.io
    • Triggering command: /usr/share/dotnet/dotnet dotnet restore --no-dependencies /home/REDACTED/work/CodingGuidelines/CodingGuidelines/Tools/XMLtoMD/GuidelineXmlToMD.sln --packages /tmp/codeql-scratch-ec4d69bafe4e84e6/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/tmp/codeql-scratch-ec4d69bafe4e84e6/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/tmp/codeql-scratch-ec4d69bafe4e84e6/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)
    • Triggering command: /usr/share/dotnet/dotnet dotnet restore --no-dependencies /home/REDACTED/work/CodingGuidelines/CodingGuidelines/Tools/XMLtoMD/GuidelineXmlToMD/GuidelineXmlToMD.csproj --packages /tmp/codeql-scratch-ec4d69bafe4e84e6/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/tmp/codeql-scratch-ec4d69bafe4e84e6/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/tmp/codeql-scratch-ec4d69bafe4e84e6/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)
    • Triggering command: /usr/share/dotnet/dotnet dotnet restore --no-dependencies /home/REDACTED/work/CodingGuidelines/CodingGuidelines/Tools/XMLtoMD/GuidelineXmlToMD.Test/GuidelineXmlToMD.Test.csproj --packages /tmp/codeql-scratch-ec4d69bafe4e84e6/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/tmp/codeql-scratch-ec4d69bafe4e84e6/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/tmp/codeql-scratch-ec4d69bafe4e84e6/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)
  • s8mvsblobprodcus38.vsblob.vsassets.io
    • Triggering command: /usr/share/dotnet/dotnet dotnet restore --no-dependencies /tmp/codeql-scratch-ec4d69bafe4e84e6/dbs/csharp/working/152969D1C94CACFB2DD8DDFC3D3B91A8/missingpackages_workingdir --packages /tmp/codeql-scratch-ec4d69bafe4e84e6/dbs/csharp/working/missingpackages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal --configfile /tmp/codeql-scratch-ec4d69bafe4e84e6/dbs/csharp/working/nugetconfig/nuget.config --force (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Enable Nullable Reference Types across codebase fix: Consistent null handling in BanImplicitDateTimeToDateTimeOffsetConversion Mar 9, 2026
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