Skip to content

Commit

Permalink
[Code refactoring] Make code comment and NullOrEmpty check more clear (
Browse files Browse the repository at this point in the history
…#13352)

* Clarify code

* grammar fix

* comment change
  • Loading branch information
htcfreek committed Sep 22, 2021
1 parent b05378c commit a0ebe5e
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,14 @@ public string EncoderGuid

public void AddRow(string sizeNamePrefix)
{
// Without validation we get warning CA1062 when unsing the parameter variable sizeNamePrefix
string prefixString = string.IsNullOrEmpty(sizeNamePrefix) ? "New Size" : sizeNamePrefix;
/// This is a fallback validation to eliminate the warning "CA1062:Validate arguments of public methods" when using the parameter (variable) "sizeNamePrefix" in the code.
/// If the parameter is unexpectedly empty or null, we fill the parameter with a non-localized string.
/// Normally the parameter "sizeNamePrefix" can't be null or empty because it is filled with a localized string when we call this method from <see cref="UI.Views.ImageResizerPage.AddSizeButton_Click"/>.
sizeNamePrefix = string.IsNullOrEmpty(sizeNamePrefix) ? "New Size" : sizeNamePrefix;

ObservableCollection<ImageSize> imageSizes = Sizes;
int maxId = imageSizes.Count > 0 ? imageSizes.OrderBy(x => x.Id).Last().Id : -1;
string sizeName = GenerateNameForNewSize(imageSizes, prefixString);
string sizeName = GenerateNameForNewSize(imageSizes, sizeNamePrefix);

ImageSize newSize = new ImageSize(maxId + 1, sizeName, ResizeFit.Fit, 854, 480, ResizeUnit.Pixel);
newSize.PropertyChanged += SizePropertyChanged;
Expand Down

0 comments on commit a0ebe5e

Please sign in to comment.