{"record":{"id":"1d4f9663d80fded2","repo":"unoplatform/uno","slug":"value-cannot-be-null-parameter-storecontext","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'storeContext')","messagePattern":"Value cannot be null\\. \\(Parameter 'storeContext'\\)","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/AddIns/Uno.UI.GooglePlay/StoreContextExtension.cs","lineNumber":28,"sourceCode":"using Android.OS;\nusing Android.Print;\nusing Uno.Foundation.Logging;\nusing Windows.Foundation.Metadata;\nusing Windows.Services.Store;\nusing Windows.Services.Store.Internal;\nusing Xamarin.Google.Android.Play.Core.Review;\nusing Xamarin.Google.Android.Play.Core.Review.Testing;\nusing Xamarin.Google.Android.Play.Core.Tasks;\n\nnamespace Uno.UI.GooglePlay;\n\npublic class StoreContextExtension : IStoreContextExtension\n{\n\tprivate readonly StoreContext _storeContext;\n\n\tpublic StoreContextExtension(object storeContext)\n\t{\n\t\t_storeContext = storeContext as StoreContext ?? throw new ArgumentNullException(nameof(storeContext));\n\t}\n\n\tpublic async Task<StoreRateAndReviewResult> RequestRateAndReviewAsync(CancellationToken token)\n\t{\n\t\tTaskCompletionSource<StoreRateAndReviewResult>? inAppRateTcs;\n\n\t\tinAppRateTcs = new();\n\n\t\tusing var reviewManager = WinRTFeatureConfiguration.StoreContext.TestMode\n\t\t\t? new FakeReviewManager(Application.Context)\n\t\t\t: ReviewManagerFactory.Create(Application.Context);\n\n\t\tusing var request = reviewManager.RequestReviewFlow();\n\n\t\tusing var listener = new InAppReviewListener(reviewManager, inAppRateTcs);\n\t\trequest.AddOnCompleteListener(listener);\n\n\t\treturn await inAppRateTcs.Task;","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/AddIns/Uno.UI.GooglePlay/StoreContextExtension.cs#L10-L46","documentation":"Thrown as ArgumentNullException by the StoreContextExtension constructor when the storeContext argument is null or cannot be cast to the Xamarin Google Play StoreContext type (the 'as' cast yields null for a wrong type). This add-in wraps the Google Play in-app review API and requires a valid StoreContext instance.","triggerScenarios":"The caller passes null to the StoreContextExtension constructor, or passes an object that is not a StoreContext (the 'as StoreContext' yields null). This happens when StoreContext.GetDefault or equivalent returned null on a device without Google Play services.","commonSituations":"Running on a device/emulator without Google Play Services (where StoreContext cannot be obtained); the managed StoreContext was not initialized before the extension was created; passing a mock/wrong-type object in tests.","solutions":["Obtain a valid StoreContext before constructing StoreContextExtension — check for null from the Google Play StoreContext API.","Guard the constructor call: only create StoreContextExtension when StoreContext is non-null (e.g. device has Google Play Services).","On emulators, use WinRTFeatureConfiguration.StoreContext.TestMode = true to route through FakeReviewManager."],"exampleFix":"// before\nvar ext = new StoreContextExtension(storeContext); // storeContext is null → throws\n\n// after\nif (storeContext is StoreContext ctx)\n{\n    var ext = new StoreContextExtension(ctx);\n}\nelse\n{\n    // device lacks Google Play Services — skip in-app review\n}","handlingStrategy":"type-guard","validationCode":"// Before constructing, verify storeContext is a valid StoreContext\nif (storeContext is StoreContext ctx)\n{\n    var ext = new StoreContextExtension(ctx);\n}","typeGuard":"// Type guard to ensure the argument is a valid StoreContext\nstatic bool IsValidStoreContext(object obj) => obj is StoreContext;","tryCatchPattern":"try {\n    var ext = new StoreContextExtension(storeContext);\n} catch (ArgumentNullException ex) when (ex.ParamName == 'storeContext') {\n    // Google Play StoreContext unavailable — skip in-app review\n}","preventionTips":["Check StoreContext.GetDefault for null before passing to the extension.","Use WinRTFeatureConfiguration.StoreContext.TestMode = true on emulators for FakeReviewManager.","Verify the device has Google Play Services before requesting in-app review."],"tags":["android","google-play","in-app-review","validation","csharp","add-in"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}