From e32c2aa50a41624e5ccac42dc70ef9de6330ea20 Mon Sep 17 00:00:00 2001 From: Colin Dawson Date: Sun, 25 Apr 2021 20:16:07 +0100 Subject: [PATCH] Sorted out some code inspection issues --- Meade.net.Telescope/Telescope.cs | 23 +++++++---------------- Meade.net/EnumExtensionMethods.cs | 8 ++++---- Meade.net/SharedResources.cs | 5 +---- Meade.net/TelescopeList.cs | 1 + 4 files changed, 13 insertions(+), 24 deletions(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index cdb6257..81605b3 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -446,7 +446,7 @@ namespace ASCOM.Meade.net } else { - LogMessage("Connected Set", $"Autostar Attempting manual bypass of prompts"); + LogMessage("Connected Set", "Autostar Attempting manual bypass of prompts"); ApplySkipAutoStarPrompts("Connect"); SendCurrentDateTime("Connect"); } @@ -633,7 +633,7 @@ namespace ASCOM.Meade.net if((Math.Abs(RightAscension - rightTargetAscension ) <= eps) && (Math.Abs(Declination - targetDeclination) <= eps)) { - LogMessage("IsTargetCoordinateInitRequired", $"0 diff -> false"); + LogMessage("IsTargetCoordinateInitRequired", "0 diff -> false"); _isTargetCoordinateInitRequired = false; return _isTargetCoordinateInitRequired; } @@ -657,7 +657,7 @@ namespace ASCOM.Meade.net } catch (Exception ex) { - LogMessage("InitTargetCoordinates", $"Error sync telescope position", ex.Message); + LogMessage("InitTargetCoordinates", "Error sync telescope position", ex.Message); } } @@ -1804,13 +1804,13 @@ namespace ASCOM.Meade.net LogMessage("SiteElevation", $"Set: {value}"); if (Math.Abs(value - base.SiteElevation) < 0.1) { - LogMessage("SiteElevation", $"Set: no change detected"); + LogMessage("SiteElevation", "Set: no change detected"); return; } LogMessage("SiteElevation", $"Set: {value} was {base.SiteElevation}"); base.SiteElevation = value; - base.UpdateSiteElevation(); + UpdateSiteElevation(); } } @@ -2184,16 +2184,7 @@ namespace ASCOM.Meade.net try { if (Connected) - { - if (!MovingAxis()) - { - result = IsSlewingToTarget(); - } - else - { - result = true; - } - } + result = MovingAxis() || IsSlewingToTarget(); } finally { @@ -2210,7 +2201,7 @@ namespace ASCOM.Meade.net if (_isGuiding) return false; - var result = string.Empty; + string result; try { result = SharedResourcesWrapper.SendString(":D#"); diff --git a/Meade.net/EnumExtensionMethods.cs b/Meade.net/EnumExtensionMethods.cs index 82b834a..2df6a5a 100644 --- a/Meade.net/EnumExtensionMethods.cs +++ b/Meade.net/EnumExtensionMethods.cs @@ -8,13 +8,13 @@ namespace ASCOM.Meade.net { public static string GetDescription(this Enum GenericEnum) { - Type genericEnumType = GenericEnum.GetType(); - MemberInfo[] memberInfo = genericEnumType.GetMember(GenericEnum.ToString()); - if ((memberInfo != null && memberInfo.Length > 0)) + var genericEnumType = GenericEnum.GetType(); + var memberInfo = genericEnumType.GetMember(GenericEnum.ToString()); + if (memberInfo.Length > 0) { var _Attribs = memberInfo[0] .GetCustomAttributes(typeof(System.ComponentModel.DescriptionAttribute), false); - if ((_Attribs != null && _Attribs.Count() > 0)) + if (_Attribs.Any()) { return ((System.ComponentModel.DescriptionAttribute) _Attribs.ElementAt(0)).Description; } diff --git a/Meade.net/SharedResources.cs b/Meade.net/SharedResources.cs index c2d8f8e..61a6249 100644 --- a/Meade.net/SharedResources.cs +++ b/Meade.net/SharedResources.cs @@ -100,10 +100,7 @@ namespace ASCOM.Meade.net { SharedSerial.ClearBuffers(); - if (includePrefix) - SharedSerial.Transmit( $"#{message}"); - else - SharedSerial.Transmit(message); + SharedSerial.Transmit(includePrefix ? $"#{message}" : message); try { diff --git a/Meade.net/TelescopeList.cs b/Meade.net/TelescopeList.cs index fd92c1b..e41f2e9 100644 --- a/Meade.net/TelescopeList.cs +++ b/Meade.net/TelescopeList.cs @@ -14,6 +14,7 @@ // ReSharper disable once InconsistentNaming public const string Autostar497_43Eg = "43Eg"; + // ReSharper disable once InconsistentNaming public const string AudioStar_A4S4 = "A4S4"; #endregion