使用 NO 构造函数实例化 class 会导致 'does not contain constructor which takes 0 arguments' 错误
Instantiating class with NO constructor results in 'does not contain constructor which takes 0 arguments' error
我正在尝试从 Azure.Search.Documents 库中实例化一个 FacetResult
:
var facetResult = new Azure.Search.Documents.Models.FacetResult();
VS 告诉我 class 不包含零参数的构造函数。当我检查 class 的元数据时 - 没有构造函数。
查看 the docs for the class 似乎可以确认没有构造函数 - 那么问题是什么?
I'm having the same issue with other library classes with no constructors such as Azure.Storage.Blobs.Models.BlobItem, while classes which appear to explicitly declare a parameterless constructor seem fine, such as System.Exception
非常感谢任何对此的帮助,它阻止了我的单元测试!
这个 class 的构造函数是内部的。
实例可能由工厂创建和返回。
//src code @ https://github.com/Azure/azure-sdk-for-net/
namespace Azure.Search.Documents.Models
{
/// <summary> A single bucket of a facet query result. Reports the number of documents with a field value falling within a particular range or having a particular value or interval. </summary>
public partial class FacetResult
{
/// <summary> Initializes a new instance of FacetResult. </summary>
internal FacetResult()
{
AdditionalProperties = new ChangeTrackingDictionary<string, object>();
}
/// <summary> Initializes a new instance of FacetResult. </summary>
/// <param name="count"> The approximate count of documents falling within the bucket described by this facet. </param>
/// <param name="additionalProperties"> Additional Properties. </param>
internal FacetResult(long? count, IReadOnlyDictionary<string, object> additionalProperties)
{
Count = count;
AdditionalProperties = additionalProperties;
}
我正在尝试从 Azure.Search.Documents 库中实例化一个 FacetResult
:
var facetResult = new Azure.Search.Documents.Models.FacetResult();
VS 告诉我 class 不包含零参数的构造函数。当我检查 class 的元数据时 - 没有构造函数。
查看 the docs for the class 似乎可以确认没有构造函数 - 那么问题是什么?
I'm having the same issue with other library classes with no constructors such as Azure.Storage.Blobs.Models.BlobItem, while classes which appear to explicitly declare a parameterless constructor seem fine, such as System.Exception
非常感谢任何对此的帮助,它阻止了我的单元测试!
这个 class 的构造函数是内部的。 实例可能由工厂创建和返回。
//src code @ https://github.com/Azure/azure-sdk-for-net/
namespace Azure.Search.Documents.Models
{
/// <summary> A single bucket of a facet query result. Reports the number of documents with a field value falling within a particular range or having a particular value or interval. </summary>
public partial class FacetResult
{
/// <summary> Initializes a new instance of FacetResult. </summary>
internal FacetResult()
{
AdditionalProperties = new ChangeTrackingDictionary<string, object>();
}
/// <summary> Initializes a new instance of FacetResult. </summary>
/// <param name="count"> The approximate count of documents falling within the bucket described by this facet. </param>
/// <param name="additionalProperties"> Additional Properties. </param>
internal FacetResult(long? count, IReadOnlyDictionary<string, object> additionalProperties)
{
Count = count;
AdditionalProperties = additionalProperties;
}