/
githubmirror
/
roslyn
Обзор
Документация
Войти
/
githubmirror
/
roslyn
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Compilers/CSharp/Portable/Utilities/ValueSetFactory.CharTC.cs
72 строки
2 KB
Jan Jones
Fix nullable annotations of `SymbolDisplay.FormatPrimitive` (#79869)
14 авг 2025, 12:41
Не верифицирован
14 авг 2025, 12:41
a523b84
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Diagnostics; namespace Microsoft.CodeAnalysis.CSharp { using static BinaryOperatorKind; internal static partial class ValueSetFactory { private class CharTC : INumericTC<char> { public static readonly CharTC Instance = new CharTC(); char INumericTC<char>.MinValue => char.MinValue; char INumericTC<char>.MaxValue => char.MaxValue; char INumericTC<char>.Zero => (char)0; bool INumericTC<char>.Related(BinaryOperatorKind relation, char left, char right) { switch (relation) { case Equal: return left == right; case GreaterThanOrEqual: return left >= right; case GreaterThan: return left > right; case LessThanOrEqual: return left <= right; case LessThan: return left < right; default: throw new ArgumentException("relation"); } } char INumericTC<char>.Next(char value) { Debug.Assert(value != char.MaxValue); return (char)(value + 1); } char INumericTC<char>.FromConstantValue(ConstantValue constantValue) => constantValue.IsBad ? (char)0 : constantValue.CharValue; string INumericTC<char>.ToString(char c) { var result = ObjectDisplay.FormatPrimitive(c, ObjectDisplayOptions.EscapeNonPrintableCharacters | ObjectDisplayOptions.UseQuotes); Debug.Assert(result != null); return result; } char INumericTC<char>.Prev(char value) { Debug.Assert(value != char.MinValue); return (char)(value - 1); } char INumericTC<char>.Random(Random random) { return (char)random.Next((int)char.MinValue, 1 + (int)char.MaxValue); } ConstantValue INumericTC<char>.ToConstantValue(char value) => ConstantValue.Create(value); } } }