When using Query() and Form() diferent from 'everything' results the error: Specified method is not supported: String>.Add(String item)
Test case to simulate the error in DocTest.cs:
var url = "https://micro.prismic.io/api";
Api api = await TestHelper.GetApi(url);
var form = api.Form("doc").Ref(api.Master);
var query = form.Query(
Predicates.At("document.type", "docchapter"),
Predicates.Fulltext("my.docchapter.title", "Using with other projects")
);
Stacktrace:
String>.Add(String item)
SearchForm.Set(String field, String value) line 126
SearchForm.Query(String q) line 321
SearchForm.Query(IPredicate[] predicates) line 346
The main problem is within the StringValues.Add() that is not supported, besides it implement the ICollection interface. In Form.cs we can use StringValues.Concat(data[field], value); instead of .Add() to concatenate the values. I´ll submit a PR with the tests cases and the correction.
The proposed change will be:
public SearchForm Set(string field, string value)
{
if (value == null)
return this;
if (!form.Fields.TryGetValue(field, out var fieldDesc))
throw new ArgumentException("Unknown field", nameof(field));
if (fieldDesc.IsMultiple)
{
if (data.ContainsKey(field))
{
data[field] = StringValues.Concat(data[field], value);
}
else
{
data[field] = new StringValues(value);
}
}
else
{
data[field] = new StringValues(value);
}
return this;
}
When using
Query()
andForm()
diferent from 'everything' results the error:Specified method is not supported: String>.Add(String item)
Test case to simulate the error in
DocTest.cs
:Stacktrace:
The main problem is within the
StringValues.Add()
that is not supported, besides it implement theICollection
interface. InForm.cs
we can useStringValues.Concat(data[field], value);
instead of.Add()
to concatenate the values. I´ll submit a PR with the tests cases and the correction.The proposed change will be: