Enabling DataAnnotations in Full-Featured .NET Core Platforms

I created a .NET Core library project (package) that has this class:

public class Subscriber //: Representation
{
    [Required]
    public SubscriberDef Info;
    public Guid ProviderID;
}

No matter what I do, the compiler is not satisfied with the attribute [Required]. They constantly tell me:

NET Framework 4.5.1 - Not Available
NET Platform 5.4 - Available

My project.json initially looked like this:

"frameworks": {
  "net451": {
    "dependencies": {
      "WebApi.Hal": "2.6.0",
    }
  },
  "dotnet5.4": {
    "dependencies": {
      "Microsoft.CSharp": "4.0.1-beta-23516",
      "System.Collections": "4.0.11-beta-23516",
      "System.Linq": "4.0.1-beta-23516",
      "System.Runtime": "4.0.21-beta-23516",
      "System.Threading": "4.0.11-beta-23516",
    }
  }
},
"dependencies": {
  "Excqape": "0.7.0",
  "System.ComponentModel.Annotations": "4.0.11-beta-23516"
}

I tried switching the scroll target structure (TFM) from net451to net46. Bad luck. I tried different versions of System.ComponentModel.Annotations that are used for both frameworks, so far no luck.

What is especially strange is that if I create an ASP.NET Core project, then I am free to have two structures in which data annotations are respected and compiled:

"frameworks": {
  "dnx46": { },
  "dnxcore50": { }
},

I believe that if data annotations work inside ASP.NET Core, then will they certainly work in .NET Core?

- .NET Core fullCLR ?

+4

All Articles