Skip to content

Add null checks for type registration in RegisterService method - #258

Merged
theRainbird merged 2 commits into
theRainbird:masterfrom
sancheolz:null-check-service-name
Dec 3, 2026
Merged

theRainbird merged 2 commits into
theRainbird:masterfrom
sancheolz:null-check-service-name

Conversation

@sancheolz

Copy link
Copy Markdown
Contributor

According to the documentation, FullName may return null for some types. https://learn.microsoft.com/en-us/dotnet/api/System.Type.FullName?view=netstandard-2.0

Found by Linux Verification Center (linuxtesting.org) with SVACE.

@theRainbird
theRainbird self-requested a review December 3, 2026 04:57
@theRainbird
theRainbird merged commit 4cc885b into theRainbird:master Dec 3, 2026
4 checks passed
@sancheolz
sancheolz deleted the null-check-service-name branch December 3, 2026 05:31
@yallie

yallie commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

According to the documentation, FullName may return null for some types.

Wow, that's weird!

var nullable = typeof(Nullable<>);
var typeName = nullable.GetGenericArguments().First().FullName;

Console.WriteLine(typeName switch
{
    null => "null",
    var s => $"not null: {s}",
});

// prints: null

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