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

Improvements in convert and format handling #1936

Closed
wants to merge 24 commits into from
Closed

Improvements in convert and format handling #1936

wants to merge 24 commits into from

Conversation

edleno2
Copy link
Contributor

@edleno2 edleno2 commented May 29, 2021

Description

  • Added FormatException and code to report formatting errors in Parse routines, Updated versions and interop structure.
  • Replace some current exceptions with FormatException to be consistent with .net core.
  • Replaced some other generic exceptions with ArgumentOutOfRangeException to be consistent with .net core.
  • Some cleanup generated by CLANG format as headers were modified to allow new exception type.
  • Fixed handling of signed and unsigned Parse strings - allowed "-0" for example. Refactored some code to allow this.
  • Added errno processing for integers to catch formatting errors from native math functions.
  • Corrected min/max check logic for integer and float logic.
  • Correctly handle (.net core compliant) empty strings and/or space preceding string values about to be parsed.
  • Report cast errors as invalid cast - .net core compliant.
  • Added System.IO.Ports to STM32F429I-Discovery device in variants.make so it would generate correct includes when running cmake.

Motivation and Context

How Has This Been Tested?

Ran unit tests on Win32 with both SUPPORT_ANY_BASE_CONVERSION and without that, then ESP32-WROOM and STM32F429I-Discovery.

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.

edleno2 and others added 16 commits May 19, 2021 15:22
Removed call to GetIntegerPart since it couldn't support UInt64 conversions and edit for invalid values.  Wrote new string parse loop based on code that is being used for SUPPORT_ANY_BASE_CONVERSION.  Moved some code so it could be used by both SUPPORT_ANY... and the radix 10/16 logic.

Possible problem change in Double parsing - used pow() method to better generate the IEEE 574 compliant double in storage.  pow() is considered to be slow, but without a more precise float multiplication the resulting double will not match what is used by the Roslyn compiler when creating and comparing doubles.

Fixes #715
Cleaned up brackets in system convert to be consistent with rest of file.  Added "signed" to char for cast operation - win32 treats char as signed, but gcc does not.  Adding signed makes this un-ambiguous.

Fix #715
Automated fixes for code style.
…c0f-9575-4847-8842-0c97899413f7

Code style fixes for nanoframework/nf-interpreter PR#1928
Unit tests of boxing/unboxing are expecting invalid cast exception.  Code was returning generic System.Exception with HR of CLR_E_WRONG_TYPE.  Changed code since invalid cast exception is more descriptive of the problem.
Add a FormatException and edits for formatting of int and doubles.

Fix #708
Win32 builds worked, but not ESP32 and STM32.  Fixed (1) missing API in target cmake-variants.json; (2) moved location of <cerrno> declaration to allow it to be defined before redefines happen for "errno".

Fix #708
Some code was simplified by combing the handling of both positive and negative results into one routine that checked for adjusting the sign at the end just before returning a value.  Remove the code that was commented out now that all unit testing is complete.

Fix #708
@edleno2
Copy link
Contributor Author

edleno2 commented May 29, 2021

Trying to find another way to use errno - the lwip library has overridden the functionality of errno processing and I'm not sure how to replace it AND have it work. I can fix the build, but then the unit tests fail when run on hardware.

@@ -893,7 +893,7 @@ HRESULT CLR_RT_HeapBlock::PerformUnboxing(const CLR_RT_TypeDef_Instance &cls)

if (this->DataType() != DATATYPE_OBJECT)
{
NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE);
NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_CAST);
Copy link
Member

Choose a reason for hiding this comment

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

Are we sure that it's safe to replace this exception? I'm asking because I recall this being used in the generics processing and not sure about the impact at this time... So, just asking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The current hResult of CLR_E_WRONG_TYPE generates a generic Exception, so any managed code doing a Catch (Exception ex) will continue to work. I could not find any references to the CLR_E_WRONG_TYPE in nanoCLR that was looking at that specific HR and acted different - i.e. all of the references were to setting that hResult. The invalid cast exception IS what is being returned in .net core in the same situation, so that led me to the change after checking if there were references to the old hr.

@josesimoes josesimoes changed the title Fixes to unit tests for CoreLibrary Improvements in convert and format handling May 29, 2021
@josesimoes josesimoes changed the base branch from develop to pr1936 May 29, 2021 09:30
@josesimoes
Copy link
Member

@edleno2 just rebased and fix some style issues. As I couldn't push to your fork, I've made this in branch "pr1936".
Please pull from it.

@josesimoes
Copy link
Member

@edleno2 just fixed the build issue with errno. Pull from pr1936 😉

@nfbot
Copy link
Member

nfbot commented May 29, 2021

@edleno2 there are issues with the code style on the source files.
A PR was submitted with the code style fixes. Please click https://github.com/edleno2/nf-interpreter/pull/3, review the changes if you want and merge it.

Make sure to follow the project code style. Check the details here on how it works and the tools required to help you with that.

@nfbot
Copy link
Member

nfbot commented May 30, 2021

@edleno2 there are issues with the code style on the source files.
A PR was submitted with the code style fixes. Please click https://github.com/edleno2/nf-interpreter/pull/4, review the changes if you want and merge it.

Make sure to follow the project code style. Check the details here on how it works and the tools required to help you with that.

When compiled with devices that use LWIP for networking certain stdlib routines are required to be reentrant.
Cleaned up a little left over formatting in nf_errors_exceptions.h

Fix #708
@nfbot
Copy link
Member

nfbot commented May 31, 2021

@edleno2 there are issues with the code style on the source files.
A PR was submitted with the code style fixes. Please click https://github.com/edleno2/nf-interpreter/pull/5, review the changes if you want and merge it.

Make sure to follow the project code style. Check the details here on how it works and the tools required to help you with that.

@edleno2
Copy link
Contributor Author

edleno2 commented May 31, 2021

Closing this PR - made a mess of it while trying to rebase. Will open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UnitTestParseTests.box_unbox_Test_1 fails
4 participants