Skip to content
New issue

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

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

Already on GitHub? # to your account

[dotnet-sdk-9.0.100-preview.2.24113.6] SharpScss.dll causes application crash when converting scss to css #21

Closed
Junjun-zhao opened this issue Feb 27, 2024 · 6 comments · Fixed by #22
Labels

Comments

@Junjun-zhao
Copy link

When testing 3rd party application which referring to the SharpScss nuget package with the latest .NET 9 build, it stops working after accessing page. It is caused by SharpScss.dll when converting scss to css. The exception from Visual Studio output window is: "Exception thrown: 'SharpScss.ScssException' in SharpScss.dll". Please refer to dotnet/runtime#98646 for more reference.

Reproduction Steps
Minimal Repro steps (Demo attached):
ConsoleDemo.zip

The machine has dotnet-sdk-9.0.100-preview.2.24113.6 installed.

  1. Create a new console project.
  2. Install SharpScss nuget package.
  3. Copy the following code to Program.cs:
using SharpScss;
var result = Scss.ConvertToCss(@"@import ""foo"";", new ScssOptions()
{
    OutputStyle = ScssOutputStyle.Compressed,
    InputFile = "test.scss",
    TryImport = (ref string file, string path, out string scss, out string map) =>
    {
        scss = "div {color: #FFF;}";
        map = null;
        return true;
    }
});
var css = result.Css.Trim();
Console.WriteLine(css);
Console.ReadKey();
  1. Build the app.
  2. Change the runtime.config file to let the app run against with dotnet-sdk-9.0.100-preview.2.24113.6.
 "framework": {
      "name": "Microsoft.NETCore.App",
      "version": "9.0.0-preview.2.24112.33"
    }
  1. Launch the app.

Expected behavior
Launch successfully with converted css output in command window:
image

Actual behavior
App crashed with stop working prompt window.

@ronikurnia1
Copy link

Hi @Junjun-zhao, I've got the same issue. Do you have any workaround?

@Junjun-zhao
Copy link
Author

Hi @ronikurnia1 No, we are still blocked by this issue.

xoofx added a commit that referenced this issue Nov 2, 2024
Though this is not normal. It seems this is a bug in .NET 9
@xoofx xoofx mentioned this issue Nov 2, 2024
@xoofx xoofx closed this as completed in #22 Nov 2, 2024
@xoofx xoofx added the bug label Nov 2, 2024
@xoofx
Copy link
Owner

xoofx commented Nov 2, 2024

2.1.0 should fix the issue, but while investigating, I believe it is a regression in .NET 9 and DllImport interop/trampoline passing an invalid argument when passing null but haven't been able to reproduce it with a simpler example.

@ronikurnia1
Copy link

I've just tested it using 2.1.0 and it works like a charm in my env. Great job thanks @xoofx !

@xoofx
Copy link
Owner

xoofx commented Nov 2, 2024

Actually, I think it is tracked in this issue dotnet/runtime#109033 and it should be fixed in a upcoming version of .NET 9

@Junjun-zhao
Copy link
Author

Thanks @xoofx. This issue has been fixed on the latest 3.0.0 and .NET 9 GA build.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants