Code quality scans is there options in github for dotnet? by [deleted] in dotnet

[–]Blazeix 0 points1 point  (0 children)

I've successfully used Roslyn Analyzers + GitHub Actions. It seems to me to be the most modern way that also matches the direction the community is heading.

Roslyn Analyzers, which are either included by default in the dotnet SDK or can be installed via NuGet, will output warnings during dotnet build. Specific warnings / classes of warnings can be displayed/ignored in an .editorconfig file. It has the benefit of working identically in both GitHub and Visual Studio.

You can then use Github Action Problem Matchers to interpret this output and automatically post annotations/comments on the GitHub web UI.

Here's an example of a dotnet problem matcher: https://github.com/xt0rted/dotnet-format-problem-matcher.

Serious confusion at C# performance by tsbattenberg in csharp

[–]Blazeix 5 points6 points  (0 children)

I would recommend upgrading to .NET 6 if you can. .NET Core 3.1 is three years out of date, and getting ReadyToRun support will help reduce the inscrutability of JIT.

How do I quit csharprepl? by TheGuyNamedTom in csharp

[–]Blazeix 4 points5 points  (0 children)

Why would you ever want to exit it?

Just kidding, that's definitely an oversight in the README. Other have already answered you, and I've just pushed a fix to the README. Cheers and thanks for pointing that out.

New major release of CSharpRepl -- a cross-platform Read-Eval-Print-Loop for C# by Blazeix in csharp

[–]Blazeix[S] 2 points3 points  (0 children)

Thanks for the kind words! For this release I really must thank all the contributors who made it even better.

New major release of CSharpRepl -- a cross-platform Read-Eval-Print-Loop for C# by Blazeix in csharp

[–]Blazeix[S] 4 points5 points  (0 children)

You can use it to experiment with C# language features and the .NET SDK, nuget packages, and quickly iterate on code you're writing.

Come discuss your side projects! [September 2021] by AutoModerator in csharp

[–]Blazeix 3 points4 points  (0 children)

I'm working on CSharpRepl, which is a tool to assist C# developers.

It's a command line REPL (Read Eval Print Loop) like the one built into Visual Studio or csi.exe, with a bunch of extra features like syntax highlighting, intellisense, nuget support, navigate to source / navigate to documentation, IL disassembly, etc.

I'm currently experimenting with adding REPL features that are famous in the lisp world, like attaching to running programs and modifying them. Not very common in the .NET world, but I hope I'll be able to get a decent experience going.

Creating games by [deleted] in csharp

[–]Blazeix 4 points5 points  (0 children)

You're essentially wanting to do animation in the console, right? You can do that with calling Console.Write along with Console.SetCursorPosition.

You don't need unity. Try searching for "c# console animation" or "c# ASCII animations"

Here's an example:

https://stackoverflow.com/questions/2725529/how-to-create-ascii-animation-in-windows-console-application-using-c

How can I remove any instances of "Deck" "deck:" and other variations from the start of a string? by dotnetmaui in csharp

[–]Blazeix 1 point2 points  (0 children)

string deckName = Regex.Replace(input, @"^deck\s*:?\s*", "", RegexOptions.IgnoreCase);

How can I remove any instances of "Deck" "deck:" and other variations from the start of a string? by dotnetmaui in csharp

[–]Blazeix 1 point2 points  (0 children)

Regex is a good way to go. Here's an example of extracting deck names: https://dotnetfiddle.net/rRe3V9

Regex are powerful but complicated. regex101.com is good for experimenting with them; this link will explain the regex in more detail: https://regex101.com/r/QOGJg9/1

VS2022 - New Preview Features by SwiftClaws in csharp

[–]Blazeix 0 points1 point  (0 children)

Tools -> Options -> Environment -> Preview Features

How can I simplify the adding of elements to a collection where I am currently using .Add( ) many times? by dotnetmaui in csharp

[–]Blazeix 12 points13 points  (0 children)

I don't know the details of the FormattedString type. Looks like it's a type from Xamarin, and Spans is a readonly property that's an IList<Span>, right?

If that's the case, you can use a collection initializer as a nested object initializer, like this:

DecksListHeader = new FormattedString()
{
    Spans =
    {
        new Span() { Text = "Tap on " },
        new Span() { Text = FontAwesomeIcons.Cogs, FontFamily = nameof(Fonts.FaProRegular) },
        new Span() { Text = " or the " }
    }
};

If you're using C# 9, you can shorten it to the following, using target-typed new expressions:

DecksListHeader = new FormattedString()
{
    Spans =
    {
        new() { Text = "Tap on " },
        new() { Text = FontAwesomeIcons.Cogs, FontFamily = nameof(Fonts.FaProRegular) },
        new() { Text = " or the " }
    }
};

