mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 06:10:30 +01:00
[PR #293] [MERGED] workaround for AppContext.BaseDirectory being null on some platforms #842
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 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:
master← Head:NullAppContextBaseDirectoryWorkaround📝 Commits (1)
eea99edworkaround 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.