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

+49 -8
View File
@@ -35,25 +35,32 @@ namespace VocaluxeLib.Utils.Player
set
{
if (_VideoEnabled == value)
{
return;
}
_VideoEnabled = value;
if (_VideoEnabled)
{
_LoadVideo();
}
else
{
_CloseVideo();
}
}
}
public int SongID
public int SongId
{
get { return _Song == null ? -1 : _Song.ID; }
get { return _Song == null ? -1 : _Song.Id; }
}
public bool SongHasVideo
{
get
{
return _Song != null && !String.IsNullOrEmpty(_Song.Folder) && !String.IsNullOrEmpty(_Song.VideoFileName) &&
return _Song != null && !string.IsNullOrEmpty(_Song.Folder) && !string.IsNullOrEmpty(_Song.VideoFileName) &&
File.Exists(Path.Combine(_Song.Folder, _Song.VideoFileName));
}
}
@@ -62,8 +69,11 @@ namespace VocaluxeLib.Utils.Player
{
get
{
if (_Song != null && !String.IsNullOrEmpty(_Song.Artist) && !String.IsNullOrEmpty(_Song.Title))
if (_Song != null && !string.IsNullOrEmpty(_Song.Artist) && !string.IsNullOrEmpty(_Song.Title))
{
return _Song.Artist + " - " + _Song.Title;
}
return base.ArtistAndTitle;
}
}
@@ -73,30 +83,39 @@ namespace VocaluxeLib.Utils.Player
get { return _Song == null ? CBase.Cover.GetNoCover() : _Song.CoverTextureBig; }
}
public CSongPlayer(bool loop = false) : base(loop) {}
public CSongPlayer(bool loop = false) : base(loop) { }
public CTextureRef GetVideoTexture()
{
if (_Video == null || _Song == null)
{
return null;
if (CBase.Video.GetFrame(_Video, CBase.Sound.GetPosition(_StreamID)))
}
if (CBase.Video.GetFrame(_Video, CBase.Sound.GetPosition(_StreamId)))
{
if (_VideoFading != null)
{
bool finished;
_Video.Texture.Color.A = _VideoFading.GetValue(out finished);
if (finished)
{
_VideoFading = null;
}
}
return _Video.Texture;
}
return null;
}
public void Load(CSong song, float position = 0f, bool autoplay = false)
{
if (song == null)
{
throw new ArgumentNullException("song");
}
Load(song.GetMP3(), position, autoplay);
_Song = song;
@@ -106,15 +125,21 @@ namespace VocaluxeLib.Utils.Player
private void _LoadVideo()
{
if (_Song == null)
{
return;
}
if (_Video != null || !SongHasVideo)
{
return;
}
string videoFilePath = Path.Combine(_Song.Folder, _Song.VideoFileName);
var videoFilePath = Path.Combine(_Song.Folder, _Song.VideoFileName);
_Video = CBase.Video.Load(videoFilePath);
if (_Video == null)
{
return;
}
_VideoFading = new CFading(0f, 1f, 3f);
@@ -124,48 +149,64 @@ namespace VocaluxeLib.Utils.Player
CBase.Video.Resume(_Video);
}
else
{
CBase.Video.Skip(_Video, 0f, _Song.VideoGap);
}
}
public override bool Play()
{
if (!base.Play())
{
return false;
}
if (_Video != null)
{
CBase.Video.Skip(_Video, Position, _Song.VideoGap);
CBase.Video.Resume(_Video);
}
return true;
}
public override bool Pause()
{
if (!base.Pause())
{
return false;
}
if (_Video != null)
{
CBase.Video.Pause(_Video);
}
return true;
}
public override bool Stop()
{
if (!base.Stop())
{
return false;
}
if (_Video != null)
{
CBase.Video.Pause(_Video);
CBase.Video.Skip(_Video, 0f, _Song.VideoGap);
}
return true;
}
private void _CloseVideo()
{
if (_Video != null)
{
CBase.Video.Close(ref _Video);
}
}
public override void Close()
@@ -176,4 +217,4 @@ namespace VocaluxeLib.Utils.Player
_CloseVideo();
}
}
}
}
+43 -19
View File
@@ -21,7 +21,7 @@ namespace VocaluxeLib.Utils.Player
{
public class CSoundPlayer
{
protected int _StreamID = -1;
protected int _StreamId = -1;
protected readonly float _FadeTime = CBase.Settings.GetSoundPlayerFadeTime();
public string FilePath { get; private set; }
@@ -35,27 +35,30 @@ namespace VocaluxeLib.Utils.Player
set
{
if (!SoundLoaded)
{
return;
CBase.Sound.SetPosition(_StreamID, value);
}
CBase.Sound.SetPosition(_StreamId, value);
}
get { return !SoundLoaded ? -1 : CBase.Sound.GetPosition(_StreamID); }
get { return !SoundLoaded ? -1 : CBase.Sound.GetPosition(_StreamId); }
}
public float Length
{
get { return !SoundLoaded ? -1 : CBase.Sound.GetLength(_StreamID); }
get { return !SoundLoaded ? -1 : CBase.Sound.GetLength(_StreamId); }
}
public bool IsPlaying { get; private set; }
public bool IsFinished
{
get { return !Loop && (CBase.Sound.IsFinished(_StreamID) || !IsPlaying); }
get { return !Loop && (CBase.Sound.IsFinished(_StreamId) || !IsPlaying); }
}
public bool SoundLoaded
{
get { return _StreamID != -1; }
get { return _StreamId != -1; }
}
public virtual string ArtistAndTitle
@@ -72,14 +75,22 @@ namespace VocaluxeLib.Utils.Player
{
Close();
_StreamID = CBase.Sound.Load(file, false, true);
if (_StreamID < 0)
_StreamId = CBase.Sound.Load(file, false, true);
if (_StreamId < 0)
{
return;
}
FilePath = file;
if (position > 0f)
{
Position = position;
}
if (autoplay)
{
Play();
}
}
/// <summary>
@@ -89,11 +100,13 @@ namespace VocaluxeLib.Utils.Player
public virtual bool Play()
{
if (!SoundLoaded || IsPlaying)
{
return false;
}
CBase.Sound.SetStreamVolume(_StreamID, 0);
CBase.Sound.Fade(_StreamID, 100, _FadeTime);
CBase.Sound.Play(_StreamID);
CBase.Sound.SetStreamVolume(_StreamId, 0);
CBase.Sound.Fade(_StreamId, 100, _FadeTime);
CBase.Sound.Play(_StreamId);
IsPlaying = true;
return true;
}
@@ -104,10 +117,12 @@ namespace VocaluxeLib.Utils.Player
/// <returns>True if state changed, false if nothing loaded or already paused</returns>
public virtual bool Pause()
{
if (!SoundLoaded || CBase.Sound.IsPaused(_StreamID))
if (!SoundLoaded || CBase.Sound.IsPaused(_StreamId))
{
return false;
}
CBase.Sound.Fade(_StreamID, 0, _FadeTime, EStreamAction.Pause);
CBase.Sound.Fade(_StreamId, 0, _FadeTime, EStreamAction.Pause);
IsPlaying = false;
return true;
}
@@ -119,9 +134,11 @@ namespace VocaluxeLib.Utils.Player
public virtual bool Stop()
{
if (!SoundLoaded)
{
return false;
}
CBase.Sound.Fade(_StreamID, 0, _FadeTime, EStreamAction.Stop);
CBase.Sound.Fade(_StreamId, 0, _FadeTime, EStreamAction.Stop);
IsPlaying = false;
return true;
}
@@ -129,10 +146,12 @@ namespace VocaluxeLib.Utils.Player
public virtual void Close()
{
if (!SoundLoaded)
{
return;
}
CBase.Sound.Fade(_StreamID, 0, _FadeTime, EStreamAction.Close);
_StreamID = -1;
CBase.Sound.Fade(_StreamId, 0, _FadeTime, EStreamAction.Close);
_StreamId = -1;
FilePath = "";
IsPlaying = false;
}
@@ -140,9 +159,11 @@ namespace VocaluxeLib.Utils.Player
public void Update()
{
if (!IsPlaying)
{
return;
}
bool finished = CBase.Sound.IsFinished(_StreamID);
var finished = CBase.Sound.IsFinished(_StreamId);
if (Loop)
{
if (finished)
@@ -151,14 +172,17 @@ namespace VocaluxeLib.Utils.Player
Stop();
Play();
}
return;
}
float len = CBase.Sound.GetLength(_StreamID);
float timeToPlay = (len > 0f) ? len - CBase.Sound.GetPosition(_StreamID) : _FadeTime + 1f;
var len = CBase.Sound.GetLength(_StreamId);
var timeToPlay = len > 0f ? len - CBase.Sound.GetPosition(_StreamId) : _FadeTime + 1f;
if (timeToPlay <= _FadeTime || finished)
{
Stop();
}
}
}
}