麺麭
麺麭
CC#
Created by 麺麭 on 10/27/2023 in #help
❔ Blazor .NET 8 RenderModeInteractiveAuto - fetch data via API
Blazor WASM: use HttpClient to call service (co-hosted or external) Blazor Server: interactivity invokes code on server, virtual DOM, blah blah Ok so how do I write a component that can fetch data for both modes?
Component authors should avoid coupling a component's implementation to a specific render mode. Instead, component authors should typically design components to support any render mode or hosting model...
https://learn.microsoft.com/en-us/aspnet/core/blazor/components/render-modes?view=aspnetcore-8.0 two ideas: 1. read some static property at runtime to determine the mode (or a hacky equivalent of this) Good: doesn't couple component to a dependency Bad: doing control flow like this means some path will always be unused in a component, looks kinda hacky and probably bug prone 2. inject an interface instead to do data fetching into a component, one with a server concrete implementation and a client concrete implementation, and register the client service in the wasm Client project and the server service in the Server project Good: seems like the "right" way to do it Bad: couples to an interface (not a huge problem since im not a component library author and still I imagine component library authors don't need to have a concrete fetch from web api impl that often). im gonna jump in and try #2 but i thought i'd ask first because I thought I'd see this in docs or a sample or something, but the samples still just have hardcoded data
50 replies
CC#
Created by 麺麭 on 10/5/2023 in #help
❔ IL CodeGen for toy compiler [advice]
I am trying to learn more about compilers. I'd like to target some type of IR language for a toy compiler, because I don't really want to target a high-level language and I don't want to mess with LLVM stuff yet. WASM seems like a good target and I'll probably go with it if this IL stuff does not work out, but being able to leverage a bunch of BCL code from the start even for a toy language sounds really cool, so I'd like to start out targeting a small, small subset of IL. Problem is, I'm having trouble producing an assembly, like, at all: 1. I keep reading System.Reflection.Emit can write a dynamic assembly to a PE, but all this seems like it's .NET Framework stuff. I've also heard emit can be slow but this is a toy project so whatever 2. When I try to override Compilation from Microsoft.CodeAnalysis, there are internal abstract members which tells me I'm not supposed to touch it (I'm sure implementing MyLangCompilation is wayyy more work than I realize, but this seems like the nicest option) 3. (https://github.com/kkokosa/Mobius.ILasm)[Mobius.ILasm] is apparently what https://sharplab.io uses to compile IL, and while this is a toy project and I'm not stuck up, I was hoping to plug into something from dotnet organization. Seems like this is the best bet so far 4. I know the F# compiler predates Roslyn and can produce IL on it own, so I tried peeking into it to see if there are any interfaces (nuget packages, dependencies, idk, etc.,) that it plugs into when emitting IL.. you know, for things like release signing, writing to streams, byte alignment,, just "staying in spec" type stuff, and I came away so confused seeing why the Rosyln team didn't bother trying to fit in F#. 5. Maybe Mono.Cecil ????
43 replies
CC#
Created by 麺麭 on 9/29/2023 in #help
❔ Update all packages in project or sln
With the Nuget Package Manager console, you can update all packages in a project (or solution I think) with
Update-Package
Update-Package
which is useful in general but also useful for me especially with the Include-Prerelease switch can you do the same thing with the dotnet CLI? Does not work:
dotnet add package --prerelease
dotnet add package --prerelease
dotnet update package --prerelease
dotnet update package --prerelease
19 replies
CC#
Created by 麺麭 on 8/14/2023 in #help
❔ How do I see possible options using the dotnet CLI?
dotnet publish --help shows help menu. For example,
-a, --arch <ARCH> The target architecture.
-a, --arch <ARCH> The target architecture.
is a possible option. How do I view all possible options I can pass? Another example:
--os <OS> The target operating system.
--os <OS> The target operating system.
21 replies
CC#
Created by 麺麭 on 8/19/2022 in #help
Direction for ASP.NET Core WebApp with Authorization without direct connection to database
Test first time creating thread in public server
15 replies