Skip to content

Conversation

@stephentoub
Copy link
Member

Closes #121017

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Copilot finished reviewing on behalf of stephentoub November 19, 2025 04:57
Copy link
Contributor

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

This PR adds a new MediaTypeMap class to the System.Net.Mime namespace that provides bidirectional mapping between file extensions and media types (MIME types). The implementation includes comprehensive mappings for 429 extensions to media types and 278 media types to extensions, supporting common scenarios like determining content types for email attachments or web responses.

  • Adds static methods for converting file paths/extensions to media types and vice versa
  • Includes both string and ReadOnlySpan overloads for performance
  • Provides extensive test coverage for various edge cases and common scenarios

Reviewed Changes

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

Show a summary per file
File Description
src/libraries/System.Net.Mail/src/System/Net/Mime/MediaTypeMap.cs New class implementing bidirectional mapping with 429 extension→media type and 278 media type→extension mappings using Dictionary AlternateLookup for efficient span-based lookups
src/libraries/System.Net.Mail/src/System.Net.Mail.csproj Registers the new MediaTypeMap.cs file in the project
src/libraries/System.Net.Mail/ref/System.Net.Mail.cs Adds public API surface for the four MediaTypeMap methods (string and span overloads for GetMediaType and GetExtension)
src/libraries/System.Net.Mail/tests/Functional/MediaTypeMapTest.cs Comprehensive test suite covering null handling, unknown values, case-insensitivity, parameter stripping, round-trip conversions, and whitespace handling
src/libraries/System.Net.Mail/tests/Functional/System.Net.Mail.Functional.Tests.csproj Registers the new test file in the test project

Copy link
Member

@ManickaP ManickaP left a comment

Choose a reason for hiding this comment

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

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[API Proposal]: System.Net.Mime.MediaTypeMap

3 participants