Cleanup and get rid of warnings

This commit is contained in:
Stephan
2018-05-30 11:56:31 +02:00
parent e0f97feb1c
commit 38eae90640
13 changed files with 58 additions and 71 deletions

View File

@@ -97,14 +97,14 @@ namespace Umbraco.Core.Events
public bool Equals(CancellableObjectEventArgs<T> other)
{
if (ReferenceEquals(null, other)) return false;
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;
return base.Equals(other) && EqualityComparer<T>.Default.Equals(EventObject, other.EventObject);
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (obj is null) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((CancellableObjectEventArgs<T>)obj);
@@ -154,7 +154,7 @@ namespace Umbraco.Core.Events
public bool Equals(CancellableEnumerableObjectEventArgs<T> other)
{
if (ReferenceEquals(null, other)) return false;
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;
return EventObject.SequenceEqual(other.EventObject);
@@ -162,7 +162,7 @@ namespace Umbraco.Core.Events
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (obj is null) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((CancellableEnumerableObjectEventArgs<T>)obj);

View File

@@ -17,7 +17,7 @@ namespace Umbraco.Core.Events
/// A colleciton of MoveEventInfo objects that exposes all entities that have been moved during a single move operation
/// </param>
public MoveEventArgs(bool canCancel, EventMessages eventMessages, params MoveEventInfo<TEntity>[] moveInfo)
: base(default(TEntity), canCancel, eventMessages)
: base(default, canCancel, eventMessages)
{
if (moveInfo.FirstOrDefault() == null)
{
@@ -27,7 +27,6 @@ namespace Umbraco.Core.Events
MoveInfoCollection = moveInfo;
//assign the legacy props
EventObject = moveInfo.First().Entity;
ParentId = moveInfo.First().NewParentId;
}
/// <summary>
@@ -38,7 +37,7 @@ namespace Umbraco.Core.Events
/// A colleciton of MoveEventInfo objects that exposes all entities that have been moved during a single move operation
/// </param>
public MoveEventArgs(EventMessages eventMessages, params MoveEventInfo<TEntity>[] moveInfo)
: base(default(TEntity), eventMessages)
: base(default, eventMessages)
{
if (moveInfo.FirstOrDefault() == null)
{
@@ -48,7 +47,6 @@ namespace Umbraco.Core.Events
MoveInfoCollection = moveInfo;
//assign the legacy props
EventObject = moveInfo.First().Entity;
ParentId = moveInfo.First().NewParentId;
}
/// <summary>
@@ -59,7 +57,7 @@ namespace Umbraco.Core.Events
/// A colleciton of MoveEventInfo objects that exposes all entities that have been moved during a single move operation
/// </param>
public MoveEventArgs(bool canCancel, params MoveEventInfo<TEntity>[] moveInfo)
: base(default(TEntity), canCancel)
: base(default, canCancel)
{
if (moveInfo.FirstOrDefault() == null)
{
@@ -69,7 +67,6 @@ namespace Umbraco.Core.Events
MoveInfoCollection = moveInfo;
//assign the legacy props
EventObject = moveInfo.First().Entity;
ParentId = moveInfo.First().NewParentId;
}
/// <summary>
@@ -79,7 +76,7 @@ namespace Umbraco.Core.Events
/// A colleciton of MoveEventInfo objects that exposes all entities that have been moved during a single move operation
/// </param>
public MoveEventArgs(params MoveEventInfo<TEntity>[] moveInfo)
: base(default(TEntity))
: base(default)
{
if (moveInfo.FirstOrDefault() == null)
{
@@ -89,22 +86,17 @@ namespace Umbraco.Core.Events
MoveInfoCollection = moveInfo;
//assign the legacy props
EventObject = moveInfo.First().Entity;
ParentId = moveInfo.First().NewParentId;
}
[Obsolete("Use the overload that specifies the MoveEventInfo object")]
public MoveEventArgs(TEntity eventObject, bool canCancel, int parentId)
: base(eventObject, canCancel)
{
ParentId = parentId;
}
{ }
[Obsolete("Use the overload that specifies the MoveEventInfo object")]
public MoveEventArgs(TEntity eventObject, int parentId)
: base(eventObject)
{
ParentId = parentId;
}
{ }
/// <summary>
/// Gets all MoveEventInfo objects used to create the object
@@ -124,7 +116,6 @@ namespace Umbraco.Core.Events
//assign the legacy props
EventObject = first.Entity;
ParentId = first.NewParentId;
}
}
@@ -137,22 +128,16 @@ namespace Umbraco.Core.Events
get { return EventObject; }
}
/// <summary>
/// Gets the Id of the object's new parent
/// </summary>
[Obsolete("Retrieve the ParentId from the MoveInfoCollection property instead")]
public int ParentId { get; private set; }
public bool Equals(MoveEventArgs<TEntity> other)
{
if (ReferenceEquals(null, other)) return false;
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;
return base.Equals(other) && MoveInfoCollection.Equals(other.MoveInfoCollection);
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (obj is null) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((MoveEventArgs<TEntity>) obj);

View File

@@ -115,6 +115,9 @@ namespace Umbraco.Core.IO
if (FileExists(file) == false) return;
DeleteFile(file);
#pragma warning disable 162 // unreachable code
// Not implemented yet, so need to disable warnings
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
if (UseTheNewMediaPathScheme == false)
{
// old scheme: filepath is "<int>/<filename>" OR "<int>-<filename>"
@@ -130,6 +133,7 @@ namespace Umbraco.Core.IO
var dir = Path.GetDirectoryName(file);
DeleteDirectory(dir, true);
}
#pragma warning restore 162
}
catch (Exception e)
{
@@ -155,6 +159,9 @@ namespace Umbraco.Core.IO
filename = IOHelper.SafeFileName(filename.ToLowerInvariant());
string folder;
#pragma warning disable 162 // unreachable code
// Not implemented yet, so need to disable warnings
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
if (UseTheNewMediaPathScheme == false)
{
// old scheme: filepath is "<int>/<filename>" OR "<int>-<filename>"
@@ -169,6 +176,7 @@ namespace Umbraco.Core.IO
// for a single content cannot store two different files with the same name
folder = Combine(cuid, puid).ToHexString(/*'/', 2, 4*/); // could use ext to fragment path eg 12/e4/f2/...
}
#pragma warning restore 162
var filepath = UmbracoConfig.For.UmbracoSettings().Content.UploadAllowDirectories
? Path.Combine(folder, filename).Replace('\\', '/')
@@ -213,9 +221,8 @@ namespace Umbraco.Core.IO
var sep = UmbracoConfig.For.UmbracoSettings().Content.UploadAllowDirectories ? "/" : "-";
var pos = prevpath.IndexOf(sep, StringComparison.Ordinal);
var s = pos > 0 ? prevpath.Substring(0, pos) : null;
int ignored;
var folder = (pos > 0 && int.TryParse(s, out ignored)) ? s : GetNextFolder();
var folder = (pos > 0 && int.TryParse(s, out _)) ? s : GetNextFolder();
// ReSharper disable once AssignNullToNotNullAttribute
var filepath = UmbracoConfig.For.UmbracoSettings().Content.UploadAllowDirectories
@@ -246,8 +253,7 @@ namespace Umbraco.Core.IO
var directories = GetDirectories("");
foreach (var directory in directories)
{
long folderNumber;
if (long.TryParse(directory, out folderNumber) && folderNumber > _folderCounter)
if (long.TryParse(directory, out var folderNumber) && folderNumber > _folderCounter)
_folderCounter = folderNumber;
}

View File

@@ -92,6 +92,7 @@ namespace Umbraco.Core.Logging
}
// obsolete but that's the one that's called ;-(
[Obsolete]
public override MiniProfiler Start(ProfileLevel level, string sessionName = null)
{
return Start(sessionName);

View File

@@ -134,7 +134,7 @@ namespace Umbraco.Core.Migrations.Install
{
SaveConnectionString(EmbeddedDatabaseConnectionString, Constants.DbProviderNames.SqlCe, logger);
var path = Path.Combine(GlobalSettings.FullPathToRoot, "App_Data", "Umbraco.sdf");
var path = Path.Combine(IOHelper.GetRootDirectorySafe(), "App_Data", "Umbraco.sdf");
if (File.Exists(path) == false)
{
// this should probably be in a "using (new SqlCeEngine)" clause but not sure
@@ -173,8 +173,7 @@ namespace Umbraco.Core.Migrations.Install
/// <param name="databaseProvider">The name the provider (Sql, Sql Azure, Sql Ce, MySql).</param>
public void ConfigureDatabaseConnection(string server, string databaseName, string user, string password, string databaseProvider)
{
string providerName;
var connectionString = GetDatabaseConnectionString(server, databaseName, user, password, databaseProvider, out providerName);
var connectionString = GetDatabaseConnectionString(server, databaseName, user, password, databaseProvider, out var providerName);
SaveConnectionString(connectionString, providerName, _logger);
_databaseFactory.Configure(connectionString, providerName);

View File

@@ -1,4 +1,5 @@
using System.Linq;
using System;
using System.Linq;
namespace Umbraco.Core.Migrations.Upgrade.V_7_5_0
{
@@ -14,19 +15,23 @@ namespace Umbraco.Core.Migrations.Upgrade.V_7_5_0
public override void Migrate()
{
// these have been obsoleted, need to copy the values here
var stylesheetPropertyObjectType = new Guid("5555da4f-a123-42b2-4488-dcdfb25e4111");
var stylesheetObjectType = new Guid("9F68DA4F-A3A8-44C2-8226-DCBD125E4840");
//Clear all stylesheet data if the tables exist
var tables = SqlSyntax.GetTablesInSchema(Context.Database).ToArray();
if (tables.InvariantContains("cmsStylesheetProperty"))
{
Delete.FromTable("cmsStylesheetProperty").AllRows().Do();
Delete.FromTable("umbracoNode").Row(new { nodeObjectType = Constants.ObjectTypes.StylesheetProperty }).Do();
Delete.FromTable("umbracoNode").Row(new { nodeObjectType = stylesheetPropertyObjectType }).Do();
Delete.Table("cmsStylesheetProperty").Do();
}
if (tables.InvariantContains("cmsStylesheet"))
{
Delete.FromTable("cmsStylesheet").AllRows().Do();
Delete.FromTable("umbracoNode").Row(new { nodeObjectType = Constants.ObjectTypes.Stylesheet }).Do();
Delete.FromTable("umbracoNode").Row(new { nodeObjectType = stylesheetObjectType }).Do();
Delete.Table("cmsStylesheet").Do();
}

View File

@@ -25,7 +25,7 @@ namespace Umbraco.Core.Packaging
public PackageInstallation(IPackagingService packagingService, IMacroService macroService,
IFileService fileService, IPackageExtraction packageExtraction)
: this(packagingService, macroService, fileService, packageExtraction, GlobalSettings.FullPathToRoot)
: this(packagingService, macroService, fileService, packageExtraction, IOHelper.GetRootDirectorySafe())
{}
public PackageInstallation(IPackagingService packagingService, IMacroService macroService,
@@ -212,9 +212,8 @@ namespace Umbraco.Core.Packaging
private XDocument GetConfigXmlDoc(string packageFilePath)
{
string filePathInPackage;
string configXmlContent = _packageExtraction.ReadTextFileFromArchive(packageFilePath,
Constants.Packaging.PackageXmlFileName, out filePathInPackage);
var configXmlContent = _packageExtraction.ReadTextFileFromArchive(packageFilePath,
Constants.Packaging.PackageXmlFileName, out _);
return XDocument.Parse(configXmlContent);
}
@@ -294,15 +293,13 @@ namespace Umbraco.Core.Packaging
};
XAttribute attr = elemet.Attribute(Constants.Packaging.RunatNodeAttribute);
var attr = elemet.Attribute(Constants.Packaging.RunatNodeAttribute);
ActionRunAt runAt;
if (attr != null && Enum.TryParse(attr.Value, true, out runAt)) { packageAction.RunAt = runAt; }
if (attr != null && Enum.TryParse(attr.Value, true, out ActionRunAt runAt)) { packageAction.RunAt = runAt; }
attr = elemet.Attribute(Constants.Packaging.UndoNodeAttribute);
bool undo;
if (attr != null && bool.TryParse(attr.Value, out undo)) { packageAction.Undo = undo; }
if (attr != null && bool.TryParse(attr.Value, out var undo)) { packageAction.Undo = undo; }
return packageAction;
@@ -570,8 +567,7 @@ namespace Umbraco.Core.Packaging
private static int IntValue(XElement xElement, int defaultValue = 0)
{
int val;
return xElement == null ? defaultValue : int.TryParse(xElement.Value, out val) ? val : defaultValue;
return xElement == null ? defaultValue : int.TryParse(xElement.Value, out var val) ? val : defaultValue;
}
private static string UpdatePathPlaceholders(string path)

View File

@@ -34,7 +34,8 @@ using System.Runtime.InteropServices;
[assembly: InternalsVisibleTo("Umbraco.Forms.Web")]
// Umbraco Headless
[assembly: InternalsVisibleTo("Umbraco.Headless")]
[assembly: InternalsVisibleTo("Umbraco.Headless")]
// v8
[assembly: InternalsVisibleTo("Umbraco.Compat7")]
// code analysis
// IDE1006 is broken, wants _value syntax for consts, etc - and it's even confusing ppl at MS, kill it
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "~_~")]

View File

@@ -45,8 +45,8 @@ namespace Umbraco.Core.Runtime
public virtual void Boot(ServiceContainer container)
{
// some components may want to initialize with the UmbracoApplicationBase
// well, they should not - we should not do this - however, Compat7 wants
// it, so let's do it, but we should remove this eventually.
// well, they should not - we should not do this
// TODO remove this eventually.
container.RegisterInstance(_app);
Compose(container);

View File

@@ -68,13 +68,10 @@ namespace Umbraco.Core.Strings
/// <summary>
/// Flag mask for encoding.
/// </summary>
CodeMask = Unicode | Utf8 | Ascii | TryAscii,
/// <summary>
/// Unicode encoding.
/// </summary>
[Obsolete("Use .Utf8 instead.")]
Unicode = 0x0100,
CodeMask = Utf8 | Ascii | TryAscii,
// Unicode encoding is obsolete, use Utf8
//Unicode = 0x0100,
/// <summary>
/// Utf8 encoding.

View File

@@ -11,11 +11,11 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.CodeAnalysis" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.7.0.0" newVersion="2.7.0.0"/>
<bindingRedirect oldVersion="0.0.0.0-2.8.0.0" newVersion="2.8.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.CodeAnalysis.CSharp" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.7.0.0" newVersion="2.7.0.0"/>
<bindingRedirect oldVersion="0.0.0.0-2.8.0.0" newVersion="2.8.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Diagnostics.Tracing.TraceEvent" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
@@ -275,11 +275,11 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.2.4.0" newVersion="5.2.4.0"/>
<bindingRedirect oldVersion="0.0.0.0-5.2.6.0" newVersion="5.2.6.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.2.4.0" newVersion="5.2.4.0"/>
<bindingRedirect oldVersion="0.0.0.0-5.2.6.0" newVersion="5.2.6.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Xml.ReaderWriter" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>

View File

@@ -113,11 +113,11 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.CodeAnalysis" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.7.0.0" newVersion="2.7.0.0"/>
<bindingRedirect oldVersion="0.0.0.0-2.8.0.0" newVersion="2.8.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.CodeAnalysis.CSharp" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.7.0.0" newVersion="2.7.0.0"/>
<bindingRedirect oldVersion="0.0.0.0-2.8.0.0" newVersion="2.8.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
@@ -157,11 +157,11 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.2.4.0" newVersion="5.2.4.0"/>
<bindingRedirect oldVersion="0.0.0.0-5.2.6.0" newVersion="5.2.6.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.2.4.0" newVersion="5.2.4.0"/>
<bindingRedirect oldVersion="0.0.0.0-5.2.6.0" newVersion="5.2.6.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>

View File

@@ -36,9 +36,6 @@ using System.Runtime.InteropServices;
// Umbraco Headless
[assembly: InternalsVisibleTo("Umbraco.Headless")]
// v8
[assembly: InternalsVisibleTo("Umbraco.Compat7")]
// code analysis
// IDE1006 is broken, wants _value syntax for consts, etc - and it's even confusing ppl at MS, kill it
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "~_~")]