Permalink
Browse files

First commit with a UserControl

  • Loading branch information...
0 parents commit 64567552b043ff0207fd229ced1e8fb55ad0fccf @laurentkempe committed May 30, 2012
@@ -0,0 +1,29 @@
+#ignore thumbnails created by windows
+Thumbs.db
+#Ignore files build by Visual Studio
+*.obj
+*.exe
+*.pdb
+*.user
+*.aps
+*.pch
+*.vspscc
+*_i.c
+*_p.c
+*.ncb
+*.suo
+*.tlb
+*.tlh
+*.bak
+*.cache
+*.ilk
+*.log
+[Bb]in
+[Dd]ebug*/
+*.lib
+*.sbr
+obj/
+[Rr]elease*/
+_ReSharper*/
+[Tt]est[Rr]esult*
+packages
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <solution>
+ <add key="disableSourceControlIntegration" value="true" />
+ </solution>
+</configuration>
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
+
+ <!-- Windows specific commands -->
+ <NuGetToolsPath Condition=" '$(OS)' == 'Windows_NT'">$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
+ <PackagesConfig Condition=" '$(OS)' == 'Windows_NT'">$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig>
+ <PackagesDir Condition=" '$(OS)' == 'Windows_NT'">$([System.IO.Path]::Combine($(SolutionDir), "packages"))</PackagesDir>
+
+ <!-- We need to launch nuget.exe with the mono command if we're not on windows -->
+ <NuGetToolsPath Condition=" '$(OS)' != 'Windows_NT'">$(SolutionDir).nuget</NuGetToolsPath>
+ <PackagesConfig Condition=" '$(OS)' != 'Windows_NT' ">packages.config</PackagesConfig>
+ <PackagesDir Condition=" '$(OS)' != 'Windows_NT'">$(SolutionDir)packages</PackagesDir>
+
+ <!-- NuGet command -->
+ <NuGetExePath>$(NuGetToolsPath)\nuget.exe</NuGetExePath>
+ <NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
+ <NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(NuGetExePath)</NuGetCommand>
+
+ <PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>
+
+ <!-- Package sources used to restore packages. By default will used the registered sources under %APPDATA%\NuGet\NuGet.Config -->
+ <PackageSources>""</PackageSources>
+
+ <!-- Enable the restore command to run before builds -->
+ <RestorePackages Condition="$(RestorePackages) == ''">false</RestorePackages>
+
+ <!-- Property that enables building a package from a project -->
+ <BuildPackage Condition="$(BuildPackage) == ''">false</BuildPackage>
+
+ <!-- Commands -->
+ <RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source $(PackageSources) -o "$(PackagesDir)"</RestoreCommand>
+ <BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols</BuildCommand>
+
+ <!-- Make the build depend on restore packages -->
+ <BuildDependsOn Condition="$(RestorePackages) == 'true'">
+ RestorePackages;
+ $(BuildDependsOn);
+ </BuildDependsOn>
+
+ <!-- Make the build depend on restore packages -->
+ <BuildDependsOn Condition="$(BuildPackage) == 'true'">
+ $(BuildDependsOn);
+ BuildPackage;
+ </BuildDependsOn>
+ </PropertyGroup>
+
+ <Target Name="CheckPrerequisites">
+ <!-- Raise an error if we're unable to locate nuget.exe -->
+ <Error Condition="!Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
+ </Target>
+
+ <Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
+ <Exec Command="$(RestoreCommand)"
+ Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />
+
+ <Exec Command="$(RestoreCommand)"
+ LogStandardErrorAsError="true"
+ Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
+ </Target>
+
+ <Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
+ <Exec Command="$(BuildCommand)"
+ Condition=" '$(OS)' != 'Windows_NT' " />
+
+ <Exec Command="$(BuildCommand)"
+ LogStandardErrorAsError="true"
+ Condition=" '$(OS)' == 'Windows_NT' " />
+ </Target>
+</Project>
Oops, something went wrong.
@@ -0,0 +1,38 @@
+using GitDiffMargin.Git;
+using NUnit.Framework;
+using Shouldly;
+
+namespace GitDiffMargin.Unit.Tests.Git
+{
+ // ReSharper disable InconsistentNaming
+
+ [TestFixture]
+ public class HunkRangeTests
+ {
+ [Test]
+ public void HunkRange_HunkOriginalFile_ExpectHunkOriginalFile()
+ {
+ //Arrange
+ //Act
+ var hunkRange = new HunkRange(@"41,0");
+
+ //Assert
+ hunkRange.StartingLineNumber.ShouldBe(40);
+ hunkRange.NumberOfLines.ShouldBe(0);
+ }
+
+ [Test]
+ public void HunkRange_ValidHunk_ExpectHunkNewFile()
+ {
+ //Arrange
+ //Act
+ var hunkRange = new HunkRange(@"42,20");
+
+ //Assert
+ hunkRange.StartingLineNumber.ShouldBe(41);
+ hunkRange.NumberOfLines.ShouldBe(20);
+ }
+ }
+
+ // ReSharper restore InconsistentNaming
+}
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{B954F515-AC6F-40D4-8169-03985AC62B06}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>GitDiffMargin.Unit.Tests</RootNamespace>
+ <AssemblyName>GitDiffMargin.Unit.Tests</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
+ <RestorePackages>true</RestorePackages>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <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' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="nunit.framework">
+ <HintPath>..\packages\NUnit.2.6.0.12054\lib\nunit.framework.dll</HintPath>
+ </Reference>
+ <Reference Include="Shouldly">
+ <HintPath>..\packages\Shouldly.1.1.1.1\lib\35\Shouldly.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <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="Git\GitDiffParserTests.cs" />
+ <Compile Include="Git\HunkRangeTests.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\GitDiffMargin\GitDiffMargin.csproj">
+ <Project>{233B6F13-7687-4823-870B-A8F44B79D4F0}</Project>
+ <Name>GitDiffMargin</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <Import Project="$(SolutionDir)\.nuget\nuget.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>
@@ -0,0 +1,17 @@
+<ProjectConfiguration>
+ <CopyReferencedAssembliesToWorkspace>false</CopyReferencedAssembliesToWorkspace>
+ <ConsiderInconclusiveTestsAsPassing>false</ConsiderInconclusiveTestsAsPassing>
+ <AllowCodeContractChecking>false</AllowCodeContractChecking>
+ <IgnoreThisComponentCompletely>false</IgnoreThisComponentCompletely>
+ <RunPreBuildEvents>false</RunPreBuildEvents>
+ <RunPostBuildEvents>false</RunPostBuildEvents>
+ <PreviouslyBuiltSuccessfully>true</PreviouslyBuiltSuccessfully>
+ <InstrumentAssembly>true</InstrumentAssembly>
+ <PreventSigningOfAssembly>false</PreventSigningOfAssembly>
+ <AnalyseExecutionTimes>true</AnalyseExecutionTimes>
+ <IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
+ <DefaultTestTimeout>60000</DefaultTestTimeout>
+ <UseBuildConfiguration />
+ <ProxyProcessPath />
+ <UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
+</ProjectConfiguration>
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("GitDiffMargin.Unit.Tests")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("GitDiffMargin.Unit.Tests")]
+[assembly: AssemblyCopyright("Copyright © 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("fc142244-cbb2-49c0-886d-fadfc8540210")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="NUnit" version="2.6.0.12054" />
+ <package id="Shouldly" version="1.1.1.1" />
+</packages>
@@ -0,0 +1,10 @@
+<SolutionConfiguration>
+ <FileVersion>1</FileVersion>
+ <AutoEnableOnStartup>True</AutoEnableOnStartup>
+ <AllowParallelTestExecution>true</AllowParallelTestExecution>
+ <FrameworkUtilisationTypeForNUnit>UseDynamicAnalysis</FrameworkUtilisationTypeForNUnit>
+ <FrameworkUtilisationTypeForGallio>UseStaticAnalysis</FrameworkUtilisationTypeForGallio>
+ <FrameworkUtilisationTypeForMSpec>UseStaticAnalysis</FrameworkUtilisationTypeForMSpec>
+ <FrameworkUtilisationTypeForMSTest>UseStaticAnalysis</FrameworkUtilisationTypeForMSTest>
+ <EngineModes>Run all tests automatically:BFRydWU=;Run all tests manually:BUZhbHNl;Run impacted tests automatically, others manually (experimental!):CklzSW1wYWN0ZWQ=;Run pinned tests automatically, others manually:CElzUGlubmVk</EngineModes>
+</SolutionConfiguration>
@@ -0,0 +1,32 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitDiffMargin", "GitDiffMargin\GitDiffMargin.csproj", "{233B6F13-7687-4823-870B-A8F44B79D4F0}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitDiffMargin.Unit.Tests", "GitDiffMargin.Unit.Tests\GitDiffMargin.Unit.Tests.csproj", "{B954F515-AC6F-40D4-8169-03985AC62B06}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{0A0AF18B-6698-4A12-B5AB-C37929F583E4}"
+ ProjectSection(SolutionItems) = preProject
+ .nuget\NuGet.exe = .nuget\NuGet.exe
+ .nuget\NuGet.targets = .nuget\NuGet.targets
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {233B6F13-7687-4823-870B-A8F44B79D4F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {233B6F13-7687-4823-870B-A8F44B79D4F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {233B6F13-7687-4823-870B-A8F44B79D4F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {233B6F13-7687-4823-870B-A8F44B79D4F0}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B954F515-AC6F-40D4-8169-03985AC62B06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B954F515-AC6F-40D4-8169-03985AC62B06}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B954F515-AC6F-40D4-8169-03985AC62B06}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B954F515-AC6F-40D4-8169-03985AC62B06}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace GitDiffMargin.Git
+{
+ public class GitDiffParser
+ {
+ private readonly string _gitDiff;
+
+ public GitDiffParser(string gitDiff)
+ {
+ _gitDiff = gitDiff;
+ }
+
+ public IEnumerable<HunkRangeInfo> Parse()
+ {
+ return
+ GetUnifiedFormatHunkLines().Select(
+ hunkLine => new HunkRangeInfo(new HunkRange(GetHunkOriginalFile(hunkLine)), new HunkRange(GetHunkNewFile(hunkLine))));
+ }
+
+ public IEnumerable<string> GetUnifiedFormatHunkLines()
+ {
+ var split = _gitDiff.Split('\n');
+ //var split = _gitDiff.Split(new[] {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries);
+ return
+ split.Where(line => line.StartsWith("@@"))
+ .Select(line => line.Trim());
+ }
+
+ public string GetHunkOriginalFile(string hunkLine)
+ {
+ return hunkLine.Split(new[] {"@@ -", " +"}, StringSplitOptions.RemoveEmptyEntries).First();
+ }
+
+ public string GetHunkNewFile(string hunkLine)
+ {
+ return hunkLine.Split(new[] { "@@ -", " +" }, StringSplitOptions.RemoveEmptyEntries).ToArray()[1].Split(' ')[0];
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit 6456755

Please sign in to comment.