无法在.net core 1.0中使用数据注释

时间:2016-07-26 18:02:49

标签: c# visual-studio-2015 data-annotations .net-core

与早期beta(dnx)天的this question一样,我正在尝试将代码移植到.net core 1.0 rtm,并且代码在以下单元上回复,其中包含ValidationAttribute类型和其他内容:

using System.ComponentModel.DataAnnotations;

namespace Hl7.Fhir.Introspection
{
    [AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = false)]
    public sealed class FhirElementAttribute : ValidationAttribute
    ...

如何将此类代码移植到dotnet core 1.0 rtm?

1 个答案:

答案 0 :(得分:4)

我使用非官方的Reverse Package Search来搜索新的Microsoft开源软件包中的类。

您正在寻找System.Runtime.AttributeUsageAttributeSystem.Runtime套餐。它适用于.NET Standard 1.0及以上。

编辑: 抱歉。您问的是ValidationAttribute,而不是AttributeUsage,我的不好。反向包search指向System.ComponentModel.Annotations