Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate why having Microsoft.NET.Test.Sdk as a dependency throw exceptions while scanning for Fable plugins #3511

Open
MangelMaxime opened this issue Aug 22, 2023 · 6 comments

Comments

@MangelMaxime
Copy link
Member

Description

While working on #3441 (via commit d212c2f) a regression has been introduced.

Indeed, when trying to compile Python and Rust tests projects, an error was reported:

Unhandled exception. FSharp.Compiler.DiagnosticsLogger+ReportedError: The exception has been reported. This internal exception should now be caught at an error recovery point on the stack. Original message: The type 'NeutralResourcesLanguageAttribute' is required here and is unavailable. You must add a reference to assembly 'System.Resources.ResourceManager, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.)

This error is caused by the lines:

let scanForPlugins =
	asm.Contents.Attributes |> Seq.exists (fun attr ->
    	attr.AttributeType.TryFullName = Some "Fable.ScanForPluginsAttribute")

Which to me is not obvious why these lines would report an error. To fix this issue I decided to mimic the old behaviour of Fable which consist of ignoring exceptions at this place 🤫

I am opening this issue to keep track of this behaviour and if someone has an idea on why or how we can improve the situation please don't hesitate to step in.

I tried believe this problem only occur if the project has Microsoft.NET.Test.Sdk in its dependencies. So perhaps we could be a bit more restrictive on the DLL we skip.

@inosik
Copy link
Contributor

inosik commented Aug 23, 2023

You're right, the assembly that causes this is testhost.dll from Microsoft.TestPlatform.TestHost, which is a dependency of Microsoft.NET.Test.Sdk. It has the NeutralResourcesLanguageAttribute set, which comes from an unreferenced assembly. We could either add a reference to the (old) System.Resources.ResourceManager package, or just skip assemblies we can't handle.

@MangelMaxime
Copy link
Member Author

Thank you for looking into it and explaining the cause of the problem.

I tried to add System.Resources.ResourceManager to the test project but it didn't change the problem.

Also, there are 3 .dll failing that comes with Microsoft.NET.Test.Sdk. For now, my solution has been to add a log about dlls that we could not check for Fable plugins and skip them.

The old behaviour was just to skip them but had the problem of making some situation hard to understand or make the user think that the compilation was correct when in fact it was not.

CleanShot 2023-08-23 at 11 11 08

The new behaviour should be transparent for most of the users because I don't think they will depends on Microsoft.NET.Test.Sdk.

@Lanayx
Copy link

Lanayx commented Sep 18, 2024

I have just stumbled upon the commit that was made for this issue, and found out that the exception should not be silently swallowed, since it makes it extremely difficult to find the reason of the error.

@MangelMaxime
Copy link
Member Author

@Lanayx If I understand, when working on a Fable plugin, if we included the exception message in the exist log it would have helped you?

@Lanayx
Copy link

Lanayx commented Sep 19, 2024

Correct. I've started with the plugin yesterday and was desperate to see the error there without having an idea of what went wrong.

@MangelMaxime
Copy link
Member Author

MangelMaxime commented Sep 19, 2024

Ok, I will add the inner error message.

Based on my tests it never included anything meaningful but Fable compiler plugins are not often used so I can have miss something here. Hopefully, it will not add too much noise / fear if it come up in someone build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants