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 getting DateTime value from boxed object #1647

Merged
merged 1 commit into from
May 27, 2020

Conversation

josesimoes
Copy link
Member

Description

  • Add return value to Expand.
  • Improve code in GetDateTimePart___I4__SystemDateT to deal with fail/success of call to Expand.
  • Add code to GetValuePtr to process boxed DateTime objects.

Motivation and Context

  • Trying to get a pointer to a boxed DateTime object was not possible.
  • Failing to expand a DateTime wasn't being properly handled. It just continued happily with whatever rubbish was in the memory.

How Has This Been Tested?

Using the following code:

var now = DateTime.UtcNow;
var nowString = now.ToString();

Console.WriteLine("OUTPUT_1: " + nowString);
Console.WriteLine($"OUTPUT_2: {now}");

Notes:

  1. the 1st call outputs the already built string)
  2. the 2nd call is processed by Roslyn which adds a call to String.Format inside of which the output argument is boxed inside an array.

Output before the fix:

OUTPUT_1: 01/01/1980 03:35:58
OUTPUT_2: 53375/00/59512 60928:53375:01

Output after the fix:

OUTPUT_1: 01/01/1980 03:40:08
OUTPUT_2: 01/01/1980 03:40:08

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)

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.

Signed-off-by: josesimoes [email protected]

- Add return value to Expand.
- Improve code in GetDateTimePart___I4__SystemDateT to deal with fail/success of call to Expand.
- Add code to GetValuePtr to process boxed DateTime objects.

Signed-off-by: josesimoes <[email protected]>
@josesimoes josesimoes added Type: bug Area: Common libs Everything related with common libraries labels May 27, 2020
@nfbot
Copy link
Member

nfbot commented May 27, 2020

Hi @josesimoes,

I'm nanoFramework bot.
Thank you for your contribution!

A human will be reviewing it shortly. 😉

@josesimoes josesimoes closed this May 27, 2020
@josesimoes josesimoes deleted the fix-datetime-unboxing branch May 27, 2020 15:58
@josesimoes josesimoes restored the fix-datetime-unboxing branch May 27, 2020 15:59
@josesimoes josesimoes reopened this May 27, 2020
@josesimoes josesimoes merged commit ad4ae0c into nanoframework:develop May 27, 2020
@josesimoes josesimoes deleted the fix-datetime-unboxing branch May 27, 2020 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Common libs Everything related with common libraries Type: bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants