Skip to content
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

Fix initialization of Expires in WP Request #302

Merged
merged 1 commit into from
May 8, 2021

Conversation

edleno2
Copy link
Contributor

@edleno2 edleno2 commented May 8, 2021

Description

Logic was using DateTime.MaxValue which could establish a value that is later adjusted for time zone. DateTimeOffset.MaxValue is already set to UTC which is the default for DateTimeOffset.

Additional problem was in Engine.cs - there are a couple of of commands that are used in the test harness that need to be declared as public so they can be tested.

Added some comments in PortSerialManager.cs about the possibility of eating non-serial problems in the try/catch block.

  1. Initialized Expires with DateTimeOffset.MaxValue instead of DateTime.MaxValue
  2. Changed two interfaces to public to allow testing with the test harness that is in the repo
  3. Documented via comment that the open catch in the try/catch could hide programming mistakes

Motivation and Context

How Has This Been Tested?

Tested using the Serial Test App WPF project that is in the nf-debugger repository and is part of the nanoFramework.Tools.Debugger solution file.

Screenshots

Types of changes

  • Improvement (non-breaking change that improves a feature, code or algorithm)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Config and build (change in the configuration and build system, has no impact on code or features)
  • Dependencies (update dependencies and changes associated, has no impact on code or features)
  • Unit Tests (work on Unit Tests, has no impact on code or features)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Logic was using DateTime.MaxValue which could establish a value that is later adjusted for time zone.  DateTimeOffset.MaxValue is already set to UTC which is the default for DateTimeOffset.

Additional problem was in Engine.cs - there are a couple of of commands that are used in the test harness that need to be declared as public so they can be tested.

Added some comments in PortSerialManager.cs about the possibility of eating non-serial problems in the try/catch block.

Fix #742
@nfbot nfbot added the Type: Bug label May 8, 2021
@@ -611,7 +611,7 @@ private bool CheckValidNanoFrameworkSerialDevice(NanoDevice<NanoSerialDevice> de
}
}
}
catch
catch (Exception /* ex */) // we could eat simple programming errors here - like a bad cast or other problem when changing code
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your comment is correct, of course!
This was (is) here because of the bad things always happening when we where using the UWP APIs.
Probably needs to be revisited now that we aren't using that anymore.

I'm no big fan of "catch all" like this one, but sometimes that's the way to go...

Copy link
Member

@josesimoes josesimoes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!! Thanks for looking into this.

@josesimoes josesimoes changed the title Fix initialization of Expires to use DateTimeOffset.MaxValue Fix initialization of Expires in WP Request May 8, 2021
@josesimoes josesimoes merged commit c626bd6 into nanoframework:develop May 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WireProtocol problem detecting ports
3 participants