Skip to content

Commit aa53f1a

Browse files
committed
Clarify namespace version prefix support in docs
Updated XML comments and code documentation in NamespaceParser.cs to specify that API version parsing supports 'v', 'V', or '_' as valid namespace prefixes. Added remarks and examples explaining the use of the underscore prefix, especially for folder names starting with numbers. Improved TryParse parameter documentation to reflect these changes.
1 parent f66f87f commit aa53f1a

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/Abstractions/src/Asp.Versioning.Abstractions/NamespaceParser.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ namespace Asp.Versioning;
1717
/// <summary>
1818
/// Represents API version parser from a type namespace.
1919
/// </summary>
20+
/// <remarks>
21+
/// The namespace identifier can use 'v', 'V', or '_' as a prefix. The '_' prefix is useful when
22+
/// a folder starts with a number because Visual Studio automatically prefixes it with an underscore.
23+
/// For example, <c>Contoso.Api._2018_04_01.Controllers</c> is equivalent to <c>Contoso.Api.v2018_04_01.Controllers</c>.
24+
/// </remarks>
2025
public class NamespaceParser
2126
{
2227
private const string CompactDateFormat = "yyyyMMdd";
@@ -142,7 +147,8 @@ public IReadOnlyList<ApiVersion> Parse( Type type )
142147
/// <summary>
143148
/// Attempts to parse an API version from the specified namespace identifier.
144149
/// </summary>
145-
/// <param name="identifier">The namespace identifier to parse.</param>
150+
/// <param name="identifier">The namespace identifier to parse. The identifier must start with
151+
/// 'v', 'V', or '_' followed by the version components.</param>
146152
/// <param name="apiVersion">The parsed <see cref="ApiVersion">API version</see> or <c>null</c>.</param>
147153
/// <returns>True if parsing is successful; otherwise, false.</returns>
148154
protected virtual bool TryParse( Text identifier, out ApiVersion? apiVersion )
@@ -164,7 +170,12 @@ protected virtual bool TryParse( Text identifier, out ApiVersion? apiVersion )
164170
// - v2_0_Beta
165171
// - v20180401
166172
// - v2018_04_01_1_1_Beta
173+
// - _1
174+
// - _1_1
175+
// - _20180401
167176
// - _2018_04_01
177+
// - _2018_04_01_Beta
178+
// - _2018_04_01_1_0_Beta
168179
var ch = identifier[0];
169180

170181
if ( ch != 'v' && ch != 'V' && ch != '_' )

0 commit comments

Comments
 (0)