[PR #293] [MERGED] workaround for AppContext.BaseDirectory being null on some platforms #842

Closed
opened 2025-12-29 15:33:37 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/wiremock/WireMock.Net/pull/293
Author: @eli-darkly
Created: 6/28/2019
Status: Merged
Merged: 7/3/2019
Merged by: @StefH

Base: masterHead: NullAppContextBaseDirectoryWorkaround


📝 Commits (1)

  • eea99ed workaround for AppContext.BaseDirectory being null on some platforms

📊 Changes

1 file changed (+12 additions, -1 deletions)

View changed files

📝 src/WireMock.Net/Owin/AspNetCoreSelfHost.cs (+12 -1)

📄 Description

This addresses https://github.com/WireMock-Net/WireMock.Net/issues/292 which is known to affect Xamarin Android.

I'm not aware of any other platforms where this is a problem, but if there are any, the principle is the same: if AppContext.BaseDirectory is null, then WebHostBuilder won't work without setting ContentRoot. WireMock.Net wouldn't work at all under that condition before, so the workaround can't hurt - and the workaround is only used in that condition, so platforms where WireMock.Net did work are not affected.

I don't know of any way to unit-test this change, since it's not possible to change AppContext.BaseDirectory dynamically in a test. However, I have tested manually in Xamarin Android and it solved the problem for me.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/wiremock/WireMock.Net/pull/293 **Author:** [@eli-darkly](https://github.com/eli-darkly) **Created:** 6/28/2019 **Status:** ✅ Merged **Merged:** 7/3/2019 **Merged by:** [@StefH](https://github.com/StefH) **Base:** `master` ← **Head:** `NullAppContextBaseDirectoryWorkaround` --- ### 📝 Commits (1) - [`eea99ed`](https://github.com/wiremock/WireMock.Net/commit/eea99ed3cdbd6431a4f9aacb3089f63638c24723) workaround for AppContext.BaseDirectory being null on some platforms ### 📊 Changes **1 file changed** (+12 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/WireMock.Net/Owin/AspNetCoreSelfHost.cs` (+12 -1) </details> ### 📄 Description This addresses https://github.com/WireMock-Net/WireMock.Net/issues/292 which is known to affect Xamarin Android. I'm not aware of any other platforms where this is a problem, but if there are any, the principle is the same: if AppContext.BaseDirectory is null, then WebHostBuilder won't work without setting ContentRoot. WireMock.Net wouldn't work at all under that condition before, so the workaround can't hurt - and the workaround is only used in that condition, so platforms where WireMock.Net _did_ work are not affected. I don't know of any way to unit-test this change, since it's not possible to change AppContext.BaseDirectory dynamically in a test. However, I have tested manually in Xamarin Android and it solved the problem for me. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 15:33:37 +01:00
adam closed this issue 2025-12-29 15:33:37 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#842