mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-19 06:53:26 +08:00
[Code refactoring] Make code comment and NullOrEmpty check more clear (#13352)
* Clarify code * grammar fix * comment change
This commit is contained in:
parent
b05378cdf7
commit
a0ebe5ed54
@ -252,12 +252,14 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
||||
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user