Code style - Omit the type in a new expressions

This commit is contained in:
SpoinkyNL committed 2020-12-18 17:54:01 +01:00
1 parent 099f56f4fe
commit 10e6cdc54b
117 files changed
+251 -252

No files matched your search

@@ -13,7 +13,7 @@ namespace Artemis.Core.DataModelExpansions
/// </summary>
public abstract class DataModel
{
private readonly Dictionary<string, DataModel> _dynamicDataModels = new Dictionary<string, DataModel>();
private readonly Dictionary<string, DataModel> _dynamicDataModels = new();
/// <summary>
/// Creates a new instance of the <see cref="DataModel" /> class
@@ -47,7 +47,7 @@ namespace Artemis.Core.DataModelExpansions
/// Gets an read-only dictionary of all dynamic data models
/// </summary>
[DataModelIgnore]
public ReadOnlyDictionary<string, DataModel> DynamicDataModels => new ReadOnlyDictionary<string, DataModel>(_dynamicDataModels);
public ReadOnlyDictionary<string, DataModel> DynamicDataModels => new(_dynamicDataModels);
/// <summary>
/// Returns a read-only collection of all properties in this datamodel that are to be ignored
@@ -13,7 +13,7 @@ namespace Artemis.Core.DataModelExpansions
/// <summary>
/// Gets a list of all properties ignored at runtime using <c>IgnoreProperty(x => x.y)</c>
/// </summary>
protected internal readonly List<PropertyInfo> HiddenPropertiesList = new List<PropertyInfo>();
protected internal readonly List<PropertyInfo> HiddenPropertiesList = new();
/// <summary>
/// Gets a list of all properties ignored at runtime using <c>IgnoreProperty(x => x.y)</c>
@@ -41,7 +41,7 @@ namespace Artemis.Core.DataModelExpansions
/// <returns></returns>
public virtual DataModelPropertyAttribute GetDataModelDescription()
{
return new DataModelPropertyAttribute {Name = Plugin.Info.Name, Description = Plugin.Info.Description};
return new() {Name = Plugin.Info.Name, Description = Plugin.Info.Description};
}
}
}
@@ -34,7 +34,7 @@ namespace Artemis.Core.DeviceProviders
[Inject]
public ILogger? Logger { get; set; }
internal Dictionary<IRGBDevice, string> DeviceLayoutPaths { get; set; } = new Dictionary<IRGBDevice, string>();
internal Dictionary<IRGBDevice, string> DeviceLayoutPaths { get; set; } = new();
/// <inheritdoc />
public override void Disable()
@@ -41,7 +41,7 @@ namespace Artemis.Core.LayerBrushes
if (!IsEnabled)
throw new ArtemisPluginException(Plugin, "Can only add a layer brush descriptor when the plugin is enabled");
LayerBrushDescriptor descriptor = new LayerBrushDescriptor(displayName, description, icon, typeof(T), this);
LayerBrushDescriptor descriptor = new(displayName, description, icon, typeof(T), this);
_layerBrushDescriptors.Add(descriptor);
LayerBrushStore.Add(descriptor);
}
@@ -34,8 +34,8 @@ namespace Artemis.Core.LayerBrushes
if (Layer.General.TransformMode.CurrentValue == LayerTransformMode.Normal && SupportsTransformation)
canvas.SetMatrix(canvas.TotalMatrix.PreConcat(Layer.GetTransformMatrix(true, false, false, true).Invert()));
using SKPath pointsPath = new SKPath();
using SKPaint ledPaint = new SKPaint();
using SKPath pointsPath = new();
using SKPaint ledPaint = new();
foreach (ArtemisLed artemisLed in Layer.Leds)
{
pointsPath.AddPoly(new[]
@@ -87,7 +87,7 @@ namespace Artemis.Core.LayerEffects
{
if (PlaceholderFor == null)
throw new ArtemisCoreException("Cannot create a placeholder instance using a layer effect descriptor that is not a placeholder for anything");
PlaceholderLayerEffect effect = new PlaceholderLayerEffect(entity, PlaceholderFor)
PlaceholderLayerEffect effect = new(entity, PlaceholderFor)
{
ProfileElement = renderElement,
Descriptor = this
@@ -41,7 +41,7 @@ namespace Artemis.Core.LayerEffects
if (!IsEnabled)
throw new ArtemisPluginFeatureException(this, "Can only add a layer effect descriptor when the plugin is enabled");
LayerEffectDescriptor descriptor = new LayerEffectDescriptor(displayName, description, icon, typeof(T), this);
LayerEffectDescriptor descriptor = new(displayName, description, icon, typeof(T), this);
_layerEffectDescriptors.Add(descriptor);
LayerEffectStore.Add(descriptor);
}
@@ -4,7 +4,7 @@
{
public static LayerEffectDescriptor Create(string missingProviderId)
{
LayerEffectDescriptor descriptor = new LayerEffectDescriptor("Missing effect", "This effect could not be loaded", "FileQuestion", null, Constants.EffectPlaceholderPlugin)
LayerEffectDescriptor descriptor = new("Missing effect", "This effect could not be loaded", "FileQuestion", null, Constants.EffectPlaceholderPlugin)
{
PlaceholderFor = missingProviderId
};
+2 -2
View File
@@ -42,7 +42,7 @@ namespace Artemis.Core.Modules
/// <returns></returns>
public virtual DataModelPropertyAttribute GetDataModelDescription()
{
return new DataModelPropertyAttribute {Name = Plugin.Info.Name, Description = Plugin.Info.Description};
return new() {Name = Plugin.Info.Name, Description = Plugin.Info.Description};
}
internal override void InternalEnable()
@@ -98,7 +98,7 @@ namespace Artemis.Core.Modules
/// A list of activation requirements
/// <para>Note: if empty the module is always activated</para>
/// </summary>
public List<IModuleActivationRequirement> ActivationRequirements { get; } = new List<IModuleActivationRequirement>();
public List<IModuleActivationRequirement> ActivationRequirements { get; } = new();
/// <summary>
/// Gets or sets the activation requirement mode, defaults to <see cref="ActivationRequirementType.Any" />
@@ -46,7 +46,7 @@ namespace Artemis.Core.Modules
/// <returns></returns>
public virtual DataModelPropertyAttribute GetDataModelDescription()
{
return new DataModelPropertyAttribute {Name = Plugin.Info.Name, Description = Plugin.Info.Description};
return new() {Name = Plugin.Info.Name, Description = Plugin.Info.Description};
}
/// <summary>
@@ -94,8 +94,8 @@ namespace Artemis.Core.Modules
/// <summary>
/// Gets a list of all properties ignored at runtime using <c>IgnoreProperty(x => x.y)</c>
/// </summary>
protected internal readonly List<PropertyInfo> HiddenPropertiesList = new List<PropertyInfo>();
private readonly object _lock = new object();
protected internal readonly List<PropertyInfo> HiddenPropertiesList = new();
private readonly object _lock = new();
/// <summary>
/// Creates a new instance of the <see cref="ProfileModule" /> class
@@ -54,7 +54,7 @@ namespace Artemis.Core
_pluginRepository.AddSetting(settingEntity);
}
PluginSetting<T> pluginSetting = new PluginSetting<T>(Plugin, _pluginRepository, settingEntity);
PluginSetting<T> pluginSetting = new(Plugin, _pluginRepository, settingEntity);
// This overrides null with the default value, I'm not sure if that's desirable because you
// might expect something to go null and you might not
@@ -13,7 +13,7 @@ namespace Artemis.Core
private DateTime _lastEvent;
private Timer? _timer;
private bool _disposed;
private readonly object _lock = new object();
private readonly object _lock = new();
internal TimedUpdateRegistration(PluginFeature feature, TimeSpan interval, Action<double> action)
{