From b278015dd490a81c645da3adaafdf3c5478e10db Mon Sep 17 00:00:00 2001 From: Florian Zevedei Date: Fri, 29 Sep 2023 18:26:39 +0200 Subject: [PATCH] Replacing static names in exception messages with nameof literal --- .../MSSQLSerializer.cs | 2 +- TelegramBotBase/Factories/DefaultStartFormFactory.cs | 2 +- TelegramBotBase/Factories/ServiceProviderStartFormFactory.cs | 2 +- TelegramBotBase/States/JSONStateMachine.cs | 2 +- TelegramBotBase/States/SimpleJSONStateMachine.cs | 2 +- TelegramBotBase/States/XMLStateMachine.cs | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/TelegramBotBase.Extensions.Serializer.Database.MSSQL/MSSQLSerializer.cs b/TelegramBotBase.Extensions.Serializer.Database.MSSQL/MSSQLSerializer.cs index ed08d95..a25cbcd 100644 --- a/TelegramBotBase.Extensions.Serializer.Database.MSSQL/MSSQLSerializer.cs +++ b/TelegramBotBase.Extensions.Serializer.Database.MSSQL/MSSQLSerializer.cs @@ -31,7 +31,7 @@ namespace TelegramBotBase.Extensions.Serializer.Database.MSSQL if (FallbackStateForm != null && !FallbackStateForm.IsSubclassOf(typeof(FormBase))) { - throw new ArgumentException("FallbackStateForm is not a subclass of FormBase"); + throw new ArgumentException($"{nameof(FallbackStateForm)} is not a subclass of FormBase"); } } diff --git a/TelegramBotBase/Factories/DefaultStartFormFactory.cs b/TelegramBotBase/Factories/DefaultStartFormFactory.cs index 7ce2988..a908c85 100644 --- a/TelegramBotBase/Factories/DefaultStartFormFactory.cs +++ b/TelegramBotBase/Factories/DefaultStartFormFactory.cs @@ -12,7 +12,7 @@ public class DefaultStartFormFactory : IStartFormFactory { if (!typeof(FormBase).IsAssignableFrom(startFormClass)) { - throw new ArgumentException("startFormClass argument must be a FormBase type"); + throw new ArgumentException($"{nameof(startFormClass)} argument must be a {nameof(FormBase)} type"); } _startFormClass = startFormClass; diff --git a/TelegramBotBase/Factories/ServiceProviderStartFormFactory.cs b/TelegramBotBase/Factories/ServiceProviderStartFormFactory.cs index 4ee81db..fbe4394 100644 --- a/TelegramBotBase/Factories/ServiceProviderStartFormFactory.cs +++ b/TelegramBotBase/Factories/ServiceProviderStartFormFactory.cs @@ -14,7 +14,7 @@ public class ServiceProviderStartFormFactory : IStartFormFactory { if (!typeof(FormBase).IsAssignableFrom(startFormClass)) { - throw new ArgumentException("startFormClass argument must be a FormBase type"); + throw new ArgumentException($"{nameof(startFormClass)} argument must be a {nameof(FormBase)} type"); } _startFormClass = startFormClass; diff --git a/TelegramBotBase/States/JSONStateMachine.cs b/TelegramBotBase/States/JSONStateMachine.cs index ada7fe4..5c764a6 100644 --- a/TelegramBotBase/States/JSONStateMachine.cs +++ b/TelegramBotBase/States/JSONStateMachine.cs @@ -29,7 +29,7 @@ public class JsonStateMachine : IStateMachine if (FallbackStateForm != null && !FallbackStateForm.IsSubclassOf(typeof(FormBase))) { - throw new ArgumentException("FallbackStateForm is not a subclass of FormBase"); + throw new ArgumentException($"{nameof(FallbackStateForm)} is not a subclass of {nameof(FormBase)}"); } FilePath = file ?? throw new ArgumentNullException(nameof(file)); diff --git a/TelegramBotBase/States/SimpleJSONStateMachine.cs b/TelegramBotBase/States/SimpleJSONStateMachine.cs index 7e8fa58..e722305 100644 --- a/TelegramBotBase/States/SimpleJSONStateMachine.cs +++ b/TelegramBotBase/States/SimpleJSONStateMachine.cs @@ -30,7 +30,7 @@ public class SimpleJsonStateMachine : IStateMachine if (FallbackStateForm != null && !FallbackStateForm.IsSubclassOf(typeof(FormBase))) { - throw new ArgumentException("FallbackStateForm is not a subclass of FormBase"); + throw new ArgumentException($"{nameof(FallbackStateForm)} is not a subclass of {nameof(FormBase)}"); } FilePath = file ?? throw new ArgumentNullException(nameof(file)); diff --git a/TelegramBotBase/States/XMLStateMachine.cs b/TelegramBotBase/States/XMLStateMachine.cs index 1a569eb..fdaea1a 100644 --- a/TelegramBotBase/States/XMLStateMachine.cs +++ b/TelegramBotBase/States/XMLStateMachine.cs @@ -27,7 +27,7 @@ public class XmlStateMachine : IStateMachine if (FallbackStateForm != null && !FallbackStateForm.IsSubclassOf(typeof(FormBase))) { - throw new ArgumentException("FallbackStateForm is not a subclass of FormBase"); + throw new ArgumentException($"{nameof(FallbackStateForm)} is not a subclass of {nameof(FormBase)}"); } FilePath = file ?? throw new ArgumentNullException(nameof(file));