New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DateTime does not contain a definition for 'ToShortDateString' #4783
Comments
.NET Core is a subset of .NET Framework and not all types and methods are available. And not all methods are really needed:
|
I'm aware about ToXString equivalent, I can get satisfied with a workaround. |
@adun are you talking differences between the desktop and coreclr? if this is the case, we already have many differences between these 2 platforms as we don't support all the desktop public surface. please let me know if you mean something else. I agree we can expose these APIs just for convenience usages. but we have to be aware we'll have different ways to achieve the same results. I am listing the workaround explicitly here for the record. ToShortDateString use DateTime.ToString("d") ToOADate is for OLE which became not popular scenario |
To the review guys. the suggestion is to expose the following APIs for convenience usage reason only: namespace System I am not strangely believe we need to expose ToOADate as it is for OLE automation scenario which is not popular scenario anymore but I listed the API just to get it into the discussion |
+1 |
This really isn't "for convenience usage reason only", but rather a compatibility issue. Yes, the ToShortxxxString() and ToLongxxxString() methods have a corresponding ToString() method. That's not the issue. The issue is that by removing these methods, you break the upgrade scenario for a lot of projects simply by not having those calls. (By the way, they seem to have been present in earlier versions of .NET Core.) These methods all still exist in the 1.0 release as well: https://github.com/dotnet/coreclr/blob/release/1.0.0/src/mscorlib/src/System/DateTime.cs#L1121 So, why are they not being made available? |
Agreed, should be available, mostly for compatibility. Using this fix meanwhile :
|
we are currently evaluating the compat work across the board. so most likely we'll bring all missing APIs back. https://github.com/dotnet/corefx/issues/9643#issuecomment-230459531 |
(I added the emphasis.) Please don't just simply bring back all of the missing APIs. The direction .NET Core is taking of removing APIs (that are unused, little used or redundant) and trimming the API surface is the right direction overall. The real problems here are:
For some of these redundant APIs (like I think the approach should be to _add back only those APIs that make sense to add and don't prevent .NET Core from being able to run on all platforms_. If it should be added back but might limit what platforms it can run on, it should be added through a NuGet package that allows the developer to take an explicit dependency on it (and therefor acknowledging that they're limiting the availability). |
CC @danmosemsft |
Broadly, the criteria we're right now using for growing .NET Core API parity include: is it available to Xamarin mobile apps at the base class layer (and if implemented - we implement). That certainly includes many types and members that already have alternatives, or are problematic in one way or another, but it's important to us that we make it easy for existing code to work on .NET Core. We're also valuing "just works without recompilation" which makes it tough to avoid specific API. When we bring API back to help bring existing codebases to .NET Core, there's still several ways we can try to steer developers from writing new code against them, such as: not referencing by default, or using analyzers or other tools to help flag the code. Our blog post explains the reasoning. We promised more concrete details and we'll follow up soon with that. |
This was completed already. |
Description
I'm facing an issue using System.DateTime class. I've got the following error:
with: ToShortDateString(), ToShortTimeString(), ToLongDateString(), ToLongTimeString(), ToOADate() and maybe more.
But ToLocalTime() works fine.
I've checked the sources, those methods exists.
https://github.com/dotnet/coreclr/blob/release/1.0.0-rc1/src/mscorlib/src/System/DateTime.cs#L1146
I'm working under OSX El Capitan. I've tested on both version of execution env:
Steps to reproduce
The text was updated successfully, but these errors were encountered: