This repository has been archived by the owner on Jul 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
91334d2
commit 861b216
Showing
14 changed files
with
1,304 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{5A2EAD0F-FF3E-4968-A865-7B29C4B10A72}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>ApiPort</RootNamespace> | ||
<AssemblyName>ApiPort</AssemblyName> | ||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<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> | ||
<Prefer32Bit>false</Prefer32Bit> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Microsoft.Fx.Portability, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>..\Microsoft.Fx.Portability\bin\Debug\net45\Microsoft.Fx.Portability.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Microsoft.Practices.ServiceLocation"> | ||
<HintPath>..\..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Microsoft.Practices.Unity"> | ||
<HintPath>..\..\packages\Unity.3.5.1404.0\lib\net45\Microsoft.Practices.Unity.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Microsoft.Practices.Unity.Configuration"> | ||
<HintPath>..\..\packages\Unity.3.5.1404.0\lib\net45\Microsoft.Practices.Unity.Configuration.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Microsoft.Practices.Unity.RegistrationByConvention"> | ||
<HintPath>..\..\packages\Unity.3.5.1404.0\lib\net45\Microsoft.Practices.Unity.RegistrationByConvention.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Configuration" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Runtime.Serialization" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="AppCommands.cs" /> | ||
<Compile Include="CommandLineOptions.cs" /> | ||
<Compile Include="DependencyBuilder.cs" /> | ||
<Compile Include="ICommandLineOptions.cs" /> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Resources\LocalizedStrings.Designer.cs"> | ||
<AutoGen>True</AutoGen> | ||
<DesignTime>True</DesignTime> | ||
<DependentUpon>LocalizedStrings.resx</DependentUpon> | ||
</Compile> | ||
<Compile Include="ConsoleProgressReporter.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Folder Include="Properties\" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<EmbeddedResource Include="Resources\LocalizedStrings.resx"> | ||
<Generator>PublicResXFileCodeGenerator</Generator> | ||
<LastGenOutput>LocalizedStrings.Designer.cs</LastGenOutput> | ||
</EmbeddedResource> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="app.config" /> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<runtime> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.Practices.ServiceLocation" publicKeyToken="31bf3856ad364e35" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" /> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
</runtime> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace ApiPort | ||
{ | ||
public enum AppCommands | ||
{ | ||
ListTargets, | ||
AnalyzeAssemblies, | ||
ListOutputFormats, | ||
#if DOCID_SEARCH | ||
DocIdSearch | ||
#endif | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using Microsoft.Fx.Portability.ObjectModel; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
|
||
namespace ApiPort | ||
{ | ||
internal class CommandLineOptions : ICommandLineOptions | ||
{ | ||
public static ICommandLineOptions ParseCommandLineOptions(string[] args) | ||
{ | ||
return new CommandLineOptions(); | ||
} | ||
|
||
public AppCommands Command | ||
{ | ||
get { return AppCommands.ListTargets; } | ||
} | ||
|
||
public string OutputFileName | ||
{ | ||
get { return "ApiPort"; } | ||
} | ||
|
||
public IEnumerable<string> InvalidInputFiles | ||
{ | ||
get | ||
{ | ||
return Enumerable.Empty<string>(); | ||
} | ||
} | ||
|
||
public string Description | ||
{ | ||
get; set; | ||
} | ||
|
||
public IEnumerable<FileInfo> InputAssemblies | ||
{ | ||
get | ||
{ | ||
return Enumerable.Empty<FileInfo>(); | ||
} | ||
} | ||
|
||
public IEnumerable<string> OutputFormats | ||
{ | ||
get | ||
{ | ||
return Enumerable.Empty<string>(); | ||
} | ||
} | ||
|
||
public AnalyzeRequestFlags RequestFlags | ||
{ | ||
get | ||
{ | ||
return AnalyzeRequestFlags.None; | ||
} | ||
} | ||
|
||
public string ServiceEndpoint | ||
{ | ||
get | ||
{ | ||
return "https://portability.cloudapp.net/"; | ||
} | ||
} | ||
|
||
public IEnumerable<string> Targets | ||
{ | ||
get | ||
{ | ||
return Enumerable.Empty<string>(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using ApiPort.Resources; | ||
using Microsoft.Fx.Portability; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace ApiPort | ||
{ | ||
public class ConsoleProgressReporter : IProgressReporter | ||
{ | ||
private readonly List<string> _issuesReported = new List<string>(); | ||
|
||
public IProgressTask StartTask(string taskName) | ||
{ | ||
return new ConsoleProgressTask(taskName, null); | ||
} | ||
|
||
public IProgressTask StartTask(string taskName, int total) | ||
{ | ||
return new ConsoleProgressTask(taskName, total); | ||
} | ||
|
||
public IReadOnlyCollection<string> Issues { get { return _issuesReported.AsReadOnly(); } } | ||
|
||
public void ReportIssue(string issue) | ||
{ | ||
_issuesReported.Add(issue); | ||
} | ||
|
||
private static void WriteColor(string message, ConsoleColor color) | ||
{ | ||
var previousColor = Console.ForegroundColor; | ||
|
||
try | ||
{ | ||
Console.ForegroundColor = color; | ||
Console.Write(message); | ||
} | ||
finally | ||
{ | ||
Console.ForegroundColor = previousColor; | ||
} | ||
} | ||
|
||
private static void WriteColorLine(string message, ConsoleColor color) | ||
{ | ||
WriteColor(message, color); | ||
Console.WriteLine(); | ||
} | ||
|
||
private sealed class ConsoleProgressTask : IProgressTask | ||
{ | ||
private readonly static char[] s_chars = new char[] { '-', '\\', '|', '/' }; | ||
|
||
private readonly Task _animationTask; | ||
private readonly CancellationTokenSource _cancellationSource = new CancellationTokenSource(); | ||
private readonly int? _totalCount; | ||
private readonly string _task; | ||
|
||
private bool _completed = false; | ||
|
||
public ConsoleProgressTask(string task, int? totalCount) | ||
{ | ||
_task = task.TrimEnd().PadRight(50); | ||
Console.Write(_task); | ||
|
||
_totalCount = totalCount; | ||
_animationTask = RunBusyAnimation(_cancellationSource.Token); | ||
} | ||
|
||
private async Task RunBusyAnimation(CancellationToken cancelToken) | ||
{ | ||
await Task.Delay(1); | ||
|
||
{ | ||
var count = 0; | ||
|
||
// 'left' is the last character written after the task name was written. | ||
var left = Console.CursorLeft; | ||
while (!cancelToken.IsCancellationRequested) | ||
{ | ||
Console.SetCursorPosition(left, Console.CursorTop); | ||
|
||
WriteColor(string.Format(LocalizedStrings.ProgressReportInProgress, new string('.', ++count % 4).PadRight(3)), ConsoleColor.Yellow); | ||
|
||
|
||
await Task.Delay(350); | ||
} | ||
|
||
// Make sure we remove the last characted that we wrote. | ||
Console.SetCursorPosition(0, Console.CursorTop); | ||
Console.Write(" ".PadLeft(Console.WindowWidth - 1)); | ||
Console.SetCursorPosition(0, Console.CursorTop); | ||
Console.Write(_task); | ||
} | ||
} | ||
|
||
public void ReportUnitComplete() | ||
{ | ||
} | ||
|
||
public void Abort() | ||
{ | ||
EndTask(Microsoft.Fx.Portability.Resources.LocalizedStrings.ProgressReportFailed, ConsoleColor.Red); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
EndTask(Microsoft.Fx.Portability.Resources.LocalizedStrings.ProgressReportDone, ConsoleColor.Green); | ||
} | ||
|
||
private void EndTask(string message, ConsoleColor color) | ||
{ | ||
if (_completed) | ||
{ | ||
return; | ||
} | ||
|
||
_completed = true; | ||
|
||
if (_cancellationSource != null) | ||
{ | ||
_cancellationSource.Cancel(); | ||
} | ||
|
||
if (_animationTask != null) | ||
{ | ||
_animationTask.Wait(); | ||
} | ||
|
||
WriteColorLine(message, color); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.