/
githubmirror
/
PowerShell
Обзор
Документация
Войти
/
githubmirror
/
PowerShell
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/HttpVersionCompletionsAttribute.cs
51 строка
1 KB
xtqqczze
Fix `SA1028`: Code should not contain trailing whitespace. Part 1. (#26203)
16 окт 2025, 10:58
Не верифицирован
16 окт 2025, 10:58
a10ff10
Код
Авторство
О чём код?
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. #nullable enable using System; using System.Collections.Generic; using System.Management.Automation; using System.Net; using System.Reflection; namespace Microsoft.PowerShell.Commands { /// <summary> /// A completer for HTTP version names. /// </summary> internal sealed class HttpVersionCompletionsAttribute : ArgumentCompletionsAttribute { public static readonly string[] AllowedVersions; static HttpVersionCompletionsAttribute() { FieldInfo[] fields = typeof(HttpVersion).GetFields(BindingFlags.Static | BindingFlags.Public); var versions = new List<string>(fields.Length - 1); for (int i = 0; i < fields.Length; i++) { // skip field Unknown and not Version type if (fields[i].Name == nameof(HttpVersion.Unknown) || fields[i].FieldType != typeof(Version)) { continue; } var version = (Version?)fields[i].GetValue(null); if (version is not null) { versions.Add(version.ToString()); } } AllowedVersions = versions.ToArray(); } /// <inheritdoc/> public HttpVersionCompletionsAttribute() : base(AllowedVersions) { } } }