From b187502d92875fbf88227e399b3dfd503b5ddf6d Mon Sep 17 00:00:00 2001 From: Tyrel Souza Date: Tue, 26 Jul 2022 01:56:22 -0400 Subject: [PATCH] solidify variable types from var --- BenchtopParser/ProgramConfig.cs | 12 +++++------ BenchtopParser/TransducerVerify.cs | 22 ++++++++++----------- BenchtopParserTests/Program_Config_Tests.cs | 2 +- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/BenchtopParser/ProgramConfig.cs b/BenchtopParser/ProgramConfig.cs index b11ae4f..1927147 100644 --- a/BenchtopParser/ProgramConfig.cs +++ b/BenchtopParser/ProgramConfig.cs @@ -31,7 +31,7 @@ namespace BenchtopParser { public void AddToGroup(String group, Configuration config) { // UGLY - but helpful later. // TODO: Find out what the config names are and MAKE A MAP - var name = config.name; + string name = config.name; if (name == null) { throw new Exception("Name is null, adding before Config has set name"); } @@ -81,7 +81,7 @@ namespace BenchtopParser { public ProgramConfig(String program_config_value) { Program? current = null; - foreach (var line in program_config_value.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) { + foreach (string line in program_config_value.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) { List configLine = line.Split("\t").ToList(); if (configLine.Count < 2) { throw new Exception("Invalid Program Config, please provide an I28 Program Config file data"); @@ -107,7 +107,7 @@ namespace BenchtopParser { // TODO: What if multiple configs how to handle start and stop? break; } - var config = configLine[0].Split(",", 2).ToList(); + List config = configLine[0].Split(",", 2).ToList(); if (configLine.Count == 1) { // Set Program Number if (current == null) { @@ -118,10 +118,10 @@ namespace BenchtopParser { } /* CREATE A CONFIGURATION */ - var value = config[1]; + string value = config[1]; - var programnumber_group_data = value.Split('\\'); // snake case as its three values - var data = programnumber_group_data[2]; + string[] programnumber_group_data = value.Split('\\'); // snake case as its three values + string data = programnumber_group_data[2]; if (data.StartsWith("=")) { continue; /* comment line */ } Configuration lineConfig = new(configLine, data); diff --git a/BenchtopParser/TransducerVerify.cs b/BenchtopParser/TransducerVerify.cs index 4147453..b0c6a48 100644 --- a/BenchtopParser/TransducerVerify.cs +++ b/BenchtopParser/TransducerVerify.cs @@ -19,31 +19,31 @@ namespace BenchtopParser { }; } public void SetIndent(int id, String line) { - var endOfCurrentTransducerKey = $"Transducer {id}".Length; - var restOfLine = line.Substring(endOfCurrentTransducerKey); - var additionalSpaces = restOfLine.TakeWhile(c => c == ' ').Count(); + int endOfCurrentTransducerKey = $"Transducer {id}".Length; + string restOfLine = line.Substring(endOfCurrentTransducerKey); + int additionalSpaces = restOfLine.TakeWhile(c => c == ' ').Count(); // length 1 based, remove 1, then add additional spaces this.indent = endOfCurrentTransducerKey - 1 + additionalSpaces; } public TransducerVerify(String transducer_verify_value) { - var separator = "==============================================================="; - var documentLines = transducer_verify_value.Split(new string[] { Environment.NewLine }, StringSplitOptions.TrimEntries).ToList(); + string separator = "==============================================================="; + List documentLines = transducer_verify_value.Split(new string[] { Environment.NewLine }, StringSplitOptions.TrimEntries).ToList(); // Check if proper document - var title = documentLines[0]; + string title = documentLines[0]; documentLines.RemoveAt(0); if (title != "|| Transducer Verify Report ||") { throw new Exception("Invalid Transducer Verify Report, please provide a Transducer Verify Report file data"); } - var countDict = documentLines.GroupBy(p => p).ToDictionary(p => p.Key, q => q.Count()); - var numTransducers = countDict[separator]; - var currentTransducer = 0; // ONE BASED - will add 1 later at check step, but first transducer is 1. + Dictionary countDict = documentLines.GroupBy(p => p).ToDictionary(p => p.Key, q => q.Count()); + int numTransducers = countDict[separator]; + int currentTransducer = 0; // ONE BASED - will add 1 later at check step, but first transducer is 1. // Find the the indexes of each transducer start and stop for (int i = 0; i < documentLines.Count(); i++) { - var line = documentLines[i]; + string line = documentLines[i]; if (line == $"TRANSDUCER{currentTransducer + 1}") { currentTransducer++; continue; // Skip TITLE line and separator @@ -66,7 +66,7 @@ namespace BenchtopParser { continue; } // Add transducer parameters - var _line = SplitLine(line); + string[] _line = SplitLine(line); if (transducers != null) { transducers[currentTransducer].parameters[_line[0]] = _line[1]; } else { diff --git a/BenchtopParserTests/Program_Config_Tests.cs b/BenchtopParserTests/Program_Config_Tests.cs index 7fd0db3..ed2a6be 100644 --- a/BenchtopParserTests/Program_Config_Tests.cs +++ b/BenchtopParserTests/Program_Config_Tests.cs @@ -43,7 +43,7 @@ namespace BenchtopParserTests { BenchtopParser.Program program = new(); program.AddToGroup(group, config); - var check = program.X["namename"]; + BenchtopParser.Configuration check = program.X["namename"]; Assert.That(check, Is.EqualTo(config)); } }