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

War*_* P 4 c# data-annotations visual-studio-2015 .net-core

就像早期测试版 (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
    ...
Run Code Online (Sandbox Code Playgroud)

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

Ger*_*oli 5

我使用非官方的反向包搜索来搜索新的 Microsoft 开源包中的类。

您正在寻找System.Runtime.AttributeUsageAttribute内部System.Runtime包。它适用于.NET Standard 1.0及以上。

编辑:对不起。你问的是ValidationAttribute,不是AttributeUsage,我的不好。反向包搜索指向System.ComponentModel.Annotations