Skip to content

Commit

Permalink
Merged the two CLI projects. (v0.0.5)
Browse files Browse the repository at this point in the history
  • Loading branch information
EraYaN committed Jan 5, 2020
1 parent 26a0a64 commit 907063b
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 145 deletions.
12 changes: 3 additions & 9 deletions CompatibilityChecker.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.271
# Visual Studio Version 16
VisualStudioVersion = 16.0.29519.181
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C355D891-5C1D-4794-9981-9077586D4D39}"
ProjectSection(SolutionItems) = preProject
Expand All @@ -14,9 +14,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompatibilityCheckerTests",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CompatibilityChecker", "CompatibilityChecker\CompatibilityChecker.csproj", "{9A4BE2CE-277F-41C5-AB31-E5C6ECFD0EEB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CompatibilityCheckerCoreCLI", "CompatibilityCheckerCoreCLI\CompatibilityCheckerCoreCLI.csproj", "{F12B242C-9EC3-4ABC-BFC5-50156E4B5CB4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompatibilityCheckerCLI", "CompatibilityCheckerCLI\CompatibilityCheckerCLI.csproj", "{A9745E2F-F26C-4071-8461-1E381E0A654C}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CompatibilityCheckerCLI", "CompatibilityCheckerCLI\CompatibilityCheckerCLI.csproj", "{F12B242C-9EC3-4ABC-BFC5-50156E4B5CB4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -36,10 +34,6 @@ Global
{F12B242C-9EC3-4ABC-BFC5-50156E4B5CB4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F12B242C-9EC3-4ABC-BFC5-50156E4B5CB4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F12B242C-9EC3-4ABC-BFC5-50156E4B5CB4}.Release|Any CPU.Build.0 = Release|Any CPU
{A9745E2F-F26C-4071-8461-1E381E0A654C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A9745E2F-F26C-4071-8461-1E381E0A654C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A9745E2F-F26C-4071-8461-1E381E0A654C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A9745E2F-F26C-4071-8461-1E381E0A654C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
23 changes: 22 additions & 1 deletion CompatibilityChecker/AzurePipelinesMessageLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,30 @@

public class AzurePipelinesMessageLogger : IMessageLogger
{
Severity? maxSeverity;

public AzurePipelinesMessageLogger(Severity? MaxSeverity)
{
maxSeverity = MaxSeverity;
}

public AzurePipelinesMessageLogger()
{
maxSeverity = null;
}

public virtual void Report(Message message)
{
switch (message.Severity)
Severity sev;
if (maxSeverity.HasValue)
{
sev = message.Severity > maxSeverity.Value ? maxSeverity.Value : message.Severity;
}
else
{
sev = message.Severity;
}
switch (sev)
{
case Severity.Error:
Console.Error.WriteLine("##vso[task.logissue type=error]{0}", message);
Expand Down
9 changes: 7 additions & 2 deletions CompatibilityChecker/CompatibilityChecker.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net47;netcoreapp2.2</TargetFrameworks>
<TargetFrameworks>net48;netstandard2.1</TargetFrameworks>
<Version>0.0.5</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Collections.Immutable" Version="1.5.0" />
<PackageReference Include="System.Reflection.Metadata" Version="1.6.0" />
</ItemGroup>

<ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net48' ">
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' ">
<PackageReference Include="Microsoft.CSharp" Version="4.7.0"/>
</ItemGroup>

</Project>
10 changes: 5 additions & 5 deletions CompatibilityChecker/Severity.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
namespace CompatibilityChecker
{
internal enum Severity
public enum Severity
{
Disabled,
Information,
Warning,
Error,
Disabled = 0,
Information = 1,
Warning = 2,
Error = 3,
}
}
6 changes: 0 additions & 6 deletions CompatibilityCheckerCLI/App.config

This file was deleted.

73 changes: 19 additions & 54 deletions CompatibilityCheckerCLI/CompatibilityCheckerCLI.csproj
Original file line number Diff line number Diff line change
@@ -1,63 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A9745E2F-F26C-4071-8461-1E381E0A654C}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>CompatibilityCheckerCLI</RootNamespace>
<AssemblyName>CompatibilityCheckerCLI</AssemblyName>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworks>netcoreapp3.1;net48</TargetFrameworks>
<RuntimeIdentifiers>win-x64;linux-x64</RuntimeIdentifiers>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<ApplicationIcon />
<StartupObject />
<LangVersion>latest</LangVersion>
<Version>0.0.5</Version>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\CompatibilityCheckerCoreCLI\Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\CompatibilityChecker\CompatibilityChecker.csproj">
<Project>{9a4be2ce-277f-41c5-ab31-e5c6ecfd0eeb}</Project>
<Name>CompatibilityChecker</Name>
</ProjectReference>
<PackageReference Include="CommandLineParser" Version="2.5.0" />
<PackageReference Include="System.Reflection.Metadata" Version="1.6.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommandLineParser">
<Version>2.5.0</Version>
</PackageReference>
<PackageReference Include="System.Reflection.Metadata">
<Version>1.6.0</Version>
</PackageReference>
<ProjectReference Include="..\CompatibilityChecker\CompatibilityChecker.csproj" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public class Options
[Option('a', "azure-pipelines", Required = false, Default = false, HelpText = "Include the logging prefixes for Azure Pipelines.")]
public bool AzurePipelines { get; set; }

[Option('w', "warnings-only", Required = false, Default = false, HelpText = "Do not raise errors for Azure Pipelines, it also swallows the return code.")]
public bool WarningsOnly { get; set; }

[Usage()]
public static IEnumerable<Example> Examples {
get {
Expand Down Expand Up @@ -65,7 +68,21 @@ private static void RunWithOptions(Options opts)
{
using (PEReader newAssembly = new PEReader(File.OpenRead(newFile.FullName)))
{
IMessageLogger logger = opts.AzurePipelines ? (IMessageLogger)new AzurePipelinesMessageLogger() : new ConsoleMessageLogger();
IMessageLogger logger;
if (opts.AzurePipelines)
{
if (opts.WarningsOnly)
{
logger = new AzurePipelinesMessageLogger(Severity.Warning);
}
else
{
logger = new AzurePipelinesMessageLogger();
}
} else
{
logger = new ConsoleMessageLogger();
}
Analyzer analyzer = new Analyzer(referenceAssembly, newAssembly, null, logger);
analyzer.Run();
if (analyzer.HasRun)
Expand All @@ -76,7 +93,7 @@ private static void RunWithOptions(Options opts)
{
if(opts.AzurePipelines)
Console.WriteLine("##vso[task.complete result=SucceededWithIssues]");
Environment.ExitCode = -2;
Environment.ExitCode = opts.WarningsOnly ? 0 : -2;
return;
}
else
Expand All @@ -90,7 +107,7 @@ private static void RunWithOptions(Options opts)
{
if (opts.AzurePipelines)
Console.WriteLine("##vso[task.complete result=Failed]");
Environment.ExitCode = -1;
Environment.ExitCode = opts.WarningsOnly ? 0 : -1;
return;
}
}
Expand Down
36 changes: 0 additions & 36 deletions CompatibilityCheckerCLI/Properties/AssemblyInfo.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"CompatibilityCheckerCoreExample": {
"commandName": "Project",
"commandLineArgs": "\"..\\..\\..\\..\\MediaBrowser.Common_nuget.dll\" \"..\\..\\..\\..\\MediaBrowser.Common_artifact.dll\" --azure-pipelines"
"commandLineArgs": "\"..\\..\\..\\..\\MediaBrowser.Common_nuget.dll\" \"..\\..\\..\\..\\MediaBrowser.Common_artifact.dll\" --azure-pipelines --warnings-only"
}
}
}
27 changes: 0 additions & 27 deletions CompatibilityCheckerCoreCLI/CompatibilityCheckerCoreCLI.csproj

This file was deleted.

2 changes: 1 addition & 1 deletion CompatibilityCheckerTests/CompatibilityCheckerTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CompatibilityCheckerTests</RootNamespace>
<AssemblyName>CompatibilityCheckerTests</AssemblyName>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
Expand Down
3 changes: 3 additions & 0 deletions build-for-ci.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@ECHO OFF

dotnet publish -c Release --framework netcoreapp3.1 --self-contained false -r linux-x64 CompatibilityCheckerCLI\CompatibilityCheckerCLI.csproj

0 comments on commit 907063b

Please sign in to comment.