B2026 053 find unlinked values of selected #795
Reference in New Issue
Block a user
Delete Branch "B2026-053-Find-Unlinked-Values-of-Selected"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Likely shouldn't be changes to: ItemExt.cs, VlnFlexGrid.cs, VlnFlexGrid.Designer.cs, & DisplaySearch.Designer.cs
With the Tech debt project we will be changing every file in PROMS - thus we need to limit our changes to necessary ones to avoid unnecessary Merge Conflicts later on.
ItemExt.cs looks to only have spacing changes so shouldn't be included.
VlnFlexGrid.cs & VlnFlexGrid.Designer.cs appear relaed to another project.
DisplaySearch.Designer.cs - changes appear by accident by opening in the designer.
@@ -7279,6 +7279,7 @@ namespace VEPROMS.CSLA.Library_ByWordSuffix = byWordSuffix;}}Thinking this shouldn't be included for adding 1 blank line --- with the Tech debt project we will be changing every file in PROMS - thus we need to limit our changes to necessary ones to avoid unnecessary Merge Conflicts later on.
@@ -2193,0 +2199,4 @@if (match.Success) // Special case for percents.{int sl = SearchString.Length;int precentIdx = SearchString.LastIndexOf('%');What if multiple % signs? - like search for:
3% or 4% --- I believe the matches returned by the Regex object will give position of what is found.
@@ -2193,0 +2205,4 @@{ss = SearchString.Substring(startIndex, sl - 1);var isNumeric = int.TryParse(ss, out int n);if (isNumeric == true) // B2026-053 other that a % are the rest of the characters numbers.With working on tech debt project --- moving forward need to follow suggested code practices / suggestions by SonarLint --- if (isNumeric == true) should be
if (isNumeric)
@@ -2193,0 +2207,4 @@var isNumeric = int.TryParse(ss, out int n);if (isNumeric == true) // B2026-053 other that a % are the rest of the characters numbers.{ss = ' ' + SearchString + ' '; // to get exact match add spaces before and after search string.With working on technical debt - should avoid concatenating strings & use string interpolation instead.
@@ -2193,0 +2211,4 @@}else{ss = ' ' + SearchString + ' '; // string it not a percent.With working on technical debt - should avoid concatenating strings & use string interpolation instead.
@@ -2193,0 +2221,4 @@int strIdx2 = 0;if (strl2 == prcIdx2 + 1) // if the last char is ' ' the last char.{ss = ' ' + SearchString; //B2026-053 add a space prefix to make the search exact. If search is 5% this makes it excult 25% 55% etc.;With working on technical debt - should avoid concatenating strings & use string interpolation instead.
@@ -2193,0 +2225,4 @@}else{ss = ' ' + SearchString + ' '; // Exact match add spaces before and after search string.With working on technical debt - should avoid concatenating strings & use string interpolation instead.
@@ -2193,0 +2231,4 @@}else{ss = ' ' + SearchString + ' '; // Exact match add spaces before and after search string.With working on technical debt - should avoid concatenating strings & use string interpolation instead.
I think there is a mis-understanding on what the B2026-053 was asking to be fixed.
It was to generically find only exact matches of ANY RO return value.
The % statement was just an example showing how, the search results gets cluttered with "matches" that are of no interest to the user.
B2026-053 text:
"Performing a referenced object global search for a particular value with the "Find Unlinked Values of Selected" option check should not return partial matches."
VlnFlexGrid.Designer.cs should not be included --- looks like there were spacing changes.
Should there be any changes to DisplaySearch.Designer.cs? --- I thought we were just changing how the search behaved, not anything visually on the form? --- if there were no UI changes, this probably shouldn't have changes also.
Also - branch needed updated - I updated it but you will have to pull it down locally before making further changes/fixes.
by always adding a space before the search text, it will not find places where the unlinked RO Value is the first thing on the line. Ex. an Equipment List might have only the unlinked RO Value.
I noticed that the last two fields in the call to GetListFromTextSearch() are for a "by word" text search and passes in a Regx expression. Could that be used? - look for "if (cbxByWord.Checked)"
@@ -2190,6 +2191,25 @@ namespace Volian.Controls.LibraryOnSearchComplete(new DisplaySearchEventArgs(TimeSpan.FromTicks(DateTime.Now.Ticks - start.Ticks)));}private string exactsearch(string SearchString) // B2026-053by always adding a space before the search text, it will not find places where the unlinked RO Value is the first thing on the line. Ex. an Equipment List might have only the unlinked RO Value.
I noticed that the last two fields in the call to GetListFromTextSearch() are for a "by word" text search and passes in a Regx expression. Could that be used? - look for "if (cbxByWord.Checked)"
See Note Regarding Regex performance
@@ -2083,0 +2081,4 @@string byWordPrefix = string.Empty;string byWordSuffix = string.Empty;if (Regex.IsMatch(ROSearchList, @"^[\d\.]")) // starts with a number or '.' decimal ptlines 2092 - 2099 - the setting of ByWordPrefeix and ByWordSuffixL
Regexes are very hard on applications performance wise --- If just want to determine if a string ends in a Number, can't you use something like:
char.IsNumber(ROSearchList, ROSearchList.Length - 1);
char.IsLetter(ROSearchList, ROSearchList.Length - 1);
char.IsNumber(ROSearchList, 0);
char.IsLetter(ROSearchList, 0);
There are also functions like char.IsDigit if needed.
Obviously, you would need to 1st check that temp.Length > 0
Side question - if all we are doing is adding a regex prefix/suffix onto the checking code --- could we end up with stuff like 3.5 matching 3.52 since both end in a number and contain 3.5 ? -- You may be able to do something like pull back all the matches and then use LINQ to filter the list to ones that either end with the match or contain a space/bracket/parenthesis/punctuation after the match .
Matt,
I don't know if this makes any difference, but the byWordPrex and byWordSuffix strings get passed to a SQL stored procedure.
That same code is used above this code block for doing a By Word text search. I was going to suggest that instead of copying the code, to make it it's own function and call it in the two places.
Would agree - if it is repeated code / a repeated idea - better to make it it's own function. That being said, while regexes are necessary in some places, any place that it works where we can replace a call with function calls like char.IsNumeric, it will benefit performance,
Previous comments regarding Regexes still apply -- also it appears now we have 2 variables that we declared but did not use in string byWordPrefix & string byWordSuffix
@@ -2192,1 +2182,4 @@Dictionary<string, string> settings = new Dictionary<string, string>();string byWordPrefix = string.Empty;Previous comments regarding Regexes still apply -- also it appears now we have 2 variables that we declared but did not use in string byWordPrefix & string byWordSuffix
I removed the two unneeded variable declarations. I used what was previous used for the regex string. If you notice both tests are looking to see what the first character is and not the whole searchstring and from that it selects different regex strings. On account of this I am not sure char.IsNumeric will work because there are searchstrings that start with a number but are a mix of numbers and characters. Example 5% code: "if (Regex.IsMatch(ss, @"^[\d.]")) // starts with a number or '.' decimal pt"
@@ -2046,0 +2020,4 @@//if (cbxByWord.Checked)//{// // Generate a prefix & suffix to be used in the sql query around the search string.Please move this descriptive comment (the stuff inside the curly braces) into the function you had created.
Then remove the rest of the stuff you had commented out.
@@ -2191,1 +2175,4 @@}private string GetByWordSettings(string ss, bool checkstart){//if (Regex.IsMatch(ss, @"^[\d\.]")) // starts with a number or '.' decimal ptPlease remove the code you had commented out.
Need to look at comments --- what is commented out code and should be removed & where non-code comments should be moved to.
Also, noticed
if (cbxByWord.Checked)
was commented out - does that change some of the purpose for that code?
In testing doc would be sure to include testing for both searches & if cbxByWord is checked / unchecked.
@@ -2044,2 +2020,2 @@}}//if (cbxByWord.Checked)Was this if intentionally commented out? -- just checking since doesn't it change the logic around this other search --- for testing would make sure both searches tested with the different options.
Thanks, that code needs to be there and account of that I need to change the logic for updating the pre and post additions.
I'm good with the changes
Looks Good. Ready For QA.