dotnet / dotnet/aspnetcore

Format arguments for IStringLocalizer do not support nullable reference types

Open
#44,251 4 comments 3 reactions 0 assignees View on GitHub
area-mvc enhancement feature-localization
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

The indexer of `this[string name, params object[] arguments]` of `IStringLocalizer` and the extension method `GetString(IStringLocalizer, String, Object[])` provided for `IStringLocalizer` do not support nullable format arguments.

### Expected Behavior

Nullable format arguments should be supported as they are also supported with `Format(string format, params object?[] args)` of `string`.

### Steps To Reproduce

Repro Project: https://github.com/dd-inno/stringlocalizer-format-issue

### Exceptions (if any)

_No response_

### .NET Version

6.0.400

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by reading the IStringLocalizer indexer and its GetString extension method, then run the linked repro project to observe nullable format arguments. Compare their signatures with string.Format(string format, params object?[] args). Done means nullable arguments are accepted without nullable-reference-type warnings and the repro behaves as expected.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
internationalization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.