| @@ -96,13 +96,20 @@ namespace Discord.Commands | |||||
| PropertyInfo GetPropAndValue(out string argv) | PropertyInfo GetPropAndValue(out string argv) | ||||
| { | { | ||||
| bool quoted = state == ReadState.InQuotedArgument; | |||||
| state = (currentRead == input.Length) | state = (currentRead == input.Length) | ||||
| ? ReadState.End | ? ReadState.End | ||||
| : ReadState.LookingForParameter; | : ReadState.LookingForParameter; | ||||
| var prop = _tProps[currentParam]; | |||||
| argv = input.Substring(beginRead, currentRead - beginRead); | |||||
| return prop; | |||||
| if (quoted) | |||||
| { | |||||
| argv = input.Substring(beginRead + 1, currentRead - beginRead - 1); | |||||
| currentRead++; | |||||
| } | |||||
| else | |||||
| argv = input.Substring(beginRead, currentRead - beginRead); | |||||
| return _tProps[currentParam]; | |||||
| } | } | ||||
| } | } | ||||
| @@ -1,4 +1,4 @@ | |||||
| <Project Sdk="Microsoft.NET.Sdk"> | |||||
| <Project Sdk="Microsoft.NET.Sdk"> | |||||
| <PropertyGroup> | <PropertyGroup> | ||||
| <OutputType>Exe</OutputType> | <OutputType>Exe</OutputType> | ||||
| <RootNamespace>Discord</RootNamespace> | <RootNamespace>Discord</RootNamespace> | ||||
| @@ -24,8 +24,8 @@ | |||||
| <PackageReference Include="Akavache" Version="5.0.0" /> | <PackageReference Include="Akavache" Version="5.0.0" /> | ||||
| <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" /> | <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" /> | ||||
| <PackageReference Include="Newtonsoft.Json" Version="11.0.2" /> | <PackageReference Include="Newtonsoft.Json" Version="11.0.2" /> | ||||
| <PackageReference Include="xunit" Version="2.3.1" /> | |||||
| <PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" /> | |||||
| <PackageReference Include="xunit.runner.reporters" Version="2.3.1" /> | |||||
| <PackageReference Include="xunit" Version="2.4.0" /> | |||||
| <PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" /> | |||||
| <PackageReference Include="xunit.runner.reporters" Version="2.4.0" /> | |||||
| </ItemGroup> | </ItemGroup> | ||||
| </Project> | </Project> | ||||
| @@ -32,6 +32,32 @@ namespace Discord | |||||
| Assert.Equal(expected: 42, actual: m.Foo); | Assert.Equal(expected: 42, actual: m.Foo); | ||||
| Assert.Equal(expected: "hello", actual: m.Bar); | Assert.Equal(expected: "hello", actual: m.Bar); | ||||
| } | } | ||||
| [Fact] | |||||
| public async Task TestQuotedArgumentValue() | |||||
| { | |||||
| var commands = new CommandService(); | |||||
| var module = await commands.AddModuleAsync<TestModule>(null); | |||||
| Assert.NotNull(module); | |||||
| Assert.NotEmpty(module.Commands); | |||||
| var cmd = module.Commands[0]; | |||||
| Assert.NotNull(cmd); | |||||
| Assert.NotEmpty(cmd.Parameters); | |||||
| var param = cmd.Parameters[0]; | |||||
| Assert.NotNull(param); | |||||
| Assert.True(param.IsRemainder); | |||||
| var result = await param.ParseAsync(null, "bar: 《hello》 foo: 42"); | |||||
| Assert.True(result.IsSuccess); | |||||
| var m = result.BestMatch as ArgumentType; | |||||
| Assert.NotNull(m); | |||||
| Assert.Equal(expected: 42, actual: m.Foo); | |||||
| Assert.Equal(expected: "hello", actual: m.Bar); | |||||
| } | |||||
| } | } | ||||
| [NamedArgumentType] | [NamedArgumentType] | ||||