Skip to content

Commit

Permalink
(build) Fixed resharper issues
Browse files Browse the repository at this point in the history
  • Loading branch information
AdmiringWorm committed May 12, 2019
1 parent 391b01c commit 30fd26b
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
@@ -1,6 +1,6 @@
image:
- Ubuntu
- Visual Studio 2017
- Visual Studio 2019
version: '{build}'
pull_requests:
do_not_increment_build_number: true
Expand Down
1 change: 0 additions & 1 deletion .vscode/tasks.json
Expand Up @@ -40,7 +40,6 @@
"label": "watch",
"command": "dotnet",
"type": "process",
"dependsOn":["build"],
"args": [
"watch",
"--project",
Expand Down
7 changes: 4 additions & 3 deletions src/Cake.Warp.Demo/Program.cs
@@ -1,10 +1,11 @@
using System;
using System;

namespace Cake.Warp.Demo
{
class Program
// ReSharper disable once ClassNeverInstantiated.Global
internal class Program
{
static void Main(string[] args)
internal static void Main()
{
Console.WriteLine("I should work from a single binary!");
}
Expand Down
3 changes: 2 additions & 1 deletion src/Cake.Warp.IntegrationTests/ModuleInitiazerTests.cs
Expand Up @@ -14,7 +14,7 @@ public class ModuleInitializerTests
[SetUp]
public void SetAddinAssemblyDirectory()
{
string directory = typeof(Cake.Warp.ModuleInitializer).Assembly.Location;
string directory = typeof(ModuleInitializer).Assembly.Location;
var attr = File.GetAttributes(directory);
if ((attr & FileAttributes.Directory) != FileAttributes.Directory)
{
Expand Down Expand Up @@ -59,6 +59,7 @@ public void Should_Be_Able_To_Launch_Warp_Binary_File()
// This will throw an exception if the file can't be run
var proc = Process.Start(processInfo);

Assume.That(proc, Is.Not.Null);
proc.WaitForExit();
}
}
Expand Down
13 changes: 13 additions & 0 deletions src/Cake.Warp.sln.DotSettings
@@ -0,0 +1,13 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=0BB62FD9_002D8844_002D4BCA_002DBCAE_002D9C01418A2C14_002Ff_003AInclude_005FT4Include_002Ecs/@EntryIndexedValue">ExplicitlyExcluded</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/AnalysisEnabled/@EntryValue">SOLUTION</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeThisQualifier/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/ThisQualifier/INSTANCE_MEMBERS_QUALIFY_MEMBERS/@EntryValue">Field, Property, Event, Method</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CSharpUsing/PreferQualifiedReference/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CSharpUsing/QualifiedUsingAtNestedScope/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OS/@EntryIndexedValue">OS</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:Boolean x:Key="/Default/UserDictionary/Words/=addin/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Fody/@EntryIndexedValue">True</s:Boolean>
</wpf:ResourceDictionary>
1 change: 1 addition & 0 deletions src/Cake.Warp/Cake.Warp.csproj
Expand Up @@ -12,6 +12,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="JetBrains.Annotations" Version="2019.1.1" PrivateAssets="All"/>
<PackageReference Include="ModuleInit.Fody" Version="2.0.0" PrivateAssets="All" />
<PackageReference Include="Resourcer.Fody" Version="1.7.3" />
<PackageReference Include="stylecop.analyzers" Version="1.1.118">
Expand Down
13 changes: 1 addition & 12 deletions src/Cake.Warp/Common/AddinConfiguration.cs
@@ -1,6 +1,5 @@
namespace Cake.Warp.Common
{
using System;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
Expand All @@ -27,17 +26,7 @@ private AddinConfiguration()
/// Gets the singleton instance of the addin configuration class.
/// </summary>
public static AddinConfiguration Instance
{
get
{
if (instance == null)
{
instance = new AddinConfiguration();
}

return instance;
}
}
=> instance ?? (instance = new AddinConfiguration());

/// <summary>
/// Gets the current path to the executing assembly directory.
Expand Down
16 changes: 12 additions & 4 deletions src/Cake.Warp/ModuleInitializer.cs
Expand Up @@ -4,10 +4,11 @@ namespace Cake.Warp
using System.Diagnostics;
using System.IO;
using Cake.Warp.Common;
using JetBrains.Annotations;
using Resourcer;

/// <summary>
/// Module class responible for the logic needed
/// Module class responsible for the logic needed
/// to run when the library is loaded.
/// </summary>
public static class ModuleInitializer
Expand All @@ -21,13 +22,14 @@ public static class ModuleInitializer
/// called manually. It should only be called
/// using the existing IL weaving.
/// </notes>
[UsedImplicitly]
public static void Initialize()
{
var assemblyDirectory = AddinConfiguration.Instance.AssemblyDirectoryPath;
var warpFileName = "warp-packer";
if (AddinConfiguration.Instance.IsWindows)
{
// Would prefer to get the file extension preffered by
// Would prefer to get the file extension preferred by
// system instead of hard-coding this.
// Not found anything related to this.
warpFileName += ".exe";
Expand All @@ -42,16 +44,21 @@ public static void Initialize()
}

using (var resourceStream = GetWarpResource())
using (var filestream = File.Create(fullPathToFile))
using (var fileStream = File.Create(fullPathToFile))
{
// Is there perhaps a better way, than doing this
resourceStream.CopyTo(filestream);
resourceStream.CopyTo(fileStream);
}

if (!AddinConfiguration.Instance.IsWindows)
{
// This is required, otherwise we won't be able to run warp-packer
var process = Process.Start("chmod", $"755 \"{fullPathToFile}\"");
if (process == null)
{
throw new NullReferenceException("Unable to run chmod on warp packer");
}

process.WaitForExit();
}
}
Expand All @@ -64,6 +71,7 @@ private static Stream GetWarpResource()
}
else if (AddinConfiguration.Instance.IsMacOS)
{
// ReSharper disable once StringLiteralTypo
return Resource.AsStream("warp.macos-x64.warp-packer");
}
else if (AddinConfiguration.Instance.IsWindows)
Expand Down
2 changes: 1 addition & 1 deletion src/Cake.Warp/WarpPlatforms.cs
Expand Up @@ -14,7 +14,7 @@ public enum WarpPlatforms
/// <summary>
/// Create the application as a Mac OSX x64 executable.
/// /// </summary>
MacOSX64,
MacOsx64,

/// <summary>
/// Create the application as a Windows x64 executable.
Expand Down
4 changes: 3 additions & 1 deletion src/Cake.Warp/WarpSettings.cs
Expand Up @@ -3,6 +3,7 @@ namespace Cake.Warp
using Cake.Core.IO;
using Cake.Core.Tooling;
using Cake.Warp.Common;
using JetBrains.Annotations;

/// <summary>
/// Contains the settings used by <see cref="WarpRunner" />.
Expand Down Expand Up @@ -32,6 +33,7 @@ public WarpSettings()
/// <remarks>
/// This is just an alias for <see cref="Architecture" />.
/// </remarks>
[PublicAPI]
public WarpPlatforms Platform
{
get => this.Architecture;
Expand All @@ -43,7 +45,7 @@ public WarpPlatforms Platform
/// the created application is being executed by a user.
/// </summary>
/// <remarks>
/// This should only be the filaname including the file extension.
/// This should only be the filename including the file extension.
/// </remarks>
public string ExecutableName { get; set; }

Expand Down

0 comments on commit 30fd26b

Please sign in to comment.