Repository navigation
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 40103Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 40103" |
This comment has been minimized.
This comment has been minimized.
|
Hey there @@MykhailoDav! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
|
Hey there @MykhailoDav! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| && serviceProvider.GetService(typeof(IRootObjectProvider)) is IRootObjectProvider rootProvider | ||
| && rootProvider.RootObject is ResourceDictionary) | ||
| { | ||
| style.BaseResourceKey = Key; |
There was a problem hiding this comment.
[major] Logic and Correctness Verification - Converting this StaticResource to BaseResourceKey changes which base style is selected. With the new sibling-dictionary fixture, add a Button-local resource named ButtonBaseStyle with Padding=99: Style.Apply calls SetDynamicResource, whose lookup starts at the consuming Button, so it selects 99 instead of the sibling dictionary's 10,7. Keeping the base in the referencing dictionary resolves it statically and selects 10,7. Resolve the deferred reference against the completed dictionary scope rather than changing it into a per-element dynamic resource.
| && rootProvider.RootObject is ResourceDictionary) | ||
| { | ||
| style.BaseResourceKey = Key; | ||
| return null; |
There was a problem hiding this comment.
[moderate] Logic and Correctness Verification - This return also permanently suppresses genuinely missing base-style errors. Rename the new Rd2 reference to ButonBaseStyle without defining that key anywhere: loading now succeeds and the Button silently loses its base setters, because Element.OnSetDynamicResource does nothing when lookup fails. During Hot Reload this also bypasses ExceptionHandler2, dropping the missing-resource diagnostic preserved by #35020. Preserve error reporting when deferred lookup still cannot resolve the key, and add a negative missing-base regression case; the new fixture always supplies the key.
PR Test Gate
🧪 Gate analysis — click to expand✅ Passed. The selected verification satisfied the gate's passing conditions. Unmatched, skipped, or inconclusive groups are not passing evidence. 📄 XAML unit tests
Execution log excerptsWithout fix With fix Without fix With fix PR head: abe47b72. Without-fix baseline: c7e8239c. |
3c00b5f
into
dotnet:candidate/11.0.1xx-sr2
…aries (#40103) ### Description of Change When a `ResourceDictionary` is inflated at runtime (for example a style dictionary without code-behind loaded through `Source=`), a `BasedOn="{StaticResource …}"` lookup can only see resources already added in that same file, plus application resources that already exist. A base style living in a sibling merged dictionary is not reachable yet, so loading the dictionary throws `XamlParseException: StaticResource not found for key ButtonBaseStyle` and crashes the app at startup. Declaring a global (implicit) style based on a shared keyed style this way is the scenario from the issue. **Fix** In `StaticResourceExtension.ProvideValue`, when the unresolved target is `Style.BasedOn` and the XAML root being parsed is a `ResourceDictionary` (one that is still being loaded), defer the lookup to apply time through the existing `Style.BaseResourceKey` mechanism instead of throwing. The base style is then resolved through the consuming element's resource scope, where the merged dictionaries are available. Failed lookups anywhere else keep throwing exactly as before. **Tests** `Maui24667` (Xaml.UnitTests) inflates a page whose resources merge two source dictionaries — a keyed `ButtonBaseStyle` and an implicit `Button` style based on it — plus the issue's implicit-`BaseResourceKey` snippet, and verifies the base setters are applied. The test runs on all three inflators (Runtime, XamlC, SourceGen). | | Without fix | With fix | |---|---|---| | Implicit style with `BasedOn="{StaticResource …}"` to a keyed style in a sibling merged dictionary | `XamlParseException`: StaticResource not found for key ButtonBaseStyle | Style applied, base setters inherited | | Implicit style with `BaseResourceKey` (issue snippet) | works | works | | Full Xaml.UnitTests + Core.UnitTests | — | No new failures | ### Issues Fixed Fixes #24667
…aries (#40103) ### Description of Change When a `ResourceDictionary` is inflated at runtime (for example a style dictionary without code-behind loaded through `Source=`), a `BasedOn="{StaticResource …}"` lookup can only see resources already added in that same file, plus application resources that already exist. A base style living in a sibling merged dictionary is not reachable yet, so loading the dictionary throws `XamlParseException: StaticResource not found for key ButtonBaseStyle` and crashes the app at startup. Declaring a global (implicit) style based on a shared keyed style this way is the scenario from the issue. **Fix** In `StaticResourceExtension.ProvideValue`, when the unresolved target is `Style.BasedOn` and the XAML root being parsed is a `ResourceDictionary` (one that is still being loaded), defer the lookup to apply time through the existing `Style.BaseResourceKey` mechanism instead of throwing. The base style is then resolved through the consuming element's resource scope, where the merged dictionaries are available. Failed lookups anywhere else keep throwing exactly as before. **Tests** `Maui24667` (Xaml.UnitTests) inflates a page whose resources merge two source dictionaries — a keyed `ButtonBaseStyle` and an implicit `Button` style based on it — plus the issue's implicit-`BaseResourceKey` snippet, and verifies the base setters are applied. The test runs on all three inflators (Runtime, XamlC, SourceGen). | | Without fix | With fix | |---|---|---| | Implicit style with `BasedOn="{StaticResource …}"` to a keyed style in a sibling merged dictionary | `XamlParseException`: StaticResource not found for key ButtonBaseStyle | Style applied, base setters inherited | | Implicit style with `BaseResourceKey` (issue snippet) | works | works | | Full Xaml.UnitTests + Core.UnitTests | — | No new failures | ### Issues Fixed Fixes #24667
…aries (#40103) ### Description of Change When a `ResourceDictionary` is inflated at runtime (for example a style dictionary without code-behind loaded through `Source=`), a `BasedOn="{StaticResource …}"` lookup can only see resources already added in that same file, plus application resources that already exist. A base style living in a sibling merged dictionary is not reachable yet, so loading the dictionary throws `XamlParseException: StaticResource not found for key ButtonBaseStyle` and crashes the app at startup. Declaring a global (implicit) style based on a shared keyed style this way is the scenario from the issue. **Fix** In `StaticResourceExtension.ProvideValue`, when the unresolved target is `Style.BasedOn` and the XAML root being parsed is a `ResourceDictionary` (one that is still being loaded), defer the lookup to apply time through the existing `Style.BaseResourceKey` mechanism instead of throwing. The base style is then resolved through the consuming element's resource scope, where the merged dictionaries are available. Failed lookups anywhere else keep throwing exactly as before. **Tests** `Maui24667` (Xaml.UnitTests) inflates a page whose resources merge two source dictionaries — a keyed `ButtonBaseStyle` and an implicit `Button` style based on it — plus the issue's implicit-`BaseResourceKey` snippet, and verifies the base setters are applied. The test runs on all three inflators (Runtime, XamlC, SourceGen). | | Without fix | With fix | |---|---|---| | Implicit style with `BasedOn="{StaticResource …}"` to a keyed style in a sibling merged dictionary | `XamlParseException`: StaticResource not found for key ButtonBaseStyle | Style applied, base setters inherited | | Implicit style with `BaseResourceKey` (issue snippet) | works | works | | Full Xaml.UnitTests + Core.UnitTests | — | No new failures | ### Issues Fixed Fixes #24667
…aries (#40103) ### Description of Change When a `ResourceDictionary` is inflated at runtime (for example a style dictionary without code-behind loaded through `Source=`), a `BasedOn="{StaticResource …}"` lookup can only see resources already added in that same file, plus application resources that already exist. A base style living in a sibling merged dictionary is not reachable yet, so loading the dictionary throws `XamlParseException: StaticResource not found for key ButtonBaseStyle` and crashes the app at startup. Declaring a global (implicit) style based on a shared keyed style this way is the scenario from the issue. **Fix** In `StaticResourceExtension.ProvideValue`, when the unresolved target is `Style.BasedOn` and the XAML root being parsed is a `ResourceDictionary` (one that is still being loaded), defer the lookup to apply time through the existing `Style.BaseResourceKey` mechanism instead of throwing. The base style is then resolved through the consuming element's resource scope, where the merged dictionaries are available. Failed lookups anywhere else keep throwing exactly as before. **Tests** `Maui24667` (Xaml.UnitTests) inflates a page whose resources merge two source dictionaries — a keyed `ButtonBaseStyle` and an implicit `Button` style based on it — plus the issue's implicit-`BaseResourceKey` snippet, and verifies the base setters are applied. The test runs on all three inflators (Runtime, XamlC, SourceGen). | | Without fix | With fix | |---|---|---| | Implicit style with `BasedOn="{StaticResource …}"` to a keyed style in a sibling merged dictionary | `XamlParseException`: StaticResource not found for key ButtonBaseStyle | Style applied, base setters inherited | | Implicit style with `BaseResourceKey` (issue snippet) | works | works | | Full Xaml.UnitTests + Core.UnitTests | — | No new failures | ### Issues Fixed Fixes #24667
…aries (#40103) ### Description of Change When a `ResourceDictionary` is inflated at runtime (for example a style dictionary without code-behind loaded through `Source=`), a `BasedOn="{StaticResource …}"` lookup can only see resources already added in that same file, plus application resources that already exist. A base style living in a sibling merged dictionary is not reachable yet, so loading the dictionary throws `XamlParseException: StaticResource not found for key ButtonBaseStyle` and crashes the app at startup. Declaring a global (implicit) style based on a shared keyed style this way is the scenario from the issue. **Fix** In `StaticResourceExtension.ProvideValue`, when the unresolved target is `Style.BasedOn` and the XAML root being parsed is a `ResourceDictionary` (one that is still being loaded), defer the lookup to apply time through the existing `Style.BaseResourceKey` mechanism instead of throwing. The base style is then resolved through the consuming element's resource scope, where the merged dictionaries are available. Failed lookups anywhere else keep throwing exactly as before. **Tests** `Maui24667` (Xaml.UnitTests) inflates a page whose resources merge two source dictionaries — a keyed `ButtonBaseStyle` and an implicit `Button` style based on it — plus the issue's implicit-`BaseResourceKey` snippet, and verifies the base setters are applied. The test runs on all three inflators (Runtime, XamlC, SourceGen). | | Without fix | With fix | |---|---|---| | Implicit style with `BasedOn="{StaticResource …}"` to a keyed style in a sibling merged dictionary | `XamlParseException`: StaticResource not found for key ButtonBaseStyle | Style applied, base setters inherited | | Implicit style with `BaseResourceKey` (issue snippet) | works | works | | Full Xaml.UnitTests + Core.UnitTests | — | No new failures | ### Issues Fixed Fixes #24667
…aries (#40103) ### Description of Change When a `ResourceDictionary` is inflated at runtime (for example a style dictionary without code-behind loaded through `Source=`), a `BasedOn="{StaticResource …}"` lookup can only see resources already added in that same file, plus application resources that already exist. A base style living in a sibling merged dictionary is not reachable yet, so loading the dictionary throws `XamlParseException: StaticResource not found for key ButtonBaseStyle` and crashes the app at startup. Declaring a global (implicit) style based on a shared keyed style this way is the scenario from the issue. **Fix** In `StaticResourceExtension.ProvideValue`, when the unresolved target is `Style.BasedOn` and the XAML root being parsed is a `ResourceDictionary` (one that is still being loaded), defer the lookup to apply time through the existing `Style.BaseResourceKey` mechanism instead of throwing. The base style is then resolved through the consuming element's resource scope, where the merged dictionaries are available. Failed lookups anywhere else keep throwing exactly as before. **Tests** `Maui24667` (Xaml.UnitTests) inflates a page whose resources merge two source dictionaries — a keyed `ButtonBaseStyle` and an implicit `Button` style based on it — plus the issue's implicit-`BaseResourceKey` snippet, and verifies the base setters are applied. The test runs on all three inflators (Runtime, XamlC, SourceGen). | | Without fix | With fix | |---|---|---| | Implicit style with `BasedOn="{StaticResource …}"` to a keyed style in a sibling merged dictionary | `XamlParseException`: StaticResource not found for key ButtonBaseStyle | Style applied, base setters inherited | | Implicit style with `BaseResourceKey` (issue snippet) | works | works | | Full Xaml.UnitTests + Core.UnitTests | — | No new failures | ### Issues Fixed Fixes #24667
…aries (#40103) ### Description of Change When a `ResourceDictionary` is inflated at runtime (for example a style dictionary without code-behind loaded through `Source=`), a `BasedOn="{StaticResource …}"` lookup can only see resources already added in that same file, plus application resources that already exist. A base style living in a sibling merged dictionary is not reachable yet, so loading the dictionary throws `XamlParseException: StaticResource not found for key ButtonBaseStyle` and crashes the app at startup. Declaring a global (implicit) style based on a shared keyed style this way is the scenario from the issue. **Fix** In `StaticResourceExtension.ProvideValue`, when the unresolved target is `Style.BasedOn` and the XAML root being parsed is a `ResourceDictionary` (one that is still being loaded), defer the lookup to apply time through the existing `Style.BaseResourceKey` mechanism instead of throwing. The base style is then resolved through the consuming element's resource scope, where the merged dictionaries are available. Failed lookups anywhere else keep throwing exactly as before. **Tests** `Maui24667` (Xaml.UnitTests) inflates a page whose resources merge two source dictionaries — a keyed `ButtonBaseStyle` and an implicit `Button` style based on it — plus the issue's implicit-`BaseResourceKey` snippet, and verifies the base setters are applied. The test runs on all three inflators (Runtime, XamlC, SourceGen). | | Without fix | With fix | |---|---|---| | Implicit style with `BasedOn="{StaticResource …}"` to a keyed style in a sibling merged dictionary | `XamlParseException`: StaticResource not found for key ButtonBaseStyle | Style applied, base setters inherited | | Implicit style with `BaseResourceKey` (issue snippet) | works | works | | Full Xaml.UnitTests + Core.UnitTests | — | No new failures | ### Issues Fixed Fixes #24667
…aries (#40103) ### Description of Change When a `ResourceDictionary` is inflated at runtime (for example a style dictionary without code-behind loaded through `Source=`), a `BasedOn="{StaticResource …}"` lookup can only see resources already added in that same file, plus application resources that already exist. A base style living in a sibling merged dictionary is not reachable yet, so loading the dictionary throws `XamlParseException: StaticResource not found for key ButtonBaseStyle` and crashes the app at startup. Declaring a global (implicit) style based on a shared keyed style this way is the scenario from the issue. **Fix** In `StaticResourceExtension.ProvideValue`, when the unresolved target is `Style.BasedOn` and the XAML root being parsed is a `ResourceDictionary` (one that is still being loaded), defer the lookup to apply time through the existing `Style.BaseResourceKey` mechanism instead of throwing. The base style is then resolved through the consuming element's resource scope, where the merged dictionaries are available. Failed lookups anywhere else keep throwing exactly as before. **Tests** `Maui24667` (Xaml.UnitTests) inflates a page whose resources merge two source dictionaries — a keyed `ButtonBaseStyle` and an implicit `Button` style based on it — plus the issue's implicit-`BaseResourceKey` snippet, and verifies the base setters are applied. The test runs on all three inflators (Runtime, XamlC, SourceGen). | | Without fix | With fix | |---|---|---| | Implicit style with `BasedOn="{StaticResource …}"` to a keyed style in a sibling merged dictionary | `XamlParseException`: StaticResource not found for key ButtonBaseStyle | Style applied, base setters inherited | | Implicit style with `BaseResourceKey` (issue snippet) | works | works | | Full Xaml.UnitTests + Core.UnitTests | — | No new failures | ### Issues Fixed Fixes #24667
…aries (#40103) ### Description of Change When a `ResourceDictionary` is inflated at runtime (for example a style dictionary without code-behind loaded through `Source=`), a `BasedOn="{StaticResource …}"` lookup can only see resources already added in that same file, plus application resources that already exist. A base style living in a sibling merged dictionary is not reachable yet, so loading the dictionary throws `XamlParseException: StaticResource not found for key ButtonBaseStyle` and crashes the app at startup. Declaring a global (implicit) style based on a shared keyed style this way is the scenario from the issue. **Fix** In `StaticResourceExtension.ProvideValue`, when the unresolved target is `Style.BasedOn` and the XAML root being parsed is a `ResourceDictionary` (one that is still being loaded), defer the lookup to apply time through the existing `Style.BaseResourceKey` mechanism instead of throwing. The base style is then resolved through the consuming element's resource scope, where the merged dictionaries are available. Failed lookups anywhere else keep throwing exactly as before. **Tests** `Maui24667` (Xaml.UnitTests) inflates a page whose resources merge two source dictionaries — a keyed `ButtonBaseStyle` and an implicit `Button` style based on it — plus the issue's implicit-`BaseResourceKey` snippet, and verifies the base setters are applied. The test runs on all three inflators (Runtime, XamlC, SourceGen). | | Without fix | With fix | |---|---|---| | Implicit style with `BasedOn="{StaticResource …}"` to a keyed style in a sibling merged dictionary | `XamlParseException`: StaticResource not found for key ButtonBaseStyle | Style applied, base setters inherited | | Implicit style with `BaseResourceKey` (issue snippet) | works | works | | Full Xaml.UnitTests + Core.UnitTests | — | No new failures | ### Issues Fixed Fixes #24667
…aries (#40103) ### Description of Change When a `ResourceDictionary` is inflated at runtime (for example a style dictionary without code-behind loaded through `Source=`), a `BasedOn="{StaticResource …}"` lookup can only see resources already added in that same file, plus application resources that already exist. A base style living in a sibling merged dictionary is not reachable yet, so loading the dictionary throws `XamlParseException: StaticResource not found for key ButtonBaseStyle` and crashes the app at startup. Declaring a global (implicit) style based on a shared keyed style this way is the scenario from the issue. **Fix** In `StaticResourceExtension.ProvideValue`, when the unresolved target is `Style.BasedOn` and the XAML root being parsed is a `ResourceDictionary` (one that is still being loaded), defer the lookup to apply time through the existing `Style.BaseResourceKey` mechanism instead of throwing. The base style is then resolved through the consuming element's resource scope, where the merged dictionaries are available. Failed lookups anywhere else keep throwing exactly as before. **Tests** `Maui24667` (Xaml.UnitTests) inflates a page whose resources merge two source dictionaries — a keyed `ButtonBaseStyle` and an implicit `Button` style based on it — plus the issue's implicit-`BaseResourceKey` snippet, and verifies the base setters are applied. The test runs on all three inflators (Runtime, XamlC, SourceGen). | | Without fix | With fix | |---|---|---| | Implicit style with `BasedOn="{StaticResource …}"` to a keyed style in a sibling merged dictionary | `XamlParseException`: StaticResource not found for key ButtonBaseStyle | Style applied, base setters inherited | | Implicit style with `BaseResourceKey` (issue snippet) | works | works | | Full Xaml.UnitTests + Core.UnitTests | — | No new failures | ### Issues Fixed Fixes #24667
…aries (#40103) ### Description of Change When a `ResourceDictionary` is inflated at runtime (for example a style dictionary without code-behind loaded through `Source=`), a `BasedOn="{StaticResource …}"` lookup can only see resources already added in that same file, plus application resources that already exist. A base style living in a sibling merged dictionary is not reachable yet, so loading the dictionary throws `XamlParseException: StaticResource not found for key ButtonBaseStyle` and crashes the app at startup. Declaring a global (implicit) style based on a shared keyed style this way is the scenario from the issue. **Fix** In `StaticResourceExtension.ProvideValue`, when the unresolved target is `Style.BasedOn` and the XAML root being parsed is a `ResourceDictionary` (one that is still being loaded), defer the lookup to apply time through the existing `Style.BaseResourceKey` mechanism instead of throwing. The base style is then resolved through the consuming element's resource scope, where the merged dictionaries are available. Failed lookups anywhere else keep throwing exactly as before. **Tests** `Maui24667` (Xaml.UnitTests) inflates a page whose resources merge two source dictionaries — a keyed `ButtonBaseStyle` and an implicit `Button` style based on it — plus the issue's implicit-`BaseResourceKey` snippet, and verifies the base setters are applied. The test runs on all three inflators (Runtime, XamlC, SourceGen). | | Without fix | With fix | |---|---|---| | Implicit style with `BasedOn="{StaticResource …}"` to a keyed style in a sibling merged dictionary | `XamlParseException`: StaticResource not found for key ButtonBaseStyle | Style applied, base setters inherited | | Implicit style with `BaseResourceKey` (issue snippet) | works | works | | Full Xaml.UnitTests + Core.UnitTests | — | No new failures | ### Issues Fixed Fixes #24667
Description of Change
When a
ResourceDictionaryis inflated at runtime (for example a style dictionary without code-behind loaded throughSource=), aBasedOn="{StaticResource …}"lookup can only see resources already added in that same file, plus application resources that already exist. A base style living in a sibling merged dictionary is not reachable yet, so loading the dictionary throwsXamlParseException: StaticResource not found for key ButtonBaseStyleand crashes the app at startup. Declaring a global (implicit) style based on a shared keyed style this way is the scenario from the issue.Fix
In
StaticResourceExtension.ProvideValue, when the unresolved target isStyle.BasedOnand the XAML root being parsed is aResourceDictionary(one that is still being loaded), defer the lookup to apply time through the existingStyle.BaseResourceKeymechanism instead of throwing. The base style is then resolved through the consuming element's resource scope, where the merged dictionaries are available. Failed lookups anywhere else keep throwing exactly as before.Tests
Maui24667(Xaml.UnitTests) inflates a page whose resources merge two source dictionaries — a keyedButtonBaseStyleand an implicitButtonstyle based on it — plus the issue's implicit-BaseResourceKeysnippet, and verifies the base setters are applied. The test runs on all three inflators (Runtime, XamlC, SourceGen).BasedOn="{StaticResource …}"to a keyed style in a sibling merged dictionaryXamlParseException: StaticResource not found for key ButtonBaseStyleBaseResourceKey(issue snippet)Issues Fixed
Fixes #24667