I have started a very simple "kick the tires" ASP.Net MVC (beta) project in VS2015 and am having an issue wrapping my head around the DNX and DNX Core references.
In this example I am trying to use DateTime.ToShortDateString()
and have the intellisense for DNX Core enabled.
I understand that this is because this isn't implemented in DNX Core and I can wrap compiler directives around it.
Is this the correct approach? Are the differences between the two platforms documented anywhere? Finally, if I'm an all Windows, all IIS all the time shop does the DNX Core offer anything or should my first task to be to just remove it from the project.json file?
DNX, a Dot Net eXecution environment, contains all of the code that is required to bootstrap and run an application. It includes the compilation system, SDK tools and the native CLR host, with NuGet packages being used to access assemblies that are referenced by the application.
DNX Digital Services Platform is an intelligent open digital platform that allows individual services to operate across a cohesive environment, with seamless access to your organisation's data. DNX is open, flexible, adaptable, secure and agile.
I guess the only answer is it depends.
Dnx runs on top of today's .NET framework (as well as mono), and has access to the full .NET 4.5.2 (now .NET 4.6) BCL. Basically everything has been added to .NET since 1.0.
Dnx Core runs ontop of the CoreClr which is essentially a stripped down version of the .NET Framework. Some things are missing, some things will never be coming over to CoreClr for various reasons. I don't know of a specific list of what is coming / not coming. You can poke around on the corefx and coreclr github projects to see what is there.
Now the question is really about the best approach. You have a few choices.
If you're not ever planning on running the project on the CoreCLR, then you can remove it from your project.json all together.
If you do plan on to run on CoreCLR (whatever the reason may be) you can do a few things.
Use the common API methods for the environment
In your case if theDate.ToString("d")
is equivalent to theDate.ToShortDateString()
then why not just use the former?
Use the appropriate compiler directive DNX451
, etc.
For environments that don't have an implementation of what you're looking for you can throw or implement your own version if it makes sense.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With