Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 16, 2025

Description

Adds IANA-registered .cgm extension (ISO 8632 Computer GraphicsMetafile) to MediaTypeMap.cs:

  • Added bidirectional mapping: .cgmimage/cgm
  • Updated dictionary size constants: ExtensionToMediaTypeCount (403→404), MediaTypeToExtensionCount (294→295)
  • Added test coverage for both direction conversions

Customer Impact

Applications using MediaTypeMap to resolve .cgm files will now correctly identify them as image/cgm instead of returning null. Affects technical documentation, engineering, and aviation industry applications that use CGM format.

Regression

No. This adds new functionality without modifying existing mappings.

Testing

  • All existing System.Net.Mail tests pass (760 total: 442 functional, 318 unit)
  • Added new test cases for .cgm extension in both directions
  • Verified dictionary consistency assertions pass in DEBUG builds

Risk

Low. Changes are purely additive (new dictionary entries only), no existing behavior modified.

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:

  • 012af33cbd3644b387e6b11417ae90d1
    • Triggering command: /home/REDACTED/work/runtime/runtime/artifacts/bin/testhost/net11.0-linux-Debug-x64/dotnet /home/REDACTED/work/runtime/runtime/artifacts/bin/testhost/net11.0-linux-Debug-x64/dotnet exec --runtimeconfig System.Net.Mail.Functional.Tests.runtimeconfig.json --depsfile System.Net.Mail.Functional.Tests.deps.json /home/REDACTED/.nuget/packages/microsoft.dotnet.xunitconsoleREDACTED/2.9.3-beta.25613.101/build/../tools/net/xunit.console.dll System.Net.Mail.Functional.Tests.dll -xml testResults.xml -nologo -notrait category=OuterLoop -notrait category=failing (dns block)
  • 02e2f870988a42a581f57bff00771dab
    • Triggering command: /home/REDACTED/work/runtime/runtime/artifacts/bin/testhost/net11.0-linux-Debug-x64/dotnet /home/REDACTED/work/runtime/runtime/artifacts/bin/testhost/net11.0-linux-Debug-x64/dotnet exec --runtimeconfig System.Net.Mail.Functional.Tests.runtimeconfig.json --depsfile System.Net.Mail.Functional.Tests.deps.json /home/REDACTED/.nuget/packages/microsoft.dotnet.xunitconsoleREDACTED/2.9.3-beta.25613.101/build/../tools/net/xunit.console.dll System.Net.Mail.Functional.Tests.dll -xml testResults.xml -nologo -notrait category=OuterLoop -notrait category=failing (dns block)
  • 3e7368d4357249b6b3f95fbbcd7b1c93
    • Triggering command: /home/REDACTED/work/runtime/runtime/artifacts/bin/testhost/net11.0-linux-Debug-x64/dotnet /home/REDACTED/work/runtime/runtime/artifacts/bin/testhost/net11.0-linux-Debug-x64/dotnet exec --runtimeconfig System.Net.Mail.Functional.Tests.runtimeconfig.json --depsfile System.Net.Mail.Functional.Tests.deps.json /home/REDACTED/.nuget/packages/microsoft.dotnet.xunitconsoleREDACTED/2.9.3-beta.25613.101/build/../tools/net/xunit.console.dll System.Net.Mail.Functional.Tests.dll -xml testResults.xml -nologo -notrait category=OuterLoop -notrait category=failing (dns block)
  • 587579ce91d347bf8950d8853485e7b9
    • Triggering command: /home/REDACTED/work/runtime/runtime/artifacts/bin/testhost/net11.0-linux-Debug-x64/dotnet /home/REDACTED/work/runtime/runtime/artifacts/bin/testhost/net11.0-linux-Debug-x64/dotnet exec --runtimeconfig System.Net.Mail.Functional.Tests.runtimeconfig.json --depsfile System.Net.Mail.Functional.Tests.deps.json /home/REDACTED/.nuget/packages/microsoft.dotnet.xunitconsoleREDACTED/2.9.3-beta.25613.101/build/../tools/net/xunit.console.dll System.Net.Mail.Functional.Tests.dll -xml testResults.xml -nologo -notrait category=OuterLoop -notrait category=failing (dns block)
  • 95059a425b004bb8afc673f7715e3b84
    • Triggering command: /home/REDACTED/work/runtime/runtime/artifacts/bin/testhost/net11.0-linux-Debug-x64/dotnet /home/REDACTED/work/runtime/runtime/artifacts/bin/testhost/net11.0-linux-Debug-x64/dotnet exec --runtimeconfig System.Net.Mail.Functional.Tests.runtimeconfig.json --depsfile System.Net.Mail.Functional.Tests.deps.json /home/REDACTED/.nuget/packages/microsoft.dotnet.xunitconsoleREDACTED/2.9.3-beta.25613.101/build/../tools/net/xunit.console.dll System.Net.Mail.Functional.Tests.dll -xml testResults.xml -nologo -notrait category=OuterLoop -notrait category=failing (dns block)
  • www.iana.org
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

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

Original prompt

Summary

Add support for the .cgm (Computer Graphics Metafile) file extension to MediaTypeMap.cs.

Background

