From dfab6d4eafb1cd5f12f7c3e285c1f20fca628e0d Mon Sep 17 00:00:00 2001 From: Michael Krisper <michael.krisper@tugraz.at> Date: Thu, 3 Dec 2015 13:36:27 +0100 Subject: [PATCH] added project for adding licence headers to all cs files --- LicenceHeader/App.config | 6 +++ LicenceHeader/LicenceHeader.csproj | 63 ++++++++++++++++++++++++ LicenceHeader/Program.cs | 37 ++++++++++++++ LicenceHeader/Properties/AssemblyInfo.cs | 36 ++++++++++++++ LicenceHeader/header.txt | 16 ++++++ VECTO.sln | 10 ++++ 6 files changed, 168 insertions(+) create mode 100644 LicenceHeader/App.config create mode 100644 LicenceHeader/LicenceHeader.csproj create mode 100644 LicenceHeader/Program.cs create mode 100644 LicenceHeader/Properties/AssemblyInfo.cs create mode 100644 LicenceHeader/header.txt diff --git a/LicenceHeader/App.config b/LicenceHeader/App.config new file mode 100644 index 0000000000..8e15646352 --- /dev/null +++ b/LicenceHeader/App.config @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8" ?> +<configuration> + <startup> + <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> + </startup> +</configuration> \ No newline at end of file diff --git a/LicenceHeader/LicenceHeader.csproj b/LicenceHeader/LicenceHeader.csproj new file mode 100644 index 0000000000..c9bfdc60fe --- /dev/null +++ b/LicenceHeader/LicenceHeader.csproj @@ -0,0 +1,63 @@ +<?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>{E8B0B447-1A54-4BEC-A160-AF0017000781}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>LicenceHeader</RootNamespace> + <AssemblyName>LicenceHeader</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> + </PropertyGroup> + <ItemGroup> + <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="Program.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="App.config" /> + </ItemGroup> + <ItemGroup> + <Content Include="header.txt"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + </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 diff --git a/LicenceHeader/Program.cs b/LicenceHeader/Program.cs new file mode 100644 index 0000000000..e1921558fe --- /dev/null +++ b/LicenceHeader/Program.cs @@ -0,0 +1,37 @@ +using System; +using System.IO; +using System.Text.RegularExpressions; + +namespace LicenceHeader +{ + /// <summary> + /// Updates/Adds the EUPL license header to every .cs file in the projects: VectoCore, VectoConsole, VectoCoreTest + /// </summary> + internal class Program + { + private const string SolutionRootDirectory = @"..\\..\\.."; + private static readonly string[] ProjectDirectories = { "VectoCore", "VectoConsole", "VectoCoreTest" }; + + private static void Main() + { + var licence = File.ReadAllText("header.txt"); + + foreach (var dir in ProjectDirectories) { + foreach ( + var file in Directory.GetFiles(Path.Combine(SolutionRootDirectory, dir), "*.cs", SearchOption.AllDirectories)) { + if (file.Contains("\\obj\\") || file.Contains("\\bin\\")) { + continue; + } + + var re = new Regex("^.*?(?=using|namespace)"); + var content = File.ReadAllText(file); + var updatedContent = re.Replace(content, licence); + if (updatedContent != content) { + File.WriteAllText(file, updatedContent); + } + Console.WriteLine(file); + } + } + } + } +} \ No newline at end of file diff --git a/LicenceHeader/Properties/AssemblyInfo.cs b/LicenceHeader/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..f474a7f484 --- /dev/null +++ b/LicenceHeader/Properties/AssemblyInfo.cs @@ -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("LicenceHeader")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("LicenceHeader")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[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("90e6bcfe-f3da-4689-b4cd-b191771f1d1b")] + +// 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")] diff --git a/LicenceHeader/header.txt b/LicenceHeader/header.txt new file mode 100644 index 0000000000..4ad4eb3d90 --- /dev/null +++ b/LicenceHeader/header.txt @@ -0,0 +1,16 @@ +/* +* Copyright 2015 European Union +* +* Licensed under the EUPL (the "Licence"); +* You may not use this work except in compliance with the Licence. +* You may obtain a copy of the Licence at: +* +* http://ec.europa.eu/idabc/eupl5 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the Licence is distributed on an "AS IS" basis, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the Licence for the specific language governing permissions and +* limitations under the Licence. +*/ + diff --git a/VECTO.sln b/VECTO.sln index c32622f882..700c109249 100644 --- a/VECTO.sln +++ b/VECTO.sln @@ -19,6 +19,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GraphDrawer", "GraphDrawer\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeclarationCycleZip", "DeclarationCycleZip\DeclarationCycleZip.csproj", "{2320CD6F-FE7B-4341-A9BB-3ABCA7EF18F6}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LicenceHeader", "LicenceHeader\LicenceHeader.csproj", "{E8B0B447-1A54-4BEC-A160-AF0017000781}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -93,6 +95,14 @@ Global {2320CD6F-FE7B-4341-A9BB-3ABCA7EF18F6}.Release|Any CPU.Build.0 = Release|Any CPU {2320CD6F-FE7B-4341-A9BB-3ABCA7EF18F6}.Release|x64.ActiveCfg = Release|Any CPU {2320CD6F-FE7B-4341-A9BB-3ABCA7EF18F6}.Release|x86.ActiveCfg = Release|Any CPU + {E8B0B447-1A54-4BEC-A160-AF0017000781}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E8B0B447-1A54-4BEC-A160-AF0017000781}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E8B0B447-1A54-4BEC-A160-AF0017000781}.Debug|x64.ActiveCfg = Debug|Any CPU + {E8B0B447-1A54-4BEC-A160-AF0017000781}.Debug|x86.ActiveCfg = Debug|Any CPU + {E8B0B447-1A54-4BEC-A160-AF0017000781}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E8B0B447-1A54-4BEC-A160-AF0017000781}.Release|Any CPU.Build.0 = Release|Any CPU + {E8B0B447-1A54-4BEC-A160-AF0017000781}.Release|x64.ActiveCfg = Release|Any CPU + {E8B0B447-1A54-4BEC-A160-AF0017000781}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE -- GitLab