Skip to content

Commit 50fba3b

Browse files
committed
more fixes
1 parent d518622 commit 50fba3b

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

Guify.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<Nullable>enable</Nullable>
66
<RepositoryUrl>https://github.com/Quantumzhao/Guify</RepositoryUrl>
77
<Authors>Quantumzhao</Authors>
8-
<Version>1.0.0</Version>
8+
<Version>1.0.1</Version>
99
<Company>Quantum</Company>
1010
<!--Avalonia doesen't support TrimMode=link currently,but we are working on that https://github.com/AvaloniaUI/Avalonia/issues/6892 -->
1111
<TrimMode>copyused</TrimMode>

Models/Components/OpenFileField.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class OpenFileField : FieldBase<string[]?>
88
public OpenFileField(string? customDefaultFileName, string? customDefaultFolder,
99
bool? allowMultiple, bool isRequired, string description
1010
, string? longName, string? shortName, bool useEqualConnector) : base(
11-
new[] { Path.Join(customDefaultFolder, customDefaultFileName) }
11+
JoinPath(customDefaultFolder, customDefaultFileName)
1212
, isRequired, longName, shortName, description, useEqualConnector)
1313
{
1414
CustomDefaultFileName = customDefaultFileName;
@@ -21,5 +21,15 @@ public OpenFileField(string? customDefaultFileName, string? customDefaultFolder,
2121
public string? CustomDefaultFileName { get; init; }
2222

2323
public override string ValueToString(string[]? value)
24-
=> string.Join(' ', value ?? Array.Empty<string>());
24+
=> string.Join(' ', (value ?? Array.Empty<string>()).Select(Escape));
25+
26+
private static string[]? JoinPath(string? folder, string? file)
27+
=> (folder, file) switch
28+
{
29+
(not null, not null) => new[] { Path.Join(folder, file) },
30+
_ => null
31+
};
32+
33+
private static string Escape(string s)
34+
=> '\"' + s.Replace("\"", "\\\"") + '\"';
2535
}

Models/Verb.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ public Verb(string label, string comment, ComponentBase[] items)
1919
public bool IsUsingThis { get; set; } = false;
2020

2121
public string Compile()
22-
=> Name + " " + string.Join(' ', Items.Select(i => i.Compile()));
22+
=> Name + " " + string.Join(' ', Items.Select(i => i.Compile())
23+
.Where(s => !string.IsNullOrWhiteSpace(s)));
2324
}

0 commit comments

Comments
 (0)