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

Remove explicit libraries #157

Merged
merged 3 commits into from
Nov 15, 2024
Merged

Remove explicit libraries #157

merged 3 commits into from
Nov 15, 2024

Conversation

ScarletKuro
Copy link
Member

@ScarletKuro ScarletKuro commented Nov 14, 2024

This is a trick I found in DotNetInternals, specifically in the following file:
https://github.com/jjonescz/DotNetInternals/blob/main/src/RazorAccess/RazorAccess.csproj

This parts:

<AssemblyName>Microsoft.CodeAnalysis.Razor.Test</AssemblyName>
<KeyOriginatorFile>$(PkgMicrosoft_DotNet_Arcade_Sdk)\tools\snk\AspNetCore.snk</KeyOriginatorFile>

Seems to be a workaround to gain access to internal classes of razor compiler.

It looks like this tool MSFT uses for testing purposes: https://lab.razor.fyi/.

To stay up-to-date with the correct assembly versions for the following packages:

  • Microsoft.CodeAnalysis.CSharp
  • Microsoft.CodeAnalysis.CSharp.Features
  • Microsoft.DotNet.Arcade.Sdk
  • Microsoft.Net.Compilers.Razor.Toolset

It’s recommended to periodically check the versions in Directory.Packages.props from the DotNetInternals

While this approach may seem like a dirty workaround, it’s better than manually dragging and updating the lib folder ourselves. I couldn’t find an easier way to handle this, as the following packages do not seem to be included:

  • Microsoft.AspNetCore.Mvc.Razor.Extensions
  • Microsoft.AspNetCore.Razor.Language
  • Microsoft.AspNetCore.Razor.Utilities.Shared
  • Microsoft.CodeAnalysis.Razor
  • Microsoft.Extensions.ObjectPool

Even in these nuget feeds:

<add key="nuget" value="https://api.nuget.org/v3/index.json" />
<add key="dotnet-eng" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" />
<add key="dotnet-tools" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" />
<add key="dotnet8" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json" />

So, I believe the magic comes from the Microsoft.DotNet.Arcade.Sdk reference.

@ScarletKuro
Copy link
Member Author

I made sure that @bind:get, @bind:set, @bind:after from #155 (comment) are working.
The difference is also that with this the RazorLanguageVersion has a RazorLanguageVersion.Version_9_0 razor version, while the public nuget only has RazorLanguageVersion.Version_6_0. And for bind:set a minimum version 7.0 support is required.

Copy link
Collaborator

@henon henon left a comment

Choose a reason for hiding this comment

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

Very interesting magic.

@mikes-gh
Copy link

Tested using

delete all bin obj directories
delete lib directory
clean
rebuild
run
test using

<input type="text"
    @bind:get="text"
    @bind:set="SetValue" />
    
@code {
    private string text = string.Empty;

    private void SetValue(string value)
    {
        text = value + "test";
    }
}

All works fine

I think you need to delete the libs directory from the repo?

@mikes-gh mikes-gh merged commit 3cc27b0 into MudBlazor:main Nov 15, 2024
3 checks passed
@mikes-gh
Copy link

Thanks @ScarletKuro

@ScarletKuro ScarletKuro deleted the lib_trick branch November 15, 2024 12:51
ScarletKuro added a commit to ScarletKuro/TryMudBlazor that referenced this pull request Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants