Name validation is stricter than VS and MSBuild
@richardstanton 已经在做这个了。
开始于 2026年6月4日。
评估
这个 Issue 还没有评估数据。
描述
Parsing a valid .sln file with a solution folder named CI/CD throws SolutionException because ValidateName rejects the / character. More broadly, the library rejects / ? : * " < > | and DOS reserved names (CON, AUX, LPT4, etc.) in folder names, project names, and configuration names — even though these are filesystem concerns that don't apply to display names stored in .sln files.
How other parsers handle this
We surveyed two other .sln parsers to understand established behavior:
VS's original parser (src/env/vscore/package/Solutions/SolutionPersistence.cs):
- Display names: no character validation at all during read. On write, project names are truncated at the first
\r,\n, or\t— that's the only sanitization. - No reserved name checks (CON, AUX, etc.).
- Solution folder names are treated as plain display strings with no special validation.
MSBuild's parser (src/Build/Construction/Solution/SolutionFile.cs):
- Display names: zero character validation.
ParseFirstProjectLineregex-extracts the name and assigns it directly. Empty names get a synthesized placeholder; that's the only special handling. - Project relative paths: validated against
Path.GetInvalidPathChars()(control characters only), notGetInvalidFileNameChars(). - Configuration names: only structural validation —
BuildType|Platformmust split into exactly two parts on|. No character validation on the individual parts. - When names need to become MSBuild XML identifiers,
MakeIntoSafeItemNameandCleanseProjectNametransform invalid characters to_rather than rejecting them. - No reserved name checks.
This library (Microsoft.VisualStudio.SolutionPersistence):
ValidateName(used for solution folder names only — viaCreateFolder,AddFolder, and theNamesetter) rejects/ ? : \ * " < > |, control characters, DOS reserved names,.,.., and names over 260 characters.- The same validation is shared for configuration names (
AddBuildType,AddPlatform). - Project display names are not validated by
ValidateName— they only get duplicate-name checking.
Summary
| Concern | VS original | MSBuild | This library |
|---|---|---|---|
/ ? : * " < > | in display names |
Allowed | Allowed | Rejected |
\ (backslash) in display names |
Allowed | Allowed | Rejected |
| DOS reserved names (CON, AUX, etc.) | Allowed | Allowed | Rejected |
. and .. as names |
Allowed | Allowed | Rejected |
| Control characters | Stripped on write | Rejected in paths only | Rejected |
| Configuration name characters | No validation | Only | split must yield 2 parts |
Rejected: / ? : \ * " < > | |
The key principle in both VS and MSBuild is that display names are arbitrary strings, not filesystem paths. Filesystem-invalid characters and reserved names are only relevant when a name maps to something on disk (like a project's relative path), not for logical names like solution folders or build configurations.
Considerations
ValidateName is only called for solution folder names — the one type of name that is purely virtual and never touches the filesystem. Ironically, project display names (which do derive from filesystem paths) skip this validation entirely.
The \ restriction is the one character that has a structural justification in this library's model, since the folder path format (/Folder/Subfolder/) normalizes backslashes. The / restriction is also structurally motivated for configuration names, since it's the folder-path segment delimiter, and | is the BuildType|Platform separator.
The remaining restrictions (? : * " < >, DOS reserved names, ./..) have no structural justification in the model — they are carried over from filesystem naming rules that don't apply to display names.
- 主要语言
- C#
- 星标
- 213
- 派生
- 14
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/vs-solutionpersistence 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
microsoft/vs-solutionpersistence#73 · 2 条评论 ·
-
难度 5/5 一周以上 新手友好度 45/100
-
难度 3/5 1-2 天 新手友好度 72/100
-
难度 5/5 一周以上 新手友好度 30/100
-
难度 3/5 1-2 天 新手友好度 55/100
microsoft/vs-solutionpersistence#147 · 4 个 reaction ·
查看 microsoft/vs-solutionpersistence 的全部 Issue
相似的 Issue
-
The test-platform skill doesn't say what three of its failures look like可能已有人在做 @yasmoradi 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
bitfoundation/bitplatform#14022 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
getsentry/sentry-dotnet#5756 · 1 条评论 ·
维护者通常 1 天内回复
-
area-TableView bug needs-triage team-Controls
难度 2/5 1-3 小时 新手友好度 66/100
microsoft/microsoft-ui-xaml#12351 · 1 条评论 ·
维护者通常 2 天内回复
-
AudioClient and ImageClient file path overloads send the full local path as the multipart file name可能已有人在做 @sebxt 今天认领。 未关闭area: audio area: images feature-request
难度 2/5 1-3 小时 新手友好度 76/100
openai/openai-dotnet#1453 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 73/100
维护者通常 1 天内回复