2016-07-26 69 views
4

与早期beta(dnx)天的this question类似,我试图将代码移植到.net core 1.0 rtm,并且代码在以下单元中回复,其中包含诸如ValidationAttribute类型和其他内容:无法在.net核心1.0中使用数据注释

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?

+0

一些早期的测试版日期表明单元名称已更改为System.ComponentModel.Annotations,但这不起作用。 –

+1

你有没有试过[this](https://www.nuget.org/packages/System.ComponentModel.Annotations/4.1.0-rc2-24027)? – lokusking

+0

哦,这是预发布位,但不是一个dotnet-RC2级别的位 –

回答

4

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

您正在寻找System.Runtime包装内的System.Runtime.AttributeUsageAttribute。它可用于.NET Standard 1.0及以上。编辑: 对不起。你问的是ValidationAttribute,而不是AttributeUsage,我的不好。反向包search指向System.ComponentModel.Annotations,

+0

谢谢。为我节省了很多时间。 –