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

use invariant culture to parse inputs to converters - #10006

Merged

Conversation

mjkkirschner
Copy link
Member

@mjkkirschner mjkkirschner commented Sep 25, 2019

we were passing the culture before but this was usually set to en-us EVEN in localized environments
unless something set it explicitly
wrap with try catch and return some default conversion

Purpose

This one has a bit of a history.
issue from user:
#6261
fix:
#6724
fix:
#9994

When this was fixed originally by @sm6srw it appears that unlike what it implies in his PR - unintentionally the culture might have always been set to en-us as @angelowang points out WPF passes en-us culture to the converters EVEN if the environment is localized. (I tried both localizing dynamo and localizing windows and got en-us everytime!)

SO - this means that the original fix three years ago, was close, but in certain situations it lets the host change the culture - we don't want that.

Our strings are hardcoded in en-us format in our xaml, and I think that is okay, these converters are not really for public consumption. SO this pr does the following.

  • switches to using invariant culture
  • documents that the culture parameter is unusued on the convert method
  • adds some more test cases (the fr-FR cases failed before this PR)
  • wraps the conversions in try catch blocks which logs the exception - incase something fails or someone uses these converters from an extension or in an unanticipated way.
  • adds a TODO to remove a converter I cannot find used anywhere.

I've added similar logic to two other converters that @sm6srw added culture to. It appears to me the only time strings are used on these converters is from hardcoded xaml values, or the tests.

I still need to run the self serve tests.

  • cherry pick to 2.4.1

Declarations

Check these if you believe they are true

  • The code base is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning, and are documented in the API Changes document.

Reviewers

@QilongTang
@sm6srw

FYIs

@angelowang

we were passing the culture before but this was usually set to en-us EVEN in localized enviornments
unless something set it explicitly
wrap with try catch and return some default conversion
@mjkkirschner mjkkirschner changed the title use invariant culture to parse inputs - use invariant culture to parse inputs to converters - Sep 25, 2019
@mjkkirschner mjkkirschner added the PTAL Please Take A Look 👀 label Sep 25, 2019
@@ -1414,15 +1414,29 @@ public object ConvertBack(object value, Type targetType, object parameter, Syste
}
}

//TODO remove(this is not used anywhere)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add Dynamo 3.0? Will be easier to identify when the time comes :)

Copy link
Contributor

@QilongTang QilongTang left a comment

Choose a reason for hiding this comment

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

LGTM with some comments

@@ -1414,15 +1414,29 @@ public object ConvertBack(object value, Type targetType, object parameter, Syste
}
}

//TODO remove(this is not used anywhere) in Dynamo 3.0
Copy link
Member Author

Choose a reason for hiding this comment

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

@saintentropy this is the converter I was talking about .... is this the one you were thinking of? I can't find this particular one used anywhere.

@QilongTang QilongTang added LGTM Looks good to me and removed PTAL Please Take A Look 👀 labels Sep 25, 2019
@mjkkirschner mjkkirschner merged commit 3dc4202 into DynamoDS:master Sep 25, 2019
mjkkirschner added a commit to mjkkirschner/Dynamo that referenced this pull request Sep 25, 2019
* use invariant culture to parse inputs -
we were passing the culture before but this was usually set to en-us EVEN in localized enviornments
unless something set it explicitly
wrap with try catch and return some default conversion

* Update src/DynamoCoreWpf/UI/Converters.cs

* Update src/DynamoCoreWpf/UI/Converters.cs

(cherry picked from commit 3dc4202)
mjkkirschner added a commit that referenced this pull request Sep 25, 2019
* use invariant culture to parse inputs -
we were passing the culture before but this was usually set to en-us EVEN in localized enviornments
unless something set it explicitly
wrap with try catch and return some default conversion

* Update src/DynamoCoreWpf/UI/Converters.cs

* Update src/DynamoCoreWpf/UI/Converters.cs

(cherry picked from commit 3dc4202)
mjkkirschner added a commit that referenced this pull request Sep 30, 2019
* use invariant culture to parse inputs to converters - (#10006)

* use invariant culture to parse inputs -
we were passing the culture before but this was usually set to en-us EVEN in localized enviornments
unless something set it explicitly
wrap with try catch and return some default conversion

* Update src/DynamoCoreWpf/UI/Converters.cs

* Update src/DynamoCoreWpf/UI/Converters.cs

(cherry picked from commit 3dc4202)

* merge conflicts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LGTM Looks good to me
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants