From bc92ae4d2b1281825108887c55ea6d54cdb40ea4 Mon Sep 17 00:00:00 2001 From: jsakamoto Date: Sat, 2 Dec 2023 20:05:55 +0900 Subject: [PATCH] Refactor ToKeys method to ToStringKeys --- HotKeys2.Test/HotKeyEntryTest.cs | 12 ++++++------ HotKeys2/HotKeyEntry.cs | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/HotKeys2.Test/HotKeyEntryTest.cs b/HotKeys2.Test/HotKeyEntryTest.cs index 9219732..65335eb 100644 --- a/HotKeys2.Test/HotKeyEntryTest.cs +++ b/HotKeys2.Test/HotKeyEntryTest.cs @@ -37,22 +37,22 @@ public void ToString_for_ByCode_Test() } [Test] - public void ToKeys_for_ByCode_Test() + public void ToStringKeys_for_ByCode_Test() { var ctrl_alt_f12 = new HotKeyEntryByCode(null!, ModCode.Ctrl | ModCode.Alt, Code.F12, _ => ValueTask.CompletedTask, null, new() { Description = "Set the volume level to 10." }); - ctrl_alt_f12.ToKeys().IsStructuralEqual(new[] { "Ctrl", "Alt", "F12" }); + ctrl_alt_f12.ToStringKeys().IsStructuralEqual(new[] { "Ctrl", "Alt", "F12" }); var meta_one = new HotKeyEntryByCode(null!, ModCode.Meta, Code.Num1, _ => ValueTask.CompletedTask, null, new() { Description = "Launch the notepad." }); - meta_one.ToKeys().IsStructuralEqual(new[] { "Meta", "1" }); + meta_one.ToStringKeys().IsStructuralEqual(new[] { "Meta", "1" }); var u = new HotKeyEntryByCode(null!, ModCode.None, Code.U, _ => ValueTask.CompletedTask, null, new() { Description = "Increment counter." }); - u.ToKeys().IsStructuralEqual(new[] { "U" }); + u.ToStringKeys().IsStructuralEqual(new[] { "U" }); } [Test] - public void ToKeys_for_ByKey_Test() + public void ToStringKeys_for_ByKey_Test() { var hotKeyEntry = new HotKeyEntryByKey(null!, ModKey.None, Key.Question, _ => ValueTask.CompletedTask, null, new() { Description = "Show help." }); - hotKeyEntry.ToKeys().IsStructuralEqual(new[] { "?" }); + hotKeyEntry.ToStringKeys().IsStructuralEqual(new[] { "?" }); } } diff --git a/HotKeys2/HotKeyEntry.cs b/HotKeys2/HotKeyEntry.cs index 1b87b63..fe64d18 100644 --- a/HotKeys2/HotKeyEntry.cs +++ b/HotKeys2/HotKeyEntry.cs @@ -116,14 +116,14 @@ protected void CommonProcess(Func action) /// {0} will be replaced with key combination text, and {1} will be replaced with description of this hotkey entry object. public string ToString(string format) { - var keyComboText = string.Join(" + ", this.ToKeys()); + var keyComboText = string.Join(" + ", this.ToStringKeys()); return string.Format(format, keyComboText, this.Description); } /// /// Returns an array of String formatted keys. /// - public string[] ToKeys() + public string[] ToStringKeys() { var keyCombo = new List(); if (this._Modifiers != 0)