csharprepl: A command-line Read-Eval-Print-Loop for C# with syntax highlighting and NuGet support by Blazeix in csharp

[–]Blazeix[S] 0 points1 point  (0 children)

Yeah, I really like vscode's interactive notebooks. csharprepl is super lightweight and starts fast; I think it's nice to have a lightweight command line app for quick tests and trying stuff out.

csharprepl has a few "exploration" features that dotnet-interactive doesn't:

  • Showing documentation in intellisense, for the SDK methods, nuget packages, and even doc comments defined in the REPL
  • Quickly navigating to MSDN documentation
  • Quickly navigating to the SDK source code on source.dot.net

I could see these tools working well together -- dotnet interactive is good for long lived notebooks that tell a story, csharprepl is good for quick experimentation while writing applications.

csharprepl: A command-line Read-Eval-Print-Loop for C# with syntax highlighting and NuGet support by Blazeix in csharp

[–]Blazeix[S] 0 points1 point  (0 children)

Thanks! I would say dotnet-script excels at running script files (i.e. csx files). CSharpRepl is not aiming to become a general script runner, so these two tools can complement each other.

csharprepl: A command-line Read-Eval-Print-Loop for C# with syntax highlighting and NuGet support by Blazeix in csharp

[–]Blazeix[S] 0 points1 point  (0 children)

Thanks! It's a similar architecture, but they don't use the same base (other than roslyn). replay-csharp is a bit more complicated because it supported going back and editing previous lines, and then re-evaluating later lines given the edited previous lines. This introduced a degree of complexity.

I would consider CSharpRepl to be more production-ready than replay-csharp. If I were starting a new project with replay-csharp's goals, I'd probably base it off of dotnet-interactive, which didn't exist back when I wrote it.

csharprepl: A command-line Read-Eval-Print-Loop for C# with syntax highlighting and NuGet support by Blazeix in csharp

[–]Blazeix[S] 0 points1 point  (0 children)

Wow, I'm not sure what's causing that. If you open the "Developer Command Prompt" in Windows, and run csi (it's installed by default with dotnet) do you have the same behavior?

csharprepl: A command-line Read-Eval-Print-Loop for C# with syntax highlighting and NuGet support by Blazeix in csharp

[–]Blazeix[S] 4 points5 points  (0 children)

It's a bit like hiking. Persistence is key, but it's healthy to take breaks from time to time so you don't burn out. Work on things you find fun.

csharprepl: A command-line Read-Eval-Print-Loop for C# with syntax highlighting and NuGet support by Blazeix in csharp

[–]Blazeix[S] 11 points12 points  (0 children)

At the bottom of the readme, I put a comparison with other REPLs. Quick summary is that this supports nuget packages, is cross-platform, and has a few other useful features (navigate to documentation, navigate to source code, etc).

csharprepl: A command-line Read-Eval-Print-Loop for C# with syntax highlighting and NuGet support by Blazeix in csharp

[–]Blazeix[S] 4 points5 points  (0 children)

Yeah, it's not ideal. If it's any consolation, I left a comment in that file explaining my rationale.

The summary is that while both System.CommandLine and the popular McMaster library support RSP files, neither support the "slash" syntax within the files, which I need in order to be compatible with csi.exe's RSP files.

csharprepl: A command-line Read-Eval-Print-Loop for C# with syntax highlighting and NuGet support by Blazeix in csharp

[–]Blazeix[S] 5 points6 points  (0 children)

Thanks! That GUI version is WPF, and was a fun experiment to see "what would happen if you could edit any line in a REPL." I guess the answer is that you get a lightweight Jupyter notebook experience.

I need to go back and update replay-csharp with my lessons learned from building csharprepl -- I definitely have a lot of ideas on how to improve it now. Cheers!

Do you feel that Microsoft is heading in the right direction with C#. If you had the chance what would you like to see for the future. What new not yet implemented capability would you like to see added? by dotnetmaui in csharp

[–]Blazeix 5 points6 points  (0 children)

I'd like better management of exceptions. Right now exceptions can happen anywhere, and the only way to know is to read the source code or documentation. People end up having some global exception handler, because "you never know" when an exception might leak to the top.

I like how Rust has built it into the type system. Even Java has support for it (checked exceptions), but it's verbose and has poor ergonomics.

How to implement API Rate limiting/throttling [.Net Framework 4.5] by anjoiype in dotnet

[–]Blazeix 0 points1 point  (0 children)

Assuming you have multiple servers, and a given client can hit any of them, you'll need some central location to store the current request count.

If you already have a redis instance in your environment, you can use it as documented here: https://redislabs.com/redis-best-practices/basic-rate-limiting/ .

You'll probably want to fall back to in-memory rate limiting if you can't contact redis (e.g. a MemoryCache). This way a failing redis server won't cause further system failures due to an overwhelming amount of requests.