dotnet / dotnet/dotnet-api-docs

Testing old solutions using VSCode reveals mismatch in System.IO.Path.GetExtension

Open
#1,837 0 comments 0 reactions 0 assignees View on GitHub
area-System.IO dotnet-api/prod Pri2 untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

I have been trying to find an issue in some legacy code written by a dev at my company in 2012. I prefer to use VSCode and assumed that, as the doc suggests, the System.IO.Path.GetExtension method works the same in the versions listed in the doc.

But, there is a big difference:
.NET Core v2.1 (and possibly others) does not lineup with the functionality of checking for invalid characters in the filename. .NET Core will accept "<1235.pdf>.pdf" as a filename and extract ".pdf" from it.
.NET Framework, however, throws an ArgumentException because the filename contains invalid characters "<" and ">". Both versions are fine, but it did make finding the issue in this legacy code a hassle.

Please update the doc or fix the discrepancy so that devs in the future won't be so confused.
Note: Great work on the .NET Core and Framework!! I'm a C# dev and it is my favorite desktop application development language as of right now, especially when paired with Visual Studio.

---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: 00371794-2f55-5e6d-5646-e44474ce93f4
* Version Independent ID: f887b103-6668-321b-516a-50daf422a533
* Content: [Path.GetExtension Method (System.IO)](https://docs.microsoft.com/en-us/dotnet/api/system.io.path.getextension?view=netframework-3.5)
* Content Source: [xml/System.IO/Path.xml](https://github.com/dotnet/dotnet-api-docs/blob/master/xml/System.IO/Path.xml)
* Product: **dotnet-api**
* GitHub Login: @dotnet-bot
* Microsoft Alias: **dotnetcontent**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.