From e782ac36fbc4b83f599f55df61fe5804d3fa0147 Mon Sep 17 00:00:00 2001 From: Colin Date: Sat, 28 Sep 2019 22:20:21 +0100 Subject: [PATCH 01/27] Code inspection cleanup --- AstroMath.UnitTests/AstroMathsUnitTests.cs | 18 +++-- .../FocuserUnitTests.cs | 16 ++--- .../TelescopeUnitTests.cs | 14 ++-- Meade.net.Telescope/AstroMaths/AstroMaths.cs | 9 +-- Meade.net.Telescope/Rates.cs | 32 ++++----- Meade.net.Telescope/Telescope.cs | 58 ++++++++-------- Meade.net.focuser/Focuser.cs | 54 +++++++-------- Meade.net/AssemblyInfo.cs | 2 +- Meade.net/ClassFactory.cs | 10 +-- Meade.net/LocalServer.cs | 67 ++++++++++--------- Meade.net/SetupDialogForm.cs | 10 +-- Meade.net/SharedResources.cs | 53 +++++++-------- Meade.net/TelescopeList.cs | 12 ++-- Meade.net/Win32Utilities.cs | 14 ++-- Meade.net/frmMain.cs | 2 - 15 files changed, 184 insertions(+), 187 deletions(-) diff --git a/AstroMath.UnitTests/AstroMathsUnitTests.cs b/AstroMath.UnitTests/AstroMathsUnitTests.cs index c6c0082..489c873 100644 --- a/AstroMath.UnitTests/AstroMathsUnitTests.cs +++ b/AstroMath.UnitTests/AstroMathsUnitTests.cs @@ -113,11 +113,13 @@ namespace AstroMath.UnitTests { var latitude = 52.0; - EquatorialCoordinates equatorialCoordinates = new EquatorialCoordinates(); - equatorialCoordinates.RightAscension = 5.862222222222222;//5 51' 44" - equatorialCoordinates.Declination = 23.21944444444444;//23 13' 10" + var equatorialCoordinates = new EquatorialCoordinates + { + RightAscension = 5.862222222222222, //5 51' 44" + Declination = 23.21944444444444 //23 13' 10" + }; - var hourAngle = 5.682222; + const double hourAngle = 5.682222; var altAz = _astroMath.ConvertEqToHoz(hourAngle, latitude, equatorialCoordinates); @@ -131,9 +133,11 @@ namespace AstroMath.UnitTests DateTime dateTime = new DateTime(2019, 05, 18, 22, 26, 15, DateTimeKind.Utc); var longitude = -1.7833333333333332; var latitude = 52.0; - EquatorialCoordinates equatorialCoordinates = new EquatorialCoordinates(); - equatorialCoordinates.RightAscension = 4.15361111111111; - equatorialCoordinates.Declination = 30.0019444444444; + EquatorialCoordinates equatorialCoordinates = new EquatorialCoordinates + { + RightAscension = 4.15361111111111, + Declination = 30.0019444444444 + }; var hourAngle = _astroMath.RightAscensionToHourAngle(dateTime, longitude, equatorialCoordinates.RightAscension); var altaz = _astroMath.ConvertEqToHoz(hourAngle, latitude, equatorialCoordinates); diff --git a/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs b/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs index 9dfd50b..58bf548 100644 --- a/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs +++ b/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs @@ -23,11 +23,13 @@ namespace Meade.net.Focuser.UnitTests [SetUp] public void Setup() { - _profileProperties = new ProfileProperties(); - _profileProperties.TraceLogger = false; - _profileProperties.ComPort = "TestCom1"; - _profileProperties.GuideRateArcSecondsPerSecond = 1.23; - _profileProperties.Precision = "Unchanged"; + _profileProperties = new ProfileProperties + { + TraceLogger = false, + ComPort = "TestCom1", + GuideRateArcSecondsPerSecond = 1.23, + Precision = "Unchanged" + }; _utilMock = new Mock(); @@ -84,7 +86,7 @@ namespace Meade.net.Focuser.UnitTests { var actionName = "Action"; - var exception = Assert.Throws(() => { var actualResult = _focuser.Action(actionName, string.Empty); }); + Assert.Throws(() => { var actualResult = _focuser.Action(actionName, string.Empty); }); } [Test] @@ -246,8 +248,6 @@ namespace Meade.net.Focuser.UnitTests [Test] public void DriverInfo_Get() { - Version version = System.Reflection.Assembly.GetAssembly(typeof(ASCOM.Meade.net.Focuser)).GetName().Version; - string exptectedDriverInfo = $"{_focuser.Description} .net driver. Version: {_focuser.DriverVersion}"; var driverInfo = _focuser.DriverInfo; diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index 3fb595c..416d6ac 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -28,11 +28,13 @@ namespace Meade.net.Telescope.UnitTests [SetUp] public void Setup() { - _profileProperties = new ProfileProperties(); - _profileProperties.TraceLogger = false; - _profileProperties.ComPort = "TestCom1"; - _profileProperties.GuideRateArcSecondsPerSecond = 1.23; - _profileProperties.Precision = "Unchanged"; + _profileProperties = new ProfileProperties + { + TraceLogger = false, + ComPort = "TestCom1", + GuideRateArcSecondsPerSecond = 1.23, + Precision = "Unchanged" + }; _utilMock = new Mock(); _utilExtraMock = new Mock(); @@ -521,8 +523,6 @@ namespace Meade.net.Telescope.UnitTests [Test] public void DriverInfo_Get() { - Version version = System.Reflection.Assembly.GetAssembly(typeof(ASCOM.Meade.net.Telescope)).GetName().Version; - string exptectedDriverInfo = $"{_telescope.Description} .net driver. Version: {_telescope.DriverVersion}"; var driverInfo = _telescope.DriverInfo; diff --git a/Meade.net.Telescope/AstroMaths/AstroMaths.cs b/Meade.net.Telescope/AstroMaths/AstroMaths.cs index 17e168b..beeb403 100644 --- a/Meade.net.Telescope/AstroMaths/AstroMaths.cs +++ b/Meade.net.Telescope/AstroMaths/AstroMaths.cs @@ -9,7 +9,7 @@ namespace ASCOM.Meade.net.AstroMaths //returns the decimal hour angle for given right ascension on a given datetime for a given logitude. public double RightAscensionToHourAngle(DateTime utcDateTime, double longitude, double rightAscension) { - var ut = DateTimeToDecimalHours( utcDateTime); + //var ut = DateTimeToDecimalHours( utcDateTime); var gst = UTtoGst( utcDateTime); var lst = GsTtoLst( gst, longitude); var raHours = rightAscension; @@ -82,10 +82,11 @@ namespace ASCOM.Meade.net.AstroMaths var upperA = Math.Atan2(y, x); var upperB = RadiansToDegrees(upperA); - var horizonCoordinates = new HorizonCoordinates(); - horizonCoordinates.Altitude = RadiansToDegrees(Math.Asin(sinA)); + var horizonCoordinates = new HorizonCoordinates + { + Altitude = RadiansToDegrees(Math.Asin(sinA)), Azimuth = upperB + }; - horizonCoordinates.Azimuth = upperB; if (upperB < 0) { diff --git a/Meade.net.Telescope/Rates.cs b/Meade.net.Telescope/Rates.cs index b3f6f22..d9fcefa 100644 --- a/Meade.net.Telescope/Rates.cs +++ b/Meade.net.Telescope/Rates.cs @@ -19,17 +19,14 @@ namespace ASCOM.Meade.net [ComVisible(true)] public class Rate : IRate { - private double _maximum = 0; - private double _minimum = 0; - // // Default constructor - Internal prevents public creation // of instances. These are values for AxisRates. // internal Rate(double minimum, double maximum) { - _maximum = maximum; - _minimum = minimum; + Maximum = maximum; + Minimum = minimum; } #region Implementation of IRate @@ -39,17 +36,9 @@ namespace ASCOM.Meade.net // TODO Add any required object cleanup here } - public double Maximum - { - get => _maximum; - set => _maximum = value; - } + public double Maximum { get; set; } - public double Minimum - { - get => _minimum; - set => _minimum = value; - } + public double Minimum { get; set; } #endregion } @@ -152,7 +141,7 @@ namespace ASCOM.Meade.net private readonly DriveRates[] _trackingRates; // this is used to make the index thread safe - private readonly ThreadLocal _pos = new ThreadLocal(() => { return -1; }); + private readonly ThreadLocal _pos = new ThreadLocal(() => -1); private static readonly object LockObj = new object(); // @@ -176,7 +165,11 @@ namespace ASCOM.Meade.net public IEnumerator GetEnumerator() { - _pos.Value = -1; + lock (LockObj) + { + _pos.Value = -1; + } + return this as IEnumerator; } @@ -220,7 +213,10 @@ namespace ASCOM.Meade.net public void Reset() { - _pos.Value = -1; + lock (LockObj) + { + _pos.Value = -1; + } } #endregion } diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index cf94f12..f86cb37 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -98,9 +98,7 @@ namespace ASCOM.Meade.net } private double _guideRate; - - private const double SIDRATE = 0.9972695677; //synodic/solar seconds per sidereal second - + private void Initialise() { //todo move the TraceLogger out to a factory class. @@ -152,9 +150,7 @@ namespace ASCOM.Meade.net get { LogMessage("SupportedActions Get", "Returning empty arraylist"); - var supportedActions = new ArrayList(); - supportedActions.Add("handbox"); - supportedActions.Add("site"); + var supportedActions = new ArrayList {"handbox", "site"}; return supportedActions; } } @@ -540,9 +536,9 @@ namespace ASCOM.Meade.net CheckConnected("SelectSite"); if (site < 1) - throw new ArgumentOutOfRangeException("site",site,"Site cannot be lower than 1"); + throw new ArgumentOutOfRangeException(nameof(site),site,"Site cannot be lower than 1"); else if (site > 4) - throw new ArgumentOutOfRangeException("site", site, "Site cannot be higher than 4"); + throw new ArgumentOutOfRangeException(nameof(site), site, "Site cannot be higher than 4"); _sharedResourcesWrapper.SendBlind($":W{site}#"); //:W# @@ -555,9 +551,9 @@ namespace ASCOM.Meade.net CheckConnected("SetSiteName"); if (site < 1) - throw new ArgumentOutOfRangeException("site", site, "Site cannot be lower than 1"); + throw new ArgumentOutOfRangeException(nameof(site), site, "Site cannot be lower than 1"); else if (site > 4) - throw new ArgumentOutOfRangeException("site", site, "Site cannot be higher than 4"); + throw new ArgumentOutOfRangeException(nameof(site), site, "Site cannot be higher than 4"); string command = String.Empty; switch (site) @@ -609,9 +605,9 @@ namespace ASCOM.Meade.net CheckConnected("GetSiteName"); if (site < 1) - throw new ArgumentOutOfRangeException("site", site, "Site cannot be lower than 1"); + throw new ArgumentOutOfRangeException(nameof(site), site, "Site cannot be lower than 1"); else if (site > 4) - throw new ArgumentOutOfRangeException("site", site, "Site cannot be higher than 4"); + throw new ArgumentOutOfRangeException(nameof(site), site, "Site cannot be higher than 4"); switch (site) { @@ -637,7 +633,7 @@ namespace ASCOM.Meade.net //A ‘#’ terminated string with the name of the requested site. } - throw new ArgumentOutOfRangeException("site", site, "Site out of range"); + throw new ArgumentOutOfRangeException(nameof(site), site, "Site out of range"); } public string Description @@ -874,7 +870,7 @@ namespace ASCOM.Meade.net } } - private bool _atPark = false; + private bool _atPark; public bool AtPark { @@ -1162,10 +1158,10 @@ namespace ASCOM.Meade.net if (!value.InRange(0, 15.0417)) { - throw new InvalidValueException(propertyName, value.ToString(), "0 to 15.0417”/sec"); + throw new InvalidValueException(propertyName, value.ToString(CultureInfo.CurrentCulture), $"{0.ToString(CultureInfo.CurrentCulture)} to {15.0417.ToString(CultureInfo.CurrentCulture)}”/sec"); } - LogMessage($"{propertyName} Set", $"Setting new guiderate {value.ToString()} arc seconds/second ({value.ToString()} degrees/second)"); + LogMessage($"{propertyName} Set", $"Setting new guiderate {value.ToString(CultureInfo.CurrentCulture)} arc seconds/second ({value.ToString(CultureInfo.CurrentCulture)} degrees/second)"); _sharedResourcesWrapper.SendBlind($":Rg{value:00.0}#"); //:RgSS.S# //Set guide rate to +/ -SS.S to arc seconds per second.This rate is added to or subtracted from the current tracking @@ -1708,10 +1704,8 @@ namespace ASCOM.Meade.net throw new InvalidValueException("Azimuth cannot be less than 0."); LogMessage("SlewToAltAzAsync", $"Az={azimuth} Alt={altitude}"); - - HorizonCoordinates altAz = new HorizonCoordinates(); - altAz.Azimuth = azimuth; - altAz.Altitude = altitude; + + HorizonCoordinates altAz = new HorizonCoordinates {Azimuth = azimuth, Altitude = altitude}; var utcDateTime = UTCDate; var latitude = SiteLatitude; @@ -2128,18 +2122,20 @@ namespace ASCOM.Meade.net LogMessage("UTCDate", "Get started"); - TelescopeDateDetails telescopeDateDetails = _sharedResourcesWrapper.Lock(() => + var telescopeDateDetails = _sharedResourcesWrapper.Lock(() => { - TelescopeDateDetails tdd = new TelescopeDateDetails(); - tdd.TelescopeDate = _sharedResourcesWrapper.SendString(":GC#"); - //:GC# Get current date. - //Returns: MM/DD/YY# - //The current local calendar date for the telescope. - tdd.TelescopeTime = _sharedResourcesWrapper.SendString(":GL#"); - //:GL# Get Local Time in 24 hour format - //Returns: HH:MM:SS# - //The Local Time in 24 - hour Format - tdd.UtcCorrection = GetUtcCorrection(); + var tdd = new TelescopeDateDetails + { + TelescopeDate = _sharedResourcesWrapper.SendString(":GC#"), + //:GC# Get current date. + //Returns: MM/DD/YY# + //The current local calendar date for the telescope. + TelescopeTime = _sharedResourcesWrapper.SendString(":GL#"), + //:GL# Get Local Time in 24 hour format + //Returns: HH:MM:SS# + //The Local Time in 24 - hour Format + UtcCorrection = GetUtcCorrection() + }; return tdd; }); diff --git a/Meade.net.focuser/Focuser.cs b/Meade.net.focuser/Focuser.cs index 81cccf4..9aab8c5 100644 --- a/Meade.net.focuser/Focuser.cs +++ b/Meade.net.focuser/Focuser.cs @@ -54,7 +54,7 @@ namespace ASCOM.Meade.net /// /// Variable to hold the trace logger object (creates a diagnostic log file with information that you specify) /// - private static TraceLogger Tl; + private static TraceLogger _tl; private readonly ISharedResourcesWrapper _sharedResourcesWrapper; @@ -83,7 +83,7 @@ namespace ASCOM.Meade.net private void Initialise() { //todo move the TraceLogger out to a factory class. - Tl = new TraceLogger("", "Meade.Generic.focusser"); + _tl = new TraceLogger("", "Meade.Generic.focusser"); ReadProfile(); // Read device configuration from the ASCOM Profile store @@ -108,17 +108,17 @@ namespace ASCOM.Meade.net /// public void SetupDialog() { - Tl.LogMessage("SetupDialog", "Opening setup dialog"); + _tl.LogMessage("SetupDialog", "Opening setup dialog"); _sharedResourcesWrapper.SetupDialog(); ReadProfile(); - Tl.LogMessage("SetupDialog", "complete"); + _tl.LogMessage("SetupDialog", "complete"); } public ArrayList SupportedActions { get { - Tl.LogMessage("SupportedActions Get", "Returning empty arraylist"); + _tl.LogMessage("SupportedActions Get", "Returning empty arraylist"); return new ArrayList(); } } @@ -163,9 +163,9 @@ namespace ASCOM.Meade.net public void Dispose() { // Clean up the tracelogger and util objects - Tl.Enabled = false; - Tl.Dispose(); - Tl = null; + _tl.Enabled = false; + _tl.Dispose(); + _tl = null; } public bool Connected @@ -177,7 +177,7 @@ namespace ASCOM.Meade.net } set { - Tl.LogMessage("Connected", "Set {0}", value); + _tl.LogMessage("Connected", "Set {0}", value); if (value == IsConnected) return; @@ -216,7 +216,7 @@ namespace ASCOM.Meade.net // TODO customise this device description get { - Tl.LogMessage("Description Get", DriverDescription); + _tl.LogMessage("Description Get", DriverDescription); return DriverDescription; } } @@ -259,7 +259,7 @@ namespace ASCOM.Meade.net { //string name = "Short driver name - please customise"; string name = DriverDescription; - Tl.LogMessage("Name Get", name); + _tl.LogMessage("Name Get", name); return name; } } @@ -274,14 +274,14 @@ namespace ASCOM.Meade.net { CheckConnected("Absolute Get"); - Tl.LogMessage("Absolute Get", false.ToString()); + _tl.LogMessage("Absolute Get", false.ToString()); return false; // This is a relative focuser } } public void Halt() { - Tl.LogMessage("Halt", "Halting"); + _tl.LogMessage("Halt", "Halting"); CheckConnected("Halt"); @@ -302,7 +302,7 @@ namespace ASCOM.Meade.net { get { - Tl.LogMessage("IsMoving Get", false.ToString()); + _tl.LogMessage("IsMoving Get", false.ToString()); return false; // This focuser always moves instantaneously so no need for IsMoving ever to be True } } @@ -311,12 +311,12 @@ namespace ASCOM.Meade.net { get { - Tl.LogMessage("Link Get", Connected.ToString()); + _tl.LogMessage("Link Get", Connected.ToString()); return Connected; // Direct function to the connected method, the Link method is just here for backwards compatibility } set { - Tl.LogMessage("Link Set", value.ToString()); + _tl.LogMessage("Link Set", value.ToString()); Connected = value; // Direct function to the connected method, the Link method is just here for backwards compatibility } } @@ -326,7 +326,7 @@ namespace ASCOM.Meade.net { get { - Tl.LogMessage("MaxIncrement Get", _maxIncrement.ToString()); + _tl.LogMessage("MaxIncrement Get", _maxIncrement.ToString()); return _maxIncrement; // Maximum change in one move } } @@ -336,14 +336,14 @@ namespace ASCOM.Meade.net { get { - Tl.LogMessage("MaxStep Get", _maxStep.ToString()); + _tl.LogMessage("MaxStep Get", _maxStep.ToString()); return _maxStep; } } public void Move(int position) { - Tl.LogMessage("Move", position.ToString()); + _tl.LogMessage("Move", position.ToString()); CheckConnected("Move"); //todo implement backlash compensation @@ -405,7 +405,7 @@ namespace ASCOM.Meade.net { get { - Tl.LogMessage("StepSize Get", "Not implemented"); + _tl.LogMessage("StepSize Get", "Not implemented"); throw new PropertyNotImplementedException("StepSize", false); } } @@ -414,13 +414,13 @@ namespace ASCOM.Meade.net { get { - Tl.LogMessage("TempComp Get", false.ToString()); + _tl.LogMessage("TempComp Get", false.ToString()); return false; } // ReSharper disable once ValueParameterNotUsed set { - Tl.LogMessage("TempComp Set", "Not implemented"); + _tl.LogMessage("TempComp Set", "Not implemented"); throw new PropertyNotImplementedException("TempComp", false); } } @@ -429,7 +429,7 @@ namespace ASCOM.Meade.net { get { - Tl.LogMessage("TempCompAvailable Get", false.ToString()); + _tl.LogMessage("TempCompAvailable Get", false.ToString()); return false; // Temperature compensation is not available in this driver } } @@ -438,7 +438,7 @@ namespace ASCOM.Meade.net { get { - Tl.LogMessage("Temperature Get", "Not implemented"); + _tl.LogMessage("Temperature Get", "Not implemented"); throw new PropertyNotImplementedException("Temperature", false); } } @@ -546,10 +546,10 @@ namespace ASCOM.Meade.net private void ReadProfile() { var profileProperties = _sharedResourcesWrapper.ReadProfile(); - Tl.Enabled = profileProperties.TraceLogger; + _tl.Enabled = profileProperties.TraceLogger; _comPort = profileProperties.ComPort; - LogMessage("ReadProfile", $"Trace logger enabled: {Tl.Enabled}"); + LogMessage("ReadProfile", $"Trace logger enabled: {_tl.Enabled}"); LogMessage("ReadProfile", $"Com Port: {_comPort}"); } @@ -562,7 +562,7 @@ namespace ASCOM.Meade.net private static void LogMessage(string identifier, string message, params object[] args) { var msg = string.Format(message, args); - Tl.LogMessage(identifier, msg); + _tl.LogMessage(identifier, msg); } #endregion } diff --git a/Meade.net/AssemblyInfo.cs b/Meade.net/AssemblyInfo.cs index 04b5aaf..a10829d 100644 --- a/Meade.net/AssemblyInfo.cs +++ b/Meade.net/AssemblyInfo.cs @@ -12,7 +12,7 @@ namespace ASCOM.Meade.net Product = "", Copyright = "", Trademark = "", AssemblyVersion = "", FileVersion = "", Guid = "", NeutralLanguage = ""; - public bool IsComVisible = false; + public bool IsComVisible; // Return a particular assembly attribute value. public static T GetAssemblyAttribute(Assembly assembly) diff --git a/Meade.net/ClassFactory.cs b/Meade.net/ClassFactory.cs index bbb5771..caa2b43 100644 --- a/Meade.net/ClassFactory.cs +++ b/Meade.net/ClassFactory.cs @@ -33,8 +33,8 @@ namespace ASCOM.Meade.net #region Access to ole32.dll functions for class factories // Define two common GUID objects for public usage. - private static readonly Guid _iidIUnknown = new Guid("{00000000-0000-0000-C000-000000000046}"); - private static readonly Guid _iidIDispatch = new Guid("{00020400-0000-0000-C000-000000000046}"); + private static readonly Guid IidIUnknown = new Guid("{00000000-0000-0000-C000-000000000046}"); + private static readonly Guid IidIDispatch = new Guid("{00020400-0000-0000-C000-000000000046}"); [Flags] enum Clsctx : uint @@ -118,7 +118,7 @@ namespace ASCOM.Meade.net public ClassFactory(Type type) { if (type == null) - throw new ArgumentNullException("type"); + throw new ArgumentNullException(nameof(type)); _mClassType = type; //PWGS Get the ProgID from the MetaData @@ -201,12 +201,12 @@ namespace ASCOM.Meade.net // // Handle requests for IDispatch or IUnknown on the class // - if (riid == _iidIDispatch) + if (riid == IidIDispatch) { ppvObject = Marshal.GetIDispatchForObject(Activator.CreateInstance(_mClassType)); return; } - else if (riid == _iidIUnknown) + else if (riid == IidIUnknown) { ppvObject = Marshal.GetIUnknownForObject(Activator.CreateInstance(_mClassType)); } diff --git a/Meade.net/LocalServer.cs b/Meade.net/LocalServer.cs index 4fb6769..e321c59 100644 --- a/Meade.net/LocalServer.cs +++ b/Meade.net/LocalServer.cs @@ -29,7 +29,7 @@ namespace ASCOM.Meade.net public static class Server { - private const string DRIVER_NAME = "Meade Generic"; + private const string DriverName = "Meade Generic"; #region Access to kernel32.dll, user32.dll, and ole32.dll functions [Flags] @@ -259,7 +259,7 @@ namespace ASCOM.Meade.net catch (Exception e) { MessageBox.Show($"Failed to load served COM class assembly {fi.Name} - {e.Message}", - DRIVER_NAME, MessageBoxButtons.OK, MessageBoxIcon.Stop); + DriverName, MessageBoxButtons.OK, MessageBoxIcon.Stop); return false; } @@ -287,19 +287,21 @@ namespace ASCOM.Meade.net // private static void ElevateSelf(string arg) { - ProcessStartInfo si = new ProcessStartInfo(); - si.Arguments = arg; - si.WorkingDirectory = Environment.CurrentDirectory; - si.FileName = Application.ExecutablePath; - si.Verb = "runas"; + var si = new ProcessStartInfo + { + Arguments = arg, + WorkingDirectory = Environment.CurrentDirectory, + FileName = Application.ExecutablePath, + Verb = "runas" + }; try { Process.Start(si); } catch (System.ComponentModel.Win32Exception) { - MessageBox.Show($"The {DRIVER_NAME} was not {(arg == "/register" ? "registered" : "unregistered")} because you did not allow it.", DRIVER_NAME, MessageBoxButtons.OK, MessageBoxIcon.Warning); + MessageBox.Show($"The {DriverName} was not {(arg == "/register" ? "registered" : "unregistered")} because you did not allow it.", DriverName, MessageBoxButtons.OK, MessageBoxIcon.Warning); } catch (Exception ex) { - MessageBox.Show(ex.ToString(), DRIVER_NAME, MessageBoxButtons.OK, MessageBoxIcon.Stop); + MessageBox.Show(ex.ToString(), DriverName, MessageBoxButtons.OK, MessageBoxIcon.Stop); } return; } @@ -349,8 +351,8 @@ namespace ASCOM.Meade.net // // HKCR\APPID\exename.ext // - using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(string.Format("APPID\\{0}", - Application.ExecutablePath.Substring(Application.ExecutablePath.LastIndexOf('\\') + 1)))) + using (RegistryKey key = Registry.ClassesRoot.CreateSubKey( + $"APPID\\{Application.ExecutablePath.Substring(Application.ExecutablePath.LastIndexOf('\\') + 1)}")) { key.SetValue("AppID", _sAppId); } @@ -358,7 +360,7 @@ namespace ASCOM.Meade.net catch (Exception ex) { MessageBox.Show($"Error while registering the server:\n{ex}", - DRIVER_NAME, MessageBoxButtons.OK, MessageBoxIcon.Stop); + DriverName, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } finally @@ -381,7 +383,7 @@ namespace ASCOM.Meade.net //PWGS Generate device type from the Class name string deviceType = type.Name; - using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(string.Format("CLSID\\{0}", clsid))) + using (RegistryKey key = Registry.ClassesRoot.CreateSubKey($"CLSID\\{clsid}")) { key.SetValue(null, progid); // Could be assyTitle/Desc??, but .NET components show ProgId here key.SetValue("AppId", _sAppId); @@ -427,7 +429,7 @@ namespace ASCOM.Meade.net catch (Exception ex) { MessageBox.Show("Error while registering the server:\n" + ex.ToString(), - DRIVER_NAME, MessageBoxButtons.OK, MessageBoxIcon.Stop); + DriverName, MessageBoxButtons.OK, MessageBoxIcon.Stop); bFail = true; } finally @@ -454,9 +456,9 @@ namespace ASCOM.Meade.net // // Local server's DCOM/AppID information // - Registry.ClassesRoot.DeleteSubKey(string.Format("APPID\\{0}", _sAppId), false); - Registry.ClassesRoot.DeleteSubKey(string.Format("APPID\\{0}", - Application.ExecutablePath.Substring(Application.ExecutablePath.LastIndexOf('\\') + 1)), false); + Registry.ClassesRoot.DeleteSubKey($"APPID\\{_sAppId}", false); + Registry.ClassesRoot.DeleteSubKey( + $"APPID\\{Application.ExecutablePath.Substring(Application.ExecutablePath.LastIndexOf('\\') + 1)}", false); // // For each of the driver assemblies @@ -472,17 +474,17 @@ namespace ASCOM.Meade.net // // HKCR\progid // - Registry.ClassesRoot.DeleteSubKey(String.Format("{0}\\CLSID", progid), false); + Registry.ClassesRoot.DeleteSubKey($"{progid}\\CLSID", false); Registry.ClassesRoot.DeleteSubKey(progid, false); // // HKCR\CLSID\clsid // - Registry.ClassesRoot.DeleteSubKey(String.Format("CLSID\\{0}\\Implemented Categories\\{{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}}", clsid), false); - Registry.ClassesRoot.DeleteSubKey(String.Format("CLSID\\{0}\\Implemented Categories", clsid), false); - Registry.ClassesRoot.DeleteSubKey(String.Format("CLSID\\{0}\\ProgId", clsid), false); - Registry.ClassesRoot.DeleteSubKey(String.Format("CLSID\\{0}\\LocalServer32", clsid), false); - Registry.ClassesRoot.DeleteSubKey(String.Format("CLSID\\{0}\\Programmable", clsid), false); - Registry.ClassesRoot.DeleteSubKey(String.Format("CLSID\\{0}", clsid), false); + Registry.ClassesRoot.DeleteSubKey($"CLSID\\{clsid}\\Implemented Categories\\{{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}}", false); + Registry.ClassesRoot.DeleteSubKey($"CLSID\\{clsid}\\Implemented Categories", false); + Registry.ClassesRoot.DeleteSubKey($"CLSID\\{clsid}\\ProgId", false); + Registry.ClassesRoot.DeleteSubKey($"CLSID\\{clsid}\\LocalServer32", false); + Registry.ClassesRoot.DeleteSubKey($"CLSID\\{clsid}\\Programmable", false); + Registry.ClassesRoot.DeleteSubKey($"CLSID\\{clsid}", false); try { // @@ -494,7 +496,10 @@ namespace ASCOM.Meade.net p.Unregister(progid); } } - catch (Exception) { } + catch (Exception) + { + // ignored + } } } #endregion @@ -515,7 +520,7 @@ namespace ASCOM.Meade.net if (!factory.RegisterClassObject()) { MessageBox.Show("Failed to register class factory for " + type.Name, - DRIVER_NAME, MessageBoxButtons.OK, MessageBoxIcon.Stop); + DriverName, MessageBoxButtons.OK, MessageBoxIcon.Stop); return false; } } @@ -571,7 +576,7 @@ namespace ASCOM.Meade.net default: MessageBox.Show("Unknown argument: " + args[0] + "\nValid are : -register, -unregister and -embedding", - DRIVER_NAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + DriverName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); break; } } @@ -610,9 +615,11 @@ namespace ASCOM.Meade.net RegisterClassFactories(); // Start up the garbage collection thread. - GarbageCollection garbageCollector = new GarbageCollection(1000); - Thread gcThread = new Thread(new ThreadStart(garbageCollector.GcWatch)); - gcThread.Name = "Garbage Collection Thread"; + var garbageCollector = new GarbageCollection(1000); + var gcThread = new Thread(garbageCollector.GcWatch) + { + Name = "Garbage Collection Thread" + }; gcThread.Start(); // diff --git a/Meade.net/SetupDialogForm.cs b/Meade.net/SetupDialogForm.cs index 6815a09..b58a0f3 100644 --- a/Meade.net/SetupDialogForm.cs +++ b/Meade.net/SetupDialogForm.cs @@ -1,5 +1,6 @@ using System; using System.ComponentModel; +using System.Globalization; using System.Runtime.InteropServices; using System.Windows.Forms; @@ -52,7 +53,7 @@ namespace ASCOM.Meade.net comboBoxComPort.SelectedItem = profileProperties.ComPort; } - txtGuideRate.Text = profileProperties.GuideRateArcSecondsPerSecond.ToString(); + txtGuideRate.Text = profileProperties.GuideRateArcSecondsPerSecond.ToString(CultureInfo.CurrentCulture); try { cboPrecision.SelectedItem = profileProperties.Precision; @@ -86,7 +87,6 @@ namespace ASCOM.Meade.net private void TextBox1_TextChanged(object sender, EventArgs e) { - //const double SIDRATE = 0.9972695677; //synodic/solar seconds per sidereal second try { double newGuideRate = double.Parse(txtGuideRate.Text.Trim()); @@ -103,17 +103,17 @@ namespace ASCOM.Meade.net _guideRateValid = false; } - UpdateOKButton(); + UpdateOkButton(); } - private void UpdateOKButton() + private void UpdateOkButton() { cmdOK.Enabled = _guideRateValid && (comboBoxComPort.SelectedItem != null); } private void ComboBoxComPort_SelectedValueChanged(object sender, EventArgs e) { - UpdateOKButton(); + UpdateOkButton(); } public void SetReadOnlyMode() diff --git a/Meade.net/SharedResources.cs b/Meade.net/SharedResources.cs index 8ed30b9..79eec62 100644 --- a/Meade.net/SharedResources.cs +++ b/Meade.net/SharedResources.cs @@ -15,6 +15,7 @@ // using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using ASCOM.Utilities; @@ -64,7 +65,7 @@ namespace ASCOM.Meade.net /// /// number of connections to the shared serial port /// - public static int Connections { get; set; } = 0; + public static int Connections { get; set; } public static void SendBlind(string message) { @@ -179,7 +180,7 @@ namespace ASCOM.Meade.net driverProfile.DeviceType = "Telescope"; driverProfile.WriteValue(DriverId, TraceStateProfileName, profileProperties.TraceLogger.ToString()); driverProfile.WriteValue(DriverId, ComPortProfileName, profileProperties.ComPort); - driverProfile.WriteValue(DriverId, GuideRateProfileName, profileProperties.GuideRateArcSecondsPerSecond.ToString()); + driverProfile.WriteValue(DriverId, GuideRateProfileName, profileProperties.GuideRateArcSecondsPerSecond.ToString(CultureInfo.CurrentCulture)); driverProfile.WriteValue(DriverId, PrecisionProfileName, profileProperties.Precision); } } @@ -264,9 +265,9 @@ namespace ASCOM.Meade.net /// The Key is the connection number that identifies the device, it could be the COM port name, /// USB ID or IP Address, the Value is the DeviceHardware class /// - private static readonly Dictionary _connectedDevices = new Dictionary(); + private static readonly Dictionary ConnectedDevices = new Dictionary(); - private static readonly Dictionary _connectedDeviceIds = new Dictionary(); + private static readonly Dictionary ConnectedDeviceIds = new Dictionary(); /// @@ -278,17 +279,17 @@ namespace ASCOM.Meade.net { lock (LockObject) { - if (!_connectedDevices.ContainsKey(deviceId)) - _connectedDevices.Add(deviceId, new DeviceHardware()); - _connectedDevices[deviceId].Count++; // increment the value + if (!ConnectedDevices.ContainsKey(deviceId)) + ConnectedDevices.Add(deviceId, new DeviceHardware()); + ConnectedDevices[deviceId].Count++; // increment the value - if (!_connectedDeviceIds.ContainsKey(driverId)) - _connectedDeviceIds.Add(driverId, new DeviceHardware()); - _connectedDeviceIds[driverId].Count++; // increment the value + if (!ConnectedDeviceIds.ContainsKey(driverId)) + ConnectedDeviceIds.Add(driverId, new DeviceHardware()); + ConnectedDeviceIds[driverId].Count++; // increment the value if (deviceId == "Serial") { - if (_connectedDevices[deviceId].Count == 1) + if (ConnectedDevices[deviceId].Count == 1) { var profileProperties = ReadProfile(); SharedSerial.PortName = profileProperties.ComPort; @@ -308,8 +309,8 @@ namespace ASCOM.Meade.net return new ConnectionInfo { - Connections = _connectedDevices[deviceId].Count, - SameDevice = _connectedDeviceIds[driverId].Count + Connections = ConnectedDevices[deviceId].Count, + SameDevice = ConnectedDeviceIds[driverId].Count }; } } @@ -318,12 +319,12 @@ namespace ASCOM.Meade.net { lock (LockObject) { - if (_connectedDevices.ContainsKey(deviceId)) + if (ConnectedDevices.ContainsKey(deviceId)) { - _connectedDevices[deviceId].Count--; - if (_connectedDevices[deviceId].Count <= 0) + ConnectedDevices[deviceId].Count--; + if (ConnectedDevices[deviceId].Count <= 0) { - _connectedDevices.Remove(deviceId); + ConnectedDevices.Remove(deviceId); if (deviceId == "Serial") { SharedSerial.Connected = false; @@ -331,16 +332,16 @@ namespace ASCOM.Meade.net } } - if (_connectedDeviceIds.ContainsKey(driverId)) + if (ConnectedDeviceIds.ContainsKey(driverId)) { - _connectedDeviceIds[driverId].Count--; + ConnectedDeviceIds[driverId].Count--; } } } public static bool IsConnected() { - foreach (var device in _connectedDevices) + foreach (var device in ConnectedDevices) { if (device.Value.Count > 0) return true; @@ -351,8 +352,8 @@ namespace ASCOM.Meade.net public static bool IsConnected(string deviceId) { - if (_connectedDevices.ContainsKey(deviceId)) - return (_connectedDevices[deviceId].Count > 0); + if (ConnectedDevices.ContainsKey(deviceId)) + return (ConnectedDevices[deviceId].Count > 0); else return false; } @@ -381,13 +382,7 @@ namespace ASCOM.Meade.net /// public class DeviceHardware { - private int _count; - - internal int Count - { - set => _count = value; - get => _count; - } + internal int Count { set; get; } internal DeviceHardware() { diff --git a/Meade.net/TelescopeList.cs b/Meade.net/TelescopeList.cs index 7569e7a..feecf91 100644 --- a/Meade.net/TelescopeList.cs +++ b/Meade.net/TelescopeList.cs @@ -10,20 +10,20 @@ namespace ASCOM.Meade.net { #region Autostar 497/Audiostar - public readonly static string Autostar497 = "Autostar"; + public static readonly string Autostar497 = "Autostar"; //Autostar/Audiostar firmware revisions - public readonly static string Autostar497_30Ee = "30Ee"; - public readonly static string Autostar497_31Ee = "31Ee"; - public readonly static string Autostar497_43Eg = "43Eg"; + public static readonly string Autostar497_30Ee = "30Ee"; + public static readonly string Autostar497_31Ee = "31Ee"; + public static readonly string Autostar497_43Eg = "43Eg"; #endregion #region LX200GPS - public readonly static string LX200GPS = "LX2001"; + public static readonly string LX200GPS = "LX2001"; - public readonly static string LX200GPS_42G = "4.2G"; + public static readonly string LX200GPS_42G = "4.2G"; #endregion } diff --git a/Meade.net/Win32Utilities.cs b/Meade.net/Win32Utilities.cs index 2be80b3..959528a 100644 --- a/Meade.net/Win32Utilities.cs +++ b/Meade.net/Win32Utilities.cs @@ -77,11 +77,11 @@ namespace ASCOM.Meade.net // Published in The Delphi Magazine 55, page 16 // Converted to C# by Kevin Gale IntPtr foregroundWindow = GetForegroundWindow(); - IntPtr Dummy = IntPtr.Zero; + IntPtr dummy = IntPtr.Zero; - uint foregroundThreadId = GetWindowThreadProcessId(foregroundWindow, Dummy); + uint foregroundThreadId = GetWindowThreadProcessId(foregroundWindow, dummy); - uint thisThreadId = GetWindowThreadProcessId(hWnd, Dummy); + uint thisThreadId = GetWindowThreadProcessId(hWnd, dummy); if (AttachThreadInput(thisThreadId, foregroundThreadId, true)) { @@ -94,12 +94,12 @@ namespace ASCOM.Meade.net { // Code by Daniel P. Stasinski // Converted to C# by Kevin Gale - IntPtr Timeout = IntPtr.Zero; - SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, Timeout, 0); - SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, Dummy, SPIF_SENDCHANGE); + IntPtr timeout = IntPtr.Zero; + SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, timeout, 0); + SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, dummy, SPIF_SENDCHANGE); BringWindowToTop(hWnd); // IE 5.5 related hack SetForegroundWindow(hWnd); - SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, Timeout, SPIF_SENDCHANGE); + SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, timeout, SPIF_SENDCHANGE); } } } diff --git a/Meade.net/frmMain.cs b/Meade.net/frmMain.cs index 2ae5c27..046e739 100644 --- a/Meade.net/frmMain.cs +++ b/Meade.net/frmMain.cs @@ -4,8 +4,6 @@ namespace ASCOM.Meade.net { public partial class FrmMain : Form { - delegate void SetTextCallback(string text); - public FrmMain() { InitializeComponent(); From ca982edbf8b47548da88091ffea1c90995f58331 Mon Sep 17 00:00:00 2001 From: Colin Date: Sat, 28 Sep 2019 22:40:09 +0100 Subject: [PATCH 02/27] Code inspections --- Meade.net.Telescope/Telescope.cs | 6 +++ Meade.net/AssemblyInfo.cs | 71 +++++++++++++++----------------- 2 files changed, 40 insertions(+), 37 deletions(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index f86cb37..2334243 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -1096,6 +1096,7 @@ namespace ASCOM.Meade.net LogMessage("DeclinationRate", "Get - " + declination.ToString(CultureInfo.InvariantCulture)); return declination; } + // ReSharper disable once ValueParameterNotUsed set { LogMessage("DeclinationRate Set", "Not implemented"); @@ -1116,6 +1117,7 @@ namespace ASCOM.Meade.net LogMessage("DoesRefraction Get", "Not implemented"); throw new PropertyNotImplementedException("DoesRefraction", false); } + // ReSharper disable once ValueParameterNotUsed set { LogMessage("DoesRefraction Set", "Not implemented"); @@ -1435,6 +1437,7 @@ namespace ASCOM.Meade.net LogMessage("RightAscensionRate", "Get - " + rightAscensionRate.ToString(CultureInfo.InvariantCulture)); return rightAscensionRate; } + // ReSharper disable once ValueParameterNotUsed set { LogMessage("RightAscensionRate Set", "Not implemented"); @@ -1455,6 +1458,7 @@ namespace ASCOM.Meade.net LogMessage("SideOfPier Get", "Not implemented"); throw new PropertyNotImplementedException("SideOfPier", false); } + // ReSharper disable once ValueParameterNotUsed set { LogMessage("SideOfPier Set", "Not implemented"); @@ -1495,6 +1499,7 @@ namespace ASCOM.Meade.net LogMessage("SiteElevation Get", "Not implemented"); throw new PropertyNotImplementedException("SiteElevation", false); } + // ReSharper disable once ValueParameterNotUsed set { LogMessage("SiteElevation Set", "Not implemented"); @@ -1609,6 +1614,7 @@ namespace ASCOM.Meade.net LogMessage("SlewSettleTime Get", "Not implemented"); throw new PropertyNotImplementedException("SlewSettleTime", false); } + // ReSharper disable once ValueParameterNotUsed set { LogMessage("SlewSettleTime Set", "Not implemented"); diff --git a/Meade.net/AssemblyInfo.cs b/Meade.net/AssemblyInfo.cs index a10829d..904e4e3 100644 --- a/Meade.net/AssemblyInfo.cs +++ b/Meade.net/AssemblyInfo.cs @@ -8,10 +8,10 @@ namespace ASCOM.Meade.net public class AssemblyInfo { // The assembly information values. - public string Title = "", Description = "", Company = "", - Product = "", Copyright = "", Trademark = "", - AssemblyVersion = "", FileVersion = "", Guid = "", - NeutralLanguage = ""; + public string Title = string.Empty, Description = string.Empty, Company = string.Empty, + Product = string.Empty, Copyright = string.Empty, Trademark = string.Empty, + AssemblyVersion, FileVersion = string.Empty, Guid = string.Empty, + NeutralLanguage = string.Empty; public bool IsComVisible; // Return a particular assembly attribute value. @@ -19,11 +19,10 @@ namespace ASCOM.Meade.net where T : Attribute { // Get attributes of this type. - object[] attributes = - assembly.GetCustomAttributes(typeof(T), true); + object[] attributes = assembly.GetCustomAttributes(typeof(T), true); // If we didn't get anything, return null. - if ((attributes == null) || (attributes.Length == 0)) + if (attributes.Length == 0) return null; // Convert the first attribute value into @@ -40,51 +39,49 @@ namespace ASCOM.Meade.net public AssemblyInfo(Assembly assembly) { // Get values from the assembly. - AssemblyTitleAttribute titleAttr = - GetAssemblyAttribute(assembly); - if (titleAttr != null) Title = titleAttr.Title; + var titleAttr = GetAssemblyAttribute(assembly); + if (titleAttr != null) + Title = titleAttr.Title; - AssemblyDescriptionAttribute assemblyAttr = - GetAssemblyAttribute(assembly); - if (assemblyAttr != null) Description = - assemblyAttr.Description; + var assemblyAttr = GetAssemblyAttribute(assembly); + if (assemblyAttr != null) + Description = assemblyAttr.Description; - AssemblyCompanyAttribute companyAttr = - GetAssemblyAttribute(assembly); - if (companyAttr != null) Company = companyAttr.Company; + var companyAttr =GetAssemblyAttribute(assembly); + if (companyAttr != null) + Company = companyAttr.Company; - AssemblyProductAttribute productAttr = - GetAssemblyAttribute(assembly); - if (productAttr != null) Product = productAttr.Product; + var productAttr = GetAssemblyAttribute(assembly); + if (productAttr != null) + Product = productAttr.Product; - AssemblyCopyrightAttribute copyrightAttr = - GetAssemblyAttribute(assembly); - if (copyrightAttr != null) Copyright = copyrightAttr.Copyright; + var copyrightAttr = GetAssemblyAttribute(assembly); + if (copyrightAttr != null) + Copyright = copyrightAttr.Copyright; - AssemblyTrademarkAttribute trademarkAttr = - GetAssemblyAttribute(assembly); - if (trademarkAttr != null) Trademark = trademarkAttr.Trademark; + var trademarkAttr = GetAssemblyAttribute(assembly); + if (trademarkAttr != null) + Trademark = trademarkAttr.Trademark; var version = assembly.GetName().Version; AssemblyVersion = $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}"; - AssemblyFileVersionAttribute fileVersionAttr = - GetAssemblyAttribute(assembly); + var fileVersionAttr = GetAssemblyAttribute(assembly); if (fileVersionAttr != null) FileVersion = fileVersionAttr.Version; - GuidAttribute guidAttr = GetAssemblyAttribute(assembly); - if (guidAttr != null) Guid = guidAttr.Value; + var guidAttr = GetAssemblyAttribute(assembly); + if (guidAttr != null) + Guid = guidAttr.Value; - NeutralResourcesLanguageAttribute languageAttr = - GetAssemblyAttribute(assembly); - if (languageAttr != null) NeutralLanguage = - languageAttr.CultureName; + var languageAttr = GetAssemblyAttribute(assembly); + if (languageAttr != null) + NeutralLanguage = languageAttr.CultureName; - ComVisibleAttribute comAttr = - GetAssemblyAttribute(assembly); - if (comAttr != null) IsComVisible = comAttr.Value; + var comAttr = GetAssemblyAttribute(assembly); + if (comAttr != null) + IsComVisible = comAttr.Value; } } } From 101784adb3731d6dd6ca25c4752429c16ef62d2d Mon Sep 17 00:00:00 2001 From: Colin Date: Sat, 28 Sep 2019 22:45:34 +0100 Subject: [PATCH 03/27] Code inspections --- .../TelescopeUnitTests.cs | 125 +++++++++++++++--- Meade.net.Telescope/Rates.cs | 2 +- 2 files changed, 105 insertions(+), 22 deletions(-) diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index 416d6ac..4fa7bfd 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -105,7 +105,10 @@ namespace Meade.net.Telescope.UnitTests [Test] public void Action_WhenNotConnected_ThrowsNotConnectedException() { - var exception = Assert.Throws(() => { var actualResult = _telescope.Action(string.Empty, string.Empty); }); + var exception = Assert.Throws(() => + { + _telescope.Action(string.Empty, string.Empty); + }); Assert.That(exception.Message,Is.EqualTo("Not connected to telescope when trying to execute: Action")); } @@ -552,7 +555,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void AlignmentMode_Get_WhenNotConnected_ThrowsException() { - var exception = Assert.Throws(() => { var actualResult = _telescope.AlignmentMode; }); + var exception = Assert.Throws(() => + { + var actualResult = _telescope.AlignmentMode; + Assert.Fail($"{actualResult} should not have returned"); + }); Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: AlignmentMode Get")); } @@ -577,7 +584,11 @@ namespace Meade.net.Telescope.UnitTests { ConnectTelescope(); - Assert.Throws(() => { var actualResult = _telescope.AlignmentMode; }); + Assert.Throws(() => + { + var actualResult = _telescope.AlignmentMode; + Assert.Fail($"{actualResult} should not have returned"); + }); } [Test] @@ -617,7 +628,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void ApertureArea_Get_ThrowsNotImplementedException() { - var excpetion = Assert.Throws(() => { var result = _telescope.ApertureArea; }); + var excpetion = Assert.Throws(() => + { + var result = _telescope.ApertureArea; + Assert.Fail($"{result} should not have returned"); + }); Assert.That(excpetion.Property, Is.EqualTo("ApertureArea")); Assert.That(excpetion.AccessorSet, Is.False); @@ -626,7 +641,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void ApertureDiameter_Get_ThrowsNotImplementedException() { - var excpetion = Assert.Throws(() => { var result = _telescope.ApertureDiameter; }); + var excpetion = Assert.Throws(() => + { + var result = _telescope.ApertureDiameter; + Assert.Fail($"{result} should not have returned"); + }); Assert.That(excpetion.Property, Is.EqualTo("ApertureDiameter")); Assert.That(excpetion.AccessorSet, Is.False); @@ -714,7 +733,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void CanSetGuideRates_Get_WhenNotConnected_ThenThrowsException() { - var exception = Assert.Throws(() => { var result = _telescope.CanSetGuideRates; }); + var exception = Assert.Throws(() => + { + var result = _telescope.CanSetGuideRates; + Assert.Fail($"{result} should not have returned"); + }); Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: CanSetGuideRates Get")); } @@ -883,7 +906,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void Declination_Get_WhenNotConnected_ThenThrowsException() { - var exception = Assert.Throws(() => { var actualResult = _telescope.Declination; }); + var exception = Assert.Throws(() => + { + var actualResult = _telescope.Declination; + Assert.Fail($"{actualResult} should not have returned"); + }); Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: Declination Get")); } @@ -921,7 +948,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void DestinationSideOfPier_ThenThrowsException() { - var excpetion = Assert.Throws(() => { var result = _telescope.DestinationSideOfPier(0,0); }); + var excpetion = Assert.Throws(() => + { + var result = _telescope.DestinationSideOfPier(0,0); + Assert.Fail($"{result} should not have returned"); + }); Assert.That(excpetion.Method, Is.EqualTo("DestinationSideOfPier")); } @@ -929,7 +960,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void DoesRefraction_Get_ThenThrowsException() { - var excpetion = Assert.Throws(() => { var result = _telescope.DoesRefraction; }); + var excpetion = Assert.Throws(() => + { + var result = _telescope.DoesRefraction; + Assert.Fail($"{result} should not have returned"); + }); Assert.That(excpetion.Property, Is.EqualTo("DoesRefraction")); Assert.That(excpetion.AccessorSet, Is.False); @@ -963,7 +998,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void FocalLength_Get_ThenThrowsException() { - var excpetion = Assert.Throws(() => { var result = _telescope.FocalLength; }); + var excpetion = Assert.Throws(() => + { + var result = _telescope.FocalLength; + Assert.Fail($"{result} should not have returned"); + }); Assert.That(excpetion.Property, Is.EqualTo("FocalLength")); Assert.That(excpetion.AccessorSet, Is.False); @@ -1300,7 +1339,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void RightAscension_Get_WhenNotConnected_ThenThrowsException() { - var exception = Assert.Throws(() => { var result = _telescope.RightAscension; }); + var exception = Assert.Throws(() => + { + var result = _telescope.RightAscension; + Assert.Fail($"{result} should not have returned"); + }); Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: RightAscension Get")); } @@ -1351,7 +1394,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void SideOfPier_Get_ThenThrowsException() { - var excpetion = Assert.Throws(() => { var result = _telescope.SideOfPier; }); + var excpetion = Assert.Throws(() => + { + var result = _telescope.SideOfPier; + Assert.Fail($"{result} should not have returned"); + }); Assert.That(excpetion.Property, Is.EqualTo("SideOfPier")); Assert.That(excpetion.AccessorSet, Is.False); @@ -1369,7 +1416,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void SiteElevation_Get_ThenThrowsException() { - var excpetion = Assert.Throws(() => { var result = _telescope.SiteElevation; }); + var excpetion = Assert.Throws(() => + { + var result = _telescope.SiteElevation; + Assert.Fail($"{result} should not have returned"); + }); Assert.That(excpetion.Property, Is.EqualTo("SiteElevation")); Assert.That(excpetion.AccessorSet, Is.False); @@ -1387,7 +1438,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void SlewSettleTime_Get_ThenThrowsException() { - var excpetion = Assert.Throws(() => { var result = _telescope.SlewSettleTime; }); + var excpetion = Assert.Throws(() => + { + var result = _telescope.SlewSettleTime; + Assert.Fail($"{result} should not have returned"); + }); Assert.That(excpetion.Property, Is.EqualTo("SlewSettleTime")); Assert.That(excpetion.AccessorSet, Is.False); @@ -1413,7 +1468,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void SiteLatitude_Get_WhenNotConnected_ThenThrowsException() { - var exception = Assert.Throws(() => { var result = _telescope.SiteLatitude; }); + var exception = Assert.Throws(() => + { + var result = _telescope.SiteLatitude; + Assert.Fail($"{result} should not have returned"); + }); Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: SiteLatitude Get")); } @@ -1488,7 +1547,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void SiteLongitude_Get_WhenNotConnected_ThenThrowsException() { - var exception = Assert.Throws(() => { var result = _telescope.SiteLongitude; }); + var exception = Assert.Throws(() => + { + var result = _telescope.SiteLongitude; + Assert.Fail($"{result} should not have returned"); + }); Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: SiteLongitude Get")); } @@ -1659,7 +1722,11 @@ namespace Meade.net.Telescope.UnitTests { ConnectTelescope(); - var exception = Assert.Throws(() => { var result = _telescope.TargetDeclination; }); + var exception = Assert.Throws(() => + { + var result = _telescope.TargetDeclination; + Assert.Fail($"{result} should not have returned"); + }); Assert.That(exception.Message, Is.EqualTo("Target not set")); } @@ -1733,7 +1800,11 @@ namespace Meade.net.Telescope.UnitTests { ConnectTelescope(); - var exception = Assert.Throws(() => { var result = _telescope.TargetRightAscension; }); + var exception = Assert.Throws(() => + { + var result = _telescope.TargetRightAscension; + Assert.Fail($"{result} should not have returned"); + }); Assert.That(exception.Message, Is.EqualTo("Target not set")); } @@ -1830,7 +1901,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void UTCDate_Get_WhenNotConnected_ThenThrowsException() { - var exception = Assert.Throws(() => { var result = _telescope.UTCDate; }); + var exception = Assert.Throws(() => + { + var result = _telescope.UTCDate; + Assert.Fail($"{result} should not have returned"); + }); Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: UTCDate Get")); } @@ -2315,7 +2390,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void Azimuth_WhenNotConnected_ThenThrowsException() { - var exception = Assert.Throws(() => { var result = _telescope.Azimuth; }); + var exception = Assert.Throws(() => + { + var result = _telescope.Azimuth; + Assert.Fail($"{result} should not have returned"); + }); Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: Azimuth Get")); } @@ -2356,7 +2435,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void Altitude_WhenNotConnected_ThenThrowsException() { - var exception = Assert.Throws(() => { var result = _telescope.Altitude; }); + var exception = Assert.Throws(() => + { + var result = _telescope.Altitude; + Assert.Fail($"{result} should not have returned"); + }); Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: Altitude Get")); } diff --git a/Meade.net.Telescope/Rates.cs b/Meade.net.Telescope/Rates.cs index d9fcefa..c656683 100644 --- a/Meade.net.Telescope/Rates.cs +++ b/Meade.net.Telescope/Rates.cs @@ -170,7 +170,7 @@ namespace ASCOM.Meade.net _pos.Value = -1; } - return this as IEnumerator; + return this; } public void Dispose() From 69fbb144104f5d57a78717c1aa467fd47004bca7 Mon Sep 17 00:00:00 2001 From: Colin Date: Sat, 28 Sep 2019 22:52:30 +0100 Subject: [PATCH 04/27] Code inspections --- Meade.net.Telescope/AstroMaths/AstroMaths.cs | 2 +- Meade.net.Telescope/Telescope.cs | 2 +- Meade.net/ClassFactory.cs | 8 ++++---- Meade.net/SetupDialogForm.cs | 2 +- Meade.net/SharedResources.cs | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Meade.net.Telescope/AstroMaths/AstroMaths.cs b/Meade.net.Telescope/AstroMaths/AstroMaths.cs index beeb403..9ae12d9 100644 --- a/Meade.net.Telescope/AstroMaths/AstroMaths.cs +++ b/Meade.net.Telescope/AstroMaths/AstroMaths.cs @@ -107,7 +107,7 @@ namespace ASCOM.Meade.net.AstroMaths public double RadiansToDegrees(double radians) { double degrees = (180 / Math.PI) * radians; - return (degrees); + return degrees; } //todo convert to extension method diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 2334243..0ebbd3f 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -466,7 +466,7 @@ namespace ASCOM.Meade.net { var currentVersion = _sharedResourcesWrapper.FirmwareVersion; var comparison = String.Compare(currentVersion, minVersion, StringComparison.Ordinal); - return (comparison >= 0); + return comparison >= 0; } public void SetLongFormat(bool setLongFormat) diff --git a/Meade.net/ClassFactory.cs b/Meade.net/ClassFactory.cs index caa2b43..a02a47a 100644 --- a/Meade.net/ClassFactory.cs +++ b/Meade.net/ClassFactory.cs @@ -156,25 +156,25 @@ namespace ASCOM.Meade.net Flags, out _mCookie ); - return (i == 0); + return i == 0; } public bool RevokeClassObject() { int i = CoRevokeClassObject(_mCookie); - return (i == 0); + return i == 0; } public static bool ResumeClassObjects() { int i = CoResumeClassObjects(); - return (i == 0); + return i == 0; } public static bool SuspendClassObjects() { int i = CoSuspendClassObjects(); - return (i == 0); + return i == 0; } #endregion diff --git a/Meade.net/SetupDialogForm.cs b/Meade.net/SetupDialogForm.cs index b58a0f3..290485d 100644 --- a/Meade.net/SetupDialogForm.cs +++ b/Meade.net/SetupDialogForm.cs @@ -92,7 +92,7 @@ namespace ASCOM.Meade.net double newGuideRate = double.Parse(txtGuideRate.Text.Trim()); const double siderealArcSecondsPerSecond = 15.041; - var percentOfSideReal = (newGuideRate / siderealArcSecondsPerSecond * 100); + var percentOfSideReal = newGuideRate / siderealArcSecondsPerSecond * 100; lblPercentOfSiderealRate.Text = $"({percentOfSideReal:00.0}% of sidereal rate)"; _guideRateValid = true; diff --git a/Meade.net/SharedResources.cs b/Meade.net/SharedResources.cs index 79eec62..c01a512 100644 --- a/Meade.net/SharedResources.cs +++ b/Meade.net/SharedResources.cs @@ -353,7 +353,7 @@ namespace ASCOM.Meade.net public static bool IsConnected(string deviceId) { if (ConnectedDevices.ContainsKey(deviceId)) - return (ConnectedDevices[deviceId].Count > 0); + return ConnectedDevices[deviceId].Count > 0; else return false; } From 0bbfa5f9c3b73913ca4400c3d4285187c0e96f64 Mon Sep 17 00:00:00 2001 From: Colin Date: Sat, 28 Sep 2019 23:04:55 +0100 Subject: [PATCH 05/27] Code inspections --- .../FocuserUnitTests.cs | 30 +++++++++++--- Meade.net/LocalServer.cs | 7 +--- Meade.net/Win32Utilities.cs | 41 +++++++++++++++++++ 3 files changed, 67 insertions(+), 11 deletions(-) diff --git a/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs b/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs index 58bf548..66c5621 100644 --- a/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs +++ b/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs @@ -86,7 +86,11 @@ namespace Meade.net.Focuser.UnitTests { var actionName = "Action"; - Assert.Throws(() => { var actualResult = _focuser.Action(actionName, string.Empty); }); + Assert.Throws(() => + { + var actualResult = _focuser.Action(actionName, string.Empty); + Assert.Fail($"{actualResult} should not have a value"); + }); } [Test] @@ -277,7 +281,11 @@ namespace Meade.net.Focuser.UnitTests [Test] public void Absolute_Get_WhenNotConnected_ThenThrowsException() { - var exception = Assert.Throws(() => { var result = _focuser.Absolute; }); + var exception = Assert.Throws(() => + { + var result = _focuser.Absolute; + Assert.Fail($"{result} should not have a value"); + }); Assert.That(exception.Message, Is.EqualTo("Not connected to focuser when trying to execute: Absolute Get")); } @@ -413,14 +421,22 @@ namespace Meade.net.Focuser.UnitTests [Test] public void Position_WhenCalled_ThenThrowsException() { - var exception = Assert.Throws(() => { var result = _focuser.Position; }); + var exception = Assert.Throws(() => + { + var result = _focuser.Position; + Assert.Fail($"{result} should not have a value"); + }); Assert.That(exception.Message, Is.EqualTo("Property read Position is not implemented in this driver.")); } [Test] public void StepSize_WhenCalled_ThenThrowsException() { - var exception = Assert.Throws(() => { var result = _focuser.StepSize; }); + var exception = Assert.Throws(() => + { + var result = _focuser.StepSize; + Assert.Fail($"{result} should not have a value"); + }); Assert.That(exception.Message, Is.EqualTo("Property read StepSize is not implemented in this driver.")); } @@ -448,7 +464,11 @@ namespace Meade.net.Focuser.UnitTests [Test] public void Temperature_WhenCalled_ThenThrowsException() { - var exception = Assert.Throws(() => { var result = _focuser.Temperature; }); + var exception = Assert.Throws(() => + { + var result = _focuser.Temperature; + Assert.Fail($"{result} should not have a value"); + }); Assert.That(exception.Message, Is.EqualTo("Property read Temperature is not implemented in this driver.")); } } diff --git a/Meade.net/LocalServer.cs b/Meade.net/LocalServer.cs index e321c59..8635814 100644 --- a/Meade.net/LocalServer.cs +++ b/Meade.net/LocalServer.cs @@ -363,9 +363,6 @@ namespace ASCOM.Meade.net DriverName, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } - finally - { - } // // For each of the driver assemblies @@ -432,9 +429,7 @@ namespace ASCOM.Meade.net DriverName, MessageBoxButtons.OK, MessageBoxIcon.Stop); bFail = true; } - finally - { - } + if (bFail) break; } } diff --git a/Meade.net/Win32Utilities.cs b/Meade.net/Win32Utilities.cs index 959528a..b5b5ffa 100644 --- a/Meade.net/Win32Utilities.cs +++ b/Meade.net/Win32Utilities.cs @@ -34,32 +34,73 @@ namespace ASCOM.Meade.net static extern bool BringWindowToTop(IntPtr hWnd); [DllImport("user32.dll")] + // ReSharper disable once UnusedMember.Local private static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, Int32 nMaxCount); [DllImport("user32.dll")] + // ReSharper disable once UnusedMember.Local private static extern int GetWindowThreadProcessId(IntPtr hWnd, ref Int32 lpdwProcessId); [DllImport("User32.dll")] public static extern IntPtr GetParent(IntPtr hWnd); + // ReSharper disable once InconsistentNaming + // ReSharper disable once UnusedMember.Local private const int SW_HIDE = 0; + // ReSharper disable once InconsistentNaming + // ReSharper disable once UnusedMember.Local + // ReSharper disable once IdentifierTypo private const int SW_SHOWNORMAL = 1; + // ReSharper disable once InconsistentNaming + // ReSharper disable once UnusedMember.Local private const int SW_NORMAL = 1; + // ReSharper disable once InconsistentNaming + // ReSharper disable once UnusedMember.Local + // ReSharper disable once IdentifierTypo private const int SW_SHOWMINIMIZED = 2; + // ReSharper disable once InconsistentNaming + // ReSharper disable once UnusedMember.Local + // ReSharper disable once IdentifierTypo private const int SW_SHOWMAXIMIZED = 3; + // ReSharper disable once InconsistentNaming + // ReSharper disable once UnusedMember.Local private const int SW_MAXIMIZE = 3; + // ReSharper disable once InconsistentNaming + // ReSharper disable once UnusedMember.Local + // ReSharper disable once IdentifierTypo private const int SW_SHOWNOACTIVATE = 4; + // ReSharper disable once InconsistentNaming private const int SW_SHOW = 5; + // ReSharper disable once InconsistentNaming + // ReSharper disable once UnusedMember.Local private const int SW_MINIMIZE = 6; + // ReSharper disable once InconsistentNaming + // ReSharper disable once UnusedMember.Local + // ReSharper disable once IdentifierTypo private const int SW_SHOWMINNOACTIVE = 7; + // ReSharper disable once InconsistentNaming + // ReSharper disable once UnusedMember.Local + // ReSharper disable once IdentifierTypo private const int SW_SHOWNA = 8; + // ReSharper disable once InconsistentNaming private const int SW_RESTORE = 9; + // ReSharper disable once InconsistentNaming + // ReSharper disable once UnusedMember.Local + // ReSharper disable once IdentifierTypo private const int SW_SHOWDEFAULT = 10; + // ReSharper disable once InconsistentNaming + // ReSharper disable once UnusedMember.Local private const int SW_MAX = 10; + // ReSharper disable once InconsistentNaming + // ReSharper disable once IdentifierTypo private const uint SPI_GETFOREGROUNDLOCKTIMEOUT = 0x2000; + // ReSharper disable once InconsistentNaming + // ReSharper disable once IdentifierTypo private const uint SPI_SETFOREGROUNDLOCKTIMEOUT = 0x2001; + // ReSharper disable once InconsistentNaming + // ReSharper disable once IdentifierTypo private const int SPIF_SENDCHANGE = 0x2; From b8faab13b3062cc858e727764c35108c8c2b848d Mon Sep 17 00:00:00 2001 From: Colin Date: Sat, 28 Sep 2019 23:10:37 +0100 Subject: [PATCH 06/27] Code inspections --- Meade.net.Telescope/Telescope.cs | 4 ++-- Meade.net/TelescopeList.cs | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 0ebbd3f..1cdae28 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -2329,7 +2329,7 @@ namespace ASCOM.Meade.net LogMessage("ReadProfile", $"Precision: {_precision}"); } - internal void WriteProfile() + private void WriteProfile() { var profileProperties = new ProfileProperties { @@ -2347,7 +2347,7 @@ namespace ASCOM.Meade.net /// /// /// - internal void LogMessage(string identifier, string message, params object[] args) + private void LogMessage(string identifier, string message, params object[] args) { var msg = string.Format(message, args); _tl.LogMessage(identifier, msg); diff --git a/Meade.net/TelescopeList.cs b/Meade.net/TelescopeList.cs index feecf91..26f9417 100644 --- a/Meade.net/TelescopeList.cs +++ b/Meade.net/TelescopeList.cs @@ -13,16 +13,21 @@ namespace ASCOM.Meade.net public static readonly string Autostar497 = "Autostar"; //Autostar/Audiostar firmware revisions + // ReSharper disable once InconsistentNaming public static readonly string Autostar497_30Ee = "30Ee"; + // ReSharper disable once InconsistentNaming public static readonly string Autostar497_31Ee = "31Ee"; + // ReSharper disable once InconsistentNaming public static readonly string Autostar497_43Eg = "43Eg"; #endregion #region LX200GPS + // ReSharper disable once InconsistentNaming public static readonly string LX200GPS = "LX2001"; + // ReSharper disable once InconsistentNaming public static readonly string LX200GPS_42G = "4.2G"; #endregion From 15bf977458649dc0e1233a0b82fe25221dad745f Mon Sep 17 00:00:00 2001 From: Colin Date: Sun, 29 Sep 2019 17:37:07 +0100 Subject: [PATCH 07/27] 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 { From 6394e08c4c0949adeef788dc7c9a9e67560bb177 Mon Sep 17 00:00:00 2001 From: Colin Date: Sun, 29 Sep 2019 17:49:21 +0100 Subject: [PATCH 08/27] Code inspections --- Meade.net/AssemblyInfo.cs | 14 ++++++++++---- Meade.net/SharedResources.cs | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Meade.net/AssemblyInfo.cs b/Meade.net/AssemblyInfo.cs index 904e4e3..cfb8bda 100644 --- a/Meade.net/AssemblyInfo.cs +++ b/Meade.net/AssemblyInfo.cs @@ -8,10 +8,16 @@ namespace ASCOM.Meade.net public class AssemblyInfo { // The assembly information values. - public string Title = string.Empty, Description = string.Empty, Company = string.Empty, - Product = string.Empty, Copyright = string.Empty, Trademark = string.Empty, - AssemblyVersion, FileVersion = string.Empty, Guid = string.Empty, - NeutralLanguage = string.Empty; + public string Title = string.Empty; + public string Description = string.Empty; + public string Company = string.Empty; + public string Product = string.Empty; + public string Copyright = string.Empty; + public string Trademark = string.Empty; + public string AssemblyVersion; + public string FileVersion = string.Empty; + public string Guid = string.Empty; + public string NeutralLanguage = string.Empty; public bool IsComVisible; // Return a particular assembly attribute value. diff --git a/Meade.net/SharedResources.cs b/Meade.net/SharedResources.cs index 248e333..077d431 100644 --- a/Meade.net/SharedResources.cs +++ b/Meade.net/SharedResources.cs @@ -274,6 +274,7 @@ namespace ASCOM.Meade.net /// it add the device id to the list of devices if it's not there and increments the device count. /// /// + /// public static ConnectionInfo Connect(string deviceId, string driverId) { lock (LockObject) From 013c2fd672458591c1922e4be9cebd63b22e90fd Mon Sep 17 00:00:00 2001 From: Colin Date: Sun, 29 Sep 2019 18:00:38 +0100 Subject: [PATCH 09/27] Removed unneeded html files, which contain lots of code inspection issues --- .../Meade.net.Telescope.csproj | 1 - Meade.net.Telescope/ReadMe.htm | 147 ---- Meade.net.focuser/Meade.net.focuser.csproj | 1 - Meade.net.focuser/ReadMe.htm | 147 ---- Meade.net/Meade.net.csproj | 1 - Meade.net/ReadMe.htm | 666 ------------------ 6 files changed, 963 deletions(-) delete mode 100644 Meade.net.Telescope/ReadMe.htm delete mode 100644 Meade.net.focuser/ReadMe.htm delete mode 100644 Meade.net/ReadMe.htm diff --git a/Meade.net.Telescope/Meade.net.Telescope.csproj b/Meade.net.Telescope/Meade.net.Telescope.csproj index 37a57ba..4d1c796 100644 --- a/Meade.net.Telescope/Meade.net.Telescope.csproj +++ b/Meade.net.Telescope/Meade.net.Telescope.csproj @@ -152,7 +152,6 @@ Settings.Designer.cs - diff --git a/Meade.net.Telescope/ReadMe.htm b/Meade.net.Telescope/ReadMe.htm deleted file mode 100644 index df43505..0000000 --- a/Meade.net.Telescope/ReadMe.htm +++ /dev/null @@ -1,147 +0,0 @@ - - - - - Untitled Document - - - - - - - - - - - -
-

ASCOM Telescope Driver (C#)

-
-



-

-

You have just created the skeleton of an ASCOM -Telescope driver in C#. It produces an in-process -(assembly) based driver.

-
-

Prior to developing your first driver, please -familiarize yourself with the developer -information we've provided at the ASCOM Initiative web site -(internet required). -

-

You must do the following in order to complete -your implementation:

-
    -
  1. Switch to the Debug configuration - and build the template now. It should build without errors. -

    -
  2. Add a test project to the - solution. There are templates that can be used to add either a - console or a Windows Forms application:

    -
-
    -
  • Select the ASCOM - Test Forms App (CS) or ASCOM - Test Console App (CS) template.

    -
  • Set a name for the test - application and click on OK.

    -
  • In the Wizard: set the same device - type and model name as for the driver and select Create to build the - test project.

    -
  • Set the Test Application to Run at - Startup.

    -
  • Click on Debug and the test - application should run. You should be able to select your - application in the chooser. Selecting Properties should show the - default setup dialog for your driver.

    -
  • Trying to continue will generate - errors because the additional properties have not been implemented.

    -
-
    -
  1. Go through the Driver.cs file and - replace the System.NotImplemented exceptions with code to implement - your driver's functionality. See the ASCOM ITelescopeV3 - spec. If a property or method is not implemented in your driver the - System.NotImplemented exception must be replaced by an - ASCOM.PropertyNotImplemented or ASCOM.MethodNotImplemented - exception.

    -
  2. Customize the Setup Dialog (SetupDialogForm) to provide the - settings and other controls for your driver. You can bind settings - directly to controls on your dialog form, there's no need to manage - settings manually. A custom Settings class takes care of managing - your settings behind the scenes. -

    -
-

Notes:

-
    -
  • Successfully building the driver, - as well as using regasm - on the assembly, registers it for both COM and ASCOM (the Chooser). - See the code in the ASCOM Registration region of Driver.vb. -

    -
  • Doing a Clean for the project, as - well doing a regasm - -u on the assembly, unregisters it for both COM and ASCOM - (the Chooser). -

    -
  • Place a breakpoint in your driver class constructor, then - start debugging (go, F5). Your breakpoint will be hit when the test - application creates an instance of your driver (after selecting it - in the Chooser). You can now single step, examine variables, etc. - Please review the test application and make changes and additions to - activate various parts of your driver during debugging.

    -
  • The project's Debug configuration is already configured (The - test application creates an instance of your driver (after selecting - it in the Chooser). You can now single step, examine variables, etc. - Please review the test application and feel free to make changes and - additions to activate various parts of your driver during debugging. -

    -
-
- - - - - - - -
- - - - - -
-

ASCOM Initiative

-
-
-



-

-
-

The ASCOM Initiative consists of a group of astronomy software - developers and instrument vendors whose goals are to promote the - driver/client model and scripting automation. -

-

See the ASCOM - web site for more information. Please participate in the - ASCOM-Talk - Yahoo Group. -

-
-
-



-

-

-

- - \ No newline at end of file diff --git a/Meade.net.focuser/Meade.net.focuser.csproj b/Meade.net.focuser/Meade.net.focuser.csproj index cbde904..55eeca3 100644 --- a/Meade.net.focuser/Meade.net.focuser.csproj +++ b/Meade.net.focuser/Meade.net.focuser.csproj @@ -156,7 +156,6 @@ Settings.Designer.cs
- diff --git a/Meade.net.focuser/ReadMe.htm b/Meade.net.focuser/ReadMe.htm deleted file mode 100644 index d0e812e..0000000 --- a/Meade.net.focuser/ReadMe.htm +++ /dev/null @@ -1,147 +0,0 @@ - - - - - Untitled Document - - - - - - - - - - - -
-

ASCOM Focuser Driver (C#)

-
-



-

-

You have just created the skeleton of an ASCOM -Focuser driver in C#. It produces an in-process -(assembly) based driver.

-
-

Prior to developing your first driver, please -familiarize yourself with the developer -information we've provided at the ASCOM Initiative web site -(internet required). -

-

You must do the following in order to complete -your implementation:

-
    -
  1. Switch to the Debug configuration - and build the template now. It should build without errors. -

    -
  2. Add a test project to the - solution. There are templates that can be used to add either a - console or a Windows Forms application:

    -
-
    -
  • Select the ASCOM - Test Forms App (CS) or ASCOM - Test Console App (CS) template.

    -
  • Set a name for the test - application and click on OK.

    -
  • In the Wizard: set the same device - type and model name as for the driver and select Create to build the - test project.

    -
  • Set the Test Application to Run at - Startup.

    -
  • Click on Debug and the test - application should run. You should be able to select your - application in the chooser. Selecting Properties should show the - default setup dialog for your driver.

    -
  • Trying to continue will generate - errors because the additional properties have not been implemented.

    -
-
    -
  1. Go through the Driver.cs file and - replace the System.NotImplemented exceptions with code to implement - your driver's functionality. See the ASCOM IFocuserV3 - spec. If a property or method is not implemented in your driver the - System.NotImplemented exception must be replaced by an - ASCOM.PropertyNotImplemented or ASCOM.MethodNotImplemented - exception.

    -
  2. Customize the Setup Dialog (SetupDialogForm) to provide the - settings and other controls for your driver. You can bind settings - directly to controls on your dialog form, there's no need to manage - settings manually. A custom Settings class takes care of managing - your settings behind the scenes. -

    -
-

Notes:

-
    -
  • Successfully building the driver, - as well as using regasm - on the assembly, registers it for both COM and ASCOM (the Chooser). - See the code in the ASCOM Registration region of Driver.vb. -

    -
  • Doing a Clean for the project, as - well doing a regasm - -u on the assembly, unregisters it for both COM and ASCOM - (the Chooser). -

    -
  • Place a breakpoint in your driver class constructor, then - start debugging (go, F5). Your breakpoint will be hit when the test - application creates an instance of your driver (after selecting it - in the Chooser). You can now single step, examine variables, etc. - Please review the test application and make changes and additions to - activate various parts of your driver during debugging.

    -
  • The project's Debug configuration is already configured (The - test application creates an instance of your driver (after selecting - it in the Chooser). You can now single step, examine variables, etc. - Please review the test application and feel free to make changes and - additions to activate various parts of your driver during debugging. -

    -
-
- - - - - - - -
- - - - - -
-

ASCOM Initiative

-
-
-



-

-
-

The ASCOM Initiative consists of a group of astronomy software - developers and instrument vendors whose goals are to promote the - driver/client model and scripting automation. -

-

See the ASCOM - web site for more information. Please participate in the - ASCOM-Talk - Yahoo Group. -

-
-
-



-

-

-

- - \ No newline at end of file diff --git a/Meade.net/Meade.net.csproj b/Meade.net/Meade.net.csproj index e5b1b9c..6a41f03 100644 --- a/Meade.net/Meade.net.csproj +++ b/Meade.net/Meade.net.csproj @@ -168,7 +168,6 @@ - diff --git a/Meade.net/ReadMe.htm b/Meade.net/ReadMe.htm deleted file mode 100644 index 0a8dc80..0000000 --- a/Meade.net/ReadMe.htm +++ /dev/null @@ -1,666 +0,0 @@ - - - - - Untitled Document - - - - - - - - - - - - -
-

- ASCOM LocalServer (singleton) Host -

-
-

-
-
- -

-

- You have just created a local server (singleton) host for one or - more ASCOM driver classes. -

-
-

- This project implements an ASCOM host server for one or more - driver classes in a single-instance executable. It can be used to - serve multiple instances of a single driver class (hub), provide - driver services for multiple devices (e.g., Telescope and Focuser) to - multiple applications and allow multiple devices of the same type to - be connected. In the latter scenario, the multiple driver classes - will often share one or more resources such as the serial connection - and a microcontroller in the combined device. From the client's - perspective, using the drivers served by the local server is exactly - the same as if the drivers are loaded into the client's process space - (in-proc servers). -

-

- - NOTE: - - - Unless you are prepared to handle all of the timing issues that arise - when multiple clients are accessing the properties and methods of - your driver(s), stop now. Just because the local server serializes - the calls to your driver(s)' properties and methods does not mean - that there will be no timing or concurrency issues.
-  
For - example, suppose the hub serves instances of a Telescope driver. One - client sets the TargetRightAscension property, then another sets - TargetRightAscension to a different value, then the first client sets - TargetDeclination, then the first client calls SlewToTarget() - followed by the second client calling SlewToTarget(). Besides the - first client's slew command sending the scope to the wrong (and - possibly dangerous) coordinates, there is the problem of the second - client trying to slew a slewing scope. Local server drivers are - tricky to get right. There is no such thing as "ignorance is - bliss" here. - -
-

-

- - This implementation has changed - from what was defined for Platform 5.5 as follows: - -

-

- - The drivers are now installed in - the same folder as the local server executable. This makes deployment - cleaner because the whole driver can exist in a single folder - independently of other drivers. - -

-

- - The ProgId and friendly name as - displayed by the Chooser are defined using attributes. This allows - driver dlls to be identified clearly and so avoids confusion with - other dlls that may be required such as interop dlls. - -

-

- - Some changes have been made that - will facilitate generating multiple drivers of the same type. - -

-

- - I've put some additional advice and - comments in the notes below in italics. - -

-

- You're probably anxious to get going, but you really should read - through the Theory of Operation and - Detailed - Use and Deployment - below. -

-

You must do the following in order to complete your local server:

-
    -
  1. -

    - In the local server's project - properties, Application tab, change BOTH the AssemblyName and the - default assembly name to ASCOM.xxx (e.g., ASCOM.SuperScope). - This - may be done by default now. - -

    -
  2. -
  3. -

    - Add one or more driver skeleton - projects using the in-proc templates. You may use either the C# or - VB templates. Project name is not important (not used in ProgID) - choose something like TelescopeDriver. You will be changing the - substituted project name in these projects below. If you ensure that - the LocalServer and all the driver projects have the same NameSpace - e.g. ASCOM.SuperScope the renaming in section 6a will not be - required. -

    -
  4. -
  5. -

    - Develop and debug these driver - projects as normal in-process assemblies. This will be much simpler - because the driver and test code can be debugged in the same - process. -

    -
  6. -
  7. -

    - Build the LocalServer. -

    -
  8. -
  9. -

    - Set a reference to the local - server project in each of the driver skeleton - projects. -

    -
  10. -
  11. -

    In each skeleton driver project:

    -
      -
    1. -

      - Do a Find In Files for the - project name of the skeleton driver (e.g., TelescopeDriver) and - change it to match the project name of your local server (e.g. - SuperScope). You don't have to do this in the ReadMe.html file. - Everywhere else, however, is IMPORTANT. This sets the correct - namespace, progID, etc. If you're a bit more brave, you can use - Replace in Files. - This may not be needed if the correct - namespace and naming conventions have been followed when the - drivers and local server were generated. - -

      -
    2. -
    3. -

      - In project properties, - Application tab, change the assembly name to - ASCOM.localserverprojectname.drivertype, - (e.g., ASCOM.SuperScope.Telescope). -

      -
    4. -
    5. -

      - In project properties, - Application tab, click Assembly Information... -

      -
        -
      • -

        - Assure that Make assembly COM - visible is on (it should already be on). -

        -
      • -
      • -

        - Edit the Product Name to be the - "friendly name" of your driver as will be shown in the - Chooser. - Not used now, use the ServedClassName attribute - instead. - -

        -
      • -
      -
    6. -
    7. -

      - In project properties, Build tab, - turn off Register for COM Interop. -

      -
    8. -
    9. -

      - Modify the driver class declaration to inherit from - ReferenceCountedObjectBase. Examples:
      C#: -

      -
      -              public class Telescope :
      -              ReferenceCountedObjectBase,
      -              ITelescope
      -            
      -

      - VB: -

      -
      -              Public Class Telescope
      -              '==================================
      -              Inherits ReferenceCountedObjectBase
      -              Implements ITelescope
      -              '==================================
      -            
      -
    10. -
    11. -

      - In driver.cs/driver.vb, remove - the entire ASCOM Registration region -

      -
    12. -
    13. -

      - In driver.cs/driver.vb, remove - the private strings for driver ID and driver description. - They - may be needed internally, and if so should be set from the - associated attributes, ServedClassName for the description and - ProgId for the driver Id. - -

      -
    14. -
    15. -

      - Modify the class attributes by - adding the ServedClassName and ProgID attributes. The - ServedClassName attribute must be the friendly name shown as the - device name in the Chooser and the ProgId the progid of the driver - e.g. ASCOM.SuperScope.Telescope. The class header should look like - this: -

      -

      C#:

      -
      -              
      -                [Guid("0AE8B38D-10A1-4A8D-A5B7-1B050F74B48B")]  // set by the template
      -                [ProgId("ASCOM.SuperScope.Telescope")]
      -                [ServedClassName ("Super Scope Telescope")]
      -                [ClassInterface(ClassInterfaceType.None)]
      -                public class Telescope : ReferenceCountedObjectBase , ITelescope
      -              
      -            
      -
    16. -
    -
  12. -
-

-
-

-
    -
      -

      VB:

      -
      -          
      -            <Guid(“0AE8B38D-10A1-4A8D-A5B7-1B050F74B48B”)>
      -            <ProgId(“ASCOM.SuperScope.Telescope”)>
      -            <ServedClassName(“Super Scope Telescope”)>
      -            Public Class Telescope
      -            '==================================
      -            Inherits ReferenceCountedObjectBase
      -            Implements ITelescope
      -            '==================================
      -          
      -        
      -
    -
-

- Add the following line to the driver - constructor, this sets the driver ID using the ProgId Attribute: -

-
    -
      -

      C#

      -
      -          
      -            s_csDriverID = Marshal.GenerateProgIdForType(this.GetType());
      -          
      -        
      -

      VB:

      -
      -          
      -            s_csDriverID = Marshal.GenerateProgIdForType(Me.GetType())
      -          
      -        
      -
    -
  1. -

    - Unless you're writing a - single-driver hub, you will have two or more driver types (e.g. - Telescope and Focuser) and thus two or more driver assembly projects - added. Presumably, these drivers need to share some resources (e.g. - a single COM port via Helper.Serial). - Put shared resources into - the SharedResources class provided - . There are some examples that - should give a clue, modify and delete these as required. -

    -
  2. -
  3. -

    - A shared serial port is already - provided (see SharedResources.cs) as SharedResources.SharedSerial - and it is an ASCOM Helper Serial object. You may wish to define - additional shared resources in static member variables with public - static accessor properties as is already done for SharedSerial. - Unfortunately, if you are a Visual Basic programmer, you will have - to make these additions in C#. -

    -
  4. -
  5. -

    - If you are writing a hub and don't - need the serial port, in SharedResources.cs you can remove the - public static SharedSerial property, the m_SharedSerial member in - the private data region, and the line in main that initializes it. - If you don't need any other shared resources for your hub, then you - can remove the SharedResources.cs file completely. -

    -
  6. -
  7. -

    - If you modified the LocalServer, - build it again now. This will refresh the stuff that's visible to - the drivers. -

    -
  8. -
  9. -

    - Build the driver skeletons to - verify that you got all of the namespace and other variable changes. -

    -
  10. -
  11. -

    - The local server dynamically loads the driver assemblies from - the same folder as the local server executable.
    -
    During - development, you'll need to add a post-build task to each of your - driver assembly projects which puts a copy of the driver assembly - into the local server executable folder. Here is an example: -

    -
        copy "$(TargetPath)" "$(SolutionDir)\SuperScope\$(OutDir)\$(TargetFileName)"
    -

    - This assumes that the server project is called “SuperScope”, - and handles using the debug or release build.
    - Note the quotes for - possible path elements with spaces in them. - An alternative is to - set the build path to the required destination instead of the - default path. - -

    -
  12. -
  13. -

    - - Make sure the drivers are - registered through the local server by running it with the /register - parameter, see below for details. - -

    -
  14. -
  15. -

    - IMPORTANT: - With a local server based driver (or hub) it is possible for - multiple clients to control the device(s). It is up to you to - safeguard against abuse. - The sort of thing that's needed is to - have a counter of the number of connections to a device, the - connection is only fully broken when the number of connections is - zero. You may also need code to prevent several drivers from talking - to the hardware at the same time, the lock pattern is useful for - that. - -

    -
  16. -
  17. -

    - You may want to add controls and/or status information to the - main form frmMain of the local server. Please resist the temptation - to turn the local server's main form into a graphical device control - panel. Instead, make a separate application that uses the served - driver(s). A driver is not a program! -

    -
  18. -
-

Notes

-
    -
  • -

    - The local server handles all of - the registration and unregistration for each of its served driver - classes, including the ASCOM Chooser info and the DCOM/AppID info - needed for activation from TheSky. By running the server from a - command line and giving /register or /unregister as the command line - option, it will register or unregister all served classes - (respectively). - Never use REGASM - on the local server executable! - - This can be done in the - Visual Studio IDE by setting the server project to run as startup - and setting the command line argument to /register in Debug – - Start Options. - -

    -
  • -
  • -

    - When you make the installer for - your local server based driver/hub, do not let it register the - executable for COM. Instead, have it activate the installed local - server with the /register option. -

    -
  • -
  • -

    - The ASCOM registration uses the ServedClassName attribute as - the friendly name that will show in the chooser and the ProgId - attribute as the driver Id. -

    -
  • -
  • -

    - The best deployment way is to install all the files in a - folder that's a sub folder of the main driver, so the SuperScope - driver files will be in the folder ...\ASCOM\Telescope\SuperScope. - This can be done in the Inno script by changing the DefaultDirName - like this:
    - DefaultDirName="{cf}\ASCOM\Telescope\SuperScope"
    then - the files can all be installed with DestDir: {app}; -

    -
  • -
-

- Theory of Operation -

-

- The local server is an executable which can provide multiple - instances of multiple drivers to multiple clients. This capability is - needed for two applications: -

-
    -
  • -

    - A hub, which allows multiple - clients to share a single device -

    -
  • -
  • -

    - A device which provides multiple services, such as a - telescope which has a focuser built-in where both the telescope and - focuser are controlled by the same serial connection and different - client programs need to control to the focuser and telescope. -

    -
  • -
-

- By simply dropping suitably developed driver assemblies into the - same folder as the local server executable, the local server will - find them and register them for COM and ASCOM and serve any number of - instances of the drivers' interfaces to any number of client - programs. It does this by locating and loading the driver assemblies, - analysing them to detect their classes and interfaces, and - implementing a class factory that can create instances of them for - clients. -

-

- A driver is an assembly which contains a class that implements - one of the ASCOM standard driver interfaces and inherits the - ReferenceCountedObjectBase class of the local server. Apart from - that, driver assemblies are identical to those that are used - in-process (DLL-type). The instructions above detail the steps needed - to convert an in-process driver into one that can be served by the - local server. -

-

- The name of the local server is important, so we provide it as a - template from which you can create a local server for your - produce. To make this clear, let's assume that your company AlphaTech - produces a telescope system which contains a microcontroller that is - able to control not only the telescope mount, but also a focuser and - a camera rotator. The mount, focuser, and rotator are all controlled - via commands sent through a common serial line connecting the - computer to the microcontroller, so you need a local server. In - ASCOM, then, you probably want your system to appear as - AlphaTech.Telescope, AlphaTech.Focuser, and AlphaTech.Rotator. Then - you would name the local server AlphaTech. Be sure to give this due - consideration before creating the template, the project name is the - name of your local server. - Is this still correct? I get the - impression that ASCOM.AlphaTech.Server would be OK. - -

-

- The fact that driver classes inherit from the local server's - ReferenceCountedObjectBase class allows the local server to maintain - a reference count on the driver class. If a client creates an - instance of a served driver, the local server automatically starts up - and provides an instance of the class to the client. Once started the - local server can provide additional instances of any of its served - driver classes. If the reference count of all served classes drops to - zero as a result of clients releasing their instances, the local - server will automatically exit. -

-

- Registration services provided include not only the basic COM - class registration, but also DCOM/AppID info needed to use the served - classes from outbound connections from Software Bisque's TheSky. It - also registers the served classes for the ASCOM Chooser. The - "friendly" name of each served driver that appears in the - chooser comes from the driver's ServedClassName attribute. This also - used to identify a driver so that non driver dlls, such as Interop - dlls can be ignored. The COM ProgID for each served driver is - specified in the ProgId attribute - ASCOM.localservername.drivertype, - for example, ASCOM.AlphaTech.Telescope, where AlphaTech is the local - server name and Telescope is the type of the driver. Unregistering - removes all of this information from the system. Specifying the - ProgId as an attribute allows multiple driver assemblies to be - generated using the same source and namespace. This is used to - provide multiple instances of the same driver, each with a different - ProgId and so able to be registered separately. -

-

- Driver DLLs are identified for registering/unregistering because - they contain a type with the ServedClassName attribute. Only these - will be registered for Com and ASCOM. This has changed; in Platform - 5 there was no attribute and the local server attempted to register - all dlls. The new behaviour allows support dlls such as interop dlls - to be included without them being registered incorrectly. There was - also an interim version where the ServedClassName attribute was on - the assembly, not the class. - All these previous versions, and the - new drivers will operate together with Platform 6, the changes are - local to the individual drivers. - -

-

- Detailed Use and Deployment -

-

- Once you have built your local server and the served driver class - assemblies, here's how to use it. To register the served classes, - activate the local server from a shell command line with the option - /register (or /regserver, for VB6 compatibility): -

-
-      C:\xxx> localserver.exe /register
-    
-

- To unregister the local server and its drivers, activate the local - server from a shell command line with the option /unregister (or - /unregserver for VB6 compatibility): -

-
-      C:\xxx> localserver.exe /unregister
-    
-

- When the operating system starts the local server in response to a - client creating one of it's served driver classes, the command option - /embedding is included. The local server's code detects this and sets - a variable that you can use. -

-

- When deploying a hub or set of drivers - with the local server, you'll have to arrange for the local server - and the driver assemblies to be placed together in a folder in the - ASCOM driver folder. Any support files, such as Interop DLLs can be - put in the same fiolder. That's all you need to do, the local server - will find them in the same folder as it is located in. -

-
- - - - - - - -
- - - - - -
-

ASCOM Initiative

-
- -
-

-
-
- -

-
-

- The ASCOM Initiative consists of a group of astronomy software - developers and instrument vendors whose goals are to promote the - driver/client model and scripting automation. -

-

- See the - ASCOM - web site - for more information. Please participate in the - - ASCOM-Talk - Yahoo Group - . -

-
-
-

-
-
- -

-

-
-
- -

- - \ No newline at end of file From 4489a91eb7b045ee8dda54c820e0991fbca6f759 Mon Sep 17 00:00:00 2001 From: Colin Date: Sun, 29 Sep 2019 19:38:56 +0100 Subject: [PATCH 10/27] Code inspections --- .../Properties/Resources.Designer.cs | 27 +++++++++++++++++++ Meade.net.Telescope/Properties/Resources.resx | 9 +++++++ Meade.net.Telescope/Telescope.cs | 15 ++++++----- Meade.net/ClassFactory.cs | 4 +-- Meade.net/SetupDialogForm.cs | 6 +++++ 5 files changed, 52 insertions(+), 9 deletions(-) diff --git a/Meade.net.Telescope/Properties/Resources.Designer.cs b/Meade.net.Telescope/Properties/Resources.Designer.cs index 7df2b0c..659e1a1 100644 --- a/Meade.net.Telescope/Properties/Resources.Designer.cs +++ b/Meade.net.Telescope/Properties/Resources.Designer.cs @@ -79,5 +79,32 @@ namespace ASCOM.Meade.net.Properties { return ((System.Drawing.Icon)(obj)); } } + + /// + /// Looks up a localized string similar to Site out of range. + /// + internal static string Telescope_GetSiteName_Site_out_of_range { + get { + return ResourceManager.GetString("Telescope_GetSiteName_Site_out_of_range", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Site cannot be higher than 4. + /// + internal static string Telescope_SelectSite_Site_cannot_be_higher_than_4 { + get { + return ResourceManager.GetString("Telescope_SelectSite_Site_cannot_be_higher_than_4", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Site cannot be lower than 1. + /// + internal static string Telescope_SelectSite_Site_cannot_be_lower_than_1 { + get { + return ResourceManager.GetString("Telescope_SelectSite_Site_cannot_be_lower_than_1", resourceCulture); + } + } } } diff --git a/Meade.net.Telescope/Properties/Resources.resx b/Meade.net.Telescope/Properties/Resources.resx index e522d9e..7c00377 100644 --- a/Meade.net.Telescope/Properties/Resources.resx +++ b/Meade.net.Telescope/Properties/Resources.resx @@ -124,4 +124,13 @@ ..\ASCOM.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + Site cannot be lower than 1 + + + Site cannot be higher than 4 + + + Site out of range + \ No newline at end of file diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index d98a724..406cb34 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -9,6 +9,7 @@ using System.Collections; using System.Globalization; using System.Reflection; using ASCOM.Meade.net.AstroMaths; +using ASCOM.Meade.net.Properties; using ASCOM.Meade.net.Wrapper; using ASCOM.Utilities.Interfaces; @@ -536,9 +537,9 @@ namespace ASCOM.Meade.net CheckConnected("SelectSite"); if (site < 1) - throw new ArgumentOutOfRangeException(nameof(site),site,"Site cannot be lower than 1"); + throw new ArgumentOutOfRangeException(nameof(site),site,Resources.Telescope_SelectSite_Site_cannot_be_lower_than_1); else if (site > 4) - throw new ArgumentOutOfRangeException(nameof(site), site, "Site cannot be higher than 4"); + throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_SelectSite_Site_cannot_be_higher_than_4); _sharedResourcesWrapper.SendBlind($":W{site}#"); //:W# @@ -551,9 +552,9 @@ namespace ASCOM.Meade.net CheckConnected("SetSiteName"); if (site < 1) - throw new ArgumentOutOfRangeException(nameof(site), site, "Site cannot be lower than 1"); + throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_SelectSite_Site_cannot_be_lower_than_1); else if (site > 4) - throw new ArgumentOutOfRangeException(nameof(site), site, "Site cannot be higher than 4"); + throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_SelectSite_Site_cannot_be_higher_than_4); string command = String.Empty; switch (site) @@ -605,9 +606,9 @@ namespace ASCOM.Meade.net CheckConnected("GetSiteName"); if (site < 1) - throw new ArgumentOutOfRangeException(nameof(site), site, "Site cannot be lower than 1"); + throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_SelectSite_Site_cannot_be_lower_than_1); else if (site > 4) - throw new ArgumentOutOfRangeException(nameof(site), site, "Site cannot be higher than 4"); + throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_SelectSite_Site_cannot_be_higher_than_4); switch (site) { @@ -633,7 +634,7 @@ namespace ASCOM.Meade.net //A ‘#’ terminated string with the name of the requested site. } - throw new ArgumentOutOfRangeException(nameof(site), site, "Site out of range"); + throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_GetSiteName_Site_out_of_range); } public string Description diff --git a/Meade.net/ClassFactory.cs b/Meade.net/ClassFactory.cs index a02a47a..4626a2f 100644 --- a/Meade.net/ClassFactory.cs +++ b/Meade.net/ClassFactory.cs @@ -113,7 +113,7 @@ namespace ASCOM.Meade.net private Guid _mClassId; private readonly ArrayList _mInterfaceTypes; private uint _mCookie; - private readonly string _mProgid; + //private readonly string _mProgid; public ClassFactory(Type type) { @@ -122,7 +122,7 @@ namespace ASCOM.Meade.net _mClassType = type; //PWGS Get the ProgID from the MetaData - _mProgid = Marshal.GenerateProgIdForType(type); + //_mProgid = Marshal.GenerateProgIdForType(type); _mClassId = Marshal.GenerateGuidForType(type); // Should be nailed down by [Guid(...)] ClassContext = (uint)Clsctx.ClsctxLocalServer; // Default Flags = (uint)Regcls.RegclsMultipleuse | // Default diff --git a/Meade.net/SetupDialogForm.cs b/Meade.net/SetupDialogForm.cs index 290485d..21516b5 100644 --- a/Meade.net/SetupDialogForm.cs +++ b/Meade.net/SetupDialogForm.cs @@ -18,6 +18,12 @@ namespace ASCOM.Meade.net Text = $"{assemblyInfo.Product} Settings ({assemblyInfo.AssemblyVersion})"; } + public sealed override string Text + { + get { return base.Text; } + set { base.Text = value; } + } + private void cmdCancel_Click(object sender, EventArgs e) // Cancel button event handler { Close(); From 272fdb58d1f5991eba2e50338b7e468bb067f8b2 Mon Sep 17 00:00:00 2001 From: Colin Date: Sun, 29 Sep 2019 19:43:34 +0100 Subject: [PATCH 11/27] Code inspections --- Meade.net/SetupDialogForm.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Meade.net/SetupDialogForm.cs b/Meade.net/SetupDialogForm.cs index 21516b5..ff5b104 100644 --- a/Meade.net/SetupDialogForm.cs +++ b/Meade.net/SetupDialogForm.cs @@ -20,8 +20,8 @@ namespace ASCOM.Meade.net public sealed override string Text { - get { return base.Text; } - set { base.Text = value; } + get => base.Text; + set => base.Text = value; } private void cmdCancel_Click(object sender, EventArgs e) // Cancel button event handler From 0e0ea2d2b085aa693c867273433f9610c1cd63c4 Mon Sep 17 00:00:00 2001 From: Colin Date: Sun, 29 Sep 2019 19:51:19 +0100 Subject: [PATCH 12/27] Code inspections --- .../FocuserUnitTests.cs | 3 +- .../TelescopeUnitTests.cs | 27 ++++---- .../Properties/Resources.Designer.cs | 44 ++++++------ .../Properties/Settings.Designer.cs | 12 ++-- Meade.net.Telescope/Rates.cs | 6 +- Meade.net.Telescope/Telescope.cs | 68 ++++++++++--------- Meade.net.focuser/Focuser.cs | 8 +-- .../Properties/Resources.Designer.cs | 44 ++++++------ .../Properties/Settings.Designer.cs | 12 ++-- Meade.net/AssemblyInfo.cs | 2 +- Meade.net/ClassFactory.cs | 3 +- Meade.net/LocalServer.cs | 18 ++--- Meade.net/Localization/LocalisationHelper.cs | 4 +- Meade.net/Properties/AssemblyInfo.cs | 2 +- Meade.net/Properties/Resources.Designer.cs | 40 ++++++----- Meade.net/SetupDialogForm.cs | 6 +- Meade.net/SetupDialogForm.designer.cs | 31 +++++---- Meade.net/SetupDialogForm.resx | 2 +- Meade.net/SharedResources.cs | 9 +-- Meade.net/frmMain.Designer.cs | 7 +- Meade.net/frmMain.resx | 2 +- TelescopeTestConsole/Program.cs | 5 +- 22 files changed, 195 insertions(+), 160 deletions(-) diff --git a/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs b/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs index 19e1115..1c9d18c 100644 --- a/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs +++ b/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs @@ -1,4 +1,5 @@ using System; +using System.Reflection; using ASCOM; using ASCOM.DeviceInterface; using ASCOM.Meade.net; @@ -239,7 +240,7 @@ namespace Meade.net.Focuser.UnitTests [Test] public void DriverVersion_Get() { - Version version = System.Reflection.Assembly.GetAssembly(typeof(ASCOM.Meade.net.Focuser)).GetName().Version; + Version version = Assembly.GetAssembly(typeof(ASCOM.Meade.net.Focuser)).GetName().Version; string exptectedDriverInfo = $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}"; diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index 4fa7bfd..820561c 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -1,4 +1,5 @@ using System; +using System.Reflection; using ASCOM; using ASCOM.Astrometry.AstroUtils; using ASCOM.DeviceInterface; @@ -45,8 +46,8 @@ namespace Meade.net.Telescope.UnitTests _sharedResourcesWrapperMock.Setup(x => x.ReadProfile()).Returns(() =>_profileProperties); _sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny())).Callback(action => { action(); }); - _sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny>())).Returns>( (func) => func()); - _sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny>())).Returns>((func) => func()); + _sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny>())).Returns>( func => func()); + _sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny>())).Returns>(func => func()); _connectionInfo = new ConnectionInfo {Connections = 1, SameDevice = 1}; @@ -243,7 +244,7 @@ namespace Meade.net.Telescope.UnitTests { ConnectTelescope(); - string parameters = $"unknown"; + string parameters = "unknown"; var exception = Assert.Throws(() => { _telescope.Action("site", parameters); }); Assert.That(exception.Message, Is.EqualTo($"Site parameters {parameters} not known")); @@ -514,7 +515,7 @@ namespace Meade.net.Telescope.UnitTests [Test] public void DriverVersion_Get() { - Version version = System.Reflection.Assembly.GetAssembly(typeof(ASCOM.Meade.net.Telescope)).GetName().Version; + Version version = Assembly.GetAssembly(typeof(ASCOM.Meade.net.Telescope)).GetName().Version; string exptectedDriverInfo = $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}"; @@ -1183,7 +1184,7 @@ namespace Meade.net.Telescope.UnitTests var exception = Assert.Throws(() => { _telescope.MoveAxis(TelescopeAxes.axisTertiary, testRate); }); - Assert.That(exception.Message, Is.EqualTo($"Can not move this axis.")); + Assert.That(exception.Message, Is.EqualTo("Can not move this axis.")); } [Test] @@ -2190,8 +2191,7 @@ namespace Meade.net.Telescope.UnitTests slewCounter++; if (slewCounter <= iterations) return "|"; - else - return ""; + return ""; }); _telescope.SlewToTarget(); @@ -2259,8 +2259,7 @@ namespace Meade.net.Telescope.UnitTests slewCounter++; if (slewCounter <= iterations) return "|"; - else - return ""; + return ""; }); _telescope.SlewToCoordinates(rightAscension, declination); @@ -2330,7 +2329,7 @@ namespace Meade.net.Telescope.UnitTests _astroMathsMock .Setup(x => x.ConvertHozToEq(It.IsAny(), It.IsAny(), It.IsAny(), - It.IsAny())).Returns(new EquatorialCoordinates(){ Declination = declination, RightAscension = rightAscension }); + It.IsAny())).Returns(new EquatorialCoordinates { Declination = declination, RightAscension = rightAscension }); _sharedResourcesWrapperMock.Setup(x => x.SendChar(":MS#")).Returns("0"); @@ -2364,7 +2363,7 @@ namespace Meade.net.Telescope.UnitTests _astroMathsMock .Setup(x => x.ConvertHozToEq(It.IsAny(), It.IsAny(), It.IsAny(), - It.IsAny())).Returns(new EquatorialCoordinates() { Declination = declination, RightAscension = rightAscension }); + It.IsAny())).Returns(new EquatorialCoordinates { Declination = declination, RightAscension = rightAscension }); _sharedResourcesWrapperMock.Setup(x => x.SendChar(":MS#")).Returns("0"); @@ -2375,8 +2374,7 @@ namespace Meade.net.Telescope.UnitTests slewCounter++; if (slewCounter <= iterations) return "|"; - else - return ""; + return ""; }); _telescope.SlewToAltAz( azimuth, altitude); @@ -2499,5 +2497,4 @@ namespace Meade.net.Telescope.UnitTests _sharedResourcesWrapperMock.Verify( x => x.SendString(":D#"), Times.Once); } } -} -; \ No newline at end of file +} \ No newline at end of file diff --git a/Meade.net.Telescope/Properties/Resources.Designer.cs b/Meade.net.Telescope/Properties/Resources.Designer.cs index 659e1a1..4038f60 100644 --- a/Meade.net.Telescope/Properties/Resources.Designer.cs +++ b/Meade.net.Telescope/Properties/Resources.Designer.cs @@ -8,10 +8,16 @@ // //------------------------------------------------------------------------------ +using System.CodeDom.Compiler; +using System.ComponentModel; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Drawing; +using System.Globalization; +using System.Resources; +using System.Runtime.CompilerServices; + namespace ASCOM.Meade.net.Properties { - using System; - - /// /// A strongly-typed resource class, for looking up localized strings, etc. /// @@ -19,27 +25,27 @@ namespace ASCOM.Meade.net.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [DebuggerNonUserCode()] + [CompilerGenerated()] internal class Resources { - private static global::System.Resources.ResourceManager resourceMan; + private static ResourceManager resourceMan; - private static global::System.Globalization.CultureInfo resourceCulture; + private static CultureInfo resourceCulture; - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal Resources() { } /// /// Returns the cached ResourceManager instance used by this class. /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { + [EditorBrowsable(EditorBrowsableState.Advanced)] + internal static ResourceManager ResourceManager { get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ASCOM.Meade.net.Properties.Resources", typeof(Resources).Assembly); + if (ReferenceEquals(resourceMan, null)) { + ResourceManager temp = new ResourceManager("ASCOM.Meade.net.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; @@ -50,8 +56,8 @@ namespace ASCOM.Meade.net.Properties { /// Overrides the current thread's CurrentUICulture property for all /// resource lookups using this strongly typed resource class. /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { + [EditorBrowsable(EditorBrowsableState.Advanced)] + internal static CultureInfo Culture { get { return resourceCulture; } @@ -63,20 +69,20 @@ namespace ASCOM.Meade.net.Properties { /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// - internal static System.Drawing.Bitmap ASCOM { + internal static Bitmap ASCOM { get { object obj = ResourceManager.GetObject("ASCOM", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); + return ((Bitmap)(obj)); } } /// /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). /// - internal static System.Drawing.Icon DefaultIcon { + internal static Icon DefaultIcon { get { object obj = ResourceManager.GetObject("DefaultIcon", resourceCulture); - return ((System.Drawing.Icon)(obj)); + return ((Icon)(obj)); } } diff --git a/Meade.net.Telescope/Properties/Settings.Designer.cs b/Meade.net.Telescope/Properties/Settings.Designer.cs index 67ea42d..81d4ba1 100644 --- a/Meade.net.Telescope/Properties/Settings.Designer.cs +++ b/Meade.net.Telescope/Properties/Settings.Designer.cs @@ -8,14 +8,18 @@ // //------------------------------------------------------------------------------ +using System.CodeDom.Compiler; +using System.Configuration; +using System.Runtime.CompilerServices; + namespace ASCOM.Meade.net.Properties { - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + [CompilerGenerated()] + [GeneratedCode("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.0.0.0")] + internal sealed partial class Settings : ApplicationSettingsBase { - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + private static Settings defaultInstance = ((Settings)(Synchronized(new Settings()))); public static Settings Default { get { diff --git a/Meade.net.Telescope/Rates.cs b/Meade.net.Telescope/Rates.cs index ca60466..432c85a 100644 --- a/Meade.net.Telescope/Rates.cs +++ b/Meade.net.Telescope/Rates.cs @@ -1,7 +1,7 @@ -using System.Runtime.InteropServices; -using ASCOM.DeviceInterface; -using System.Collections; +using System.Collections; +using System.Runtime.InteropServices; using System.Threading; +using ASCOM.DeviceInterface; namespace ASCOM.Meade.net { diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 406cb34..63d36ff 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -1,16 +1,18 @@ #define Telescope using System; -using System.Runtime.InteropServices; -using ASCOM.Astrometry.AstroUtils; -using ASCOM.Utilities; -using ASCOM.DeviceInterface; using System.Collections; using System.Globalization; using System.Reflection; +using System.Runtime.InteropServices; +using ASCOM.Astrometry; +using ASCOM.Astrometry.AstroUtils; +using ASCOM.Astrometry.NOVAS; +using ASCOM.DeviceInterface; using ASCOM.Meade.net.AstroMaths; using ASCOM.Meade.net.Properties; using ASCOM.Meade.net.Wrapper; +using ASCOM.Utilities; using ASCOM.Utilities.Interfaces; namespace ASCOM.Meade.net @@ -538,7 +540,7 @@ namespace ASCOM.Meade.net if (site < 1) throw new ArgumentOutOfRangeException(nameof(site),site,Resources.Telescope_SelectSite_Site_cannot_be_lower_than_1); - else if (site > 4) + if (site > 4) throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_SelectSite_Site_cannot_be_higher_than_4); _sharedResourcesWrapper.SendBlind($":W{site}#"); @@ -553,7 +555,7 @@ namespace ASCOM.Meade.net if (site < 1) throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_SelectSite_Site_cannot_be_lower_than_1); - else if (site > 4) + if (site > 4) throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_SelectSite_Site_cannot_be_higher_than_4); string command = String.Empty; @@ -607,7 +609,7 @@ namespace ASCOM.Meade.net if (site < 1) throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_SelectSite_Site_cannot_be_lower_than_1); - else if (site > 4) + if (site > 4) throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_SelectSite_Site_cannot_be_higher_than_4); switch (site) @@ -831,7 +833,7 @@ namespace ASCOM.Meade.net UtcDateTime = UTCDate, SiteLongitude = SiteLongitude, SiteLatitude = SiteLatitude, - EquatorialCoordinates = new EquatorialCoordinates() + EquatorialCoordinates = new EquatorialCoordinates { RightAscension = RightAscension, Declination = Declination @@ -866,7 +868,7 @@ namespace ASCOM.Meade.net { get { - LogMessage("AtHome", "Get - " + false.ToString()); + LogMessage("AtHome", "Get - " + false); return false; } } @@ -885,7 +887,7 @@ namespace ASCOM.Meade.net public IAxisRates AxisRates(TelescopeAxes axis) { - LogMessage("AxisRates", "Get - " + axis.ToString()); + LogMessage("AxisRates", "Get - " + axis); return new AxisRates(axis); } @@ -915,14 +917,14 @@ namespace ASCOM.Meade.net { get { - LogMessage("CanFindHome", "Get - " + false.ToString()); + LogMessage("CanFindHome", "Get - " + false); return false; } } public bool CanMoveAxis(TelescopeAxes axis) { - LogMessage("CanMoveAxis", "Get - " + axis.ToString()); + LogMessage("CanMoveAxis", "Get - " + axis); switch (axis) { case TelescopeAxes.axisPrimary: return true; //RA or AZ @@ -936,7 +938,7 @@ namespace ASCOM.Meade.net { get { - LogMessage("CanPark", "Get - " + true.ToString()); + LogMessage("CanPark", "Get - " + true); return true; } } @@ -945,7 +947,7 @@ namespace ASCOM.Meade.net { get { - LogMessage("CanPulseGuide", "Get - " + true.ToString()); + LogMessage("CanPulseGuide", "Get - " + true); return true; } } @@ -954,7 +956,7 @@ namespace ASCOM.Meade.net { get { - LogMessage("CanSetDeclinationRate", "Get - " + false.ToString()); + LogMessage("CanSetDeclinationRate", "Get - " + false); return false; } } @@ -967,7 +969,7 @@ namespace ASCOM.Meade.net var canSetGuideRate = IsGuideRateSettingSupported(); - LogMessage("CanSetGuideRates", "Get - " + canSetGuideRate.ToString()); + LogMessage("CanSetGuideRates", "Get - " + canSetGuideRate); return canSetGuideRate; } } @@ -976,7 +978,7 @@ namespace ASCOM.Meade.net { get { - LogMessage("CanSetPark", "Get - " + false.ToString()); + LogMessage("CanSetPark", "Get - " + false); return false; } } @@ -985,7 +987,7 @@ namespace ASCOM.Meade.net { get { - LogMessage("CanSetPierSide", "Get - " + false.ToString()); + LogMessage("CanSetPierSide", "Get - " + false); return false; } } @@ -994,7 +996,7 @@ namespace ASCOM.Meade.net { get { - LogMessage("CanSetRightAscensionRate", "Get - " + false.ToString()); + LogMessage("CanSetRightAscensionRate", "Get - " + false); return false; } } @@ -1003,7 +1005,7 @@ namespace ASCOM.Meade.net { get { - LogMessage("CanSetTracking", "Get - " + true.ToString()); + LogMessage("CanSetTracking", "Get - " + true); return true; } } @@ -1012,7 +1014,7 @@ namespace ASCOM.Meade.net { get { - LogMessage("CanSlew", "Get - " + true.ToString()); + LogMessage("CanSlew", "Get - " + true); return true; } } @@ -1021,7 +1023,7 @@ namespace ASCOM.Meade.net { get { - LogMessage("CanSlewAltAz", "Get - " + true.ToString()); + LogMessage("CanSlewAltAz", "Get - " + true); return true; } } @@ -1030,7 +1032,7 @@ namespace ASCOM.Meade.net { get { - LogMessage("CanSlewAltAzAsync", "Get - " + true.ToString()); + LogMessage("CanSlewAltAzAsync", "Get - " + true); return true; } } @@ -1039,7 +1041,7 @@ namespace ASCOM.Meade.net { get { - LogMessage("CanSlewAsync", "Get - " + true.ToString()); + LogMessage("CanSlewAsync", "Get - " + true); return true; } } @@ -1048,7 +1050,7 @@ namespace ASCOM.Meade.net { get { - LogMessage("CanSync", "Get - " + true.ToString()); + LogMessage("CanSync", "Get - " + true); return true; } } @@ -1057,7 +1059,7 @@ namespace ASCOM.Meade.net { get { - LogMessage("CanSyncAltAz", "Get - " + false.ToString()); + LogMessage("CanSyncAltAz", "Get - " + false); return false; } } @@ -1066,7 +1068,7 @@ namespace ASCOM.Meade.net { get { - LogMessage("CanUnpark", "Get - " + false.ToString()); + LogMessage("CanUnpark", "Get - " + false); return false; } } @@ -1131,7 +1133,7 @@ namespace ASCOM.Meade.net get { EquatorialCoordinateType equatorialSystem = EquatorialCoordinateType.equTopocentric; - LogMessage("DeclinationRate", "Get - " + equatorialSystem.ToString()); + LogMessage("DeclinationRate", "Get - " + equatorialSystem); return equatorialSystem; } } @@ -1473,13 +1475,13 @@ namespace ASCOM.Meade.net { // Now using NOVAS 3.1 double siderealTime = 0.0; - using (var novas = new Astrometry.NOVAS.NOVAS31()) + using (var novas = new NOVAS31()) { var jd = _utilities.DateUTCToJulian(DateTime.UtcNow); novas.SiderealTime(jd, 0, novas.DeltaT(jd), - Astrometry.GstType.GreenwichApparentSiderealTime, - Astrometry.Method.EquinoxBased, - Astrometry.Accuracy.Reduced, ref siderealTime); + GstType.GreenwichApparentSiderealTime, + Method.EquinoxBased, + Accuracy.Reduced, ref siderealTime); } // Allow for the longitude @@ -2096,7 +2098,7 @@ namespace ASCOM.Meade.net LogMessage("TrackingRates", "Get - "); foreach (DriveRates driveRate in trackingRates) { - LogMessage("TrackingRates", "Get - " + driveRate.ToString()); + LogMessage("TrackingRates", "Get - " + driveRate); } return trackingRates; } diff --git a/Meade.net.focuser/Focuser.cs b/Meade.net.focuser/Focuser.cs index 9aab8c5..e61be5d 100644 --- a/Meade.net.focuser/Focuser.cs +++ b/Meade.net.focuser/Focuser.cs @@ -1,13 +1,13 @@ #define Focuser using System; -using System.Diagnostics; -using System.Runtime.InteropServices; -using ASCOM.Utilities; -using ASCOM.DeviceInterface; using System.Collections; +using System.Diagnostics; using System.Reflection; +using System.Runtime.InteropServices; +using ASCOM.DeviceInterface; using ASCOM.Meade.net.Wrapper; +using ASCOM.Utilities; using ASCOM.Utilities.Interfaces; namespace ASCOM.Meade.net diff --git a/Meade.net.focuser/Properties/Resources.Designer.cs b/Meade.net.focuser/Properties/Resources.Designer.cs index 7df2b0c..80e9977 100644 --- a/Meade.net.focuser/Properties/Resources.Designer.cs +++ b/Meade.net.focuser/Properties/Resources.Designer.cs @@ -8,10 +8,16 @@ // //------------------------------------------------------------------------------ +using System.CodeDom.Compiler; +using System.ComponentModel; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Drawing; +using System.Globalization; +using System.Resources; +using System.Runtime.CompilerServices; + namespace ASCOM.Meade.net.Properties { - using System; - - /// /// A strongly-typed resource class, for looking up localized strings, etc. /// @@ -19,27 +25,27 @@ namespace ASCOM.Meade.net.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [DebuggerNonUserCode()] + [CompilerGenerated()] internal class Resources { - private static global::System.Resources.ResourceManager resourceMan; + private static ResourceManager resourceMan; - private static global::System.Globalization.CultureInfo resourceCulture; + private static CultureInfo resourceCulture; - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal Resources() { } /// /// Returns the cached ResourceManager instance used by this class. /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { + [EditorBrowsable(EditorBrowsableState.Advanced)] + internal static ResourceManager ResourceManager { get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ASCOM.Meade.net.Properties.Resources", typeof(Resources).Assembly); + if (ReferenceEquals(resourceMan, null)) { + ResourceManager temp = new ResourceManager("ASCOM.Meade.net.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; @@ -50,8 +56,8 @@ namespace ASCOM.Meade.net.Properties { /// Overrides the current thread's CurrentUICulture property for all /// resource lookups using this strongly typed resource class. /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { + [EditorBrowsable(EditorBrowsableState.Advanced)] + internal static CultureInfo Culture { get { return resourceCulture; } @@ -63,20 +69,20 @@ namespace ASCOM.Meade.net.Properties { /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// - internal static System.Drawing.Bitmap ASCOM { + internal static Bitmap ASCOM { get { object obj = ResourceManager.GetObject("ASCOM", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); + return ((Bitmap)(obj)); } } /// /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). /// - internal static System.Drawing.Icon DefaultIcon { + internal static Icon DefaultIcon { get { object obj = ResourceManager.GetObject("DefaultIcon", resourceCulture); - return ((System.Drawing.Icon)(obj)); + return ((Icon)(obj)); } } } diff --git a/Meade.net.focuser/Properties/Settings.Designer.cs b/Meade.net.focuser/Properties/Settings.Designer.cs index 67ea42d..81d4ba1 100644 --- a/Meade.net.focuser/Properties/Settings.Designer.cs +++ b/Meade.net.focuser/Properties/Settings.Designer.cs @@ -8,14 +8,18 @@ // //------------------------------------------------------------------------------ +using System.CodeDom.Compiler; +using System.Configuration; +using System.Runtime.CompilerServices; + namespace ASCOM.Meade.net.Properties { - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + [CompilerGenerated()] + [GeneratedCode("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.0.0.0")] + internal sealed partial class Settings : ApplicationSettingsBase { - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + private static Settings defaultInstance = ((Settings)(Synchronized(new Settings()))); public static Settings Default { get { diff --git a/Meade.net/AssemblyInfo.cs b/Meade.net/AssemblyInfo.cs index cfb8bda..74aba9f 100644 --- a/Meade.net/AssemblyInfo.cs +++ b/Meade.net/AssemblyInfo.cs @@ -1,7 +1,7 @@ using System; using System.Reflection; -using System.Runtime.InteropServices; using System.Resources; +using System.Runtime.InteropServices; namespace ASCOM.Meade.net { diff --git a/Meade.net/ClassFactory.cs b/Meade.net/ClassFactory.cs index 4626a2f..2ceeda1 100644 --- a/Meade.net/ClassFactory.cs +++ b/Meade.net/ClassFactory.cs @@ -1,6 +1,6 @@ using System; -using System.Runtime.InteropServices; using System.Collections; +using System.Runtime.InteropServices; namespace ASCOM.Meade.net { @@ -204,7 +204,6 @@ namespace ASCOM.Meade.net if (riid == IidIDispatch) { ppvObject = Marshal.GetIDispatchForObject(Activator.CreateInstance(_mClassType)); - return; } else if (riid == IidIUnknown) { diff --git a/Meade.net/LocalServer.cs b/Meade.net/LocalServer.cs index eceb526..8563ba4 100644 --- a/Meade.net/LocalServer.cs +++ b/Meade.net/LocalServer.cs @@ -12,17 +12,19 @@ // Modified by Chris Rowland and Peter Simpson to allow use with multiple devices of the same type March 2011 // // + using System; -using System.IO; -using System.Windows.Forms; using System.Collections; -using System.Runtime.InteropServices; +using System.ComponentModel; +using System.Diagnostics; +using System.IO; using System.Reflection; +using System.Runtime.InteropServices; +using System.Security.Principal; +using System.Threading; +using System.Windows.Forms; using ASCOM.Utilities; using Microsoft.Win32; -using System.Threading; -using System.Security.Principal; -using System.Diagnostics; namespace ASCOM.Meade.net { @@ -109,7 +111,7 @@ namespace ASCOM.Meade.net #region Private Data private static int _objsInUse; // Keeps a count on the total number of objects alive. private static int _serverLocks; // Keeps a lock count on this application. - private static FrmMain _sMainForm = null; // Reference to our main form + private static FrmMain _sMainForm; // Reference to our main form private static ArrayList _sComObjectAssys; // Dynamically loaded assemblies containing served COM objects private static ArrayList _sComObjectTypes; // Served COM object types private static ArrayList _sClassFactories; // Served COM object class factories @@ -293,7 +295,7 @@ namespace ASCOM.Meade.net Verb = "runas" }; try { Process.Start(si); } - catch (System.ComponentModel.Win32Exception) + catch (Win32Exception) { MessageBox.Show($"The {DriverName} was not {(arg == "/register" ? "registered" : "unregistered")} because you did not allow it.", DriverName, MessageBoxButtons.OK, MessageBoxIcon.Warning); } diff --git a/Meade.net/Localization/LocalisationHelper.cs b/Meade.net/Localization/LocalisationHelper.cs index d193826..a7d4565 100644 --- a/Meade.net/Localization/LocalisationHelper.cs +++ b/Meade.net/Localization/LocalisationHelper.cs @@ -1,7 +1,7 @@ using System.Globalization; -using System.Threading; -using System.Resources; using System.Reflection; +using System.Resources; +using System.Threading; namespace ASCOM.Meade.net.Localization { diff --git a/Meade.net/Properties/AssemblyInfo.cs b/Meade.net/Properties/AssemblyInfo.cs index a2c5fb1..c906d0b 100644 --- a/Meade.net/Properties/AssemblyInfo.cs +++ b/Meade.net/Properties/AssemblyInfo.cs @@ -23,4 +23,4 @@ using System.Runtime.InteropServices; [assembly: AssemblyVersion("0.0.0.0")] [assembly: AssemblyFileVersion("0.0.0.0")] -[assembly: ComVisibleAttribute(false)] +[assembly: ComVisible(false)] diff --git a/Meade.net/Properties/Resources.Designer.cs b/Meade.net/Properties/Resources.Designer.cs index 67c41c7..71e56bc 100644 --- a/Meade.net/Properties/Resources.Designer.cs +++ b/Meade.net/Properties/Resources.Designer.cs @@ -8,10 +8,16 @@ // //------------------------------------------------------------------------------ +using System.CodeDom.Compiler; +using System.ComponentModel; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Drawing; +using System.Globalization; +using System.Resources; +using System.Runtime.CompilerServices; + namespace ASCOM.Meade.net.Properties { - using System; - - /// /// A strongly-typed resource class, for looking up localized strings, etc. /// @@ -19,27 +25,27 @@ namespace ASCOM.Meade.net.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [DebuggerNonUserCode()] + [CompilerGenerated()] internal class Resources { - private static global::System.Resources.ResourceManager resourceMan; + private static ResourceManager resourceMan; - private static global::System.Globalization.CultureInfo resourceCulture; + private static CultureInfo resourceCulture; - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal Resources() { } /// /// Returns the cached ResourceManager instance used by this class. /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { + [EditorBrowsable(EditorBrowsableState.Advanced)] + internal static ResourceManager ResourceManager { get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ASCOM.Meade.net.Properties.Resources", typeof(Resources).Assembly); + if (ReferenceEquals(resourceMan, null)) { + ResourceManager temp = new ResourceManager("ASCOM.Meade.net.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; @@ -50,8 +56,8 @@ namespace ASCOM.Meade.net.Properties { /// Overrides the current thread's CurrentUICulture property for all /// resource lookups using this strongly typed resource class. /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { + [EditorBrowsable(EditorBrowsableState.Advanced)] + internal static CultureInfo Culture { get { return resourceCulture; } @@ -63,10 +69,10 @@ namespace ASCOM.Meade.net.Properties { /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// - internal static System.Drawing.Bitmap ASCOM { + internal static Bitmap ASCOM { get { object obj = ResourceManager.GetObject("ASCOM", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); + return ((Bitmap)(obj)); } } } diff --git a/Meade.net/SetupDialogForm.cs b/Meade.net/SetupDialogForm.cs index ff5b104..e1bb086 100644 --- a/Meade.net/SetupDialogForm.cs +++ b/Meade.net/SetupDialogForm.cs @@ -1,6 +1,8 @@ using System; using System.ComponentModel; +using System.Diagnostics; using System.Globalization; +using System.IO.Ports; using System.Runtime.InteropServices; using System.Windows.Forms; @@ -33,7 +35,7 @@ namespace ASCOM.Meade.net { try { - System.Diagnostics.Process.Start("http://ascom-standards.org/"); + Process.Start("http://ascom-standards.org/"); } catch (Win32Exception noBrowser) { @@ -51,7 +53,7 @@ namespace ASCOM.Meade.net chkTrace.Checked = profileProperties.TraceLogger; // set the list of com ports to those that are currently available comboBoxComPort.Items.Clear(); - comboBoxComPort.Items.AddRange(System.IO.Ports.SerialPort + comboBoxComPort.Items.AddRange(SerialPort .GetPortNames()); // use System.IO because it's static // select the current port if possible if (comboBoxComPort.Items.Contains(profileProperties.ComPort)) diff --git a/Meade.net/SetupDialogForm.designer.cs b/Meade.net/SetupDialogForm.designer.cs index af1859b..10e1f06 100644 --- a/Meade.net/SetupDialogForm.designer.cs +++ b/Meade.net/SetupDialogForm.designer.cs @@ -1,3 +1,6 @@ +using System.ComponentModel; +using System.Windows.Forms; + namespace ASCOM.Meade.net { partial class SetupDialogForm @@ -5,7 +8,7 @@ namespace ASCOM.Meade.net /// /// Required designer variable. /// - private System.ComponentModel.IContainer components = null; + private IContainer components = null; /// /// Clean up any resources being used. @@ -162,18 +165,18 @@ namespace ASCOM.Meade.net #endregion - private System.Windows.Forms.Button cmdOK; - private System.Windows.Forms.Button cmdCancel; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.PictureBox picASCOM; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.CheckBox chkTrace; - private System.Windows.Forms.ComboBox comboBoxComPort; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.TextBox txtGuideRate; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.Label lblPercentOfSiderealRate; - private System.Windows.Forms.Label label5; - private System.Windows.Forms.ComboBox cboPrecision; + private Button cmdOK; + private Button cmdCancel; + private Label label1; + private PictureBox picASCOM; + private Label label2; + private CheckBox chkTrace; + private ComboBox comboBoxComPort; + private Label label3; + private TextBox txtGuideRate; + private Label label4; + private Label lblPercentOfSiderealRate; + private Label label5; + private ComboBox cboPrecision; } } \ No newline at end of file diff --git a/Meade.net/SetupDialogForm.resx b/Meade.net/SetupDialogForm.resx index 69e65d4..84d89dc 100644 --- a/Meade.net/SetupDialogForm.resx +++ b/Meade.net/SetupDialogForm.resx @@ -1,4 +1,4 @@ - +