/
EvilBeaver
/
OneScript
Обзор
Документация
Войти
/
EvilBeaver
/
OneScript
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
develop
src/OneScript.Core/Contexts/ContextMethodAttribute.cs
50 строк
2 KB
EvilBeaver
Другой подход к устаревшим методам
05 сен 2025, 13:24
05 сен 2025, 13:24
e6f553c
Код
Авторство
О чём код?
/*---------------------------------------------------------- This Source Code Form is subject to the terms of the Mozilla Public License, v.2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ----------------------------------------------------------*/ using System; using System.Runtime.CompilerServices; using OneScript.Commons; namespace OneScript.Contexts { [AttributeUsage(AttributeTargets.Method)] public class ContextMethodAttribute : Attribute, INameAndAliasProvider { private readonly string _name; private readonly string _alias; public ContextMethodAttribute(string name, string alias) { if (!Utils.IsValidIdentifier(name)) throw new ArgumentException($"Name '{name}' must be a valid identifier"); if (!string.IsNullOrEmpty(alias) && !Utils.IsValidIdentifier(alias)) throw new ArgumentException($"Alias '{alias}' must be a valid identifier"); _name = name; _alias = alias; } public ContextMethodAttribute(string name, string _ = null, [CallerMemberName] string nativeMethodName = null) : this(name, nativeMethodName) { } public bool IsDeprecated { get; set; } public bool ThrowOnUse { get; set; } /// <summary> /// Данный метод не будет обработан генератором документации при обходе типов /// </summary> public bool SkipForDocumenter { get; set; } public string Name => _name; public string Alias => _alias; } }