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

Unable to use data annotations in .net core 1.0

与早期测试版 (dnx) 时代的 一样,我正在尝试将代码移植到 .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?

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

您正在寻找 System.Runtime 包内的 System.Runtime.AttributeUsageAttribute.NET Standard 1.0 及以上可用。

编辑: 对不起。你问的是 ValidationAttribute,而不是 AttributeUsage,我的错。反向包search points to System.ComponentModel.Annotations,