Apply R# clean-up for reliability (#877)

* Apply R# clean-up for reliability

- Migrate to NUnit4 Assert.That
- Update dependencise versions
- Fix LangVersion to 9.0 (until net core migration)
- Reformat code
- Apply 'var' style (easier for refactoring)
- Remove redundant parentheses
- Add braces on every condition blocks (1 line)
- Uses new null checking patterns
- Uses AutoProperties when possible
- Uses string scalar type instead of class
- Clean usings
- Add .orig files in git ignore
- Rename some properties to respect defined conventions and US format definition
	- ID -> Id
	- BPM -> Bpm
	- Finish -> End

* Update R# settings according to the clean-up made
This commit is contained in:
Quentin Bray authored and GitHub committed 2026-06-22 19:52:06 +02:00
1 parent b9b0f7c8df
commit 6ffa63b923
236 files changed
+14194 -7278

No files matched your search

+87 -20
View File
@@ -36,56 +36,79 @@ namespace VocaluxeLib.Songs
private void _WriteHeaderEntry(string id, string value)
{
if (!String.IsNullOrEmpty(value))
if (!string.IsNullOrEmpty(value))
{
_Tw.WriteLine("#" + id.ToUpper() + ":" + value);
}
}
private void _WriteHeaderEntry(string id, bool value)
{
if (value)
{
_WriteHeaderEntry(id, "YES");
}
}
private void _WriteHeaderEntry(string id, float value, float def = 0f)
{
if (Math.Abs(value - def) > 0.0001)
{
_WriteHeaderEntry(id, value.ToInvariantString());
}
}
private void _WriteHeaderEntry(string id, int value, int def = 0)
{
if (value != def)
{
_WriteHeaderEntry(id, value.ToString());
}
}
private void _WriteHeaderEntrys(string id, ICollection<string> value)
{
if (value == null || value.Count <= 0)
{
return;
foreach (String val in value)
}
foreach (var val in value)
{
_WriteHeaderEntry(id, val);
}
}
private void _WriteHeader()
{
if (_Song.ManualEncoding)
{
_WriteHeaderEntry("ENCODING", _Song.Encoding.GetEncodingName());
}
_WriteHeaderEntry("CREATOR", _Song.Creator);
_WriteHeaderEntry("VERSION", _Song.Version);
_WriteHeaderEntry("LENGTH", _Song.Length);
_WriteHeaderEntry("SOURCE", _Song.Source);
if (!String.IsNullOrEmpty(_Song._Comment))
if (!string.IsNullOrEmpty(_Song._Comment))
{
string comment = _Song._Comment.Replace("\r\n", "\n").Replace('\r', '\n');
char[] splitChar = {'\n'};
var comment = _Song._Comment.Replace("\r\n", "\n").Replace('\r', '\n');
char[] splitChar = { '\n' };
_WriteHeaderEntrys("COMMENT", comment.Split(splitChar));
}
_WriteHeaderEntry("TITLE", _Song.Title);
_WriteHeaderEntry("ARTIST", _Song.Artist);
if (!_Song.Title.Equals(_Song.TitleSorting))
{
_WriteHeaderEntry("TITLE-ON-SORTING", _Song.TitleSorting);
}
if (!_Song.Artist.Equals(_Song.ArtistSorting))
{
_WriteHeaderEntry("ARTIST-ON-SORTING", _Song.ArtistSorting);
}
_WriteHeaderEntrys("EDITION", _Song.Editions);
_WriteHeaderEntrys("GENRE", _Song.Genres);
_WriteHeaderEntry("TAGS", String.Join(",", _Song.Tags.ToArray()));
@@ -98,30 +121,48 @@ namespace VocaluxeLib.Songs
_WriteHeaderEntry("VIDEO", _Song.VideoFileName);
_WriteHeaderEntry("VIDEOGAP", _Song.VideoGap);
if (_Song.VideoAspect != EAspect.Crop)
{
_WriteHeaderEntry("VIDEOASPECT", _Song.VideoAspect.ToString());
}
_WriteHeaderEntry("RELATIVE", _Song.Relative);
_WriteHeaderEntry("BPM", _Song.BPM / _BPMFactor);
_WriteHeaderEntry("BPM", _Song.Bpm / _BpmFactor);
_WriteHeaderEntry("GAP", (int)(_Song.Gap * 1000f));
if (_Song.Preview.Source == EDataSource.Tag)
{
_WriteHeaderEntry("PREVIEWSTART", _Song.Preview.StartTime);
}
_WriteHeaderEntry("START", _Song.Start);
_WriteHeaderEntry("END", (int)(_Song.Finish * 1000f));
_WriteHeaderEntry("END", (int)(_Song.End * 1000f));
if (_Song.ShortEnd.Source == EDataSource.Tag)
_WriteHeaderEntry("ENDSHORT", (int)(CBase.Game.GetTimeFromBeats(_Song.ShortEnd.EndBeat, _Song.BPM) + _Song.Gap) * 1000);
{
_WriteHeaderEntry("ENDSHORT", (int)(CBase.Game.GetTimeFromBeats(_Song.ShortEnd.EndBeat, _Song.Bpm) + _Song.Gap) * 1000);
}
if (!_Song._CalculateMedley)
{
_WriteHeaderEntry("CALCMEDLEY", "OFF");
}
if (_Song.Medley.Source == EDataSource.Tag)
{
_WriteHeaderEntry("MEDLEYSTARTBEAT", _Song.Medley.StartBeat);
_WriteHeaderEntry("MEDLEYENDBEAT", _Song.Medley.EndBeat);
}
for (int i = 0; i < _Song.Notes.VoiceCount; i++)
for (var i = 0; i < _Song.Notes.VoiceCount; i++)
{
if (_Song.Notes.VoiceNames.IsSet(i))
{
_WriteHeaderEntry("P" + i, _Song.Notes.VoiceNames[i]);
}
}
foreach (string addLine in _Song.UnknownTags)
foreach (var addLine in _Song.UnknownTags)
{
_Tw.WriteLine(addLine);
}
}
/// <summary>
@@ -134,47 +175,67 @@ namespace VocaluxeLib.Songs
private int _GetBreakBeat(int firstPossibleBeat, int firstNoteBeat)
{
int breakBeat;
int diff = firstNoteBeat - firstPossibleBeat;
float timeDiff = CBase.Game.GetTimeFromBeats(diff, _Song.BPM);
var diff = firstNoteBeat - firstPossibleBeat;
var timeDiff = CBase.Game.GetTimeFromBeats(diff, _Song.Bpm);
if (timeDiff > 4f)
breakBeat = firstPossibleBeat + (int)CBase.Game.GetBeatFromTime(2f, _Song.BPM, 0f);
{
breakBeat = firstPossibleBeat + (int)CBase.Game.GetBeatFromTime(2f, _Song.Bpm, 0f);
}
else if (timeDiff > 2f)
breakBeat = firstPossibleBeat + (int)CBase.Game.GetBeatFromTime(1f, _Song.BPM, 0f);
{
breakBeat = firstPossibleBeat + (int)CBase.Game.GetBeatFromTime(1f, _Song.Bpm, 0f);
}
else if (diff < 2)
{
breakBeat = firstPossibleBeat;
}
else if (diff < 9)
{
breakBeat = firstNoteBeat - 2;
}
else if (diff < 13)
{
breakBeat = firstNoteBeat - 3;
}
else if (diff < 17)
{
breakBeat = firstNoteBeat - 4;
}
else
{
breakBeat = firstPossibleBeat + 12;
}
return breakBeat;
}
private void _WriteNotes()
{
for (int i = 0; i < _Song.Notes.VoiceCount; i++)
for (var i = 0; i < _Song.Notes.VoiceCount; i++)
{
CVoice voice = _Song.Notes.GetVoice(i);
var voice = _Song.Notes.GetVoice(i);
if (_Song.Notes.VoiceCount > 1)
{
_Tw.WriteLine("P" + Math.Pow(2, i));
int currentBeat = 0;
}
var currentBeat = 0;
CSongLine lastLine = null;
foreach (CSongLine line in voice.Lines)
foreach (var line in voice.Lines)
{
if (lastLine != null)
{
string lineTxt = "- " + (_GetBreakBeat(lastLine.EndBeat + 1, line.FirstNoteBeat) - currentBeat);
var lineTxt = "- " + (_GetBreakBeat(lastLine.EndBeat + 1, line.FirstNoteBeat) - currentBeat);
if (_Song.Relative)
{
lineTxt += " " + (line.FirstNoteBeat - currentBeat);
currentBeat = line.FirstNoteBeat;
}
_Tw.WriteLine(lineTxt);
}
foreach (CSongNote note in line.Notes)
foreach (var note in line.Notes)
{
string tag;
switch (note.Type)
@@ -197,11 +258,14 @@ namespace VocaluxeLib.Songs
default:
throw new NotImplementedException("Note type " + note.Type);
}
_Tw.WriteLine(tag + " " + (note.StartBeat - currentBeat) + " " + note.Duration + " " + note.Tone + " " + note.Text);
}
lastLine = line;
}
}
_Tw.WriteLine("E");
}
@@ -226,8 +290,11 @@ namespace VocaluxeLib.Songs
finally
{
if (_Tw != null)
{
_Tw.Dispose();
}
}
return true;
}
}