Skip to content

Incorrect nullability on IApiRequestFormatMetadataProvider.GetSupport… #62935

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

codingwithstephen
Copy link

@codingwithstephen codingwithstephen commented Jul 25, 2025

Incorrect nullability on IApiRequestFormatMetadataProvider.GetSupportedContentTypes #62405

Fix incorrect nullability in GetSupportedContentTypes

Summary of the changes:
Corrected the nullability annotations for the GetSupportedContentTypes method in the IApiRequestFormatMetadataProvider interface to match the expected behavior.

Description

This PR fixes the nullability specification on the GetSupportedContentTypes method to ensure correct usage and compatibility with nullable reference types.

Due to the requirement of a specific .NET SDK version (10.0.100-preview.7.25322.101) pinned in global.json, I have not been able to build the solution or run existing tests. Additionally, after searching the codebase, I could not find any existing unit tests covering this particular feature or method.

Screenshot 2025-07-26 at 00 19 04

Fixes #62405

@github-actions github-actions bot added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Jul 25, 2025
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jul 25, 2025
@martincostello
Copy link
Member

This guide explains how to build the code locally: https://github.com/dotnet/aspnetcore/blob/main/docs/BuildFromSource.md

There are scripts to download the required SDK version and make it available for use in your IDE of choice.

@codingwithstephen codingwithstephen requested review from tdykstra and a team as code owners July 25, 2025 23:15
@codingwithstephen
Copy link
Author

@dotnet-policy-service agree

@codingwithstephen
Copy link
Author

@martincostello I am getting the build errors below. But I had to change these files in order for the tests to pass. What should I do here?

❌Detected modification to baseline API files. PublicAPI.Shipped.txt files should only be updated after a major release, and PublicAPI.Unshipped.txt files should not be updated in release branches. See /docs/APIBaselines.md for more information.
❌Modified API baseline files:
❌src/Mvc/Mvc.Core/src/PublicAPI.Shipped.txt

@martincostello
Copy link
Member

Sorry, I don't know the answer to that specific question for this repo.

@captainsafia
Copy link
Member

@codingwithstephen Thanks for opening this PR!

We use the PublicAPI analyzers to manage API versions in our application. The analyzer is complaining because the nullability changes should be applied in the PublicApi.Unshipped.txt file in the project directory.

Are you using VS or VS Code? There should be a codefixer offered to make this change? If not, you can try implementing it manually by creating a new PublicApi.Unshipped.txt file in this directory and adding the type signature with nullability and removing the type signature without it. Something like this:

*REMOVED*Microsoft.AspNetCore.Mvc.ApiExplorer.IApiRequestFormatMetadataProvider.GetSupportedContentTypes(string! contentType, System.Type! objectType) -> System.Collections.Generic.IReadOnlyList<string!>?
Microsoft.AspNetCore.Mvc.ApiExplorer.IApiRequestFormatMetadataProvider.GetSupportedContentTypes(string? contentType, System.Type! objectType) -> System.Collections.Generic.IReadOnlyList<string!>?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect nullability on IApiRequestFormatMetadataProvider.GetSupportedContentTypes
3 participants