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

Update InternalSDKUTils.DetermineFramework to return standard string … #3302

Merged
merged 1 commit into from Apr 26, 2024

Conversation

peterrsongg
Copy link
Contributor

@peterrsongg peterrsongg commented Apr 25, 2024

…and additional metadata if version parsing fails

Description

This updates the DetermineFramework method, which previously could return junk like "1-10-2023" or whatever was returned from GetValidSubstringOrUnknown. This is because people can build their own custom version of System.Runtime.InteropServices.RuntimeInformation.dll.

In these cases, where the version is not in the standard format i.e. n.n.n, we now return a consistent string.
In order to mock the DetermineFramework method, I had to mock the static RuntimeInformation class. This class doesn't implement and interface so I had to create an interface and a wrapper to allow me to inject the mocked version of RuntimeInformation.

Motivation and Context

Internal Ticket 7368

Testing

Added Unit Tests
Dry run passes

Screenshots (if appropriate)

Types of changes

  • 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 README document
  • I have added tests to cover my changes
  • All new and existing tests passed

License

  • I confirm that this pull request can be released under the Apache 2 license

@peterrsongg peterrsongg changed the base branch from main to main-staging April 25, 2024 16:31
/// An interface for <see cref="RuntimeInformationWrapper"/> which allows for mocking the <see cref="RuntimeInformation"/> class.
/// A wrapper is necessary because the class is static.
/// </summary>
internal interface IRuntimeInformationWrapper
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this interface need to be marked internal? It's already in the Internal namespace, and in my opinion made this PR much more complicated than necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Norm asked me to make these internal and utilize InternalsVisibleTo😅.

Copy link
Member

Choose a reason for hiding this comment

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

I'm fine with either approach. My intention was I wanted the new interface to be treated as internal. Probably not a bad thing to get our unit tests project setup to access internals for future testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree it's not a bad thing to have it set up so that we can use it in the future.

@ashovlin ashovlin requested a review from normj April 25, 2024 17:32
/// An interface for <see cref="RuntimeInformationWrapper"/> which allows for mocking the <see cref="RuntimeInformation"/> class.
/// A wrapper is necessary because the class is static.
/// </summary>
internal interface IRuntimeInformationWrapper
Copy link
Member

Choose a reason for hiding this comment

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

I'm fine with either approach. My intention was I wanted the new interface to be treated as internal. Probably not a bad thing to get our unit tests project setup to access internals for future testing.

@peterrsongg peterrsongg requested a review from normj April 26, 2024 00:02
…and additional metadata if version parsing fails
@peterrsongg peterrsongg force-pushed the petesong/language-version-update branch from 3a2e7ac to 21a28bc Compare April 26, 2024 16:39
@peterrsongg peterrsongg merged commit 031030d into main-staging Apr 26, 2024
1 check passed
@peterrsongg peterrsongg deleted the petesong/language-version-update branch April 26, 2024 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants