-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Correct issues with ApiInformation implementation #2305
Correct issues with ApiInformation implementation #2305
Conversation
.NET applications use a concept of Union WinMD, which is the union of all known types that exist in the Windows SDK that correspond to the MaxVersionTested setting of the app. If you're running the app on a down-level platform, ApiInformation will tell you the API doesn't exist, but .NET can still JIT methods based on the Union WinMD and perform some reflection tasks. If you actually try to call the API you will get a MissingMethodException at runtime because the API doesn't really exist. A different problem can occur if you include a higher-versioned .NET library inside a lower-versioned app and try to run it on the higher-versioned build of the OS. In this case, ApiInformation will succeed because the type exists in the system metadata, but .NET will throw a MissingMethodException at runtime because the type didn't exist in the Union WinMD used to build the app.
return string.Empty; | ||
return ApiInformationExtensions.ExecuteIfPropertyPresent( | ||
WinRtType, | ||
"Partition", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UserAgent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be replaced to, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was in 193077d
The UserAgent property mistakenly used Partition property
ApiInformationExtensions.ExecuteIfEventPresent( | ||
WinRtType, | ||
"LostFocus", | ||
() => { _webViewControl.GotFocus -= OnLostFocus; }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be LostFocus?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 4bc5d4c
ApiInformationExtensions.ExecuteIfEventPresent( | ||
WinRtType, | ||
"LostFocus", | ||
() => { _webViewControl.GotFocus += OnLostFocus; }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be LostFocus
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 4bc5d4c
LostFocus event handler was accidentially wired up to GotFocus event.
Issue: #2306
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Depending on OS/Windows SDK installed, WebView may throw unhandled MissingMethodException.
What is the new behavior?
.NET applications use a concept of Union WinMD, which is the union of all known types that exist in the Windows SDK that correspond to the MaxVersionTested setting of the app. If you're running the app on a down-level platform, ApiInformation will tell you the API doesn't exist, but .NET can still JIT methods based on the Union WinMD and perform some reflection tasks. If you actually try to call the API you will get a MissingMethodException at runtime because the API doesn't really exist.
A different problem can occur if you include a higher-versioned .NET library inside a lower-versioned app and try to run it on the higher-versioned build of the OS. In this case, ApiInformation will succeed because the type exists in the system metadata, but .NET will throw a MissingMethodException at runtime because the type didn't exist in the Union WinMD used to build the app.
The change includes a safer wrapper around
ApiInformation
methods catching theMissingMethodException
PR Checklist
Please check if your PR fulfills the following requirements:
Other information
@GraniteStateHacker, @purani FYI
Resolves #2306. Requires #2309 for tests to execute