Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
Add ApiPort to solution
Browse files Browse the repository at this point in the history
  • Loading branch information
twsouthwick committed Apr 14, 2015
1 parent 91334d2 commit 861b216
Show file tree
Hide file tree
Showing 14 changed files with 1,304 additions and 3 deletions.
10 changes: 10 additions & 0 deletions Microsoft.Fx.Portability.sln
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{F829
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SearchFxApi", "samples\SearchFxApi\SearchFxApi.kproj", "{C556C618-D062-4988-9379-99A716D8F2C1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApiPort", "src\ApiPort\ApiPort.csproj", "{5A2EAD0F-FF3E-4968-A865-7B29C4B10A72}"
ProjectSection(ProjectDependencies) = postProject
{C1E232EA-AC27-4D0B-9C71-7A24BE65636D} = {C1E232EA-AC27-4D0B-9C71-7A24BE65636D}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -45,6 +50,10 @@ Global
{C556C618-D062-4988-9379-99A716D8F2C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C556C618-D062-4988-9379-99A716D8F2C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C556C618-D062-4988-9379-99A716D8F2C1}.Release|Any CPU.Build.0 = Release|Any CPU
{5A2EAD0F-FF3E-4968-A865-7B29C4B10A72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5A2EAD0F-FF3E-4968-A865-7B29C4B10A72}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5A2EAD0F-FF3E-4968-A865-7B29C4B10A72}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5A2EAD0F-FF3E-4968-A865-7B29C4B10A72}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -53,5 +62,6 @@ Global
{C1E232EA-AC27-4D0B-9C71-7A24BE65636D} = {6234AABE-C4F3-4094-9C0D-FFD589235DBE}
{6900A49C-D463-43E2-AB21-487E8B73EF5C} = {7DC7AA2C-0401-495B-B42C-32F44085EBE6}
{C556C618-D062-4988-9379-99A716D8F2C1} = {F8292A68-AF7C-4B26-B1B8-B232548EF118}
{5A2EAD0F-FF3E-4968-A865-7B29C4B10A72} = {6234AABE-C4F3-4094-9C0D-FFD589235DBE}
EndGlobalSection
EndGlobal
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ repository in order to be notified as we make changes to and expand it.

Today, the repository contains the following components:

* **Microsoft.Fx.Portability**. Provides common types for API Port.

* **Microsoft.Fx.Portability Tests**. Provides tests for Microsoft.Fx.Portability.
* **src/ApiPort** Console tool to access portability webservice. *Does not analyze assemblies yet.*
* **src/Microsoft.Fx.Portability** Provides common types for API Port.
* **src/Microsoft.Fx.Portability-net45** A project targeting .NET 4.5 of Microsoft.Fx.Portability to allow desktop apps to directly reference it. *Currently a work-around for beta VS 2015 behavior.*
* **tests/Microsoft.Fx.Portability** Provides tests for Microsoft.Fx.Portability.

More libraries are coming soon. Stay tuned!

Expand Down
97 changes: 97 additions & 0 deletions src/ApiPort/ApiPort.csproj
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>
11 changes: 11 additions & 0 deletions src/ApiPort/App.config
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>
15 changes: 15 additions & 0 deletions src/ApiPort/AppCommands.cs
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
}
}
81 changes: 81 additions & 0 deletions src/ApiPort/CommandLineOptions.cs
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>();
}
}
}
}
140 changes: 140 additions & 0 deletions src/ApiPort/ConsoleProgressReporter.cs
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);
}
}
}
}
Loading

0 comments on commit 861b216

Please sign in to comment.