Skip to content

Commit

Permalink
#14 refactoring: add project templates and logging library
Browse files Browse the repository at this point in the history
  • Loading branch information
Vasar007 committed Apr 9, 2022
1 parent 6cd7669 commit 55bdd45
Show file tree
Hide file tree
Showing 16 changed files with 3,828 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="Current">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Company>Valery Kirichenko</Company>
<Product>ClipChopper</Product>
<AssemblyName>ClipChopper</AssemblyName>
<PackageId>ClipChopper</PackageId>
<Authors>Valery Kirichenko</Authors>

<Platforms>x64</Platforms>
<Configurations>Debug;Release</Configurations>
<Platforms>$(AppPlatforms)</Platforms>
<Configurations>$(AppConfigurations)</Configurations>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<LangVersion>8.0</LangVersion>
<TargetFramework>$(WindowsAppTargetFramework)</TargetFramework>
<LangVersion>$(CSharpLangVersion)</LangVersion>
<UseWPF>true</UseWPF>
<Nullable>enable</Nullable>
<WarningsAsErrors>CS8600,CS8602,CS8603,CS8618,CS8625</WarningsAsErrors>
<RootNamespace>ClipChopper</RootNamespace>
<Deterministic>true</Deterministic>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<MinVerTagPrefix>v</MinVerTagPrefix>
<RootNamespace>ClipChopper.DesktopApp</RootNamespace>
<IncludeSymbols>false</IncludeSymbols>
<IsPackable>false</IsPackable>
<ApplicationIcon>icon.ico</ApplicationIcon>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>

<PublishReadyToRun>true</PublishReadyToRun>
<!-- Workaround to fix issue with debug mode in VS. -->
<PublishSingleFile Condition="'$(Configuration)' == 'Release'">true</PublishSingleFile>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>

<AssemblyVersion>1.2.1</AssemblyVersion>
<Version>1.2.1</Version>
<PropertyGroup>
<Authors>Valery Kirichenko; Vasily Vasilyev</Authors>
<Product>ClipChopper</Product>
<Company>ClipChopper</Company>
<NeutralLanguage>en-US</NeutralLanguage>
<RepositoryUrl>https://github.com/valery-kirichenko/clip-chopper</RepositoryUrl>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<RepositoryType>git</RepositoryType>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -67,9 +73,16 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FFME.Windows" Version="4.4.350" />
<PackageReference Include="NExifTool" Version="0.11.0" />
<PackageReference Include="Ookii.Dialogs.Wpf" Version="5.0.1" />
<ProjectReference Include="$(SolutionDir)Libraries\ClipChopper.Common\ClipChopper.Common.csproj" />
<ProjectReference Include="$(SolutionDir)Libraries\ClipChopper.Core\ClipChopper.Core.csproj" />
<ProjectReference Include="$(SolutionDir)Libraries\ClipChopper.Logging\ClipChopper.Logging.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="FFME.Windows" Version="$(FFMEWindowsPackageVersion)" />
<PackageReference Include="MinVer" Version="$(MinVerPackageVersion)" PrivateAssets="all" />
<PackageReference Include="NExifTool" Version="$(NExifToolPackageVersion)" />
<PackageReference Include="Ookii.Dialogs.Wpf" Version="$(OokiiDialogsWpfPackageVersion)" />
</ItemGroup>

