[Managed DWrite] Reintroduce IDWriteFactory.CreateTextAnalyzer HRESULT validation #11388
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Contributes to #5305
Description
Reintroduces code in
Factory.CreateTextAnalyzerthat I inadvertently removed when migrating from C++/CLI to C# in #6171.IDWriteFactory.CreateTextAnalyzerdoesn't do much so the chance of it returning an error is low. Still, it's better to throw early than to letFactory.CreateTextAnalyzersucceed and throwNullReferenceExceptionwhen using the resulting TextAnalyzer.This also makes the tests in #11381 that validate that
Factory.CreateTextAnalyzersucceeds more meaningful.Original C++/CLI code:
wpf/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/Factory.cpp
Lines 411 to 418 in 07edfec
Customer Impact
I think the impact is very low, we now get proper exceptions when creating the TextAnalyzer instead of getting a NullReferenceException when using the TextAnalyzer.
Regression
Yes, was introduced in .Net 9.0 though it has very low impact.
Testing
Tested locally with the tests from #11381.
Risk
Low, reintroduces code that was removed.