While reviewing the media type mappings in dotnet/extensions IngestionDocumentReader.cs to ensure all valid entries are covered by MediaTypeMap, we identified that .cgm is a legitimate, IANA-registered MIME type that is missing from MediaTypeMap.cs.

Details

  • Extension: .cgm
  • MIME Type: image/cgm
  • IANA Registration: Yes - officially registered at https://www.iana.org/assignments/media-types/image/cgm
  • Standard: ISO 8632 (Computer Graphics Metafile)
  • Usage: Still actively used in technical documentation, engineering, and aviation industries

Changes Required

In src/libraries/System.Net.Mail/src/System/Net/Mime/MediaTypeMap.cs:

  1. Add to s_extensionToMediaType dictionary (in alphabetical order):

    [".cgm"] = "image/cgm",
  2. Add to s_mediaTypeToExtension dictionary (in alphabetical order):

    ["image/cgm"] = ".cgm",
  3. Update ExtensionToMediaTypeCount from 403 to 404

  4. Update MediaTypeToExtensionCount from 294 to 295

Reference

This change ensures that MediaTypeMap covers all valid IANA-registered MIME types used by IngestionDocumentReader in dotnet/extensions.

This pull request was created as a result of the following prompt from Copilot chat.

Summary

Add support for the .cgm (Computer Graphics Metafile) file extension to MediaTypeMap.cs.

Background

While reviewing the media type mappings in dotnet/extensions IngestionDocumentReader.cs to ensure all valid entries are covered by MediaTypeMap, we identified that .cgm is a legitimate, IANA-registered MIME type that is missing from MediaTypeMap.cs.

Details

  • Extension: .cgm
  • MIME Type: image/cgm
  • IANA Registration: Yes - officially registered at https://www.iana.org/assignments/media-types/image/cgm
  • Standard: ISO 8632 (Computer Graphics Metafile)
  • Usage: Still actively used in technical documentation, engineering, and aviation industries

Changes Required

In src/libraries/System.Net.Mail/src/System/Net/Mime/MediaTypeMap.cs:

  1. Add to s_extensionToMediaType dictionary (in alphabetical order):

    [".cgm"] = "image/cgm",
  2. Add to s_mediaTypeToExtension dictionary (in alphabetical order):

    ["image/cgm"] = ".cgm",
  3. Update ExtensionToMediaTypeCount from 403 to 404

  4. Update MediaTypeToExtensionCount from 294 to 295

Reference

This change ensures that MediaTypeMap covers all valid IANA-registered MIME types used by IngestionDocumentReader in dotnet/extensions.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Dec 16, 2025
- Added .cgm to s_extensionToMediaType dictionary mapped to image/cgm
- Added image/cgm to s_mediaTypeToExtension dictionary mapped to .cgm
- Updated ExtensionToMediaTypeCount from 403 to 404
- Updated MediaTypeToExtensionCount from 294 to 295
- Added test cases for .cgm extension in MediaTypeMapTest
- All tests passed successfully

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for .cgm file extension to MediaTypeMap.cs Add support for .cgm (Computer Graphics Metafile) extension to MediaTypeMap Dec 16, 2025
Copilot AI requested a review from stephentoub December 16, 2025 17:22
@stephentoub stephentoub marked this pull request as ready for review December 16, 2025 17:25
Copilot AI review requested due to automatic review settings December 16, 2025 17:25
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 support for the .cgm (Computer Graphics Metafile) file extension to the MediaTypeMap class, enabling proper MIME type resolution for this IANA-registered format (ISO 8632 standard) commonly used in technical documentation, engineering, and aviation industries.

Key Changes:

  • Added bidirectional mapping between .cgm extension and image/cgm MIME type in MediaTypeMap.cs
  • Updated dictionary size constants to reflect the addition (ExtensionToMediaTypeCount: 403→404, MediaTypeToExtensionCount: 294→295)
  • Added comprehensive test coverage for both mapping directions

Reviewed changes

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

File Description
src/libraries/System.Net.Mail/src/System/Net/Mime/MediaTypeMap.cs Added .cgmimage/cgm mapping in s_extensionToMediaType dictionary (line 65), added image/cgm.cgm mapping in s_mediaTypeToExtension dictionary (line 633), and updated both dictionary count constants (lines 16-17)
src/libraries/System.Net.Mail/tests/Functional/MediaTypeMapTest.cs Added test case for .cgmimage/cgm conversion in GetMediaType_WithExtension_ReturnsCorrectMediaType test (line 61), and added test case for image/cgm.cgm conversion in GetExtension_WithMediaType_ReturnsCorrectExtension test (line 122)

Review Summary: The changes are well-implemented and follow all established patterns. The .cgm entries are correctly positioned alphabetically in both dictionaries, the count constants are accurately updated, and comprehensive test coverage has been added for both conversion directions. No issues were identified during the review.

@vcsjones vcsjones added area-System.Net and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Dec 16, 2025
@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.

@stephentoub stephentoub merged commit 3333781 into main Dec 17, 2025
96 of 97 checks passed
@stephentoub stephentoub deleted the copilot/add-cgm-file-support branch December 17, 2025 11:25
@github-actions github-actions bot locked and limited conversation to collaborators Jan 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants