-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
TimeZoneInfo.FindSystemTimeZoneById throws TimeZoneNotFoundException #16917
Comments
Tests caught this, but a human decided it was OK: |
I'll cast my vote as a human that it's not ok ;-) |
What's the recommended practice to handle the scenario where this exception is caught because of cross platform differences, should it just check for Exception when assigning a TimeZoneInfo variable? |
@jchannon we have a future issue to support the IANA Ids on Windows and Windows Id on Linux/OSX. till we have this work done, you'll need to handle the cross platform manually. so it depends on your scenario you are using TZ for. if you need to have some level of cross platform TZ support you will need to do manual mapping between Windows Id and IANA Ids, otherwise you'll just need to fallback to some TZ. again this really depends on the scenario. if you can tell more about your scenario, we may think together what is best can be done for now in such scenario. |
Just to confirm, CoreFx will support Linux timezone Ids or you'll make the The example code we have at the moment is this: If the exception is removed shall I just catch for Exception? In theory |
The future work should allow both.
Yes, you need to catch Exception instead of TimeZoneNotFoundException till we expose TimeZoneNotFoundException. |
Thanks. Good news about the Ids On Tuesday, 3 May 2016, Tarek Mahmoud Sayed [email protected]
|
Final question. How does this effect the Portable Analyzer tool. At the On Tuesday, 3 May 2016, Tarek Mahmoud Sayed [email protected]
|
The portability analyzer tool pulls its data from reference assemblies (via API catalog), so it should update automatically once the changes are made. Until then, it may be worthwhile to add a 'recommended action' that mentions the API is incoming and provides a short-term workaround. |
So at the moment the Analyzer is using rc1 assemblies not rc2? On Tuesday, 3 May 2016, Mike Rousos [email protected] wrote:
|
@terrajobst @twsouthwick - do you guys know which assemblies are used to populate API catalog? Is it the RC1 stuff from NuGet or RC2/3 binaries from myget? |
It pulls it from the current CI builds as far as I know. There is a manual step to get it into the analyzer that we are working on automating. |
The tests were fixed by dotnet/corefx#11149. |
Hi @tarekgh Any news on when Windows will be able to return/handle Linux Timezone Ids? |
Hi @jchannon not soon, this is planned to be done in the future as we are currently busy working on the netstandard 2.0. |
So post netstandard 2.0? On 13 October 2016 at 17:10, Tarek Mahmoud Sayed [email protected]
|
hopefully. this is really the feature I need to do as soon as we get a chance. |
Yup really looking forward to it On Thursday, 13 October 2016, Tarek Mahmoud Sayed [email protected]
|
The TimeZone exception thrown shows that the API was not unit tested with some negative tests. And, as suggested earlier, an automation test caught it but was ignored or taken as a False Positive. We Surely need a fix for that. There can be a more crafted attack on the function/API and help crashing the systems. What is the exception: |
could you clarify the statement you mentioned What is exactly the attack you are talking about? and what is your suggestion? Usually, the applications which getting data (e.g. zone names) from external sources has to protect itself when using such data. throwing an exception in the mentioned case is legitimate |
.NET Core exposes
TimeZoneInfo.FindSystemTimeZoneById(string)
(MSDN) which throws aTimeZoneNotFoundException
.But the exception can't be caught because
TimeZoneNotFoundException
isn't exposed in .NET Core. We should include the exception type in the System.Runtime contract alongside the API that throws it.Repro:
The text was updated successfully, but these errors were encountered: