From 15bf977458649dc0e1233a0b82fe25221dad745f Mon Sep 17 00:00:00 2001 From: Colin Date: Sun, 29 Sep 2019 17:37:07 +0100 Subject: [PATCH] Code inspections --- Meade.net.Focuser.UnitTests/FocuserUnitTests.cs | 1 - .../Properties/AssemblyInfo.cs | 1 - Meade.net.Telescope/Rates.cs | 4 ++-- Meade.net.Telescope/Telescope.cs | 16 ++++++++-------- Meade.net/LocalServer.cs | 7 ++----- Meade.net/SharedResources.cs | 1 - Meade.net/TelescopeList.cs | 8 +------- 7 files changed, 13 insertions(+), 25 deletions(-) diff --git a/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs b/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs index 66c5621..19e1115 100644 --- a/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs +++ b/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs @@ -6,7 +6,6 @@ using ASCOM.Meade.net.Wrapper; using ASCOM.Utilities.Interfaces; using Moq; using NUnit.Framework; -using NotImplementedException = System.NotImplementedException; namespace Meade.net.Focuser.UnitTests { diff --git a/Meade.net.Focuser.UnitTests/Properties/AssemblyInfo.cs b/Meade.net.Focuser.UnitTests/Properties/AssemblyInfo.cs index 61a9edd..0ed52fa 100644 --- a/Meade.net.Focuser.UnitTests/Properties/AssemblyInfo.cs +++ b/Meade.net.Focuser.UnitTests/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/Meade.net.Telescope/Rates.cs b/Meade.net.Telescope/Rates.cs index c656683..ca60466 100644 --- a/Meade.net.Telescope/Rates.cs +++ b/Meade.net.Telescope/Rates.cs @@ -85,12 +85,12 @@ namespace ASCOM.Meade.net // TODO Initialize this array with any Primary axis rates that your driver may provide // Example: m_Rates = new Rate[] { new Rate(10.5, 30.2), new Rate(54.0, 43.6) } //this.rates = new Rate[0]; - _rates = new Rate[] { new Rate(1, 1), new Rate(2, 2), new Rate(3, 3), new Rate(4, 4) }; + _rates = new[] { new Rate(1, 1), new Rate(2, 2), new Rate(3, 3), new Rate(4, 4) }; break; case TelescopeAxes.axisSecondary: // TODO Initialize this array with any Secondary axis rates that your driver may provide //this.rates = new Rate[0]; - _rates = new Rate[] { new Rate(1, 1), new Rate(2, 2), new Rate(3, 3), new Rate(4, 4) }; + _rates = new[] { new Rate(1, 1), new Rate(2, 2), new Rate(3, 3), new Rate(4, 4) }; break; case TelescopeAxes.axisTertiary: // TODO Initialize this array with any Tertiary axis rates that your driver may provide diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 1cdae28..d98a724 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -384,7 +384,7 @@ namespace ASCOM.Meade.net if (connectionInfo.SameDevice == 1) { - LogMessage("Connected Set", $"Making first connection telescope adjustments"); + LogMessage("Connected Set", "Making first connection telescope adjustments"); //These settings are applied only when the first device connects to the telescope. SetLongFormat(true); @@ -426,14 +426,14 @@ namespace ASCOM.Meade.net { case "high": TelescopePointingPrecision(true); - LogMessage(propertyName, $"High precision slewing selected"); + LogMessage(propertyName, "High precision slewing selected"); break; case "low": TelescopePointingPrecision(false); - LogMessage(propertyName, $"Low precision slewing selected"); + LogMessage(propertyName, "Low precision slewing selected"); break; default: - LogMessage(propertyName, $"Precision slewing unchanged"); + LogMessage(propertyName, "Precision slewing unchanged"); break; } } @@ -494,7 +494,7 @@ namespace ASCOM.Meade.net private bool TogglePrecision() { - LogMessage("TogglePrecision", $"Toggling slewing precision"); + LogMessage("TogglePrecision", "Toggling slewing precision"); var result = _sharedResourcesWrapper.SendChar(":P#"); //:P# Toggles High Precsion Pointing. When High precision pointing is enabled scope will first allow the operator to center a nearby bright star before moving to the actual target. //Returns: @@ -1369,7 +1369,7 @@ namespace ASCOM.Meade.net if (_userNewerPulseGuiding && duration < 10000) { - LogMessage("PulseGuide", $"Using new pulse guiding technique"); + LogMessage("PulseGuide", "Using new pulse guiding technique"); _sharedResourcesWrapper.SendBlind($":Mg{d}{duration:0000}#"); //:MgnDDDD# //:MgsDDDD# @@ -1383,7 +1383,7 @@ namespace ASCOM.Meade.net } else { - LogMessage("PulseGuide", $"Using old pulse guiding technique"); + LogMessage("PulseGuide", "Using old pulse guiding technique"); _sharedResourcesWrapper.Lock(() => { _sharedResourcesWrapper.SendBlind(":RG#"); //Make sure we are at guide rate @@ -2026,7 +2026,7 @@ namespace ASCOM.Meade.net } set { - LogMessage($"Tracking Set", $"{value}"); + LogMessage("Tracking Set", $"{value}"); _tracking = value; } } diff --git a/Meade.net/LocalServer.cs b/Meade.net/LocalServer.cs index 8635814..eceb526 100644 --- a/Meade.net/LocalServer.cs +++ b/Meade.net/LocalServer.cs @@ -254,7 +254,6 @@ namespace ASCOM.Meade.net { // Probably an attempt to load a Win32 DLL (i.e. not a .net assembly) // Just swallow the exception and continue to the next item. - continue; } catch (Exception e) { @@ -262,7 +261,6 @@ namespace ASCOM.Meade.net DriverName, MessageBoxButtons.OK, MessageBoxIcon.Stop); return false; } - } return true; } @@ -303,7 +301,6 @@ namespace ASCOM.Meade.net { MessageBox.Show(ex.ToString(), DriverName, MessageBoxButtons.OK, MessageBoxIcon.Stop); } - return; } // @@ -412,7 +409,7 @@ namespace ASCOM.Meade.net // // ASCOM // - assy = type.Assembly; + //assy = type.Assembly; // Pull the display name from the ServedClassName attribute. attr = Attribute.GetCustomAttribute(type, typeof(ServedClassNameAttribute)); //PWGS Changed to search type for attribute rather than assembly @@ -425,7 +422,7 @@ namespace ASCOM.Meade.net } catch (Exception ex) { - MessageBox.Show("Error while registering the server:\n" + ex.ToString(), + MessageBox.Show($"Error while registering the server:\n{ex}", DriverName, MessageBoxButtons.OK, MessageBoxIcon.Stop); bFail = true; } diff --git a/Meade.net/SharedResources.cs b/Meade.net/SharedResources.cs index c01a512..248e333 100644 --- a/Meade.net/SharedResources.cs +++ b/Meade.net/SharedResources.cs @@ -16,7 +16,6 @@ using System; using System.Collections.Generic; using System.Globalization; -using System.Linq; using ASCOM.Utilities; namespace ASCOM.Meade.net diff --git a/Meade.net/TelescopeList.cs b/Meade.net/TelescopeList.cs index 26f9417..29bcdf9 100644 --- a/Meade.net/TelescopeList.cs +++ b/Meade.net/TelescopeList.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.NetworkInformation; -using System.Text; - -namespace ASCOM.Meade.net +namespace ASCOM.Meade.net { public static class TelescopeList {