Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing warnings #43

Merged
merged 2 commits into from
May 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ src/als-tools.infrastructure/bin/*
src/als-tools.ui.cli/bin/*
src/als-tools.ui.cli/obj/*
src/als-tools.ui.cli/output/*
ravendb-license.json
6 changes: 3 additions & 3 deletions src/als-tools.core/Config/DbOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ public class DbOptions
/// <summary>
/// The folder where the database data files will be created
/// </summary>
public string DataLocation { get; set; }
public string DataLocation { get; set; } = string.Empty;

/// <summary>
/// The database server URL to connect to
/// </summary>
public string ServerUrl { get; set; }
public string ServerUrl { get; set; } = string.Empty;

/// <summary>
/// The root document store name, where data will be saved to
/// </summary>
public string DocumentStoreName { get; set; }
public string DocumentStoreName { get; set; } = string.Empty;
}
25 changes: 14 additions & 11 deletions src/als-tools.core/Entities/LiveProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,37 @@ public LiveProject()
}

/// <summary>
/// Internal (persistency related) project ID
/// Internal (persistency related) project ID.
/// This must be nullable and null at the moment of the bulk insert for an
/// ID to be auto generated by the DB engine.
/// <see href="https://stackoverflow.com/a/52519620">BulkInsert error with RavenDB: Document id must have a non empty value</see>
/// </summary>
public string Id { get; set; }
public string? Id { get; set; }

/// <summary>
/// The project name
/// </summary>
public string Name { get; set; }
public string Name { get; set; } = string.Empty;

/// <summary>
/// The full path of this project
/// </summary>
public string Path { get; set; }
public string Path { get; set; } = string.Empty;

/// <summary>
/// Creator ("Live version")
/// </summary>
public string Creator { get; set; }
public string Creator { get; set; } = string.Empty;

/// <summary>
/// Minor version
/// </summary>
public string MinorVersion { get; set; }
public string MinorVersion { get; set; } = string.Empty;

/// <summary>
/// Major version
/// </summary>
public string MajorVersion { get; set; }
public string MajorVersion { get; set; } = string.Empty;

/// <summary>
/// Schema change count
Expand All @@ -65,15 +68,15 @@ public LiveProject()
/// <summary>
/// The tracks this project contains
/// </summary>
public IReadOnlyList<ITrack> Tracks { get; set; }
public IReadOnlyList<ITrack> Tracks { get; set; }

/// <summary>
/// The scenes this project contains
/// </summary>
public IReadOnlyList<Scene> Scenes { get; set; }
public IReadOnlyList<Scene> Scenes { get; set; }

/// <summary>
/// The locators this project contains
/// </summary>
public IReadOnlyList<Locator> Locators { get; set; }
public IReadOnlyList<Locator> Locators { get; set; }
}
16 changes: 8 additions & 8 deletions src/als-tools.core/Factories/TrackFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@ namespace AlsTools.Core.Factories;

public static class TrackFactory
{
public static ITrack CreateTrack(TrackType type, string effectiveName, string userName, string annotation, bool? isFrozen, TrackDelay trackDelay, int? parentGroupId = null)
public static ITrack CreateTrack(TrackType type, string effectiveName, string userName, string annotation, bool? isFrozen, TrackDelay trackDelay, int parentGroupId)
{
ITrack track = type switch
{
TrackType.Audio => track = new AudioTrack(),
TrackType.Midi => track = new MidiTrack(),
TrackType.Return => track = new ReturnTrack(),
TrackType.Group => track = new GroupTrack(),
_ => track = new MasterTrack()
TrackType.Audio => new AudioTrack(),
TrackType.Midi => new MidiTrack(),
TrackType.Return => new ReturnTrack(),
TrackType.Group => new GroupTrack(),
_ => new MasterTrack()
};

return SetDefaultProperties(track, effectiveName, userName, annotation, isFrozen, trackDelay, parentGroupId);
}

private static ITrack SetDefaultProperties(ITrack track, string effectiveName, string userName, string annotation, bool? isFrozen, TrackDelay trackDelay, int? parentGroupId = null)
private static ITrack SetDefaultProperties(ITrack track, string effectiveName, string userName, string annotation, bool? isFrozen, TrackDelay trackDelay, int parentGroupId)
{
track.EffectiveName = effectiveName;
track.UserName = userName;
track.Annotation = annotation;
track.IsFrozen = isFrozen;
track.TrackDelay = trackDelay;
track.TrackGroupId = parentGroupId;

return track;
}
}
6 changes: 3 additions & 3 deletions src/als-tools.core/ValueObjects/Devices/BaseDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ public BaseDevice(DeviceFamily family)

public int Id { get; set; }

public string Name { get; set; }
public string Name { get; set; } = string.Empty;

public string UserName { get; set; }
public string UserName { get; set; } = string.Empty;

public string Annotation { get; set; }
public string Annotation { get; set; } = string.Empty;

public DeviceFamily Family { get; protected set; }
}
2 changes: 1 addition & 1 deletion src/als-tools.core/ValueObjects/Devices/IDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public interface IDevice
/// The device original, factory name
/// </summary>
string Name { get; set; }

/// <summary>
/// The name the user has given to the device
/// </summary>
Expand Down
8 changes: 4 additions & 4 deletions src/als-tools.core/ValueObjects/Locator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ public class Locator
/// <summary>
/// The time point where the location is set
/// </summary>
public int? Time { get; set; }
public int Time { get; set; }

/// <summary>
/// Locator name (displayed in arrangement window)
/// </summary>
public string Name { get; set; }
public string Name { get; set; } = string.Empty;

/// <summary>
/// Locator notes
/// </summary>
public string Annotation { get; set; }
public string Annotation { get; set; } = string.Empty;

/// <summary>
/// Whether or not the locator is set as Song Start
/// </summary>
public bool? IsSongStart { get; set; }
public bool IsSongStart { get; set; }
}
14 changes: 7 additions & 7 deletions src/als-tools.core/ValueObjects/Scene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,35 @@ public class Scene
/// <summary>
/// Scene number (Id attribute)
/// </summary>
public int? Number { get; set; }
public int Number { get; set; }

/// <summary>
/// Scene name
/// </summary>
public string Name { get; set; }
public string Name { get; set; } = string.Empty;

/// <summary>
/// Scene notes
/// </summary>
public string Annotation { get; set; }
public string Annotation { get; set; } = string.Empty;

/// <summary>
/// The scene BPM/Tempo
/// </summary>
public int? Tempo { get; set; }
public int Tempo { get; set; }

/// <summary>
/// Whether a tempo/BPM is set
/// </summary>
public bool? IsTempoEnabled { get; set; }
public bool IsTempoEnabled { get; set; }

/// <summary>
/// The scene time signature Id. This is probably a bit mask value.
/// </summary>
public int? TimeSignatureId { get; set; }
public int TimeSignatureId { get; set; }

/// <summary>
/// Whether a time signature is set
/// </summary>
public bool? IsTimeSignatureEnabled { get; set; }
public bool IsTimeSignatureEnabled { get; set; }
}
2 changes: 1 addition & 1 deletion src/als-tools.core/ValueObjects/Tracks/AudioTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ public class AudioTrack : BaseTrack, ITrack
public AudioTrack() : base(TrackType.Audio)
{
}
}
}
30 changes: 16 additions & 14 deletions src/als-tools.core/ValueObjects/Tracks/BaseTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ namespace AlsTools.Core.ValueObjects.Tracks;

public abstract class BaseTrack : ITrack
{
public const int DefaultGroupId = -1;

public BaseTrack(TrackType type)
{
StockDevices = new List<LiveDevice>();
Expand All @@ -20,9 +22,9 @@ public BaseTrack(TrackType type)
// /// </summary>
// public int Id { get; set; }

public string UserName { get; set; }
public string UserName { get; set; } = string.Empty;

public string EffectiveName { get; set; }
public string EffectiveName { get; set; } = string.Empty;

public TrackType Type { get; set; }

Expand All @@ -32,30 +34,30 @@ public BaseTrack(TrackType type)

public IList<MaxForLiveDevice> MaxForLiveDevices { get; protected set; }

public string Annotation { get; set; }
public string Annotation { get; set; } = string.Empty;

public GroupTrack ParentGroupTrack { get; set; }
public GroupTrack? ParentGroupTrack { get; set; }

public bool IsPartOfGroup => ParentGroupTrack != null;

public TrackDelay TrackDelay { get; set; }
public int? TrackGroupId { get; set; }

public int TrackGroupId { get; set; }

public bool? IsFrozen { get; set; }

public void AddDevice(IDevice device)
{
//TODO: should I get rid of the specific collections (stock, plugins, max4live) and put all devices in a single collection?

List<string> l = new List<string>();
if (device == null)
throw new ArgumentNullException(nameof(device));

//TODO: should I get rid of the specific collections (stock, plugins, max4live) and put all devices in a single collection?
if (device.Family.Type == DeviceType.Plugin)
Plugins.Add(device as PluginDevice);
if (device.Family.Type == DeviceType.Stock)
StockDevices.Add(device as LiveDevice);
Plugins.Add((PluginDevice)device);
else if (device.Family.Type == DeviceType.Stock)
StockDevices.Add((LiveDevice)device);
else
MaxForLiveDevices.Add(device as MaxForLiveDevice);
MaxForLiveDevices.Add((MaxForLiveDevice)device);
}

public void AddDevices(IEnumerable<IDevice> devices)
Expand Down
2 changes: 1 addition & 1 deletion src/als-tools.core/ValueObjects/Tracks/GroupTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ public GroupTrack(IList<ITrack> childrenTracks) : base(TrackType.Group)
/// The children tracks that this group track groups under it.
/// </summary>
public IList<ITrack> ChildrenTracks { get; set; } //TODO: this shouldn`t be allowed to be set from external...
}
}
8 changes: 4 additions & 4 deletions src/als-tools.core/ValueObjects/Tracks/ITrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public interface ITrack
string EffectiveName { get; set; }

/// <summary>
/// The track type.
/// The track type.
/// <seealso cref="TrackType"/>
/// </summary>
TrackType Type { get; set; }
Expand All @@ -37,14 +37,14 @@ public interface ITrack
// /// Can be null. TrackGroupId property.
// /// TODO: this shouldn't be here, since Master and Return tracks can't be grouped.
// /// </summary>
// GroupTrack ParentGroupTrack { get; set; } //TODO: is it really necessary?
// GroupTrack ParentGroupTrack { get; set; } //TODO: is it really necessary?

/// <summary>
/// The group track Id which this track belongs to, if any.
/// Can be null. TrackGroupId property.
/// Can be null? TrackGroupId property.
/// TODO: this shouldn't be here, since Master and Return tracks can't be grouped.
/// </summary>
int? TrackGroupId { get; set; } //TODO: is it really necessary?
int TrackGroupId { get; set; } //TODO: is it really necessary?

/// <summary>
/// Whether or not this track is part of a group track
Expand Down
2 changes: 1 addition & 1 deletion src/als-tools.core/ValueObjects/Tracks/MidiTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ public class MidiTrack : BaseTrack, ITrack
public MidiTrack() : base(TrackType.Midi)
{
}
}
}
2 changes: 1 addition & 1 deletion src/als-tools.core/ValueObjects/Tracks/ReturnTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ public class ReturnTrack : BaseTrack, ITrack
public ReturnTrack() : base(TrackType.Return)
{
}
}
}
6 changes: 3 additions & 3 deletions src/als-tools.infrastructure/EmbeddedDatabaseContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ public class EmbeddedDatabaseContext : IEmbeddedDatabaseContext
private readonly ILogger<EmbeddedDatabaseContext> logger;
private readonly IOptions<DbOptions> options;
private bool isInitialized = false;
private IDocumentStore documentStore = null;
private IDocumentStore? documentStore;

public IDocumentStore DocumentStore
public IDocumentStore DocumentStore
{
get
{
Expand All @@ -33,7 +33,7 @@ public EmbeddedDatabaseContext(ILogger<EmbeddedDatabaseContext> logger, IOptions
public void Initialize()
{
logger.LogDebug("Starting database server...");

EmbeddedServer.Instance.StartServer(new ServerOptions
{
ServerUrl = options.Value.ServerUrl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public IDevice ExtractFromXml(XPathNavigator pluginDescNode)

var device = new MaxForLiveDevice(deviceSort)
{
Id = pluginDescNode.SelectSingleNode(@"@Id").ValueAsInt,
Name = GetMaxForLiveDeviceNameFromXmlNodePath(pluginDescNode.SelectSingleNode(@"SourceContext/Value/BranchSourceContext/OriginalFileRef/FileRef/Path/@Value")?.Value),
UserName = pluginDescNode.SelectSingleNode(@"UserName/@Value")?.Value,
Annotation = pluginDescNode.SelectSingleNode(@"Annotation/@Value")?.Value
Id = pluginDescNode.SelectSingleNode(@"@Id")!.ValueAsInt,
Name = GetMaxForLiveDeviceNameFromXmlNodePath(pluginDescNode.SelectSingleNode(@"SourceContext/Value/BranchSourceContext/OriginalFileRef/FileRef/Path/@Value")!.Value),
UserName = pluginDescNode.SelectSingleNode(@"UserName/@Value")!.Value,
Annotation = pluginDescNode.SelectSingleNode(@"Annotation/@Value")!.Value
};

return device;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private IPluginFormatExtractor GetPluginFormatExtractor(XPathNavigator deviceNod
{
var pluginDescNode = deviceNode.Select(@"PluginDesc");
pluginDescNode.MoveNext();
if (pluginDescNode.Current.HasChildren)
if (pluginDescNode.Current?.HasChildren ?? false)
{
if (pluginDescNode.Current.MoveToFirstChild())
{
Expand Down
Loading