Skip to content
Snippets Groups Projects
Commit 9c1685f7 authored by Andreia Gaita's avatar Andreia Gaita
Browse files

Add GitHub.Api, Octokit and helper libraries for authentication

Add the simple api client from GHfVS, add credential management stubs per platform, add octokit and TPL 3.5 ports.
Remove CredentialManagement for now, it blows up on Mono (likely due to marshaling), so needs testing first.
parent ef6595cb
No related branches found
No related tags found
No related merge requests found
Showing
with 722 additions and 1 deletion
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\LibGit2Sharp.NativeBinaries.1.0.160\build\LibGit2Sharp.NativeBinaries.props" Condition="Exists('..\packages\LibGit2Sharp.NativeBinaries.1.0.160\build\LibGit2Sharp.NativeBinaries.props')" />
<Import Project="..\..\packages\LibGit2Sharp.NativeBinaries.1.0.129\build\LibGit2Sharp.NativeBinaries.props" Condition="Exists('..\..\packages\LibGit2Sharp.NativeBinaries.1.0.129\build\LibGit2Sharp.NativeBinaries.props')" />
<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>{9AEA02DB-02B5-409C-B0CA-115D05331A6B}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>GitHub</RootNamespace>
<AssemblyName>GitHub.Exports</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<BuildType Condition="Exists('..\..\script\src\ApiClientConfiguration.cs')">Internal</BuildType>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<OutputPath>bin\$(Configuration)\</OutputPath>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<RunCodeAnalysis>false</RunCodeAnalysis>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<CodeAnalysisIgnoreGeneratedCode>true</CodeAnalysisIgnoreGeneratedCode>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<RunCodeAnalysis>true</RunCodeAnalysis>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<CodeAnalysisIgnoreGeneratedCode>true</CodeAnalysisIgnoreGeneratedCode>
<CodeAnalysisRuleSet>..\common\GitHubVS.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="$(Buildtype) == 'Internal'">
<AssemblyOriginatorKeyFile>..\..\script\Key.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<DelaySign>false</DelaySign>
</PropertyGroup>
<ItemGroup>
<None Include="..\common\settings.json">
<Link>Properties\settings.json</Link>
</None>
<Compile Include="ExceptionExtensions.cs" />
<Compile Include="Helpers\INotifyPropertySource.cs" />
<Compile Include="Extensions\PropertyNotifierExtensions.cs" />
<Compile Include="Helpers\NotificationAwareObject.cs" />
<Compile Include="Models\IProgram.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="$(SolutionDir)common\SolutionInfo.cs">
<Link>Properties\SolutionInfo.cs</Link>
</Compile>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Compile Include="Authentication\AuthenticationResultExtensions.cs" />
<Compile Include="Api\ISimpleApiClient.cs" />
<Compile Include="Api\ISimpleApiClientFactory.cs" />
<Compile Include="Authentication\AuthenticationResult.cs" />
<Compile Include="Primitives\StringEquivalent.cs" />
<Compile Include="Primitives\UriString.cs" />
<Compile Include="Primitives\HostAddress.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="AsyncBridge.Net35, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b3b1c0202c0d6a87, processorArchitecture=MSIL">
<HintPath>$(SolutionDir)packages\AsyncBridge.Net35.0.2.0\lib\net35-Client\AsyncBridge.Net35.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="ReadOnlyCollectionsInterfaces, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>$(SolutionDir)packages\ReadOnlyCollectionInterfaces.1.0.0\lib\NET20\ReadOnlyCollectionsInterfaces.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Threading, Version=1.0.2856.102, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>$(SolutionDir)packages\TaskParallelLibrary.1.0.2856.0\lib\Net35\System.Threading.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\submodules\octokit.net\Octokit\Octokit-Mono.csproj">
<Project>{49ef16a2-5ed1-480f-80a1-d1d05d6c1be4}</Project>
<Name>Octokit-Mono</Name>
</ProjectReference>
<ProjectReference Include="..\GitHub.Extensions\GitHub.Extensions.csproj">
<Project>{6afe2e2d-6db0-4430-a2ea-f5f5388d2f78}</Project>
<Name>GitHub.Extensions</Name>
</ProjectReference>
</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>
\ No newline at end of file
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("GitHub.Exports")]
[assembly: AssemblyDescription("GitHub interfaces for mef exports")]
[assembly: Guid("9aea02db-02b5-409c-b0ca-115d05331a6b")]
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AsyncBridge.Net35" version="0.2.0" targetFramework="net35" />
<package id="ReadOnlyCollectionInterfaces" version="1.0.0" targetFramework="net35" />
<package id="TaskParallelLibrary" version="1.0.2856.0" targetFramework="net35" />
</packages>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
namespace GitHub
{
public static class EnumerableExtensions
{
public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
{
foreach (var item in source) action(item);
}
public static IEnumerable<TSource> Except<TSource>(
this IEnumerable<TSource> enumerable,
IEnumerable<TSource> second,
Func<TSource, TSource, int> comparer)
{
return enumerable.Except(second, new Collections.LambdaComparer<TSource>(comparer));
}
}
}
using System;
using System.Threading;
namespace GitHub.Extensions
{
public static class ExceptionExtensions
{
/// <summary>
/// Represents exceptions we should never attempt to catch and ignore.
/// </summary>
/// <param name="exception">The exception being thrown.</param>
/// <returns></returns>
public static bool IsCriticalException(this Exception exception)
{
if (exception == null)
{
throw new ArgumentNullException("exception");
}
return exception.IsFatalException()
|| exception is AppDomainUnloadedException
|| exception is BadImageFormatException
|| exception is CannotUnloadAppDomainException
|| exception is InvalidProgramException
|| exception is NullReferenceException
|| exception is ArgumentException;
}
/// <summary>
/// Represents exceptions we should never attempt to catch and ignore when executing third party plugin code.
/// This is not as extensive as a proposed IsCriticalException method that I want to write for our own code.
/// </summary>
/// <param name="exception">The exception being thrown.</param>
/// <returns></returns>
public static bool IsFatalException(this Exception exception)
{
if (exception == null)
{
throw new ArgumentNullException("exception");
}
return exception is StackOverflowException
|| exception is OutOfMemoryException
|| exception is ThreadAbortException
|| exception is AccessViolationException;
}
public static bool CanRetry(this Exception exception)
{
return !exception.IsCriticalException()
&& !(exception is ObjectDisposedException);
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.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>{6AFE2E2D-6DB0-4430-A2EA-F5F5388D2F78}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>GitHub.Extensions</RootNamespace>
<AssemblyName>GitHub.Extensions</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<WarningLevel>4</WarningLevel>
<RunCodeAnalysis>true</RunCodeAnalysis>
<CodeAnalysisRuleSet>$(SolutionDir)common\GitHubVS.ruleset</CodeAnalysisRuleSet>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<BuildType Condition="Exists('..\..\script\src\ApiClientConfiguration.cs')">Internal</BuildType>
<OutputPath>bin\$(Configuration)\</OutputPath>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<RunCodeAnalysis>false</RunCodeAnalysis>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<CodeAnalysisIgnoreGeneratedCode>true</CodeAnalysisIgnoreGeneratedCode>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<RunCodeAnalysis>true</RunCodeAnalysis>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<CodeAnalysisIgnoreGeneratedCode>true</CodeAnalysisIgnoreGeneratedCode>
<CodeAnalysisRuleSet>$(SolutionDir)common\GitHubVS.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="$(Buildtype) == 'Internal'">
<AssemblyOriginatorKeyFile>..\..\script\Key.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<DelaySign>false</DelaySign>
</PropertyGroup>
<ItemGroup>
<Compile Include="LambdaComparer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="$(SolutionDir)common\SolutionInfo.cs">
<Link>Properties\SolutionInfo.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="EnumerableExtensions.cs" />
<Compile Include="ExceptionExtensions.cs" />
<Compile Include="Guard.cs" />
<Compile Include="ReflectionExtensions.cs" />
<Compile Include="StringExtensions.cs" />
<Compile Include="UriExtensions.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
</Target>
<!-- 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>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
namespace GitHub.Extensions
{
public static class Guard
{
public static void ArgumentNotNull(object value, string name)
{
if (value != null) return;
string message = String.Format(CultureInfo.InvariantCulture, "Failed Null Check on '{0}'", name);
throw new ArgumentNullException(name, message);
}
public static void ArgumentNonNegative(int value, string name)
{
if (value > -1) return;
var message = String.Format(CultureInfo.InvariantCulture, "The value for '{0}' must be non-negative", name);
throw new ArgumentException(message, name);
}
/// <summary>
/// Checks a string argument to ensure it isn't null or empty.
/// </summary>
/// <param name = "value">The argument value to check.</param>
/// <param name = "name">The name of the argument.</param>
public static void ArgumentNotEmptyString(string value, string name)
{
if (value.Length > 0) return;
string message = String.Format(CultureInfo.InvariantCulture, "The value for '{0}' must not be empty", name);
throw new ArgumentException(message, name);
}
public static void ArgumentInRange(int value, int minValue, string name)
{
if (value >= minValue) return;
string message = String.Format(CultureInfo.InvariantCulture,
"The value '{0}' for '{1}' must be greater than or equal to '{2}'",
value,
name,
minValue);
throw new ArgumentOutOfRangeException(name, message);
}
public static void ArgumentInRange(int value, int minValue, int maxValue, string name)
{
if (value >= minValue && value <= maxValue) return;
string message = String.Format(CultureInfo.InvariantCulture,
"The value '{0}' for '{1}' must be greater than or equal to '{2}' and less than or equal to '{3}'",
value,
name,
minValue,
maxValue);
throw new ArgumentOutOfRangeException(name, message);
}
// Borrowed from Splat.
static bool InUnitTestRunner()
{
return false;
}
}
}
using System;
using System.Collections.Generic;
namespace GitHub.Collections
{
public class LambdaComparer<T> : IEqualityComparer<T>, IComparer<T>
{
readonly Func<T, T, int> lambdaComparer;
readonly Func<T, int> lambdaHash;
public LambdaComparer(Func<T, T, int> lambdaComparer) :
this(lambdaComparer, null)
{
}
public LambdaComparer(Func<T, T, int> lambdaComparer, Func<T, int> lambdaHash)
{
this.lambdaComparer = lambdaComparer;
this.lambdaHash = lambdaHash;
}
public int Compare(T x, T y)
{
return lambdaComparer(x, y);
}
public bool Equals(T x, T y)
{
return lambdaComparer(x, y) == 0;
}
public int GetHashCode(T obj)
{
return lambdaHash != null
? lambdaHash(obj)
: obj?.GetHashCode() ?? 0;
}
}
}
\ No newline at end of file
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("GitHub.Extensions")]
[assembly: AssemblyDescription("Provides useful extension and utility methods common to the needs of GitHub applications")]
[assembly: Guid("3bf91177-3d16-425d-9c62-50a86cf26298")]
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
namespace GitHub.Extensions
{
public static class ReflectionExtensions
{
public static IEnumerable<Type> GetLoadableTypes(this Assembly assembly)
{
try
{
return assembly.GetTypes();
}
catch (ReflectionTypeLoadException e)
{
return e.Types.Where(t => t != null);
}
}
public static bool HasInterface(this Type type, Type targetInterface)
{
if (targetInterface.IsAssignableFrom(type))
return true;
return type.GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == targetInterface);
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter")]
public static string GetCustomAttributeValue<T>(this Assembly assembly, string propertyName) where T : Attribute
{
if (assembly == null || string.IsNullOrEmpty(propertyName)) return string.Empty;
object[] attributes = assembly.GetCustomAttributes(typeof(T), false);
if (attributes.Length == 0) return string.Empty;
var attribute = attributes[0] as T;
if (attribute == null) return string.Empty;
var propertyInfo = attribute.GetType().GetProperty(propertyName);
if (propertyInfo == null) return string.Empty;
var value = propertyInfo.GetValue(attribute, null);
return value.ToString();
}
public static object GetValueForProperty(this Type type, object instance, string propName)
{
var prop = type.GetProperty(propName);
Debug.Assert(prop != null, string.Format(CultureInfo.InvariantCulture, "'{0}' {1} not found in assembly '{2}'. Check if it's been moved or mistyped.",
propName, "property", type.Assembly.GetCustomAttributeValue<AssemblyFileVersionAttribute>("Version")));
if (prop == null)
return null;
var getm = prop.GetGetMethod();
Debug.Assert(prop != null, string.Format(CultureInfo.InvariantCulture, "'{0}' {1} not found in assembly '{2}'. Check if it's been moved or mistyped.",
propName, "getter", type.Assembly.GetCustomAttributeValue<AssemblyFileVersionAttribute>("Version")));
if (getm == null)
return null;
try {
return getm.Invoke(instance, null);
}
catch (Exception ex)
{
throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "'{0}' {1} in assembly '{2}' threw an exception. {3}.",
propName, "getter", type.Assembly.GetCustomAttributeValue<AssemblyFileVersionAttribute>("Version"), ex));
}
}
}
}
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
namespace GitHub.Extensions
{
public static class StringExtensions
{
public static bool Contains(this string s, string expectedSubstring, StringComparison comparison)
{
return s.IndexOf(expectedSubstring, comparison) > -1;
}
public static bool ContainsAny(this string s, IEnumerable<char> characters)
{
return s.IndexOfAny(characters.ToArray()) > -1;
}
public static string DebugRepresentation(this string s)
{
s = s ?? "(null)";
return string.Format(CultureInfo.InvariantCulture, "\"{0}\"", s);
}
public static string ToNullIfEmpty(this string s)
{
return String.IsNullOrEmpty(s) ? null : s;
}
public static bool StartsWith(this string s, char c)
{
if (String.IsNullOrEmpty(s)) return false;
return s.First() == c;
}
public static string RightAfter(this string s, string search)
{
if (s == null) return null;
int lastIndex = s.IndexOf(search, StringComparison.OrdinalIgnoreCase);
if (lastIndex < 0)
return null;
return s.Substring(lastIndex + search.Length);
}
public static string RightAfterLast(this string s, string search)
{
if (s == null) return null;
int lastIndex = s.LastIndexOf(search, StringComparison.OrdinalIgnoreCase);
if (lastIndex < 0)
return null;
return s.Substring(lastIndex + search.Length);
}
public static string LeftBeforeLast(this string s, string search)
{
if (s == null) return null;
int lastIndex = s.LastIndexOf(search, StringComparison.OrdinalIgnoreCase);
if (lastIndex < 0)
return null;
return s.Substring(0, lastIndex);
}
// Returns a file name even if the path is FUBAR.
public static string ParseFileName(this string path)
{
if (path == null) return null;
return path.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar).RightAfterLast(Path.DirectorySeparatorChar + "");
}
// Returns the parent directory even if the path is FUBAR.
public static string ParseParentDirectory(this string path)
{
if (path == null) return null;
return path.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar).LeftBeforeLast(Path.DirectorySeparatorChar + "");
}
public static string EnsureStartsWith(this string s, char c)
{
if (s == null) return null;
return c + s.TrimStart(c);
}
// Ensures the string ends with the specified character.
public static string EnsureEndsWith(this string s, char c)
{
if (s == null) return null;
return s.TrimEnd(c) + c;
}
public static string NormalizePath(this string path)
{
if (String.IsNullOrEmpty(path)) return null;
return path.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
}
public static string TrimEnd(this string s, string suffix)
{
if (s == null) return null;
if (!s.EndsWith(suffix, StringComparison.OrdinalIgnoreCase))
return s;
return s.Substring(0, s.Length - suffix.Length);
}
public static string RemoveSurroundingQuotes(this string s)
{
if (s.Length < 2)
return s;
var quoteCharacters = new[] { '"', '\'' };
char firstCharacter = s[0];
if (!quoteCharacters.Contains(firstCharacter))
return s;
if (firstCharacter != s[s.Length - 1])
return s;
return s.Substring(1, s.Length - 2);
}
public static Int32 ToInt32(this string s)
{
Int32 val;
return Int32.TryParse(s, out val) ? val : 0;
}
/// <summary>
/// Wrap a string to the specified length.
/// </summary>
/// <param name="text">The text string to wrap</param>
/// <param name="maxLength">The character length to wrap at</param>
/// <returns>A wrapped string using the platform's default newline character. This string will end in a newline.</returns>
public static string Wrap(this string text, int maxLength = 72)
{
if (text.Length == 0) return string.Empty;
var sb = new StringBuilder();
foreach (var unwrappedLine in text.Split(new[] { Environment.NewLine }, StringSplitOptions.None))
{
var line = new StringBuilder();
foreach (var word in unwrappedLine.Split(' '))
{
var needsLeadingSpace = line.Length > 0;
var extraLength = (needsLeadingSpace ? 1 : 0) + word.Length;
if (line.Length + extraLength > maxLength)
{
sb.AppendLine(line.ToString());
line.Clear();
needsLeadingSpace = false;
}
if (needsLeadingSpace)
line.Append(" ");
line.Append(word);
}
sb.AppendLine(line.ToString());
}
return sb.ToString();
}
public static Uri ToUriSafe(this string url)
{
Uri uri;
Uri.TryCreate(url, UriKind.Absolute, out uri);
return uri;
}
}
public static class StringBuilderExtensions
{
public static void Clear(this StringBuilder sb)
{
sb.Length = 0;
}
}
}
using System;
namespace GitHub.Extensions
{
public static class UriExtensions
{
/// <summary>
/// Appends a relative path to the URL.
/// </summary>
/// <remarks>
/// The Uri constructor for combining relative URLs have a different behavior with URLs that end with /
/// than those that don't.
/// </remarks>
public static Uri Append(this Uri uri, string relativePath)
{
if (!uri.AbsolutePath.EndsWith("/", StringComparison.Ordinal))
{
uri = new Uri(uri + "/");
}
return new Uri(uri, new Uri(relativePath, UriKind.Relative));
}
public static bool IsHypertextTransferProtocol(this Uri uri)
{
return uri.Scheme == "http" || uri.Scheme == "https";
}
public static bool IsSameHost(this Uri uri, Uri compareUri)
{
return uri.Host.Equals(compareUri.Host, StringComparison.OrdinalIgnoreCase);
}
}
}
......@@ -36,6 +36,10 @@
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Threading, Version=1.0.2856.102, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\..\..\packages\TaskParallelLibrary.1.0.2856.0\lib\Net35\System.Threading.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
......@@ -161,8 +165,26 @@
<None Include="$(SolutionDir)common\GitHub.ruleset">
<Link>GitHub.ruleset</Link>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\submodules\dotnet-httpclient35\System.Net.Http\System.Net.Http-net_3_5.csproj">
<Project>{9862694d-e4fa-418b-8692-a0280feddf36}</Project>
<Name>System.Net.Http-net_3_5</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\submodules\octokit.net\Octokit-Extensions35\Octokit-Extensions35.csproj">
<Project>{eb4b074e-62a7-4f1d-8f95-e64b7aea0236}</Project>
<Name>Octokit-Extensions35</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\submodules\octokit.net\Octokit\Octokit-35.csproj">
<Project>{49ef16a2-5ed1-480f-80a1-d1d05d6c1be4}</Project>
<Name>Octokit-35</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\GitHub.Api\GitHub.Api.csproj">
<Project>{b389adaf-62cc-486e-85b4-2d8b078df763}</Project>
<Name>GitHub.Api</Name>
</ProjectReference>
</ItemGroup>
<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.
......
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="TaskParallelLibrary" version="1.0.2856.0" targetFramework="net35" />
</packages>
\ No newline at end of file
Subproject commit 0cdda60efbdb759d987c62473dee3b03e6d6628e
Subproject commit 4b1e53812bbc1125dd0bcbf239261152eb282f6a
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment