Skip to content

Conversation

@steveisok
Copy link
Member

@steveisok steveisok commented Jun 25, 2020

HostFileChangeMonitor relies on FSW, which is not supported on wasm. This change disables the corresponding tests that were failing.

@Dotnet-GitSync-Bot
Copy link
Collaborator

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@jkotas
Copy link
Member

jkotas commented Jun 25, 2020

What is the behavior one gets on browser wasm before this change? Would that behavior be good enough?

(I agree we need to disable the test.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

License header

@steveisok
Copy link
Member Author

@jkotas It'll throw

System.EntryPointNotFoundException : SystemNative_INotifyInit assembly:<unknown assembly> type:<unknown type> member:(null)

@jkotas
Copy link
Member

jkotas commented Jun 25, 2020

SystemNative_INotifyInit assembly: type: member:(null)

Is it the case even after #38368 ?

@steveisok
Copy link
Member Author

SystemNative_INotifyInit assembly: type: member:(null)

Is it the case even after #38368 ?

It'll throw PNSE. I guess that raises the question, should HostFileChangeMonitor also throw PNSE?

@jkotas
Copy link
Member

jkotas commented Jun 25, 2020

I do not think we need to be transitively updating all places that depend on unsupported functionality, unless there is significant value in doing so (e.g. allow large amount of code to be linked away in frequently used library).

@steveisok
Copy link
Member Author

I do not think we need to be transitively updating all places that depend on unsupported functionality, unless there is significant value in doing so (e.g. allow large amount of code to be linked away in frequently used library).

I think we should attempt to get as close to the top of the public API as possible. In this case, it's pretty cheap to do, so why not?

@marek-safar
Copy link
Contributor

I do not think we need to be transitively updating all places that depend on unsupported functionality

I think there is almost always value in being explicit in public APIs if they throw PNSE or not. It's not only about size but more about making it easier for human reviews and tooling to extract this kind of information.

@jkotas
Copy link
Member

jkotas commented Jun 25, 2020

I think there is almost always value in being explicit in public APIs if they throw PNSE or not

I agree with that for the inbox libraries.

System.Runtime.Caching is independent nuget package that happens to live in dotnet/runtime (we are shipping the org structure). The independent nuget packages should prefer to be platform neutral and depend on the support matrix of the underlaying platform-specific libraries where possible.

@akoeplinger
Copy link
Member

What if we add a check to the HostFileMonitor constructor:

if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER"))
   throw new PlatformNotSupportedException();

Then the assembly could stay platform neutral.

@jkotas
Copy link
Member

jkotas commented Jun 26, 2020

Do you expect that every nuget package out there should add a check like this around a call to API that's unsupported on wasm?

If not, we should not be doing this in our nuget packages either.

@akoeplinger
Copy link
Member

Yes I think that would be something a nuget package should do to disable functionality that doesn't work on wasm/browser.

@jkotas
Copy link
Member

jkotas commented Jun 26, 2020

That is a very high tax on the ecosystem as a whole.

Also, it is a encouraging bad pattern that is not future proof. If a future version of webassembly adds support for some of these, it means everybody has to do a replat.

A better pattern for this is to catch PlatformNotSupported exception and convert it in more appropriate exception. This only makes sense when there is a more appropriate exception - not the case here.

@akoeplinger
Copy link
Member

I still think it's better to be explicit as most users probably treat our System.* packages as special :)

In this specific case it's pretty unlikely browsers would add something like an inotify API since there's no filesystem at all, we're using an emulation layer provided by emscripten.

@jkotas
Copy link
Member

jkotas commented Jun 26, 2020

cc @ericstj This is related to our discussion about how far we should be going with platform special casing.

@ericstj
Copy link
Member

ericstj commented Jun 26, 2020

We shouldn't be doing this. Even the type you're throwing from has another path through it where the caller can provide their own implementation by setting ObjectCache.Host.

We shouldn't be projecting our platform-specific characteristics up the stack. If we find it important enough for libraries to react to this, we should design capability APIs that they can use, like was done for Ref.Emit.

@ericstj ericstj requested review from HongGit and StephenMolloy June 26, 2020 20:40
@akoeplinger
Copy link
Member

Even the type your throwing from has another path through it where the caller can provide their own implementation by setting ObjectCache.Host.

@ericstj I'm not sure what you mean by that?

@jkotas
Copy link
Member

jkotas commented Jun 26, 2020

Look for host.GetService(typeof(IFileChangeNotificationSystem)) in HostFileChangeMonitor.cs. This can return user-supplied implementation of file watcher that does not depend on any of the underlaying platform capabilities.

@akoeplinger
Copy link
Member

I see. In that case I think I agree we should just skip the tests only.

@akoeplinger akoeplinger changed the title [Wasm] Throw PNSE for HostFileChangeMonitor [Wasm] Disable tests for HostFileChangeMonitor Jun 29, 2020
@steveisok steveisok merged commit a306b03 into dotnet:master Jun 29, 2020
@steveisok steveisok deleted the hostfcm-pnse branch June 29, 2020 19:50
@ghost ghost locked as resolved and limited conversation to collaborators Dec 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants