Rhythmic
.editorconfig and Code Cleanup question
I struggle to find information about the following:
1. Which Visual Studio Code Cleanup setting affects
IDE0059
? I can't find it in https://learn.microsoft.com/en-us/visualstudio/ide/code-styles-and-code-cleanup?view=vs-2022
2. Regarding IDE0059
is it possible to have the following config values prefer to not use any unused value assignment whatsoever?
These are my settings, which I applied after a code cleanup added unwanted _ =
in my code:
csharp_style_unused_value_assignment_preference = discard_variable:none
csharp_style_unused_value_expression_statement_preference = discard_variable:none
I.e. I want to prefer fun();
instead of _ = fun();
or int unused = fun();
.
The only options I see for these variables are discard_variable
and unused_local_variable
, and even if I find the answer to question 1, I doubt a new cleanup will remove the _ =
instead of ignoring them.
I assume "Find and Replace" is the best option in this particular case?
Here's the doc for IDE0059
for reference: https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0059?pivots=lang-csharp-vb1 replies
Add external folders to solution
I have a program which can run .cs files that aren't a part of the source code. These are essentially customizable algorithms in which certain methods from the source code are run.
Since the directory containing these external .cs files aren't part of the source code, they're not in the project solution, so IntelliSense doesn't work when editing these files, which is impractical.
Is there a way to enable IntelliSense for these directories, such that I can Ctrl+Click on methods to go to their definitions in the source code?
My solution so far is to copy all the files to a folder inside the solution, which is impractical because it isn't synchronized with the external folder and now stores all the files twice.
I'm using Visual Studio Community 2022.
14 replies
❔ Using compact switch syntax
Is it possible to set
format_code = 1
for case _
using C#8.0 switch syntax?
// int format_code
string format_name = format_code switch
{
0 => "Format8Bits",
1 => "Format16Bits",
2 => "ImaAdpcm",
_ => "UNKNOWN (trying to interpret as Format16Bits)"
};
8 replies
❔ Most efficient way to retrieve a range of objects from an array
Imagine you have some sort of array/list/dict/whatever to store every note in a song. Each note has a note-timestamp (when it appears in the song). You also have a current-timestamp, which could be i.e. the current playback position in the song. What's an efficient way to find all notes within, say, a 5 second range of the current-timestamp?
An example of an inefficient way would be to iterate through every note, evaluate whether its note-timestamp is within 5 seconds of the custom-timestamp, and then save a reference if it's true.
The goal is to match up player input notes with a song's notes for a rhythm game. Every time an input is received, the game needs to find out which note to match up the input with, but I think it would be too inefficient to check every note every time. So I'm wondering if there's a better way.
16 replies
❔ Making properties accessible by both static and non-static methods
I had to make a static duplicate of a property, because I wanted it to be accessible by both non-static and static methods:
readonly string[] NoteNames = { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };
static readonly string[] NoteNamesStatic = { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };
Is there a better way of doing this, or do I always need to define it twice?4 replies