fix: InvalidOperationException from RecipeService.Search()#1730
Merged
fix: InvalidOperationException from RecipeService.Search()#1730
Conversation
Context: #1726 Context: #1728 Build and run `Chefs.csproj` for e.g. net10.0-desktop and NativeAOT while using Uno 6.6.0-dev.3: sed -i '' 's/"Uno.Sdk": ".*"/"Uno.Sdk": "6.6.0-dev.3"/g' global.json git clean -xdf Chefs{,.Api} dotnet publish -c Release -r osx-x64 -f net10.0-desktop -p:TargetFrameworkOverride=net10.0-desktop \ -bl Chefs/Chefs.csproj -p:UseSkiaRendering=true -p:SkiaPublishAot=true \ -p:SkiaPublishAot=true \ -p:IlcGenerateMapFile=true -p:IlcGenerateMstatFile=true -p:IlcGenerateDgmlFile=true -p:IlcGenerateMetadataLog=true \ -p:EmitCompilerGeneratedFiles=true -p:CompilerGeneratedFilesOutputPath=`pwd`/_gen Chefs/bin/Release/net10.0-desktop/osx-x64/publish/Chefs From the launch screen: 1. Click **Skip** 2. Click ** Sign in with Apple** 3. Click **🔍Search** on the left 4. In the Search box, type `m` When doing this with e838af9, the search results screen shows: > An error occurred. ![Search Results > An error occurred][0] …which isn't particularly helpful. If you do all this with #1728 applied, the Console log shows: fail: Chefs.Business.Services.Recipes.RecipeService[0] Failed to search recipes with term m System.InvalidOperationException: Reflection-based serialization has been disabled for this application. Use the IServiceCollection.AddJsonTypeInfo() or IHostBuilder.UseSerialization(IHostBuilder, IEnumerable<IJsonTypeInfoResolver>, Action<IServiceCollection>) extension methods to enable JSON deserialization for type `System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Chefs.Business.Models.SearchHistory, Chefs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]`. at Uno.Extensions.Serialization.SystemTextJsonSerializer.FromStream(Stream, Type) + 0x88 at Uno.Extensions.Serialization.SerializerExtensions.FromStream[T](ISerializer, Stream) + 0x34 at Uno.Extensions.Configuration.WritableOptions`1.<UpdateAsync>d__10.MoveNext() + 0x292 --- End of stack trace from previous location --- at Chefs.Business.Services.Recipes.RecipeService.<SaveSearchHistory>d__51.MoveNext() + 0x5d --- End of stack trace from previous location --- at Chefs.Business.Services.Recipes.RecipeService.<SearchCore>d__24.MoveNext() + 0x8a --- End of stack trace from previous location --- at Chefs.Business.Services.Recipes.RecipeService.<Search>d__23.MoveNext() + 0x175 which shows what the problem is: `RecipeService.Search()` tries to save the search history, but JSON serialization does not support `Dictionary<string, SearchHistory>`, so an `InvalidOperationException` is thrown. (Unfortunately the exception is basically swallowed; PR #1728 adds logging to that code path, and was needed to diagnose this issue.) Update `MockEndpointContext` to emit JSON serialization metadata for `Dictionary<string, SearchHistory>`, so that Search now works. [0]: https://private-user-images.githubusercontent.com/155958/541004949-2be43b36-4eb1-42b1-b91d-e53a5e5545de.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Njk1NDE0NjMsIm5iZiI6MTc2OTU0MTE2MywicGF0aCI6Ii8xNTU5NTgvNTQxMDA0OTQ5LTJiZTQzYjM2LTRlYjEtNDJiMS1iOTFkLWU1M2E1ZTU1NDVkZS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwMTI3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDEyN1QxOTEyNDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0yZDlkNzA5OTM0NzI2NWMxMjg4Njc0MTVmNWMyNjkzYTQzY2MzYWIxYTAzNGRlZjE5NjlmN2FjNzRkOGIxYjJiJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.a2gF7zICQIBUqWB-qdZv58UDg_DIwzKWAD8pNKJtu_g
rajamatt
approved these changes
Jan 27, 2026
jonpryor
added a commit
that referenced
this pull request
Jan 27, 2026
Context: #1726 Context: #1730 Build and run `Chefs.csproj`` for e.g. net10.0-desktop and NativeAOT while using Uno 6.6.0-dev.3: sed -i '' 's/"Uno.Sdk": ".*"/"Uno.Sdk": "6.6.0-dev.3"/g' global.json git clean -xdf Chefs{,.Api} dotnet publish -c Release -r osx-x64 -f net10.0-desktop -p:TargetFrameworkOverride=net10.0-desktop \ -bl Chefs/Chefs.csproj -p:UseSkiaRendering=true -p:SkiaPublishAot=true \ -p:SkiaPublishAot=true \ -p:IlcGenerateMapFile=true -p:IlcGenerateMstatFile=true -p:IlcGenerateDgmlFile=true -p:IlcGenerateMetadataLog=true \ -p:EmitCompilerGeneratedFiles=true -p:CompilerGeneratedFilesOutputPath=`pwd`/_gen Chefs/bin/Release/net10.0-desktop/osx-x64/publish/Chefs From the launch screen: 1. Click **Skip** 2. Click ** Sign in with Apple** 3. Click **🔍Search** on the left 4. In the Search box, type `m` When doing this with e838af9, the search results screen shows: > An error occurred. ![Search Results > An error occurred][0] …which isn't particularly helpful. Update `ErrorTemplate` within `FeedView.xaml` to also include the `Exception.Message` property contents: > An error occurred: > Reflection-based serialization has been disabled for this application. Use the IServiceCollection.AddJsonTypeInfo() or IHostBuilder.UseSerialization(IHostBuilder, IEnumerable<IJsonTypeInfoResolver>, Action<IServiceCollection>) extension methods to enable JSON deserialization for type `System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Chefs.Business.Models.SearchHistory, Chefs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]`. ![Search Results > A better error message][1] The downside to this approach is that the Console log shows this message after signing in, after step (2), above: fail: Uno.UI.DataBinding.BindingPropertyHelper[0] The [Message] property getter does not exist on type [Chefs.Presentation.HomeViewModel] as well as this message after going to the 🔍Search page, after step (3), above: fail: Uno.UI.DataBinding.BindingPropertyHelper[0] The [Search] property getter does not exist on type [Chefs.Presentation.SearchViewModel] These messages appear because *when `ErrorTemplate` is loaded*, the associated `DataContext` is for `HomeViewModel` or `SearchViewModel`, neither of which has a `Message` property. These `fail` messages can be ignored. [0]: https://private-user-images.githubusercontent.com/155958/541004949-2be43b36-4eb1-42b1-b91d-e53a5e5545de.png [1]: https://github.com/user-attachments/assets/709f1ffd-e5fc-4d60-8027-c15029b9c799
7 tasks
jonpryor
added a commit
that referenced
this pull request
Jan 27, 2026
Context: #1726 Context: #1730 Build and run `Chefs.csproj`` for e.g. net10.0-desktop and NativeAOT while using Uno 6.6.0-dev.3: sed -i '' 's/"Uno.Sdk": ".*"/"Uno.Sdk": "6.6.0-dev.3"/g' global.json git clean -xdf Chefs{,.Api} dotnet publish -c Release -r osx-x64 -f net10.0-desktop -p:TargetFrameworkOverride=net10.0-desktop \ -bl Chefs/Chefs.csproj -p:UseSkiaRendering=true -p:SkiaPublishAot=true \ -p:SkiaPublishAot=true \ -p:IlcGenerateMapFile=true -p:IlcGenerateMstatFile=true -p:IlcGenerateDgmlFile=true -p:IlcGenerateMetadataLog=true \ -p:EmitCompilerGeneratedFiles=true -p:CompilerGeneratedFilesOutputPath=`pwd`/_gen Chefs/bin/Release/net10.0-desktop/osx-x64/publish/Chefs From the launch screen: 1. Click **Skip** 2. Click ** Sign in with Apple** 3. Click **🔍Search** on the left 4. In the Search box, type `m` When doing this with e838af9, the search results screen shows: > An error occurred. ![Search Results > An error occurred][0] …which isn't particularly helpful. Update `ErrorTemplate` within `FeedView.xaml` to also include the `Exception.Message` property contents: > An error occurred: > Reflection-based serialization has been disabled for this application. Use the IServiceCollection.AddJsonTypeInfo() or IHostBuilder.UseSerialization(IHostBuilder, IEnumerable<IJsonTypeInfoResolver>, Action<IServiceCollection>) extension methods to enable JSON deserialization for type `System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Chefs.Business.Models.SearchHistory, Chefs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]`. ![Search Results > A better error message][1] The downside to this approach is that the Console log shows this message after signing in, after step (2), above: fail: Uno.UI.DataBinding.BindingPropertyHelper[0] The [Message] property getter does not exist on type [Chefs.Presentation.HomeViewModel] as well as this message after going to the 🔍Search page, after step (3), above: fail: Uno.UI.DataBinding.BindingPropertyHelper[0] The [Search] property getter does not exist on type [Chefs.Presentation.SearchViewModel] These messages appear because *when `ErrorTemplate` is loaded*, the associated `DataContext` is for `HomeViewModel` or `SearchViewModel`, neither of which has a `Message` property. These `fail` messages can be ignored. [0]: https://private-user-images.githubusercontent.com/155958/541004949-2be43b36-4eb1-42b1-b91d-e53a5e5545de.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Njk1NDQwNTMsIm5iZiI6MTc2OTU0Mzc1MywicGF0aCI6Ii8xNTU5NTgvNTQxMDA0OTQ5LTJiZTQzYjM2LTRlYjEtNDJiMS1iOTFkLWU1M2E1ZTU1NDVkZS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwMTI3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDEyN1QxOTU1NTNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT03YTkzNDBmOWJiNzA3M2Q4MTVhMmFhZWZlNzgyMTNlNzgzNmMwYjYzNWI2NWUwZTJkZjNiYTVhMDMwMDkyMWRmJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.GVhTSVS_DsH64FV5Li4ppe2gaF9l849Im3Vba5HuFt8 [1]: https://github.com/user-attachments/assets/709f1ffd-e5fc-4d60-8027-c15029b9c799
jonpryor
added a commit
that referenced
this pull request
Jan 27, 2026
Context: #1726 Context: #1730 Build and run `Chefs.csproj`` for e.g. net10.0-desktop and NativeAOT while using Uno 6.6.0-dev.3: sed -i '' 's/"Uno.Sdk": ".*"/"Uno.Sdk": "6.6.0-dev.3"/g' global.json git clean -xdf Chefs{,.Api} dotnet publish -c Release -r osx-x64 -f net10.0-desktop -p:TargetFrameworkOverride=net10.0-desktop \ -bl Chefs/Chefs.csproj -p:UseSkiaRendering=true -p:SkiaPublishAot=true \ -p:SkiaPublishAot=true \ -p:IlcGenerateMapFile=true -p:IlcGenerateMstatFile=true -p:IlcGenerateDgmlFile=true -p:IlcGenerateMetadataLog=true \ -p:EmitCompilerGeneratedFiles=true -p:CompilerGeneratedFilesOutputPath=`pwd`/_gen Chefs/bin/Release/net10.0-desktop/osx-x64/publish/Chefs From the launch screen: 1. Click **Skip** 2. Click ** Sign in with Apple** 3. Click **🔍Search** on the left 4. In the Search box, type `m` When doing this with e838af9, the search results screen shows: > An error occurred. ![Search Results > An error occurred][0] …which isn't particularly helpful. Update `ErrorTemplate` within `FeedView.xaml` to also include the `Exception.Message` property contents: > An error occurred: > Reflection-based serialization has been disabled for this application. Use the IServiceCollection.AddJsonTypeInfo() or IHostBuilder.UseSerialization(IHostBuilder, IEnumerable<IJsonTypeInfoResolver>, Action<IServiceCollection>) extension methods to enable JSON deserialization for type `System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Chefs.Business.Models.SearchHistory, Chefs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]`. ![Search Results > A better error message][1] The downside to this approach is that the Console log shows this message after signing in, after step (2), above: fail: Uno.UI.DataBinding.BindingPropertyHelper[0] The [Message] property getter does not exist on type [Chefs.Presentation.HomeViewModel] as well as this message after going to the 🔍Search page, after step (3), above: fail: Uno.UI.DataBinding.BindingPropertyHelper[0] The [Search] property getter does not exist on type [Chefs.Presentation.SearchViewModel] These messages appear because *when `ErrorTemplate` is loaded*, the associated `DataContext` is for `HomeViewModel` or `SearchViewModel`, neither of which has a `Message` property. These `fail` messages can be ignored. [0]: https://private-user-images.githubusercontent.com/155958/541004949-2be43b36-4eb1-42b1-b91d-e53a5e5545de.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Njk1NDQwNTMsIm5iZiI6MTc2OTU0Mzc1MywicGF0aCI6Ii8xNTU5NTgvNTQxMDA0OTQ5LTJiZTQzYjM2LTRlYjEtNDJiMS1iOTFkLWU1M2E1ZTU1NDVkZS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwMTI3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDEyN1QxOTU1NTNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT03YTkzNDBmOWJiNzA3M2Q4MTVhMmFhZWZlNzgyMTNlNzgzNmMwYjYzNWI2NWUwZTJkZjNiYTVhMDMwMDkyMWRmJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.GVhTSVS_DsH64FV5Li4ppe2gaF9l849Im3Vba5HuFt8 [1]: https://github.com/user-attachments/assets/709f1ffd-e5fc-4d60-8027-c15029b9c799
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Context: #1726
Context: #1728
Build and run
Chefs.csprojfor e.g. net10.0-desktop and NativeAOT while using Uno 6.6.0-dev.3:From the launch screen:
mWhen doing this with e838af9, the search results screen shows:
…which isn't particularly helpful.
If you do all this with #1728 applied, the Console log shows:
which shows what the problem is:
RecipeService.Search()tries to save the search history, but JSON serialization does not supportDictionary<string, SearchHistory>, so anInvalidOperationExceptionis thrown.(Unfortunately the exception is basically swallowed; PR #1728 adds logging to that code path, and was needed to diagnose this issue.)
Update
MockEndpointContextto emit JSON serialization metadata forDictionary<string, SearchHistory>, so that Search now works.GitHub Issue (If applicable): #
PR Type
What kind of change does this PR introduce?
What is the current behavior?
What is the new behavior?
PR Checklist
Please check if your PR fulfills the following requirements:
Screenshots Compare Test Runresults.Other information
Internal Issue (If applicable):