</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public sealed partial class MainWindow
private string? _loadedMedia;
private FragmentSelection? _fragment;
private int _selectedAudioStream;
public ObservableCollection<AudioTrack> AudioTracks { get; } = new ObservableCollection<AudioTrack>(new List<AudioTrack>
public ObservableCollection<AudioTrack> AudioTracks { get; } = new(new List<AudioTrack>
{
new AudioTrack
{
Expand Down
31 changes: 29 additions & 2 deletions ClipChopper/ClipChopper.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29709.97
# Visual Studio Version 17
VisualStudioVersion = 17.1.32328.378
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Applications", "Applications", "{30A9B94B-57FE-4C5D-B493-2E8F2D578AF8}"
EndProject
Expand All @@ -11,6 +11,18 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{C2130176
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClipChopper.DesktopApp", "Applications\ClipChopper.DesktopApp\ClipChopper.DesktopApp.csproj", "{72CA55A6-B3C2-4779-818D-CC49758C2A15}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{30D71C54-EDCC-4DB5-8609-87B1FCD6A517}"
ProjectSection(SolutionItems) = preProject
Directory.Build.props = Directory.Build.props
NuGet.Config = NuGet.Config
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClipChopper.Core", "Libraries\ClipChopper.Core\ClipChopper.Core.csproj", "{89AE0DD0-1B71-4DF1-856C-EC3A12BDDFEE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClipChopper.Logging", "Libraries\ClipChopper.Logging\ClipChopper.Logging.csproj", "{15230E04-1457-4A66-A1CC-E74F01DA9EB0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClipChopper.Common", "Libraries\ClipChopper.Common\ClipChopper.Common.csproj", "{12A8C3E5-96AE-4374-A721-7276AAF31D4D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Expand All @@ -22,12 +34,27 @@ Global
{72CA55A6-B3C2-4779-818D-CC49758C2A15}.Release|x64.ActiveCfg = Release|x64
{72CA55A6-B3C2-4779-818D-CC49758C2A15}.Release|x64.Build.0 = Release|x64
{72CA55A6-B3C2-4779-818D-CC49758C2A15}.Release|x64.Deploy.0 = Release|x64
{89AE0DD0-1B71-4DF1-856C-EC3A12BDDFEE}.Debug|x64.ActiveCfg = Debug|x64
{89AE0DD0-1B71-4DF1-856C-EC3A12BDDFEE}.Debug|x64.Build.0 = Debug|x64
{89AE0DD0-1B71-4DF1-856C-EC3A12BDDFEE}.Release|x64.ActiveCfg = Release|x64
{89AE0DD0-1B71-4DF1-856C-EC3A12BDDFEE}.Release|x64.Build.0 = Release|x64
{15230E04-1457-4A66-A1CC-E74F01DA9EB0}.Debug|x64.ActiveCfg = Debug|x64
{15230E04-1457-4A66-A1CC-E74F01DA9EB0}.Debug|x64.Build.0 = Debug|x64
{15230E04-1457-4A66-A1CC-E74F01DA9EB0}.Release|x64.ActiveCfg = Release|x64
{15230E04-1457-4A66-A1CC-E74F01DA9EB0}.Release|x64.Build.0 = Release|x64
{12A8C3E5-96AE-4374-A721-7276AAF31D4D}.Debug|x64.ActiveCfg = Debug|x64
{12A8C3E5-96AE-4374-A721-7276AAF31D4D}.Debug|x64.Build.0 = Debug|x64
{12A8C3E5-96AE-4374-A721-7276AAF31D4D}.Release|x64.ActiveCfg = Release|x64
{12A8C3E5-96AE-4374-A721-7276AAF31D4D}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{72CA55A6-B3C2-4779-818D-CC49758C2A15} = {30A9B94B-57FE-4C5D-B493-2E8F2D578AF8}
{89AE0DD0-1B71-4DF1-856C-EC3A12BDDFEE} = {A4D3BDEB-BB70-46BC-BB8C-B58D71922315}
{15230E04-1457-4A66-A1CC-E74F01DA9EB0} = {A4D3BDEB-BB70-46BC-BB8C-B58D71922315}
{12A8C3E5-96AE-4374-A721-7276AAF31D4D} = {A4D3BDEB-BB70-46BC-BB8C-B58D71922315}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D5421CE1-B974-4F27-83D9-6EACD36B29A4}
Expand Down
26 changes: 26 additions & 0 deletions ClipChopper/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project>

<!-- Project properties -->
<PropertyGroup>
<AppPlatforms>x64</AppPlatforms>
<AppConfigurations>Debug;Release</AppConfigurations>
<AppTargetFramework>net6.0</AppTargetFramework>
<WindowsAppTargetFramework>net6.0-windows</WindowsAppTargetFramework>
<LibraryTargetFramework>net6.0</LibraryTargetFramework>
<TestTargetFramework>net6.0</TestTargetFramework>
<CSharpLangVersion>10.0</CSharpLangVersion>
</PropertyGroup>

<!-- NuGet packages -->
<PropertyGroup>
<AcolyteNETPackageVersion>2.2.0</AcolyteNETPackageVersion>
<FFMEWindowsPackageVersion>4.4.350</FFMEWindowsPackageVersion>
<NExifToolPackageVersion>0.11.0</NExifToolPackageVersion>
<MinVerPackageVersion>3.1.0</MinVerPackageVersion>
<NLogPackageVersion>4.7.15</NLogPackageVersion>
<NLogConfigPackageVersion>4.7.15</NLogConfigPackageVersion>
<NLogSchemaPackageVersion>4.7.15</NLogSchemaPackageVersion>
<OokiiDialogsWpfPackageVersion>5.0.1</OokiiDialogsWpfPackageVersion>
</PropertyGroup>

</Project>
39 changes: 39 additions & 0 deletions ClipChopper/Libraries/ClipChopper.Common/ClipChopper.Common.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Platforms>$(AppPlatforms)</Platforms>
<Configurations>$(AppConfigurations)</Configurations>
<OutputType>Library</OutputType>
<TargetFramework>$(LibraryTargetFramework)</TargetFramework>
<LangVersion>$(CSharpLangVersion)</LangVersion>
<Nullable>enable</Nullable>
<Deterministic>true</Deterministic>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<MinVerTagPrefix>v</MinVerTagPrefix>
<RootNamespace>ClipChopper.Common</RootNamespace>
<IncludeSymbols>false</IncludeSymbols>
<IsPackable>false</IsPackable>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>

<PublishReadyToRun>true</PublishReadyToRun>
<!-- Workaround to fix issue with debug mode in VS. -->
<PublishSingleFile Condition="'$(Configuration)' == 'Release'">true</PublishSingleFile>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>

<PropertyGroup>
<Authors>Valery Kirichenko; Vasily Vasilyev</Authors>
<Product>ClipChopper</Product>
<Company>ClipChopper</Company>
<NeutralLanguage>en-US</NeutralLanguage>
<RepositoryUrl>https://github.com/valery-kirichenko/clip-chopper</RepositoryUrl>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<RepositoryType>git</RepositoryType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Acolyte.NET" Version="$(AcolyteNETPackageVersion)" />
<PackageReference Include="MinVer" Version="$(MinVerPackageVersion)" PrivateAssets="all" />
</ItemGroup>

</Project>
43 changes: 43 additions & 0 deletions ClipChopper/Libraries/ClipChopper.Core/ClipChopper.Core.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Platforms>$(AppPlatforms)</Platforms>
<Configurations>$(AppConfigurations)</Configurations>
<OutputType>Library</OutputType>
<TargetFramework>$(LibraryTargetFramework)</TargetFramework>
<LangVersion>$(CSharpLangVersion)</LangVersion>
<Nullable>enable</Nullable>
<Deterministic>true</Deterministic>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<MinVerTagPrefix>v</MinVerTagPrefix>
<RootNamespace>ClipChopper.Core</RootNamespace>
<IncludeSymbols>false</IncludeSymbols>
<IsPackable>false</IsPackable>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>

<PublishReadyToRun>true</PublishReadyToRun>
<!-- Workaround to fix issue with debug mode in VS. -->
<PublishSingleFile Condition="'$(Configuration)' == 'Release'">true</PublishSingleFile>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>

<PropertyGroup>
<Authors>Valery Kirichenko; Vasily Vasilyev</Authors>
<Product>ClipChopper</Product>
<Company>ClipChopper</Company>
<NeutralLanguage>en-US</NeutralLanguage>
<RepositoryUrl>https://github.com/valery-kirichenko/clip-chopper</RepositoryUrl>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<RepositoryType>git</RepositoryType>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="$(SolutionDir)Libraries\ClipChopper.Common\ClipChopper.Common.csproj" />
<ProjectReference Include="$(SolutionDir)Libraries\ClipChopper.Logging\ClipChopper.Logging.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="MinVer" Version="$(MinVerPackageVersion)" PrivateAssets="all" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Platforms>$(AppPlatforms)</Platforms>
<Configurations>$(AppConfigurations)</Configurations>
<OutputType>Library</OutputType>
<TargetFramework>$(LibraryTargetFramework)</TargetFramework>
<LangVersion>$(CSharpLangVersion)</LangVersion>
<Nullable>enable</Nullable>
<Deterministic>true</Deterministic>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<MinVerTagPrefix>v</MinVerTagPrefix>
<RootNamespace>ClipChopper.Logging</RootNamespace>
<IncludeSymbols>false</IncludeSymbols>
<IsPackable>false</IsPackable>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>

<PublishReadyToRun>true</PublishReadyToRun>
<!-- Workaround to fix issue with debug mode in VS. -->
<PublishSingleFile Condition="'$(Configuration)' == 'Release'">true</PublishSingleFile>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>

<PropertyGroup>
<Authors>Valery Kirichenko; Vasily Vasilyev</Authors>
<Product>ClipChopper</Product>
<Company>ClipChopper</Company>
<NeutralLanguage>en-US</NeutralLanguage>
<RepositoryUrl>https://github.com/valery-kirichenko/clip-chopper</RepositoryUrl>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<RepositoryType>git</RepositoryType>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="$(SolutionDir)Libraries\ClipChopper.Common\ClipChopper.Common.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="MinVer" Version="$(MinVerPackageVersion)" PrivateAssets="all" />
<PackageReference Include="NLog" Version="$(NLogPackageVersion)" />
<PackageReference Include="NLog.Config" Version="$(NLogConfigPackageVersion)">
<ExcludeAssets>all</ExcludeAssets>
</PackageReference>
<PackageReference Include="NLog.Schema" Version="$(NLogSchemaPackageVersion)" />
</ItemGroup>

<ItemGroup>
<Content Include="NLog.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>false</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Include="NLog.xsd">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>false</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>

</Project>
16 changes: 16 additions & 0 deletions ClipChopper/Libraries/ClipChopper.Logging/ILogger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;

namespace ClipChopper.Logging
{
public interface ILogger
{
void PrintHeader(string message);
void PrintFooter(string message);
void Debug(string message);
void Info(string message);
void Warn(string message);
void Warn(Exception ex, string message);
void Error(string message);
void Error(Exception ex, string message);
}
}
46 changes: 46 additions & 0 deletions ClipChopper/Libraries/ClipChopper.Logging/LoggerFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System;
using Acolyte.Assertions;

namespace ClipChopper.Logging
{
public static class LoggerFactory
{
/// <summary>
/// Creates logger instance for passed type.
/// </summary>
/// <typeparam name="T">Type for which instance is created.</typeparam>
/// <returns>Created logger instance.</returns>
/// <exception cref="ArgumentException">
/// Cannot get full name of type <typeparamref name="T" />.
/// </exception>
public static ILogger CreateLoggerFor<T>()
{
Type type = typeof(T);
string fullName = type.FullName ?? throw new ArgumentException(
$"Could not get full name of class {type}."
);
return new NLogLoggerAdapter(fullName);
}

/// <summary>
/// Creates logger instance for passed class type.
/// </summary>
/// <param name="type">Class name. Try to pass it with <c>typeof</c> operator.</param>
/// <returns>Created logger instance.</returns>
/// <exception cref="ArgumentNullException">
/// <paramref name="type" /> is <c>null</c>.
/// </exception>
/// <exception cref="ArgumentException">
/// Cannot get full name of passed type <paramref name="type" />.
/// </exception>
public static ILogger CreateLoggerFor(Type type)
{
type.ThrowIfNull(nameof(type));

string fullName = type.FullName ?? throw new ArgumentException(
$"Could not get full name of class {nameof(type)}"
);
return new NLogLoggerAdapter(fullName);
}
}
}
Loading

0 comments on commit 55bdd45

Please sign in to comment.