From cb138852097e8a821da20db2e55ca6046c68640b Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Wed, 28 Jun 2017 15:10:13 +0100 Subject: [PATCH 1/7] #40 - Restructured solution based on netstandard 1.3 project. --- .../GitTools.Core.Tests.csproj | 6 - src/GitTools.Core.sln | 41 +- .../{GitTools.Core.Shared => }/Diposable.cs | 0 .../Exceptions/GitToolsException.cs | 0 .../Exceptions/WarningException.cs | 1 + .../Extensions/StringExtensions.cs | 0 .../Git/AuthenticationInfo.cs | 0 .../Git/DynamicRepositories.cs | 0 .../Git/DynamicRepository.cs | 0 .../AuthenticationInfoExtensions.cs | 0 .../Git/Extensions/IRepositoryExtensions.cs | 0 .../Git/Extensions/LibGitExtensions.cs | 0 .../Git/GitDirFinder.cs | 0 .../Git/Helpers/BugException.cs | 0 .../Git/Helpers/GitRepositoryHelper.cs | 0 .../Git/RepositoryInfo.cs | 0 .../Git/RepositoryLoader.cs | 0 .../Git/TaggedCommit.cs | 0 .../GitTools.Core.NET40.csproj | 82 - .../GitTools.Core.NET40.v2.ncrunchproject | Bin 2726 -> 0 bytes .../Properties/AssemblyInfo.cs | 5 - .../Properties/JetBrainsAnnotations.cs | 954 ------- .../GitTools.Core.NET40/packages.config | 6 - .../App_Packages/LibLog.4.2/LibLog.cs | 2263 ----------------- .../GitTools.Core.NET45.csproj | 81 - .../GitTools.Core.NET45.v2.ncrunchproject | Bin 2726 -> 0 bytes .../Properties/AssemblyInfo.cs | 6 - .../Properties/JetBrainsAnnotations.cs | 954 ------- .../GitTools.Core.NET45/packages.config | 6 - .../GitTools.Core.Shared.projitems | 35 - .../GitTools.Core.Shared.shproj | 13 - src/GitTools.Core/GitTools.Core.csproj | 18 + src/GitTools.Core/GitTools.Core.nuspec | 2 +- .../Helpers/ProcessHelper.cs | 0 .../IO/FileSystem.cs | 0 .../IO/Helpers/DeleteHelper.cs | 0 .../IO/Interfaces/IFileSystem.cs | 0 .../IO/TemporaryFilesContext.cs | 0 .../App_Packages => }/LibLog.4.2/LibLog.cs | 167 +- .../Logging/Extensions/LogExtensions.cs | 0 .../Pollyfill/SerializableAttribute.cs | 9 + 41 files changed, 180 insertions(+), 4469 deletions(-) rename src/GitTools.Core/{GitTools.Core.Shared => }/Diposable.cs (100%) rename src/GitTools.Core/{GitTools.Core.Shared => }/Exceptions/GitToolsException.cs (100%) rename src/GitTools.Core/{GitTools.Core.Shared => }/Exceptions/WarningException.cs (97%) rename src/GitTools.Core/{GitTools.Core.Shared => }/Extensions/StringExtensions.cs (100%) rename src/GitTools.Core/{GitTools.Core.Shared => }/Git/AuthenticationInfo.cs (100%) rename src/GitTools.Core/{GitTools.Core.Shared => }/Git/DynamicRepositories.cs (100%) rename src/GitTools.Core/{GitTools.Core.Shared => }/Git/DynamicRepository.cs (100%) rename src/GitTools.Core/{GitTools.Core.Shared => }/Git/Extensions/AuthenticationInfoExtensions.cs (100%) rename src/GitTools.Core/{GitTools.Core.Shared => }/Git/Extensions/IRepositoryExtensions.cs (100%) rename src/GitTools.Core/{GitTools.Core.Shared => }/Git/Extensions/LibGitExtensions.cs (100%) rename src/GitTools.Core/{GitTools.Core.Shared => }/Git/GitDirFinder.cs (100%) rename src/GitTools.Core/{GitTools.Core.Shared => }/Git/Helpers/BugException.cs (100%) rename src/GitTools.Core/{GitTools.Core.Shared => }/Git/Helpers/GitRepositoryHelper.cs (100%) rename src/GitTools.Core/{GitTools.Core.Shared => }/Git/RepositoryInfo.cs (100%) rename src/GitTools.Core/{GitTools.Core.Shared => }/Git/RepositoryLoader.cs (100%) rename src/GitTools.Core/{GitTools.Core.Shared => }/Git/TaggedCommit.cs (100%) delete mode 100644 src/GitTools.Core/GitTools.Core.NET40/GitTools.Core.NET40.csproj delete mode 100644 src/GitTools.Core/GitTools.Core.NET40/GitTools.Core.NET40.v2.ncrunchproject delete mode 100644 src/GitTools.Core/GitTools.Core.NET40/Properties/AssemblyInfo.cs delete mode 100644 src/GitTools.Core/GitTools.Core.NET40/Properties/JetBrainsAnnotations.cs delete mode 100644 src/GitTools.Core/GitTools.Core.NET40/packages.config delete mode 100644 src/GitTools.Core/GitTools.Core.NET45/App_Packages/LibLog.4.2/LibLog.cs delete mode 100644 src/GitTools.Core/GitTools.Core.NET45/GitTools.Core.NET45.csproj delete mode 100644 src/GitTools.Core/GitTools.Core.NET45/GitTools.Core.NET45.v2.ncrunchproject delete mode 100644 src/GitTools.Core/GitTools.Core.NET45/Properties/AssemblyInfo.cs delete mode 100644 src/GitTools.Core/GitTools.Core.NET45/Properties/JetBrainsAnnotations.cs delete mode 100644 src/GitTools.Core/GitTools.Core.NET45/packages.config delete mode 100644 src/GitTools.Core/GitTools.Core.Shared/GitTools.Core.Shared.projitems delete mode 100644 src/GitTools.Core/GitTools.Core.Shared/GitTools.Core.Shared.shproj create mode 100644 src/GitTools.Core/GitTools.Core.csproj rename src/GitTools.Core/{GitTools.Core.Shared => }/Helpers/ProcessHelper.cs (100%) rename src/GitTools.Core/{GitTools.Core.Shared => }/IO/FileSystem.cs (100%) rename src/GitTools.Core/{GitTools.Core.Shared => }/IO/Helpers/DeleteHelper.cs (100%) rename src/GitTools.Core/{GitTools.Core.Shared => }/IO/Interfaces/IFileSystem.cs (100%) rename src/GitTools.Core/{GitTools.Core.Shared => }/IO/TemporaryFilesContext.cs (100%) rename src/GitTools.Core/{GitTools.Core.NET40/App_Packages => }/LibLog.4.2/LibLog.cs (95%) rename src/GitTools.Core/{GitTools.Core.Shared => }/Logging/Extensions/LogExtensions.cs (100%) create mode 100644 src/GitTools.Core/Pollyfill/SerializableAttribute.cs diff --git a/src/GitTools.Core.Tests/GitTools.Core.Tests.csproj b/src/GitTools.Core.Tests/GitTools.Core.Tests.csproj index 3af61b7..b3ab6c9 100644 --- a/src/GitTools.Core.Tests/GitTools.Core.Tests.csproj +++ b/src/GitTools.Core.Tests/GitTools.Core.Tests.csproj @@ -78,12 +78,6 @@ - - - {C11252F9-0ECA-44DC-860B-E029C04FBD10} - GitTools.Core.NET40 - - diff --git a/src/GitTools.Core.sln b/src/GitTools.Core.sln index 1c7ec25..b5b0c30 100644 --- a/src/GitTools.Core.sln +++ b/src/GitTools.Core.sln @@ -1,10 +1,12 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25123.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.26430.14 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".misc", ".misc", "{72ECAB81-A674-4AC8-8795-7AD71C3E1A5A}" ProjectSection(SolutionItems) = preProject + ..\.gitattributes = ..\.gitattributes + ..\.gitignore = ..\.gitignore ..\.travis.yml = ..\.travis.yml ..\appveyor.yml = ..\appveyor.yml GitTools.Core.sln.DotSettings = GitTools.Core.sln.DotSettings @@ -12,29 +14,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".misc", ".misc", "{72ECAB81 ..\README.md = ..\README.md Settings.StyleCop = Settings.StyleCop SolutionAssemblyInfo.cs = SolutionAssemblyInfo.cs - ..\.gitattributes = ..\.gitattributes - ..\.gitignore = ..\.gitignore EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitTools.Core.Tests", "GitTools.Core.Tests\GitTools.Core.Tests.csproj", "{0834BE9B-5CDE-4CAB-A683-C70A7D91450B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitTools.Core.NET40", "GitTools.Core\GitTools.Core.NET40\GitTools.Core.NET40.csproj", "{C11252F9-0ECA-44DC-860B-E029C04FBD10}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GitTools.Core", "GitTools.Core", "{753DD689-12ED-42D8-8AF7-936336D65FA0}" - ProjectSection(SolutionItems) = preProject - GitTools.Core\GitTools.Core.nuspec = GitTools.Core\GitTools.Core.nuspec - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitTools.Core.NET45", "GitTools.Core\GitTools.Core.NET45\GitTools.Core.NET45.csproj", "{66295D7C-58FD-4641-AEAB-3DF7EA8FA4D2}" -EndProject -Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "GitTools.Core.Shared", "GitTools.Core\GitTools.Core.Shared\GitTools.Core.Shared.shproj", "{C4B449DF-3E78-4F3B-81A8-DE0DC5827532}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GitTools.Core", "GitTools.Core\GitTools.Core.csproj", "{DD19E93F-C6CC-4748-9EF8-146101AA7F59}" EndProject Global - GlobalSection(SharedMSBuildProjectFiles) = preSolution - GitTools.Core\GitTools.Core.Shared\GitTools.Core.Shared.projitems*{66295d7c-58fd-4641-aeab-3df7ea8fa4d2}*SharedItemsImports = 4 - GitTools.Core\GitTools.Core.Shared\GitTools.Core.Shared.projitems*{c4b449df-3e78-4f3b-81a8-de0dc5827532}*SharedItemsImports = 13 - GitTools.Core\GitTools.Core.Shared\GitTools.Core.Shared.projitems*{c11252f9-0eca-44dc-860b-e029c04fbd10}*SharedItemsImports = 4 - EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU @@ -44,21 +30,12 @@ Global {0834BE9B-5CDE-4CAB-A683-C70A7D91450B}.Debug|Any CPU.Build.0 = Debug|Any CPU {0834BE9B-5CDE-4CAB-A683-C70A7D91450B}.Release|Any CPU.ActiveCfg = Release|Any CPU {0834BE9B-5CDE-4CAB-A683-C70A7D91450B}.Release|Any CPU.Build.0 = Release|Any CPU - {C11252F9-0ECA-44DC-860B-E029C04FBD10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C11252F9-0ECA-44DC-860B-E029C04FBD10}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C11252F9-0ECA-44DC-860B-E029C04FBD10}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C11252F9-0ECA-44DC-860B-E029C04FBD10}.Release|Any CPU.Build.0 = Release|Any CPU - {66295D7C-58FD-4641-AEAB-3DF7EA8FA4D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {66295D7C-58FD-4641-AEAB-3DF7EA8FA4D2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {66295D7C-58FD-4641-AEAB-3DF7EA8FA4D2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {66295D7C-58FD-4641-AEAB-3DF7EA8FA4D2}.Release|Any CPU.Build.0 = Release|Any CPU + {DD19E93F-C6CC-4748-9EF8-146101AA7F59}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DD19E93F-C6CC-4748-9EF8-146101AA7F59}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DD19E93F-C6CC-4748-9EF8-146101AA7F59}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DD19E93F-C6CC-4748-9EF8-146101AA7F59}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {C11252F9-0ECA-44DC-860B-E029C04FBD10} = {753DD689-12ED-42D8-8AF7-936336D65FA0} - {66295D7C-58FD-4641-AEAB-3DF7EA8FA4D2} = {753DD689-12ED-42D8-8AF7-936336D65FA0} - {C4B449DF-3E78-4F3B-81A8-DE0DC5827532} = {753DD689-12ED-42D8-8AF7-936336D65FA0} - EndGlobalSection EndGlobal diff --git a/src/GitTools.Core/GitTools.Core.Shared/Diposable.cs b/src/GitTools.Core/Diposable.cs similarity index 100% rename from src/GitTools.Core/GitTools.Core.Shared/Diposable.cs rename to src/GitTools.Core/Diposable.cs diff --git a/src/GitTools.Core/GitTools.Core.Shared/Exceptions/GitToolsException.cs b/src/GitTools.Core/Exceptions/GitToolsException.cs similarity index 100% rename from src/GitTools.Core/GitTools.Core.Shared/Exceptions/GitToolsException.cs rename to src/GitTools.Core/Exceptions/GitToolsException.cs diff --git a/src/GitTools.Core/GitTools.Core.Shared/Exceptions/WarningException.cs b/src/GitTools.Core/Exceptions/WarningException.cs similarity index 97% rename from src/GitTools.Core/GitTools.Core.Shared/Exceptions/WarningException.cs rename to src/GitTools.Core/Exceptions/WarningException.cs index 0fd4cf1..fff3cc6 100644 --- a/src/GitTools.Core/GitTools.Core.Shared/Exceptions/WarningException.cs +++ b/src/GitTools.Core/Exceptions/WarningException.cs @@ -11,6 +11,7 @@ public WarningException(string message) { } + protected WarningException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/GitTools.Core/GitTools.Core.Shared/Extensions/StringExtensions.cs b/src/GitTools.Core/Extensions/StringExtensions.cs similarity index 100% rename from src/GitTools.Core/GitTools.Core.Shared/Extensions/StringExtensions.cs rename to src/GitTools.Core/Extensions/StringExtensions.cs diff --git a/src/GitTools.Core/GitTools.Core.Shared/Git/AuthenticationInfo.cs b/src/GitTools.Core/Git/AuthenticationInfo.cs similarity index 100% rename from src/GitTools.Core/GitTools.Core.Shared/Git/AuthenticationInfo.cs rename to src/GitTools.Core/Git/AuthenticationInfo.cs diff --git a/src/GitTools.Core/GitTools.Core.Shared/Git/DynamicRepositories.cs b/src/GitTools.Core/Git/DynamicRepositories.cs similarity index 100% rename from src/GitTools.Core/GitTools.Core.Shared/Git/DynamicRepositories.cs rename to src/GitTools.Core/Git/DynamicRepositories.cs diff --git a/src/GitTools.Core/GitTools.Core.Shared/Git/DynamicRepository.cs b/src/GitTools.Core/Git/DynamicRepository.cs similarity index 100% rename from src/GitTools.Core/GitTools.Core.Shared/Git/DynamicRepository.cs rename to src/GitTools.Core/Git/DynamicRepository.cs diff --git a/src/GitTools.Core/GitTools.Core.Shared/Git/Extensions/AuthenticationInfoExtensions.cs b/src/GitTools.Core/Git/Extensions/AuthenticationInfoExtensions.cs similarity index 100% rename from src/GitTools.Core/GitTools.Core.Shared/Git/Extensions/AuthenticationInfoExtensions.cs rename to src/GitTools.Core/Git/Extensions/AuthenticationInfoExtensions.cs diff --git a/src/GitTools.Core/GitTools.Core.Shared/Git/Extensions/IRepositoryExtensions.cs b/src/GitTools.Core/Git/Extensions/IRepositoryExtensions.cs similarity index 100% rename from src/GitTools.Core/GitTools.Core.Shared/Git/Extensions/IRepositoryExtensions.cs rename to src/GitTools.Core/Git/Extensions/IRepositoryExtensions.cs diff --git a/src/GitTools.Core/GitTools.Core.Shared/Git/Extensions/LibGitExtensions.cs b/src/GitTools.Core/Git/Extensions/LibGitExtensions.cs similarity index 100% rename from src/GitTools.Core/GitTools.Core.Shared/Git/Extensions/LibGitExtensions.cs rename to src/GitTools.Core/Git/Extensions/LibGitExtensions.cs diff --git a/src/GitTools.Core/GitTools.Core.Shared/Git/GitDirFinder.cs b/src/GitTools.Core/Git/GitDirFinder.cs similarity index 100% rename from src/GitTools.Core/GitTools.Core.Shared/Git/GitDirFinder.cs rename to src/GitTools.Core/Git/GitDirFinder.cs diff --git a/src/GitTools.Core/GitTools.Core.Shared/Git/Helpers/BugException.cs b/src/GitTools.Core/Git/Helpers/BugException.cs similarity index 100% rename from src/GitTools.Core/GitTools.Core.Shared/Git/Helpers/BugException.cs rename to src/GitTools.Core/Git/Helpers/BugException.cs diff --git a/src/GitTools.Core/GitTools.Core.Shared/Git/Helpers/GitRepositoryHelper.cs b/src/GitTools.Core/Git/Helpers/GitRepositoryHelper.cs similarity index 100% rename from src/GitTools.Core/GitTools.Core.Shared/Git/Helpers/GitRepositoryHelper.cs rename to src/GitTools.Core/Git/Helpers/GitRepositoryHelper.cs diff --git a/src/GitTools.Core/GitTools.Core.Shared/Git/RepositoryInfo.cs b/src/GitTools.Core/Git/RepositoryInfo.cs similarity index 100% rename from src/GitTools.Core/GitTools.Core.Shared/Git/RepositoryInfo.cs rename to src/GitTools.Core/Git/RepositoryInfo.cs diff --git a/src/GitTools.Core/GitTools.Core.Shared/Git/RepositoryLoader.cs b/src/GitTools.Core/Git/RepositoryLoader.cs similarity index 100% rename from src/GitTools.Core/GitTools.Core.Shared/Git/RepositoryLoader.cs rename to src/GitTools.Core/Git/RepositoryLoader.cs diff --git a/src/GitTools.Core/GitTools.Core.Shared/Git/TaggedCommit.cs b/src/GitTools.Core/Git/TaggedCommit.cs similarity index 100% rename from src/GitTools.Core/GitTools.Core.Shared/Git/TaggedCommit.cs rename to src/GitTools.Core/Git/TaggedCommit.cs diff --git a/src/GitTools.Core/GitTools.Core.NET40/GitTools.Core.NET40.csproj b/src/GitTools.Core/GitTools.Core.NET40/GitTools.Core.NET40.csproj deleted file mode 100644 index df1282c..0000000 --- a/src/GitTools.Core/GitTools.Core.NET40/GitTools.Core.NET40.csproj +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - Debug - AnyCPU - {C11252F9-0ECA-44DC-860B-E029C04FBD10} - Library - Properties - GitTools - GitTools.Core - v4.0 - 5 - 512 - - - - - - true - full - false - ..\..\..\output\Debug\GitTools.Core\net4\ - TRACE;DEBUG - prompt - 4 - ..\..\..\output\Debug\GitTools.Core\net4\GitTools.Core.xml - true - 1591,414 - - - pdbonly - true - ..\..\..\output\Release\GitTools.Core\net4\ - TRACE - prompt - 4 - 1591 - true - ..\..\..\output\Release\GitTools.Core\net4\GitTools.Core.xml - - - - ..\..\packages\LibGit2Sharp.0.23.0-pre20160922233542\lib\net40\LibGit2Sharp.dll - True - - - - - - - - - - - - Properties\SolutionAssemblyInfo.cs - - - - - - - - - - - - - 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}. - - - - - \ No newline at end of file diff --git a/src/GitTools.Core/GitTools.Core.NET40/GitTools.Core.NET40.v2.ncrunchproject b/src/GitTools.Core/GitTools.Core.NET40/GitTools.Core.NET40.v2.ncrunchproject deleted file mode 100644 index cdfbdeb62b94ed1a21f6f85dec6e376a397e23a7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2726 zcmb_e%TDV+4E6d-`~!b*VT10XsuUgz7Kn-#v4)VAK$DBdPEtlF1$HrTD63hVwUS^9g^?z{s;> z$ll@%Pt*2qX>H=np+5yKqC8iWj8_c1E8Tg)&J1sbXjF=R0#x)N#koZ<%H4GuMrJbs zngUku2S>CWyKS`?jtCft;=i0CvpLXYh(N4aVe~xD9MCd*&pNla)nO>uhv*~gC0j?Y**DuZhe?=)fYE1W3V+EZ z-_b7NS=U;#N;a1_+x03))TGKNzP`6Uf4eG z^`GGMHMm_OSL~O87rYnoz7c5@3QRcT45!sFX^X=J7!d9Z?99~8=^g3ari9&4)qyFr qPMJvKzMZ_;4;{ - /// Indicates that the value of the marked element could be null sometimes, - /// so the check for null is necessary before its usage. - /// - /// - /// [CanBeNull] public object Test() { return null; } - /// public void UseTest() { - /// var p = Test(); - /// var s = p.ToString(); // Warning: Possible 'System.NullReferenceException' - /// } - /// - [AttributeUsage( - AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | - AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event)] - internal sealed class CanBeNullAttribute : Attribute { } - - /// - /// Indicates that the value of the marked element could never be null. - /// - /// - /// [NotNull] public object Foo() { - /// return null; // Warning: Possible 'null' assignment - /// } - /// - [AttributeUsage( - AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | - AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event)] - internal sealed class NotNullAttribute : Attribute { } - - /// - /// Can be appplied to symbols of types derived from IEnumerable as well as to symbols of Task - /// and Lazy classes to indicate that the value of a collection item, of the Task.Result property - /// or of the Lazy.Value property can never be null. - /// - [AttributeUsage( - AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | - AttributeTargets.Delegate | AttributeTargets.Field)] - internal sealed class ItemNotNullAttribute : Attribute { } - - /// - /// Can be appplied to symbols of types derived from IEnumerable as well as to symbols of Task - /// and Lazy classes to indicate that the value of a collection item, of the Task.Result property - /// or of the Lazy.Value property can be null. - /// - [AttributeUsage( - AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | - AttributeTargets.Delegate | AttributeTargets.Field)] - internal sealed class ItemCanBeNullAttribute : Attribute { } - - /// - /// Indicates that the marked method builds string by format pattern and (optional) arguments. - /// Parameter, which contains format string, should be given in constructor. The format string - /// should be in -like form. - /// - /// - /// [StringFormatMethod("message")] - /// public void ShowError(string message, params object[] args) { /* do something */ } - /// public void Foo() { - /// ShowError("Failed: {0}"); // Warning: Non-existing argument in format string - /// } - /// - [AttributeUsage( - AttributeTargets.Constructor | AttributeTargets.Method | - AttributeTargets.Property | AttributeTargets.Delegate)] - internal sealed class StringFormatMethodAttribute : Attribute - { - /// - /// Specifies which parameter of an annotated method should be treated as format-string - /// - public StringFormatMethodAttribute(string formatParameterName) - { - FormatParameterName = formatParameterName; - } - - public string FormatParameterName { get; private set; } - } - - /// - /// For a parameter that is expected to be one of the limited set of values. - /// Specify fields of which type should be used as values for this parameter. - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field)] - internal sealed class ValueProviderAttribute : Attribute - { - public ValueProviderAttribute(string name) - { - Name = name; - } - - [NotNull] - public string Name { get; private set; } - } - - /// - /// Indicates that the function argument should be string literal and match one - /// of the parameters of the caller function. For example, ReSharper annotates - /// the parameter of . - /// - /// - /// public void Foo(string param) { - /// if (param == null) - /// throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol - /// } - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class InvokerParameterNameAttribute : Attribute { } - - /// - /// Indicates that the method is contained in a type that implements - /// System.ComponentModel.INotifyPropertyChanged interface and this method - /// is used to notify that some property value changed. - /// - /// - /// The method should be non-static and conform to one of the supported signatures: - /// - /// NotifyChanged(string) - /// NotifyChanged(params string[]) - /// NotifyChanged{T}(Expression{Func{T}}) - /// NotifyChanged{T,U}(Expression{Func{T,U}}) - /// SetProperty{T}(ref T, T, string) - /// - /// - /// - /// public class Foo : INotifyPropertyChanged { - /// public event PropertyChangedEventHandler PropertyChanged; - /// [NotifyPropertyChangedInvocator] - /// protected virtual void NotifyChanged(string propertyName) { ... } - /// - /// private string _name; - /// public string Name { - /// get { return _name; } - /// set { _name = value; NotifyChanged("LastName"); /* Warning */ } - /// } - /// } - /// - /// Examples of generated notifications: - /// - /// NotifyChanged("Property") - /// NotifyChanged(() => Property) - /// NotifyChanged((VM x) => x.Property) - /// SetProperty(ref myField, value, "Property") - /// - /// - [AttributeUsage(AttributeTargets.Method)] - internal sealed class NotifyPropertyChangedInvocatorAttribute : Attribute - { - public NotifyPropertyChangedInvocatorAttribute() { } - public NotifyPropertyChangedInvocatorAttribute(string parameterName) - { - ParameterName = parameterName; - } - - public string ParameterName { get; private set; } - } - - /// - /// Describes dependency between method input and output. - /// - /// - ///

Function Definition Table syntax:

- /// - /// FDT ::= FDTRow [;FDTRow]* - /// FDTRow ::= Input => Output | Output <= Input - /// Input ::= ParameterName: Value [, Input]* - /// Output ::= [ParameterName: Value]* {halt|stop|void|nothing|Value} - /// Value ::= true | false | null | notnull | canbenull - /// - /// If method has single input parameter, it's name could be omitted.
- /// Using halt (or void/nothing, which is the same) - /// for method output means that the methos doesn't return normally.
- /// canbenull annotation is only applicable for output parameters.
- /// You can use multiple [ContractAnnotation] for each FDT row, - /// or use single attribute with rows separated by semicolon.
- ///
- /// - /// - /// [ContractAnnotation("=> halt")] - /// public void TerminationMethod() - /// - /// - /// [ContractAnnotation("halt <= condition: false")] - /// public void Assert(bool condition, string text) // regular assertion method - /// - /// - /// [ContractAnnotation("s:null => true")] - /// public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty() - /// - /// - /// // A method that returns null if the parameter is null, - /// // and not null if the parameter is not null - /// [ContractAnnotation("null => null; notnull => notnull")] - /// public object Transform(object data) - /// - /// - /// [ContractAnnotation("s:null=>false; =>true,result:notnull; =>false, result:null")] - /// public bool TryParse(string s, out Person result) - /// - /// - [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] - internal sealed class ContractAnnotationAttribute : Attribute - { - public ContractAnnotationAttribute([NotNull] string contract) - : this(contract, false) - { } - - public ContractAnnotationAttribute([NotNull] string contract, bool forceFullStates) - { - Contract = contract; - ForceFullStates = forceFullStates; - } - - public string Contract { get; private set; } - public bool ForceFullStates { get; private set; } - } - - /// - /// Indicates that marked element should be localized or not. - /// - /// - /// [LocalizationRequiredAttribute(true)] - /// public class Foo { - /// private string str = "my string"; // Warning: Localizable string - /// } - /// - [AttributeUsage(AttributeTargets.All)] - internal sealed class LocalizationRequiredAttribute : Attribute - { - public LocalizationRequiredAttribute() : this(true) { } - public LocalizationRequiredAttribute(bool required) - { - Required = required; - } - - public bool Required { get; private set; } - } - - /// - /// Indicates that the value of the marked type (or its derivatives) - /// cannot be compared using '==' or '!=' operators and Equals() - /// should be used instead. However, using '==' or '!=' for comparison - /// with null is always permitted. - /// - /// - /// [CannotApplyEqualityOperator] - /// class NoEquality { } - /// class UsesNoEquality { - /// public void Test() { - /// var ca1 = new NoEquality(); - /// var ca2 = new NoEquality(); - /// if (ca1 != null) { // OK - /// bool condition = ca1 == ca2; // Warning - /// } - /// } - /// } - /// - [AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Struct)] - internal sealed class CannotApplyEqualityOperatorAttribute : Attribute { } - - /// - /// When applied to a target attribute, specifies a requirement for any type marked - /// with the target attribute to implement or inherit specific type or types. - /// - /// - /// [BaseTypeRequired(typeof(IComponent)] // Specify requirement - /// public class ComponentAttribute : Attribute { } - /// [Component] // ComponentAttribute requires implementing IComponent interface - /// public class MyComponent : IComponent { } - /// - [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] - [BaseTypeRequired(typeof(Attribute))] - internal sealed class BaseTypeRequiredAttribute : Attribute - { - public BaseTypeRequiredAttribute([NotNull] Type baseType) - { - BaseType = baseType; - } - - [NotNull] - public Type BaseType { get; private set; } - } - - /// - /// Indicates that the marked symbol is used implicitly (e.g. via reflection, in external library), - /// so this symbol will not be marked as unused (as well as by other usage inspections). - /// - [AttributeUsage(AttributeTargets.All)] - internal sealed class UsedImplicitlyAttribute : Attribute - { - public UsedImplicitlyAttribute() - : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) - { } - - public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags) - : this(useKindFlags, ImplicitUseTargetFlags.Default) - { } - - public UsedImplicitlyAttribute(ImplicitUseTargetFlags targetFlags) - : this(ImplicitUseKindFlags.Default, targetFlags) - { } - - public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags) - { - UseKindFlags = useKindFlags; - TargetFlags = targetFlags; - } - - public ImplicitUseKindFlags UseKindFlags { get; private set; } - public ImplicitUseTargetFlags TargetFlags { get; private set; } - } - - /// - /// Should be used on attributes and causes ReSharper to not mark symbols marked with such attributes - /// as unused (as well as by other usage inspections) - /// - [AttributeUsage(AttributeTargets.Class | AttributeTargets.GenericParameter)] - internal sealed class MeansImplicitUseAttribute : Attribute - { - public MeansImplicitUseAttribute() - : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) - { } - - public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags) - : this(useKindFlags, ImplicitUseTargetFlags.Default) - { } - - public MeansImplicitUseAttribute(ImplicitUseTargetFlags targetFlags) - : this(ImplicitUseKindFlags.Default, targetFlags) - { } - - public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags) - { - UseKindFlags = useKindFlags; - TargetFlags = targetFlags; - } - - [UsedImplicitly] - public ImplicitUseKindFlags UseKindFlags { get; private set; } - [UsedImplicitly] - public ImplicitUseTargetFlags TargetFlags { get; private set; } - } - - [Flags] - internal enum ImplicitUseKindFlags - { - Default = Access | Assign | InstantiatedWithFixedConstructorSignature, - /// Only entity marked with attribute considered used. - Access = 1, - /// Indicates implicit assignment to a member. - Assign = 2, - /// - /// Indicates implicit instantiation of a type with fixed constructor signature. - /// That means any unused constructor parameters won't be reported as such. - /// - InstantiatedWithFixedConstructorSignature = 4, - /// Indicates implicit instantiation of a type. - InstantiatedNoFixedConstructorSignature = 8, - } - - /// - /// Specify what is considered used implicitly when marked - /// with or . - /// - [Flags] - internal enum ImplicitUseTargetFlags - { - Default = Itself, - Itself = 1, - /// Members of entity marked with attribute are considered used. - Members = 2, - /// Entity marked with attribute and all its members considered used. - WithMembers = Itself | Members - } - - /// - /// This attribute is intended to mark publicly available API - /// which should not be removed and so is treated as used. - /// - [MeansImplicitUse(ImplicitUseTargetFlags.WithMembers)] - internal sealed class PublicAPIAttribute : Attribute - { - public PublicAPIAttribute() { } - public PublicAPIAttribute([NotNull] string comment) - { - Comment = comment; - } - - public string Comment { get; private set; } - } - - /// - /// Tells code analysis engine if the parameter is completely handled when the invoked method is on stack. - /// If the parameter is a delegate, indicates that delegate is executed while the method is executed. - /// If the parameter is an enumerable, indicates that it is enumerated while the method is executed. - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class InstantHandleAttribute : Attribute { } - - /// - /// Indicates that a method does not make any observable state changes. - /// The same as System.Diagnostics.Contracts.PureAttribute. - /// - /// - /// [Pure] private int Multiply(int x, int y) { return x * y; } - /// public void Foo() { - /// const int a = 2, b = 2; - /// Multiply(a, b); // Waring: Return value of pure method is not used - /// } - /// - [AttributeUsage(AttributeTargets.Method)] - internal sealed class PureAttribute : Attribute { } - - /// - /// Indicates that a parameter is a path to a file or a folder within a web project. - /// Path can be relative or absolute, starting from web root (~). - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class PathReferenceAttribute : Attribute - { - public PathReferenceAttribute() { } - public PathReferenceAttribute([PathReference] string basePath) - { - BasePath = basePath; - } - - public string BasePath { get; private set; } - } - - /// - /// An extension method marked with this attribute is processed by ReSharper code completion - /// as a 'Source Template'. When extension method is completed over some expression, it's source code - /// is automatically expanded like a template at call site. - /// - /// - /// Template method body can contain valid source code and/or special comments starting with '$'. - /// Text inside these comments is added as source code when the template is applied. Template parameters - /// can be used either as additional method parameters or as identifiers wrapped in two '$' signs. - /// Use the attribute to specify macros for parameters. - /// - /// - /// In this example, the 'forEach' method is a source template available over all values - /// of enumerable types, producing ordinary C# 'foreach' statement and placing caret inside block: - /// - /// [SourceTemplate] - /// public static void forEach<T>(this IEnumerable<T> xs) { - /// foreach (var x in xs) { - /// //$ $END$ - /// } - /// } - /// - /// - [AttributeUsage(AttributeTargets.Method)] - internal sealed class SourceTemplateAttribute : Attribute { } - - /// - /// Allows specifying a macro for a parameter of a source template. - /// - /// - /// You can apply the attribute on the whole method or on any of its additional parameters. The macro expression - /// is defined in the property. When applied on a method, the target - /// template parameter is defined in the property. To apply the macro silently - /// for the parameter, set the property value = -1. - /// - /// - /// Applying the attribute on a source template method: - /// - /// [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")] - /// public static void forEach<T>(this IEnumerable<T> collection) { - /// foreach (var item in collection) { - /// //$ $END$ - /// } - /// } - /// - /// Applying the attribute on a template method parameter: - /// - /// [SourceTemplate] - /// public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) { - /// /*$ var $x$Id = "$newguid$" + x.ToString(); - /// x.DoSomething($x$Id); */ - /// } - /// - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method, AllowMultiple = true)] - internal sealed class MacroAttribute : Attribute - { - /// - /// Allows specifying a macro that will be executed for a source template - /// parameter when the template is expanded. - /// - public string Expression { get; set; } - - /// - /// Allows specifying which occurrence of the target parameter becomes editable when the template is deployed. - /// - /// - /// If the target parameter is used several times in the template, only one occurrence becomes editable; - /// other occurrences are changed synchronously. To specify the zero-based index of the editable occurrence, - /// use values >= 0. To make the parameter non-editable when the template is expanded, use -1. - /// > - public int Editable { get; set; } - - /// - /// Identifies the target parameter of a source template if the - /// is applied on a template method. - /// - public string Target { get; set; } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - internal sealed class AspMvcAreaMasterLocationFormatAttribute : Attribute - { - public AspMvcAreaMasterLocationFormatAttribute(string format) - { - Format = format; - } - - public string Format { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - internal sealed class AspMvcAreaPartialViewLocationFormatAttribute : Attribute - { - public AspMvcAreaPartialViewLocationFormatAttribute(string format) - { - Format = format; - } - - public string Format { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - internal sealed class AspMvcAreaViewLocationFormatAttribute : Attribute - { - public AspMvcAreaViewLocationFormatAttribute(string format) - { - Format = format; - } - - public string Format { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - internal sealed class AspMvcMasterLocationFormatAttribute : Attribute - { - public AspMvcMasterLocationFormatAttribute(string format) - { - Format = format; - } - - public string Format { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - internal sealed class AspMvcPartialViewLocationFormatAttribute : Attribute - { - public AspMvcPartialViewLocationFormatAttribute(string format) - { - Format = format; - } - - public string Format { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - internal sealed class AspMvcViewLocationFormatAttribute : Attribute - { - public AspMvcViewLocationFormatAttribute(string format) - { - Format = format; - } - - public string Format { get; private set; } - } - - /// - /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter - /// is an MVC action. If applied to a method, the MVC action name is calculated - /// implicitly from the context. Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String). - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] - internal sealed class AspMvcActionAttribute : Attribute - { - public AspMvcActionAttribute() { } - public AspMvcActionAttribute(string anonymousProperty) - { - AnonymousProperty = anonymousProperty; - } - - public string AnonymousProperty { get; private set; } - } - - /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC area. - /// Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String). - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class AspMvcAreaAttribute : Attribute - { - public AspMvcAreaAttribute() { } - public AspMvcAreaAttribute(string anonymousProperty) - { - AnonymousProperty = anonymousProperty; - } - - public string AnonymousProperty { get; private set; } - } - - /// - /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is - /// an MVC controller. If applied to a method, the MVC controller name is calculated - /// implicitly from the context. Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String, String). - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] - internal sealed class AspMvcControllerAttribute : Attribute - { - public AspMvcControllerAttribute() { } - public AspMvcControllerAttribute(string anonymousProperty) - { - AnonymousProperty = anonymousProperty; - } - - public string AnonymousProperty { get; private set; } - } - - /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC Master. Use this attribute - /// for custom wrappers similar to System.Web.Mvc.Controller.View(String, String). - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class AspMvcMasterAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC model type. Use this attribute - /// for custom wrappers similar to System.Web.Mvc.Controller.View(String, Object). - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class AspMvcModelTypeAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is an MVC - /// partial view. If applied to a method, the MVC partial view name is calculated implicitly - /// from the context. Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper, String). - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] - internal sealed class AspMvcPartialViewAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. Allows disabling inspections for MVC views within a class or a method. - /// - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] - internal sealed class AspMvcSupressViewErrorAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC display template. - /// Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.DisplayExtensions.DisplayForModel(HtmlHelper, String). - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class AspMvcDisplayTemplateAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC editor template. - /// Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.EditorExtensions.EditorForModel(HtmlHelper, String). - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class AspMvcEditorTemplateAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC template. - /// Use this attribute for custom wrappers similar to - /// System.ComponentModel.DataAnnotations.UIHintAttribute(System.String). - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class AspMvcTemplateAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter - /// is an MVC view. If applied to a method, the MVC view name is calculated implicitly - /// from the context. Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Controller.View(Object). - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] - internal sealed class AspMvcViewAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. When applied to a parameter of an attribute, - /// indicates that this parameter is an MVC action name. - /// - /// - /// [ActionName("Foo")] - /// public ActionResult Login(string returnUrl) { - /// ViewBag.ReturnUrl = Url.Action("Foo"); // OK - /// return RedirectToAction("Bar"); // Error: Cannot resolve action - /// } - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property)] - internal sealed class AspMvcActionSelectorAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field)] - internal sealed class HtmlElementAttributesAttribute : Attribute - { - public HtmlElementAttributesAttribute() { } - public HtmlElementAttributesAttribute(string name) - { - Name = name; - } - - public string Name { get; private set; } - } - - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)] - internal sealed class HtmlAttributeValueAttribute : Attribute - { - public HtmlAttributeValueAttribute([NotNull] string name) - { - Name = name; - } - - [NotNull] - public string Name { get; private set; } - } - - /// - /// Razor attribute. Indicates that a parameter or a method is a Razor section. - /// Use this attribute for custom wrappers similar to - /// System.Web.WebPages.WebPageBase.RenderSection(String). - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] - internal sealed class RazorSectionAttribute : Attribute { } - - /// - /// Indicates how method, constructor invocation or property access - /// over collection type affects content of the collection. - /// - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Property)] - internal sealed class CollectionAccessAttribute : Attribute - { - public CollectionAccessAttribute(CollectionAccessType collectionAccessType) - { - CollectionAccessType = collectionAccessType; - } - - public CollectionAccessType CollectionAccessType { get; private set; } - } - - [Flags] - internal enum CollectionAccessType - { - /// Method does not use or modify content of the collection. - None = 0, - /// Method only reads content of the collection but does not modify it. - Read = 1, - /// Method can change content of the collection but does not add new elements. - ModifyExistingContent = 2, - /// Method can add new elements to the collection. - UpdatedContent = ModifyExistingContent | 4 - } - - /// - /// Indicates that the marked method is assertion method, i.e. it halts control flow if - /// one of the conditions is satisfied. To set the condition, mark one of the parameters with - /// attribute. - /// - [AttributeUsage(AttributeTargets.Method)] - internal sealed class AssertionMethodAttribute : Attribute { } - - /// - /// Indicates the condition parameter of the assertion method. The method itself should be - /// marked by attribute. The mandatory argument of - /// the attribute is the assertion type. - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class AssertionConditionAttribute : Attribute - { - public AssertionConditionAttribute(AssertionConditionType conditionType) - { - ConditionType = conditionType; - } - - public AssertionConditionType ConditionType { get; private set; } - } - - /// - /// Specifies assertion type. If the assertion method argument satisfies the condition, - /// then the execution continues. Otherwise, execution is assumed to be halted. - /// - internal enum AssertionConditionType - { - /// Marked parameter should be evaluated to true. - IS_TRUE = 0, - /// Marked parameter should be evaluated to false. - IS_FALSE = 1, - /// Marked parameter should be evaluated to null value. - IS_NULL = 2, - /// Marked parameter should be evaluated to not null value. - IS_NOT_NULL = 3, - } - - /// - /// Indicates that the marked method unconditionally terminates control flow execution. - /// For example, it could unconditionally throw exception. - /// - [Obsolete("Use [ContractAnnotation('=> halt')] instead")] - [AttributeUsage(AttributeTargets.Method)] - internal sealed class TerminatesProgramAttribute : Attribute { } - - /// - /// Indicates that method is pure LINQ method, with postponed enumeration (like Enumerable.Select, - /// .Where). This annotation allows inference of [InstantHandle] annotation for parameters - /// of delegate type by analyzing LINQ method chains. - /// - [AttributeUsage(AttributeTargets.Method)] - internal sealed class LinqTunnelAttribute : Attribute { } - - /// - /// Indicates that IEnumerable, passed as parameter, is not enumerated. - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class NoEnumerationAttribute : Attribute { } - - /// - /// Indicates that parameter is regular expression pattern. - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class RegexPatternAttribute : Attribute { } - - /// - /// XAML attribute. Indicates the type that has ItemsSource property and should be treated - /// as ItemsControl-derived type, to enable inner items DataContext type resolve. - /// - [AttributeUsage(AttributeTargets.Class)] - internal sealed class XamlItemsControlAttribute : Attribute { } - - /// - /// XAML attibute. Indicates the property of some BindingBase-derived type, that - /// is used to bind some item of ItemsControl-derived type. This annotation will - /// enable the DataContext type resolve for XAML bindings for such properties. - /// - /// - /// Property should have the tree ancestor of the ItemsControl type or - /// marked with the attribute. - /// - [AttributeUsage(AttributeTargets.Property)] - internal sealed class XamlItemBindingOfItemsControlAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] - internal sealed class AspChildControlTypeAttribute : Attribute - { - public AspChildControlTypeAttribute(string tagName, Type controlType) - { - TagName = tagName; - ControlType = controlType; - } - - public string TagName { get; private set; } - public Type ControlType { get; private set; } - } - - [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)] - internal sealed class AspDataFieldAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)] - internal sealed class AspDataFieldsAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Property)] - internal sealed class AspMethodPropertyAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] - internal sealed class AspRequiredAttributeAttribute : Attribute - { - public AspRequiredAttributeAttribute([NotNull] string attribute) - { - Attribute = attribute; - } - - public string Attribute { get; private set; } - } - - [AttributeUsage(AttributeTargets.Property)] - internal sealed class AspTypePropertyAttribute : Attribute - { - public bool CreateConstructorReferences { get; private set; } - - public AspTypePropertyAttribute(bool createConstructorReferences) - { - CreateConstructorReferences = createConstructorReferences; - } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - internal sealed class RazorImportNamespaceAttribute : Attribute - { - public RazorImportNamespaceAttribute(string name) - { - Name = name; - } - - public string Name { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - internal sealed class RazorInjectionAttribute : Attribute - { - public RazorInjectionAttribute(string type, string fieldName) - { - Type = type; - FieldName = fieldName; - } - - public string Type { get; private set; } - public string FieldName { get; private set; } - } - - [AttributeUsage(AttributeTargets.Method)] - internal sealed class RazorHelperCommonAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Property)] - internal sealed class RazorLayoutAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Method)] - internal sealed class RazorWriteLiteralMethodAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Method)] - internal sealed class RazorWriteMethodAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class RazorWriteMethodParameterAttribute : Attribute { } - - /// - /// Prevents the Member Reordering feature from tossing members of the marked class. - /// - /// - /// The attribute must be mentioned in your member reordering patterns - /// - [AttributeUsage(AttributeTargets.All)] - internal sealed class NoReorder : Attribute { } -} \ No newline at end of file diff --git a/src/GitTools.Core/GitTools.Core.NET40/packages.config b/src/GitTools.Core/GitTools.Core.NET40/packages.config deleted file mode 100644 index 3cb2b8b..0000000 --- a/src/GitTools.Core/GitTools.Core.NET40/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/GitTools.Core/GitTools.Core.NET45/App_Packages/LibLog.4.2/LibLog.cs b/src/GitTools.Core/GitTools.Core.NET45/App_Packages/LibLog.4.2/LibLog.cs deleted file mode 100644 index 4cee6a3..0000000 --- a/src/GitTools.Core/GitTools.Core.NET45/App_Packages/LibLog.4.2/LibLog.cs +++ /dev/null @@ -1,2263 +0,0 @@ -//=============================================================================== -// LibLog -// -// https://github.com/damianh/LibLog -//=============================================================================== -// Copyright © 2011-2015 Damian Hickey. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -//=============================================================================== - -// ReSharper disable PossibleNullReferenceException - -// Define LIBLOG_PORTABLE conditional compilation symbol for PCL compatibility -// -// Define LIBLOG_PUBLIC to enable ability to GET a logger (LogProvider.For<>() etc) from outside this library. NOTE: -// this can have unintended consequences of consumers of your library using your library to resolve a logger. If the -// reason is because you want to open this functionality to other projects within your solution, -// consider [InternalsVisibleTo] instead. -// -// Define LIBLOG_PROVIDERS_ONLY if your library provides its own logging API and you just want to use the -// LibLog providers internally to provide built in support for popular logging frameworks. - -#pragma warning disable 1591 - -using System.Diagnostics.CodeAnalysis; - -[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "GitTools.Logging")] -[assembly: SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Scope = "member", Target = "GitTools.Logging.Logger.#Invoke(GitTools.Logging.LogLevel,System.Func`1,System.Exception,System.Object[])")] - -// If you copied this file manually, you need to change all "YourRootNameSpace" so not to clash with other libraries -// that use LibLog -#if LIBLOG_PROVIDERS_ONLY -namespace GitTools.LibLog -#else -namespace GitTools.Logging -#endif -{ - using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; -#if LIBLOG_PROVIDERS_ONLY - using GitTools.LibLog.LogProviders; -#else - using GitTools.Logging.LogProviders; -#endif - using System; -#if !LIBLOG_PROVIDERS_ONLY - using System.Diagnostics; -#if !LIBLOG_PORTABLE - using System.Runtime.CompilerServices; -#endif -#endif - -#if LIBLOG_PROVIDERS_ONLY - internal -#else - public -#endif - delegate bool Logger(LogLevel logLevel, Func messageFunc, Exception exception = null, params object[] formatParameters); - -#if !LIBLOG_PROVIDERS_ONLY - /// - /// Simple interface that represent a logger. - /// -#if LIBLOG_PUBLIC - public -#else - internal -#endif - interface ILog - { - /// - /// Log a message the specified log level. - /// - /// The log level. - /// The message function. - /// An optional exception. - /// Optional format parameters for the message generated by the messagefunc. - /// true if the message was logged. Otherwise false. - /// - /// Note to implementers: the message func should not be called if the loglevel is not enabled - /// so as not to incur performance penalties. - /// - /// To check IsEnabled call Log with only LogLevel and check the return value, no event will be written. - /// - bool Log(LogLevel logLevel, Func messageFunc, Exception exception = null, params object[] formatParameters ); - } -#endif - - /// - /// The log level. - /// -#if LIBLOG_PROVIDERS_ONLY - internal -#else - public -#endif - enum LogLevel - { - Trace, - Debug, - Info, - Warn, - Error, - Fatal - } - -#if !LIBLOG_PROVIDERS_ONLY -#if LIBLOG_PUBLIC - public -#else - internal -#endif - static partial class LogExtensions - { - public static bool IsDebugEnabled(this ILog logger) - { - GuardAgainstNullLogger(logger); - return logger.Log(LogLevel.Debug, null); - } - - public static bool IsErrorEnabled(this ILog logger) - { - GuardAgainstNullLogger(logger); - return logger.Log(LogLevel.Error, null); - } - - public static bool IsFatalEnabled(this ILog logger) - { - GuardAgainstNullLogger(logger); - return logger.Log(LogLevel.Fatal, null); - } - - public static bool IsInfoEnabled(this ILog logger) - { - GuardAgainstNullLogger(logger); - return logger.Log(LogLevel.Info, null); - } - - public static bool IsTraceEnabled(this ILog logger) - { - GuardAgainstNullLogger(logger); - return logger.Log(LogLevel.Trace, null); - } - - public static bool IsWarnEnabled(this ILog logger) - { - GuardAgainstNullLogger(logger); - return logger.Log(LogLevel.Warn, null); - } - - public static void Debug(this ILog logger, Func messageFunc) - { - GuardAgainstNullLogger(logger); - logger.Log(LogLevel.Debug, messageFunc); - } - - public static void Debug(this ILog logger, string message) - { - if (logger.IsDebugEnabled()) - { - logger.Log(LogLevel.Debug, message.AsFunc()); - } - } - - public static void DebugFormat(this ILog logger, string message, params object[] args) - { - if (logger.IsDebugEnabled()) - { - logger.LogFormat(LogLevel.Debug, message, args); - } - } - - public static void DebugException(this ILog logger, string message, Exception exception) - { - if (logger.IsDebugEnabled()) - { - logger.Log(LogLevel.Debug, message.AsFunc(), exception); - } - } - - public static void DebugException(this ILog logger, string message, Exception exception, params object[] formatParams) - { - if (logger.IsDebugEnabled()) - { - logger.Log(LogLevel.Debug, message.AsFunc(), exception, formatParams); - } - } - - public static void Error(this ILog logger, Func messageFunc) - { - GuardAgainstNullLogger(logger); - logger.Log(LogLevel.Error, messageFunc); - } - - public static void Error(this ILog logger, string message) - { - if (logger.IsErrorEnabled()) - { - logger.Log(LogLevel.Error, message.AsFunc()); - } - } - - public static void ErrorFormat(this ILog logger, string message, params object[] args) - { - if (logger.IsErrorEnabled()) - { - logger.LogFormat(LogLevel.Error, message, args); - } - } - - public static void ErrorException(this ILog logger, string message, Exception exception, params object[] formatParams) - { - if (logger.IsErrorEnabled()) - { - logger.Log(LogLevel.Error, message.AsFunc(), exception, formatParams); - } - } - - public static void Fatal(this ILog logger, Func messageFunc) - { - logger.Log(LogLevel.Fatal, messageFunc); - } - - public static void Fatal(this ILog logger, string message) - { - if (logger.IsFatalEnabled()) - { - logger.Log(LogLevel.Fatal, message.AsFunc()); - } - } - - public static void FatalFormat(this ILog logger, string message, params object[] args) - { - if (logger.IsFatalEnabled()) - { - logger.LogFormat(LogLevel.Fatal, message, args); - } - } - - public static void FatalException(this ILog logger, string message, Exception exception, params object[] formatParams) - { - if (logger.IsFatalEnabled()) - { - logger.Log(LogLevel.Fatal, message.AsFunc(), exception, formatParams); - } - } - - public static void Info(this ILog logger, Func messageFunc) - { - GuardAgainstNullLogger(logger); - logger.Log(LogLevel.Info, messageFunc); - } - - public static void Info(this ILog logger, string message) - { - if (logger.IsInfoEnabled()) - { - logger.Log(LogLevel.Info, message.AsFunc()); - } - } - - public static void InfoFormat(this ILog logger, string message, params object[] args) - { - if (logger.IsInfoEnabled()) - { - logger.LogFormat(LogLevel.Info, message, args); - } - } - - public static void InfoException(this ILog logger, string message, Exception exception, params object[] formatParams) - { - if (logger.IsInfoEnabled()) - { - logger.Log(LogLevel.Info, message.AsFunc(), exception, formatParams); - } - } - - public static void Trace(this ILog logger, Func messageFunc) - { - GuardAgainstNullLogger(logger); - logger.Log(LogLevel.Trace, messageFunc); - } - - public static void Trace(this ILog logger, string message) - { - if (logger.IsTraceEnabled()) - { - logger.Log(LogLevel.Trace, message.AsFunc()); - } - } - - public static void TraceFormat(this ILog logger, string message, params object[] args) - { - if (logger.IsTraceEnabled()) - { - logger.LogFormat(LogLevel.Trace, message, args); - } - } - - public static void TraceException(this ILog logger, string message, Exception exception, params object[] formatParams) - { - if (logger.IsTraceEnabled()) - { - logger.Log(LogLevel.Trace, message.AsFunc(), exception, formatParams); - } - } - - public static void Warn(this ILog logger, Func messageFunc) - { - GuardAgainstNullLogger(logger); - logger.Log(LogLevel.Warn, messageFunc); - } - - public static void Warn(this ILog logger, string message) - { - if (logger.IsWarnEnabled()) - { - logger.Log(LogLevel.Warn, message.AsFunc()); - } - } - - public static void WarnFormat(this ILog logger, string message, params object[] args) - { - if (logger.IsWarnEnabled()) - { - logger.LogFormat(LogLevel.Warn, message, args); - } - } - - public static void WarnException(this ILog logger, string message, Exception exception, params object[] formatParams) - { - if (logger.IsWarnEnabled()) - { - logger.Log(LogLevel.Warn, message.AsFunc(), exception, formatParams); - } - } - - // ReSharper disable once UnusedParameter.Local - private static void GuardAgainstNullLogger(ILog logger) - { - if (logger == null) - { - throw new ArgumentNullException("logger"); - } - } - - private static void LogFormat(this ILog logger, LogLevel logLevel, string message, params object[] args) - { - logger.Log(logLevel, message.AsFunc(), null, args); - } - - // Avoid the closure allocation, see https://gist.github.com/AArnott/d285feef75c18f6ecd2b - private static Func AsFunc(this T value) where T : class - { - return value.Return; - } - - private static T Return(this T value) - { - return value; - } - } -#endif - - /// - /// Represents a way to get a - /// -#if LIBLOG_PROVIDERS_ONLY - internal -#else - public -#endif - interface ILogProvider - { - /// - /// Gets the specified named logger. - /// - /// Name of the logger. - /// The logger reference. - Logger GetLogger(string name); - - /// - /// Opens a nested diagnostics context. Not supported in EntLib logging. - /// - /// The message to add to the diagnostics context. - /// A disposable that when disposed removes the message from the context. - IDisposable OpenNestedContext(string message); - - /// - /// Opens a mapped diagnostics context. Not supported in EntLib logging. - /// - /// A key. - /// A value. - /// A disposable that when disposed removes the map from the context. - IDisposable OpenMappedContext(string key, string value); - } - - /// - /// Provides a mechanism to create instances of objects. - /// -#if LIBLOG_PROVIDERS_ONLY - internal -#else - public -#endif - static class LogProvider - { -#if !LIBLOG_PROVIDERS_ONLY - private const string NullLogProvider = "Current Log Provider is not set. Call SetCurrentLogProvider " + - "with a non-null value first."; - private static dynamic s_currentLogProvider; - private static Action s_onCurrentLogProviderSet; - - [SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline")] - static LogProvider() - { - IsDisabled = false; - } - - /// - /// Sets the current log provider. - /// - /// The log provider. - public static void SetCurrentLogProvider(ILogProvider logProvider) - { - s_currentLogProvider = logProvider; - - RaiseOnCurrentLogProviderSet(); - } - - /// - /// Gets or sets a value indicating whether this is logging is disabled. - /// - /// - /// true if logging is disabled; otherwise, false. - /// - public static bool IsDisabled { get; set; } - - /// - /// Sets an action that is invoked when a consumer of your library has called SetCurrentLogProvider. It is - /// important that hook into this if you are using child libraries (especially ilmerged ones) that are using - /// LibLog (or other logging abstraction) so you adapt and delegate to them. - /// - /// - internal static Action OnCurrentLogProviderSet - { - set - { - s_onCurrentLogProviderSet = value; - RaiseOnCurrentLogProviderSet(); - } - } - - internal static ILogProvider CurrentLogProvider - { - get - { - return s_currentLogProvider; - } - } - - /// - /// Gets a logger for the specified type. - /// - /// The type whose name will be used for the logger. - /// An instance of -#if LIBLOG_PUBLIC - public -#else - internal -#endif - static ILog For() - { - return GetLogger(typeof(T)); - } - -#if !LIBLOG_PORTABLE - /// - /// Gets a logger for the current class. - /// - /// An instance of - [MethodImpl(MethodImplOptions.NoInlining)] -#if LIBLOG_PUBLIC - public -#else - internal -#endif - static ILog GetCurrentClassLogger() - { - var stackFrame = new StackFrame(1, false); - return GetLogger(stackFrame.GetMethod().DeclaringType); - } -#endif - - /// - /// Gets a logger for the specified type. - /// - /// The type whose name will be used for the logger. - /// If the type is null then this name will be used as the log name instead - /// An instance of -#if LIBLOG_PUBLIC - public -#else - internal -#endif - static ILog GetLogger(Type type, string fallbackTypeName = "System.Object") - { - // If the type passed in is null then fallback to the type name specified - return GetLogger(type != null ? type.FullName : fallbackTypeName); - } - - /// - /// Gets a logger with the specified name. - /// - /// The name. - /// An instance of -#if LIBLOG_PUBLIC - public -#else - internal -#endif - static ILog GetLogger(string name) - { - ILogProvider logProvider = CurrentLogProvider ?? ResolveLogProvider(); - return logProvider == null - ? NoOpLogger.Instance - : (ILog)new LoggerExecutionWrapper(logProvider.GetLogger(name), () => IsDisabled); - } - - /// - /// Opens a nested diagnostics context. - /// - /// A message. - /// An that closes context when disposed. - [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "SetCurrentLogProvider")] -#if LIBLOG_PUBLIC - public -#else - internal -#endif - static IDisposable OpenNestedContext(string message) - { - ILogProvider logProvider = CurrentLogProvider ?? ResolveLogProvider(); - - return logProvider == null - ? new DisposableAction(() => { }) - : logProvider.OpenNestedContext(message); - } - - /// - /// Opens a mapped diagnostics context. - /// - /// A key. - /// A value. - /// An that closes context when disposed. - [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "SetCurrentLogProvider")] -#if LIBLOG_PUBLIC - public -#else - internal -#endif - static IDisposable OpenMappedContext(string key, string value) - { - ILogProvider logProvider = CurrentLogProvider ?? ResolveLogProvider(); - - return logProvider == null - ? new DisposableAction(() => { }) - : logProvider.OpenMappedContext(key, value); - } -#endif - -#if LIBLOG_PROVIDERS_ONLY - private -#else - internal -#endif - delegate bool IsLoggerAvailable(); - -#if LIBLOG_PROVIDERS_ONLY - private -#else - internal -#endif - delegate ILogProvider CreateLogProvider(); - -#if LIBLOG_PROVIDERS_ONLY - private -#else - internal -#endif - static readonly List> LogProviderResolvers = - new List> - { - new Tuple(SerilogLogProvider.IsLoggerAvailable, () => new SerilogLogProvider()), - new Tuple(NLogLogProvider.IsLoggerAvailable, () => new NLogLogProvider()), - new Tuple(Log4NetLogProvider.IsLoggerAvailable, () => new Log4NetLogProvider()), - new Tuple(EntLibLogProvider.IsLoggerAvailable, () => new EntLibLogProvider()), - new Tuple(LoupeLogProvider.IsLoggerAvailable, () => new LoupeLogProvider()), - }; - -#if !LIBLOG_PROVIDERS_ONLY - private static void RaiseOnCurrentLogProviderSet() - { - if (s_onCurrentLogProviderSet != null) - { - s_onCurrentLogProviderSet(s_currentLogProvider); - } - } -#endif - - [SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "System.Console.WriteLine(System.String,System.Object,System.Object)")] - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - internal static ILogProvider ResolveLogProvider() - { - try - { - foreach (var providerResolver in LogProviderResolvers) - { - if (providerResolver.Item1()) - { - return providerResolver.Item2(); - } - } - } - catch (Exception ex) - { -#if LIBLOG_PORTABLE - Debug.WriteLine( -#else - Console.WriteLine( -#endif - "Exception occurred resolving a log provider. Logging for this assembly {0} is disabled. {1}", - typeof(LogProvider).GetAssemblyPortable().FullName, - ex); - } - return null; - } - -#if !LIBLOG_PROVIDERS_ONLY - internal class NoOpLogger : ILog - { - internal static readonly NoOpLogger Instance = new NoOpLogger(); - - public bool Log(LogLevel logLevel, Func messageFunc, Exception exception, params object[] formatParameters) - { - return false; - } - } -#endif - } - -#if !LIBLOG_PROVIDERS_ONLY - internal class LoggerExecutionWrapper : ILog - { - private readonly Logger _logger; - private readonly Func _getIsDisabled; - internal const string FailedToGenerateLogMessage = "Failed to generate log message"; - - internal LoggerExecutionWrapper(Logger logger, Func getIsDisabled = null) - { - _logger = logger; - _getIsDisabled = getIsDisabled ?? (() => false); - } - - internal Logger WrappedLogger - { - get { return _logger; } - } - - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - public bool Log(LogLevel logLevel, Func messageFunc, Exception exception = null, params object[] formatParameters) - { - if (_getIsDisabled()) - { - return false; - } - if (messageFunc == null) - { - return _logger(logLevel, null); - } - - Func wrappedMessageFunc = () => - { - try - { - return messageFunc(); - } - catch (Exception ex) - { - Log(LogLevel.Error, () => FailedToGenerateLogMessage, ex); - } - return null; - }; - return _logger(logLevel, wrappedMessageFunc, exception, formatParameters); - } - } -#endif -} - -#if LIBLOG_PROVIDERS_ONLY -namespace GitTools.LibLog.LogProviders -#else -namespace GitTools.Logging.LogProviders -#endif -{ - using System; - using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; -#if !LIBLOG_PORTABLE - using System.Diagnostics; -#endif - using System.Globalization; - using System.Linq; - using System.Linq.Expressions; - using System.Reflection; -#if !LIBLOG_PORTABLE - using System.Text; -#endif - using System.Text.RegularExpressions; - - internal abstract class LogProviderBase : ILogProvider - { - protected delegate IDisposable OpenNdc(string message); - protected delegate IDisposable OpenMdc(string key, string value); - - private readonly Lazy _lazyOpenNdcMethod; - private readonly Lazy _lazyOpenMdcMethod; - private static readonly IDisposable NoopDisposableInstance = new DisposableAction(); - - protected LogProviderBase() - { - _lazyOpenNdcMethod - = new Lazy(GetOpenNdcMethod); - _lazyOpenMdcMethod - = new Lazy(GetOpenMdcMethod); - } - - public abstract Logger GetLogger(string name); - - public IDisposable OpenNestedContext(string message) - { - return _lazyOpenNdcMethod.Value(message); - } - - public IDisposable OpenMappedContext(string key, string value) - { - return _lazyOpenMdcMethod.Value(key, value); - } - - protected virtual OpenNdc GetOpenNdcMethod() - { - return _ => NoopDisposableInstance; - } - - protected virtual OpenMdc GetOpenMdcMethod() - { - return (_, __) => NoopDisposableInstance; - } - } - - internal class NLogLogProvider : LogProviderBase - { - private readonly Func _getLoggerByNameDelegate; - private static bool s_providerIsAvailableOverride = true; - - [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "LogManager")] - [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "NLog")] - public NLogLogProvider() - { - if (!IsLoggerAvailable()) - { - throw new InvalidOperationException("NLog.LogManager not found"); - } - _getLoggerByNameDelegate = GetGetLoggerMethodCall(); - } - - public static bool ProviderIsAvailableOverride - { - get { return s_providerIsAvailableOverride; } - set { s_providerIsAvailableOverride = value; } - } - - public override Logger GetLogger(string name) - { - return new NLogLogger(_getLoggerByNameDelegate(name)).Log; - } - - public static bool IsLoggerAvailable() - { - return ProviderIsAvailableOverride && GetLogManagerType() != null; - } - - protected override OpenNdc GetOpenNdcMethod() - { - Type ndcContextType = Type.GetType("NLog.NestedDiagnosticsContext, NLog"); - MethodInfo pushMethod = ndcContextType.GetMethodPortable("Push", typeof(string)); - ParameterExpression messageParam = Expression.Parameter(typeof(string), "message"); - MethodCallExpression pushMethodCall = Expression.Call(null, pushMethod, messageParam); - return Expression.Lambda(pushMethodCall, messageParam).Compile(); - } - - protected override OpenMdc GetOpenMdcMethod() - { - Type mdcContextType = Type.GetType("NLog.MappedDiagnosticsContext, NLog"); - - MethodInfo setMethod = mdcContextType.GetMethodPortable("Set", typeof(string), typeof(string)); - MethodInfo removeMethod = mdcContextType.GetMethodPortable("Remove", typeof(string)); - ParameterExpression keyParam = Expression.Parameter(typeof(string), "key"); - ParameterExpression valueParam = Expression.Parameter(typeof(string), "value"); - - MethodCallExpression setMethodCall = Expression.Call(null, setMethod, keyParam, valueParam); - MethodCallExpression removeMethodCall = Expression.Call(null, removeMethod, keyParam); - - Action set = Expression - .Lambda>(setMethodCall, keyParam, valueParam) - .Compile(); - Action remove = Expression - .Lambda>(removeMethodCall, keyParam) - .Compile(); - - return (key, value) => - { - set(key, value); - return new DisposableAction(() => remove(key)); - }; - } - - private static Type GetLogManagerType() - { - return Type.GetType("NLog.LogManager, NLog"); - } - - private static Func GetGetLoggerMethodCall() - { - Type logManagerType = GetLogManagerType(); - MethodInfo method = logManagerType.GetMethodPortable("GetLogger", typeof(string)); - ParameterExpression nameParam = Expression.Parameter(typeof(string), "name"); - MethodCallExpression methodCall = Expression.Call(null, method, nameParam); - return Expression.Lambda>(methodCall, nameParam).Compile(); - } - - internal class NLogLogger - { - private readonly dynamic _logger; - - private static Func _logEventInfoFact; - - private static readonly object _levelTrace; - private static readonly object _levelDebug; - private static readonly object _levelInfo; - private static readonly object _levelWarn; - private static readonly object _levelError; - private static readonly object _levelFatal; - - static NLogLogger() - { - try - { - var logEventLevelType = Type.GetType("NLog.LogLevel, NLog"); - if (logEventLevelType == null) - { - throw new InvalidOperationException("Type NLog.LogLevel was not found."); - } - - var levelFields = logEventLevelType.GetFieldsPortable().ToList(); - _levelTrace = levelFields.First(x => x.Name == "Trace").GetValue(null); - _levelDebug = levelFields.First(x => x.Name == "Debug").GetValue(null); - _levelInfo = levelFields.First(x => x.Name == "Info").GetValue(null); - _levelWarn = levelFields.First(x => x.Name == "Warn").GetValue(null); - _levelError = levelFields.First(x => x.Name == "Error").GetValue(null); - _levelFatal = levelFields.First(x => x.Name == "Fatal").GetValue(null); - - var logEventInfoType = Type.GetType("NLog.LogEventInfo, NLog"); - if (logEventInfoType == null) - { - throw new InvalidOperationException("Type NLog.LogEventInfo was not found."); - } - MethodInfo createLogEventInfoMethodInfo = logEventInfoType.GetMethodPortable("Create", - logEventLevelType, typeof(string), typeof(Exception), typeof(IFormatProvider), typeof(string), typeof(object[])); - ParameterExpression loggerNameParam = Expression.Parameter(typeof(string)); - ParameterExpression levelParam = Expression.Parameter(typeof(object)); - ParameterExpression messageParam = Expression.Parameter(typeof(string)); - ParameterExpression exceptionParam = Expression.Parameter(typeof(Exception)); - UnaryExpression levelCast = Expression.Convert(levelParam, logEventLevelType); - MethodCallExpression createLogEventInfoMethodCall = Expression.Call(null, - createLogEventInfoMethodInfo, - levelCast, loggerNameParam, exceptionParam, - Expression.Constant(null, typeof(IFormatProvider)), messageParam, Expression.Constant(null, typeof(object[]))); - _logEventInfoFact = Expression.Lambda>(createLogEventInfoMethodCall, - loggerNameParam, levelParam, messageParam, exceptionParam).Compile(); - } - catch { } - } - - internal NLogLogger(dynamic logger) - { - _logger = logger; - } - - [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")] - public bool Log(LogLevel logLevel, Func messageFunc, Exception exception, params object[] formatParameters) - { - if (messageFunc == null) - { - return IsLogLevelEnable(logLevel); - } - messageFunc = LogMessageFormatter.SimulateStructuredLogging(messageFunc, formatParameters); - - if (_logEventInfoFact != null) - { - if (IsLogLevelEnable(logLevel)) - { - var nlogLevel = this.TranslateLevel(logLevel); - Type s_callerStackBoundaryType; -#if !LIBLOG_PORTABLE - StackTrace stack = new StackTrace(); - Type thisType = GetType(); - Type knownType0 = typeof(LoggerExecutionWrapper); - Type knownType1 = typeof(LogExtensions); - //Maybe inline, so we may can't found any LibLog classes in stack - s_callerStackBoundaryType = null; - for (var i = 0; i < stack.FrameCount; i++) - { - var declaringType = stack.GetFrame(i).GetMethod().DeclaringType; - if (!IsInTypeHierarchy(thisType, declaringType) && - !IsInTypeHierarchy(knownType0, declaringType) && - !IsInTypeHierarchy(knownType1, declaringType)) - { - if (i > 1) - s_callerStackBoundaryType = stack.GetFrame(i - 1).GetMethod().DeclaringType; - break; - } - } -#else - s_callerStackBoundaryType = null; -#endif - if (s_callerStackBoundaryType != null) - _logger.Log(s_callerStackBoundaryType, _logEventInfoFact(_logger.Name, nlogLevel, messageFunc(), exception)); - else - _logger.Log(_logEventInfoFact(_logger.Name, nlogLevel, messageFunc(), exception)); - return true; - } - return false; - } - - if(exception != null) - { - return LogException(logLevel, messageFunc, exception); - } - switch (logLevel) - { - case LogLevel.Debug: - if (_logger.IsDebugEnabled) - { - _logger.Debug(messageFunc()); - return true; - } - break; - case LogLevel.Info: - if (_logger.IsInfoEnabled) - { - _logger.Info(messageFunc()); - return true; - } - break; - case LogLevel.Warn: - if (_logger.IsWarnEnabled) - { - _logger.Warn(messageFunc()); - return true; - } - break; - case LogLevel.Error: - if (_logger.IsErrorEnabled) - { - _logger.Error(messageFunc()); - return true; - } - break; - case LogLevel.Fatal: - if (_logger.IsFatalEnabled) - { - _logger.Fatal(messageFunc()); - return true; - } - break; - default: - if (_logger.IsTraceEnabled) - { - _logger.Trace(messageFunc()); - return true; - } - break; - } - return false; - } - - private static bool IsInTypeHierarchy(Type currentType, Type checkType) - { - while (currentType != null && currentType != typeof(object)) - { - if (currentType == checkType) - { - return true; - } - currentType = currentType.GetBaseTypePortable(); - } - return false; - } - - [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")] - private bool LogException(LogLevel logLevel, Func messageFunc, Exception exception) - { - switch (logLevel) - { - case LogLevel.Debug: - if (_logger.IsDebugEnabled) - { - _logger.DebugException(messageFunc(), exception); - return true; - } - break; - case LogLevel.Info: - if (_logger.IsInfoEnabled) - { - _logger.InfoException(messageFunc(), exception); - return true; - } - break; - case LogLevel.Warn: - if (_logger.IsWarnEnabled) - { - _logger.WarnException(messageFunc(), exception); - return true; - } - break; - case LogLevel.Error: - if (_logger.IsErrorEnabled) - { - _logger.ErrorException(messageFunc(), exception); - return true; - } - break; - case LogLevel.Fatal: - if (_logger.IsFatalEnabled) - { - _logger.FatalException(messageFunc(), exception); - return true; - } - break; - default: - if (_logger.IsTraceEnabled) - { - _logger.TraceException(messageFunc(), exception); - return true; - } - break; - } - return false; - } - - private bool IsLogLevelEnable(LogLevel logLevel) - { - switch (logLevel) - { - case LogLevel.Debug: - return _logger.IsDebugEnabled; - case LogLevel.Info: - return _logger.IsInfoEnabled; - case LogLevel.Warn: - return _logger.IsWarnEnabled; - case LogLevel.Error: - return _logger.IsErrorEnabled; - case LogLevel.Fatal: - return _logger.IsFatalEnabled; - default: - return _logger.IsTraceEnabled; - } - } - - private object TranslateLevel(LogLevel logLevel) - { - switch (logLevel) - { - case LogLevel.Trace: - return _levelTrace; - case LogLevel.Debug: - return _levelDebug; - case LogLevel.Info: - return _levelInfo; - case LogLevel.Warn: - return _levelWarn; - case LogLevel.Error: - return _levelError; - case LogLevel.Fatal: - return _levelFatal; - default: - throw new ArgumentOutOfRangeException("logLevel", logLevel, null); - } - } - } - } - - internal class Log4NetLogProvider : LogProviderBase - { - private readonly Func _getLoggerByNameDelegate; - private static bool s_providerIsAvailableOverride = true; - - [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "LogManager")] - public Log4NetLogProvider() - { - if (!IsLoggerAvailable()) - { - throw new InvalidOperationException("log4net.LogManager not found"); - } - _getLoggerByNameDelegate = GetGetLoggerMethodCall(); - } - - public static bool ProviderIsAvailableOverride - { - get { return s_providerIsAvailableOverride; } - set { s_providerIsAvailableOverride = value; } - } - - public override Logger GetLogger(string name) - { - return new Log4NetLogger(_getLoggerByNameDelegate(name)).Log; - } - - internal static bool IsLoggerAvailable() - { - return ProviderIsAvailableOverride && GetLogManagerType() != null; - } - - protected override OpenNdc GetOpenNdcMethod() - { - Type logicalThreadContextType = Type.GetType("log4net.LogicalThreadContext, log4net"); - PropertyInfo stacksProperty = logicalThreadContextType.GetPropertyPortable("Stacks"); - Type logicalThreadContextStacksType = stacksProperty.PropertyType; - PropertyInfo stacksIndexerProperty = logicalThreadContextStacksType.GetPropertyPortable("Item"); - Type stackType = stacksIndexerProperty.PropertyType; - MethodInfo pushMethod = stackType.GetMethodPortable("Push"); - - ParameterExpression messageParameter = - Expression.Parameter(typeof(string), "message"); - - // message => LogicalThreadContext.Stacks.Item["NDC"].Push(message); - MethodCallExpression callPushBody = - Expression.Call( - Expression.Property(Expression.Property(null, stacksProperty), - stacksIndexerProperty, - Expression.Constant("NDC")), - pushMethod, - messageParameter); - - OpenNdc result = - Expression.Lambda(callPushBody, messageParameter) - .Compile(); - - return result; - } - - protected override OpenMdc GetOpenMdcMethod() - { - Type logicalThreadContextType = Type.GetType("log4net.LogicalThreadContext, log4net"); - PropertyInfo propertiesProperty = logicalThreadContextType.GetPropertyPortable("Properties"); - Type logicalThreadContextPropertiesType = propertiesProperty.PropertyType; - PropertyInfo propertiesIndexerProperty = logicalThreadContextPropertiesType.GetPropertyPortable("Item"); - - MethodInfo removeMethod = logicalThreadContextPropertiesType.GetMethodPortable("Remove"); - - ParameterExpression keyParam = Expression.Parameter(typeof(string), "key"); - ParameterExpression valueParam = Expression.Parameter(typeof(string), "value"); - - MemberExpression propertiesExpression = Expression.Property(null, propertiesProperty); - - // (key, value) => LogicalThreadContext.Properties.Item[key] = value; - BinaryExpression setProperties = Expression.Assign(Expression.Property(propertiesExpression, propertiesIndexerProperty, keyParam), valueParam); - - // key => LogicalThreadContext.Properties.Remove(key); - MethodCallExpression removeMethodCall = Expression.Call(propertiesExpression, removeMethod, keyParam); - - Action set = Expression - .Lambda>(setProperties, keyParam, valueParam) - .Compile(); - - Action remove = Expression - .Lambda>(removeMethodCall, keyParam) - .Compile(); - - return (key, value) => - { - set(key, value); - return new DisposableAction(() => remove(key)); - }; - } - - private static Type GetLogManagerType() - { - return Type.GetType("log4net.LogManager, log4net"); - } - - private static Func GetGetLoggerMethodCall() - { - Type logManagerType = GetLogManagerType(); - MethodInfo method = logManagerType.GetMethodPortable("GetLogger", typeof(string)); - ParameterExpression nameParam = Expression.Parameter(typeof(string), "name"); - MethodCallExpression methodCall = Expression.Call(null, method, nameParam); - return Expression.Lambda>(methodCall, nameParam).Compile(); - } - - internal class Log4NetLogger - { - private readonly dynamic _logger; - private static Type s_callerStackBoundaryType; - private static readonly object CallerStackBoundaryTypeSync = new object(); - - private readonly object _levelDebug; - private readonly object _levelInfo; - private readonly object _levelWarn; - private readonly object _levelError; - private readonly object _levelFatal; - private readonly Func _isEnabledForDelegate; - private readonly Action _logDelegate; - private readonly Func _createLoggingEvent; - private Action _loggingEventPropertySetter; - - [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "ILogger")] - internal Log4NetLogger(dynamic logger) - { - _logger = logger.Logger; - - var logEventLevelType = Type.GetType("log4net.Core.Level, log4net"); - if (logEventLevelType == null) - { - throw new InvalidOperationException("Type log4net.Core.Level was not found."); - } - - var levelFields = logEventLevelType.GetFieldsPortable().ToList(); - _levelDebug = levelFields.First(x => x.Name == "Debug").GetValue(null); - _levelInfo = levelFields.First(x => x.Name == "Info").GetValue(null); - _levelWarn = levelFields.First(x => x.Name == "Warn").GetValue(null); - _levelError = levelFields.First(x => x.Name == "Error").GetValue(null); - _levelFatal = levelFields.First(x => x.Name == "Fatal").GetValue(null); - - // Func isEnabledFor = (logger, level) => { return ((log4net.Core.ILogger)logger).IsEnabled(level); } - var loggerType = Type.GetType("log4net.Core.ILogger, log4net"); - if (loggerType == null) - { - throw new InvalidOperationException("Type log4net.Core.ILogger, was not found."); - } - ParameterExpression instanceParam = Expression.Parameter(typeof(object)); - UnaryExpression instanceCast = Expression.Convert(instanceParam, loggerType); - ParameterExpression levelParam = Expression.Parameter(typeof(object)); - UnaryExpression levelCast = Expression.Convert(levelParam, logEventLevelType); - _isEnabledForDelegate = GetIsEnabledFor(loggerType, logEventLevelType, instanceCast, levelCast, instanceParam, levelParam); - - Type loggingEventType = Type.GetType("log4net.Core.LoggingEvent, log4net"); - - _createLoggingEvent = GetCreateLoggingEvent(instanceParam, instanceCast, levelParam, levelCast, loggingEventType); - - _logDelegate = GetLogDelegate(loggerType, loggingEventType, instanceCast, instanceParam); - - _loggingEventPropertySetter = GetLoggingEventPropertySetter(loggingEventType); - } - - private static Action GetLogDelegate(Type loggerType, Type loggingEventType, UnaryExpression instanceCast, - ParameterExpression instanceParam) - { - //Action Log = - //(logger, callerStackBoundaryDeclaringType, level, message, exception) => { ((ILogger)logger).Log(new LoggingEvent(callerStackBoundaryDeclaringType, logger.Repository, logger.Name, level, message, exception)); } - MethodInfo writeExceptionMethodInfo = loggerType.GetMethodPortable("Log", - loggingEventType); - - ParameterExpression loggingEventParameter = - Expression.Parameter(typeof(object), "loggingEvent"); - - UnaryExpression loggingEventCasted = - Expression.Convert(loggingEventParameter, loggingEventType); - - var writeMethodExp = Expression.Call( - instanceCast, - writeExceptionMethodInfo, - loggingEventCasted); - - var logDelegate = Expression.Lambda>( - writeMethodExp, - instanceParam, - loggingEventParameter).Compile(); - - return logDelegate; - } - - private static Func GetCreateLoggingEvent(ParameterExpression instanceParam, UnaryExpression instanceCast, ParameterExpression levelParam, UnaryExpression levelCast, Type loggingEventType) - { - ParameterExpression callerStackBoundaryDeclaringTypeParam = Expression.Parameter(typeof(Type)); - ParameterExpression messageParam = Expression.Parameter(typeof(string)); - ParameterExpression exceptionParam = Expression.Parameter(typeof(Exception)); - - PropertyInfo repositoryProperty = loggingEventType.GetPropertyPortable("Repository"); - PropertyInfo levelProperty = loggingEventType.GetPropertyPortable("Level"); - - ConstructorInfo loggingEventConstructor = - loggingEventType.GetConstructorPortable(typeof(Type), repositoryProperty.PropertyType, typeof(string), levelProperty.PropertyType, typeof(object), typeof(Exception)); - - //Func Log = - //(logger, callerStackBoundaryDeclaringType, level, message, exception) => new LoggingEvent(callerStackBoundaryDeclaringType, ((ILogger)logger).Repository, ((ILogger)logger).Name, (Level)level, message, exception); } - NewExpression newLoggingEventExpression = - Expression.New(loggingEventConstructor, - callerStackBoundaryDeclaringTypeParam, - Expression.Property(instanceCast, "Repository"), - Expression.Property(instanceCast, "Name"), - levelCast, - messageParam, - exceptionParam); - - var createLoggingEvent = - Expression.Lambda>( - newLoggingEventExpression, - instanceParam, - callerStackBoundaryDeclaringTypeParam, - levelParam, - messageParam, - exceptionParam) - .Compile(); - - return createLoggingEvent; - } - - private static Func GetIsEnabledFor(Type loggerType, Type logEventLevelType, - UnaryExpression instanceCast, - UnaryExpression levelCast, - ParameterExpression instanceParam, - ParameterExpression levelParam) - { - MethodInfo isEnabledMethodInfo = loggerType.GetMethodPortable("IsEnabledFor", logEventLevelType); - MethodCallExpression isEnabledMethodCall = Expression.Call(instanceCast, isEnabledMethodInfo, levelCast); - - Func result = - Expression.Lambda>(isEnabledMethodCall, instanceParam, levelParam) - .Compile(); - - return result; - } - - private static Action GetLoggingEventPropertySetter(Type loggingEventType) - { - ParameterExpression loggingEventParameter = Expression.Parameter(typeof(object), "loggingEvent"); - ParameterExpression keyParameter = Expression.Parameter(typeof(string), "key"); - ParameterExpression valueParameter = Expression.Parameter(typeof(object), "value"); - - PropertyInfo propertiesProperty = loggingEventType.GetPropertyPortable("Properties"); - PropertyInfo item = propertiesProperty.PropertyType.GetPropertyPortable("Item"); - - // ((LoggingEvent)loggingEvent).Properties[key] = value; - var body = - Expression.Assign( - Expression.Property( - Expression.Property(Expression.Convert(loggingEventParameter, loggingEventType), - propertiesProperty), item, keyParameter), valueParameter); - - Action result = - Expression.Lambda> - (body, loggingEventParameter, keyParameter, - valueParameter) - .Compile(); - - return result; - } - - public bool Log(LogLevel logLevel, Func messageFunc, Exception exception, params object[] formatParameters) - { - if (messageFunc == null) - { - return IsLogLevelEnable(logLevel); - } - - if (!IsLogLevelEnable(logLevel)) - { - return false; - } - - string message = messageFunc(); - - IEnumerable patternMatches; - - string formattedMessage = - LogMessageFormatter.FormatStructuredMessage(message, - formatParameters, - out patternMatches); - - // determine correct caller - this might change due to jit optimizations with method inlining - if (s_callerStackBoundaryType == null) - { - lock (CallerStackBoundaryTypeSync) - { -#if !LIBLOG_PORTABLE - StackTrace stack = new StackTrace(); - Type thisType = GetType(); - s_callerStackBoundaryType = Type.GetType("LoggerExecutionWrapper"); - for (var i = 1; i < stack.FrameCount; i++) - { - if (!IsInTypeHierarchy(thisType, stack.GetFrame(i).GetMethod().DeclaringType)) - { - s_callerStackBoundaryType = stack.GetFrame(i - 1).GetMethod().DeclaringType; - break; - } - } -#else - s_callerStackBoundaryType = typeof (LoggerExecutionWrapper); -#endif - } - } - - var translatedLevel = TranslateLevel(logLevel); - - object loggingEvent = _createLoggingEvent(_logger, s_callerStackBoundaryType, translatedLevel, formattedMessage, exception); - - PopulateProperties(loggingEvent, patternMatches, formatParameters); - - _logDelegate(_logger, loggingEvent); - - return true; - } - - private void PopulateProperties(object loggingEvent, IEnumerable patternMatches, object[] formatParameters) - { - IEnumerable> keyToValue = - patternMatches.Zip(formatParameters, - (key, value) => new KeyValuePair(key, value)); - - foreach (KeyValuePair keyValuePair in keyToValue) - { - _loggingEventPropertySetter(loggingEvent, keyValuePair.Key, keyValuePair.Value); - } - } - - private static bool IsInTypeHierarchy(Type currentType, Type checkType) - { - while (currentType != null && currentType != typeof(object)) - { - if (currentType == checkType) - { - return true; - } - currentType = currentType.GetBaseTypePortable(); - } - return false; - } - - private bool IsLogLevelEnable(LogLevel logLevel) - { - var level = TranslateLevel(logLevel); - return _isEnabledForDelegate(_logger, level); - } - - private object TranslateLevel(LogLevel logLevel) - { - switch (logLevel) - { - case LogLevel.Trace: - case LogLevel.Debug: - return _levelDebug; - case LogLevel.Info: - return _levelInfo; - case LogLevel.Warn: - return _levelWarn; - case LogLevel.Error: - return _levelError; - case LogLevel.Fatal: - return _levelFatal; - default: - throw new ArgumentOutOfRangeException("logLevel", logLevel, null); - } - } - } - } - - internal class EntLibLogProvider : LogProviderBase - { - private const string TypeTemplate = "Microsoft.Practices.EnterpriseLibrary.Logging.{0}, Microsoft.Practices.EnterpriseLibrary.Logging"; - private static bool s_providerIsAvailableOverride = true; - private static readonly Type LogEntryType; - private static readonly Type LoggerType; - private static readonly Type TraceEventTypeType; - private static readonly Action WriteLogEntry; - private static readonly Func ShouldLogEntry; - - [SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline")] - static EntLibLogProvider() - { - LogEntryType = Type.GetType(string.Format(CultureInfo.InvariantCulture, TypeTemplate, "LogEntry")); - LoggerType = Type.GetType(string.Format(CultureInfo.InvariantCulture, TypeTemplate, "Logger")); - TraceEventTypeType = TraceEventTypeValues.Type; - if (LogEntryType == null - || TraceEventTypeType == null - || LoggerType == null) - { - return; - } - WriteLogEntry = GetWriteLogEntry(); - ShouldLogEntry = GetShouldLogEntry(); - } - - [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "EnterpriseLibrary")] - public EntLibLogProvider() - { - if (!IsLoggerAvailable()) - { - throw new InvalidOperationException("Microsoft.Practices.EnterpriseLibrary.Logging.Logger not found"); - } - } - - public static bool ProviderIsAvailableOverride - { - get { return s_providerIsAvailableOverride; } - set { s_providerIsAvailableOverride = value; } - } - - public override Logger GetLogger(string name) - { - return new EntLibLogger(name, WriteLogEntry, ShouldLogEntry).Log; - } - - internal static bool IsLoggerAvailable() - { - return ProviderIsAvailableOverride - && TraceEventTypeType != null - && LogEntryType != null; - } - - private static Action GetWriteLogEntry() - { - // new LogEntry(...) - var logNameParameter = Expression.Parameter(typeof(string), "logName"); - var messageParameter = Expression.Parameter(typeof(string), "message"); - var severityParameter = Expression.Parameter(typeof(int), "severity"); - - MemberInitExpression memberInit = GetWriteLogExpression( - messageParameter, - Expression.Convert(severityParameter, TraceEventTypeType), - logNameParameter); - - //Logger.Write(new LogEntry(....)); - MethodInfo writeLogEntryMethod = LoggerType.GetMethodPortable("Write", LogEntryType); - var writeLogEntryExpression = Expression.Call(writeLogEntryMethod, memberInit); - - return Expression.Lambda>( - writeLogEntryExpression, - logNameParameter, - messageParameter, - severityParameter).Compile(); - } - - private static Func GetShouldLogEntry() - { - // new LogEntry(...) - var logNameParameter = Expression.Parameter(typeof(string), "logName"); - var severityParameter = Expression.Parameter(typeof(int), "severity"); - - MemberInitExpression memberInit = GetWriteLogExpression( - Expression.Constant("***dummy***"), - Expression.Convert(severityParameter, TraceEventTypeType), - logNameParameter); - - //Logger.Write(new LogEntry(....)); - MethodInfo writeLogEntryMethod = LoggerType.GetMethodPortable("ShouldLog", LogEntryType); - var writeLogEntryExpression = Expression.Call(writeLogEntryMethod, memberInit); - - return Expression.Lambda>( - writeLogEntryExpression, - logNameParameter, - severityParameter).Compile(); - } - - private static MemberInitExpression GetWriteLogExpression(Expression message, - Expression severityParameter, ParameterExpression logNameParameter) - { - var entryType = LogEntryType; - MemberInitExpression memberInit = Expression.MemberInit(Expression.New(entryType), - Expression.Bind(entryType.GetPropertyPortable("Message"), message), - Expression.Bind(entryType.GetPropertyPortable("Severity"), severityParameter), - Expression.Bind( - entryType.GetPropertyPortable("TimeStamp"), - Expression.Property(null, typeof (DateTime).GetPropertyPortable("UtcNow"))), - Expression.Bind( - entryType.GetPropertyPortable("Categories"), - Expression.ListInit( - Expression.New(typeof (List)), - typeof (List).GetMethodPortable("Add", typeof (string)), - logNameParameter))); - return memberInit; - } - - internal class EntLibLogger - { - private readonly string _loggerName; - private readonly Action _writeLog; - private readonly Func _shouldLog; - - internal EntLibLogger(string loggerName, Action writeLog, Func shouldLog) - { - _loggerName = loggerName; - _writeLog = writeLog; - _shouldLog = shouldLog; - } - - public bool Log(LogLevel logLevel, Func messageFunc, Exception exception, params object[] formatParameters) - { - var severity = MapSeverity(logLevel); - if (messageFunc == null) - { - return _shouldLog(_loggerName, severity); - } - - - messageFunc = LogMessageFormatter.SimulateStructuredLogging(messageFunc, formatParameters); - if (exception != null) - { - return LogException(logLevel, messageFunc, exception); - } - _writeLog(_loggerName, messageFunc(), severity); - return true; - } - - public bool LogException(LogLevel logLevel, Func messageFunc, Exception exception) - { - var severity = MapSeverity(logLevel); - var message = messageFunc() + Environment.NewLine + exception; - _writeLog(_loggerName, message, severity); - return true; - } - - private static int MapSeverity(LogLevel logLevel) - { - switch (logLevel) - { - case LogLevel.Fatal: - return TraceEventTypeValues.Critical; - case LogLevel.Error: - return TraceEventTypeValues.Error; - case LogLevel.Warn: - return TraceEventTypeValues.Warning; - case LogLevel.Info: - return TraceEventTypeValues.Information; - default: - return TraceEventTypeValues.Verbose; - } - } - } - } - - internal class SerilogLogProvider : LogProviderBase - { - private readonly Func _getLoggerByNameDelegate; - private static bool s_providerIsAvailableOverride = true; - - [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "Serilog")] - public SerilogLogProvider() - { - if (!IsLoggerAvailable()) - { - throw new InvalidOperationException("Serilog.Log not found"); - } - _getLoggerByNameDelegate = GetForContextMethodCall(); - } - - public static bool ProviderIsAvailableOverride - { - get { return s_providerIsAvailableOverride; } - set { s_providerIsAvailableOverride = value; } - } - - public override Logger GetLogger(string name) - { - return new SerilogLogger(_getLoggerByNameDelegate(name)).Log; - } - - internal static bool IsLoggerAvailable() - { - return ProviderIsAvailableOverride && GetLogManagerType() != null; - } - - protected override OpenNdc GetOpenNdcMethod() - { - return message => GetPushProperty()("NDC", message); - } - - protected override OpenMdc GetOpenMdcMethod() - { - return (key, value) => GetPushProperty()(key, value); - } - - private static Func GetPushProperty() - { - Type ndcContextType = Type.GetType("Serilog.Context.LogContext, Serilog") ?? - Type.GetType("Serilog.Context.LogContext, Serilog.FullNetFx"); - - MethodInfo pushPropertyMethod = ndcContextType.GetMethodPortable( - "PushProperty", - typeof(string), - typeof(object), - typeof(bool)); - - ParameterExpression nameParam = Expression.Parameter(typeof(string), "name"); - ParameterExpression valueParam = Expression.Parameter(typeof(object), "value"); - ParameterExpression destructureObjectParam = Expression.Parameter(typeof(bool), "destructureObjects"); - MethodCallExpression pushPropertyMethodCall = Expression - .Call(null, pushPropertyMethod, nameParam, valueParam, destructureObjectParam); - var pushProperty = Expression - .Lambda>( - pushPropertyMethodCall, - nameParam, - valueParam, - destructureObjectParam) - .Compile(); - - return (key, value) => pushProperty(key, value, false); - } - - private static Type GetLogManagerType() - { - return Type.GetType("Serilog.Log, Serilog"); - } - - private static Func GetForContextMethodCall() - { - Type logManagerType = GetLogManagerType(); - MethodInfo method = logManagerType.GetMethodPortable("ForContext", typeof(string), typeof(object), typeof(bool)); - ParameterExpression propertyNameParam = Expression.Parameter(typeof(string), "propertyName"); - ParameterExpression valueParam = Expression.Parameter(typeof(object), "value"); - ParameterExpression destructureObjectsParam = Expression.Parameter(typeof(bool), "destructureObjects"); - MethodCallExpression methodCall = Expression.Call(null, method, new Expression[] - { - propertyNameParam, - valueParam, - destructureObjectsParam - }); - var func = Expression.Lambda>( - methodCall, - propertyNameParam, - valueParam, - destructureObjectsParam) - .Compile(); - return name => func("SourceContext", name, false); - } - - internal class SerilogLogger - { - private readonly object _logger; - private static readonly object DebugLevel; - private static readonly object ErrorLevel; - private static readonly object FatalLevel; - private static readonly object InformationLevel; - private static readonly object VerboseLevel; - private static readonly object WarningLevel; - private static readonly Func IsEnabled; - private static readonly Action Write; - private static readonly Action WriteException; - - [SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] - [SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline")] - [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "ILogger")] - [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "LogEventLevel")] - [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "Serilog")] - static SerilogLogger() - { - var logEventLevelType = Type.GetType("Serilog.Events.LogEventLevel, Serilog"); - if (logEventLevelType == null) - { - throw new InvalidOperationException("Type Serilog.Events.LogEventLevel was not found."); - } - DebugLevel = Enum.Parse(logEventLevelType, "Debug", false); - ErrorLevel = Enum.Parse(logEventLevelType, "Error", false); - FatalLevel = Enum.Parse(logEventLevelType, "Fatal", false); - InformationLevel = Enum.Parse(logEventLevelType, "Information", false); - VerboseLevel = Enum.Parse(logEventLevelType, "Verbose", false); - WarningLevel = Enum.Parse(logEventLevelType, "Warning", false); - - // Func isEnabled = (logger, level) => { return ((SeriLog.ILogger)logger).IsEnabled(level); } - var loggerType = Type.GetType("Serilog.ILogger, Serilog"); - if (loggerType == null) - { - throw new InvalidOperationException("Type Serilog.ILogger was not found."); - } - MethodInfo isEnabledMethodInfo = loggerType.GetMethodPortable("IsEnabled", logEventLevelType); - ParameterExpression instanceParam = Expression.Parameter(typeof(object)); - UnaryExpression instanceCast = Expression.Convert(instanceParam, loggerType); - ParameterExpression levelParam = Expression.Parameter(typeof(object)); - UnaryExpression levelCast = Expression.Convert(levelParam, logEventLevelType); - MethodCallExpression isEnabledMethodCall = Expression.Call(instanceCast, isEnabledMethodInfo, levelCast); - IsEnabled = Expression.Lambda>(isEnabledMethodCall, instanceParam, levelParam).Compile(); - - // Action Write = - // (logger, level, message, params) => { ((SeriLog.ILoggerILogger)logger).Write(level, message, params); } - MethodInfo writeMethodInfo = loggerType.GetMethodPortable("Write", logEventLevelType, typeof(string), typeof(object[])); - ParameterExpression messageParam = Expression.Parameter(typeof(string)); - ParameterExpression propertyValuesParam = Expression.Parameter(typeof(object[])); - MethodCallExpression writeMethodExp = Expression.Call( - instanceCast, - writeMethodInfo, - levelCast, - messageParam, - propertyValuesParam); - var expression = Expression.Lambda>( - writeMethodExp, - instanceParam, - levelParam, - messageParam, - propertyValuesParam); - Write = expression.Compile(); - - // Action WriteException = - // (logger, level, exception, message) => { ((ILogger)logger).Write(level, exception, message, new object[]); } - MethodInfo writeExceptionMethodInfo = loggerType.GetMethodPortable("Write", - logEventLevelType, - typeof(Exception), - typeof(string), - typeof(object[])); - ParameterExpression exceptionParam = Expression.Parameter(typeof(Exception)); - writeMethodExp = Expression.Call( - instanceCast, - writeExceptionMethodInfo, - levelCast, - exceptionParam, - messageParam, - propertyValuesParam); - WriteException = Expression.Lambda>( - writeMethodExp, - instanceParam, - levelParam, - exceptionParam, - messageParam, - propertyValuesParam).Compile(); - } - - internal SerilogLogger(object logger) - { - _logger = logger; - } - - public bool Log(LogLevel logLevel, Func messageFunc, Exception exception, params object[] formatParameters) - { - var translatedLevel = TranslateLevel(logLevel); - if (messageFunc == null) - { - return IsEnabled(_logger, translatedLevel); - } - - if (!IsEnabled(_logger, translatedLevel)) - { - return false; - } - - if (exception != null) - { - LogException(translatedLevel, messageFunc, exception, formatParameters); - } - else - { - LogMessage(translatedLevel, messageFunc, formatParameters); - } - - return true; - } - - private void LogMessage(object translatedLevel, Func messageFunc, object[] formatParameters) - { - Write(_logger, translatedLevel, messageFunc(), formatParameters); - } - - private void LogException(object logLevel, Func messageFunc, Exception exception, object[] formatParams) - { - WriteException(_logger, logLevel, exception, messageFunc(), formatParams); - } - - private static object TranslateLevel(LogLevel logLevel) - { - switch (logLevel) - { - case LogLevel.Fatal: - return FatalLevel; - case LogLevel.Error: - return ErrorLevel; - case LogLevel.Warn: - return WarningLevel; - case LogLevel.Info: - return InformationLevel; - case LogLevel.Trace: - return VerboseLevel; - default: - return DebugLevel; - } - } - } - } - - internal class LoupeLogProvider : LogProviderBase - { - /// - /// The form of the Loupe Log.Write method we're using - /// - internal delegate void WriteDelegate( - int severity, - string logSystem, - int skipFrames, - Exception exception, - bool attributeToException, - int writeMode, - string detailsXml, - string category, - string caption, - string description, - params object[] args - ); - - private static bool s_providerIsAvailableOverride = true; - private readonly WriteDelegate _logWriteDelegate; - - public LoupeLogProvider() - { - if (!IsLoggerAvailable()) - { - throw new InvalidOperationException("Gibraltar.Agent.Log (Loupe) not found"); - } - - _logWriteDelegate = GetLogWriteDelegate(); - } - - /// - /// Gets or sets a value indicating whether [provider is available override]. Used in tests. - /// - /// - /// true if [provider is available override]; otherwise, false. - /// - public static bool ProviderIsAvailableOverride - { - get { return s_providerIsAvailableOverride; } - set { s_providerIsAvailableOverride = value; } - } - - public override Logger GetLogger(string name) - { - return new LoupeLogger(name, _logWriteDelegate).Log; - } - - public static bool IsLoggerAvailable() - { - return ProviderIsAvailableOverride && GetLogManagerType() != null; - } - - private static Type GetLogManagerType() - { - return Type.GetType("Gibraltar.Agent.Log, Gibraltar.Agent"); - } - - private static WriteDelegate GetLogWriteDelegate() - { - Type logManagerType = GetLogManagerType(); - Type logMessageSeverityType = Type.GetType("Gibraltar.Agent.LogMessageSeverity, Gibraltar.Agent"); - Type logWriteModeType = Type.GetType("Gibraltar.Agent.LogWriteMode, Gibraltar.Agent"); - - MethodInfo method = logManagerType.GetMethodPortable( - "Write", - logMessageSeverityType, typeof(string), typeof(int), typeof(Exception), typeof(bool), - logWriteModeType, typeof(string), typeof(string), typeof(string), typeof(string), typeof(object[])); - - var callDelegate = (WriteDelegate)method.CreateDelegate(typeof(WriteDelegate)); - return callDelegate; - } - - internal class LoupeLogger - { - private const string LogSystem = "LibLog"; - - private readonly string _category; - private readonly WriteDelegate _logWriteDelegate; - private readonly int _skipLevel; - - internal LoupeLogger(string category, WriteDelegate logWriteDelegate) - { - _category = category; - _logWriteDelegate = logWriteDelegate; -#if DEBUG - _skipLevel = 2; -#else - _skipLevel = 1; -#endif - } - - public bool Log(LogLevel logLevel, Func messageFunc, Exception exception, params object[] formatParameters) - { - if (messageFunc == null) - { - //nothing to log.. - return true; - } - - messageFunc = LogMessageFormatter.SimulateStructuredLogging(messageFunc, formatParameters); - - _logWriteDelegate(ToLogMessageSeverity(logLevel), LogSystem, _skipLevel, exception, true, 0, null, - _category, null, messageFunc.Invoke()); - - return true; - } - - private static int ToLogMessageSeverity(LogLevel logLevel) - { - switch (logLevel) - { - case LogLevel.Trace: - return TraceEventTypeValues.Verbose; - case LogLevel.Debug: - return TraceEventTypeValues.Verbose; - case LogLevel.Info: - return TraceEventTypeValues.Information; - case LogLevel.Warn: - return TraceEventTypeValues.Warning; - case LogLevel.Error: - return TraceEventTypeValues.Error; - case LogLevel.Fatal: - return TraceEventTypeValues.Critical; - default: - throw new ArgumentOutOfRangeException("logLevel"); - } - } - } - } - - internal static class TraceEventTypeValues - { - internal static readonly Type Type; - internal static readonly int Verbose; - internal static readonly int Information; - internal static readonly int Warning; - internal static readonly int Error; - internal static readonly int Critical; - - [SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline")] - static TraceEventTypeValues() - { - var assembly = typeof(Uri).GetAssemblyPortable(); // This is to get to the System.dll assembly in a PCL compatible way. - if (assembly == null) - { - return; - } - Type = assembly.GetType("System.Diagnostics.TraceEventType"); - if (Type == null) return; - Verbose = (int)Enum.Parse(Type, "Verbose", false); - Information = (int)Enum.Parse(Type, "Information", false); - Warning = (int)Enum.Parse(Type, "Warning", false); - Error = (int)Enum.Parse(Type, "Error", false); - Critical = (int)Enum.Parse(Type, "Critical", false); - } - } - - internal static class LogMessageFormatter - { - //private static readonly Regex Pattern = new Regex(@"\{@?\w{1,}\}"); -#if LIBLOG_PORTABLE - private static readonly Regex Pattern = new Regex(@"(?[^\d{][^ }]*)}"); -#else - private static readonly Regex Pattern = new Regex(@"(?[^ :{}]+)(?:[^}]+)?}", RegexOptions.Compiled); -#endif - - /// - /// Some logging frameworks support structured logging, such as serilog. This will allow you to add names to structured data in a format string: - /// For example: Log("Log message to {user}", user). This only works with serilog, but as the user of LibLog, you don't know if serilog is actually - /// used. So, this class simulates that. it will replace any text in {curly braces} with an index number. - /// - /// "Log {message} to {user}" would turn into => "Log {0} to {1}". Then the format parameters are handled using regular .net string.Format. - /// - /// The message builder. - /// The format parameters. - /// - public static Func SimulateStructuredLogging(Func messageBuilder, object[] formatParameters) - { - if (formatParameters == null || formatParameters.Length == 0) - { - return messageBuilder; - } - - return () => - { - string targetMessage = messageBuilder(); - IEnumerable patternMatches; - return FormatStructuredMessage(targetMessage, formatParameters, out patternMatches); - }; - } - - private static string ReplaceFirst(string text, string search, string replace) - { - int pos = text.IndexOf(search, StringComparison.Ordinal); - if (pos < 0) - { - return text; - } - return text.Substring(0, pos) + replace + text.Substring(pos + search.Length); - } - - public static string FormatStructuredMessage(string targetMessage, object[] formatParameters, out IEnumerable patternMatches) - { - if (formatParameters.Length == 0) - { - patternMatches = Enumerable.Empty(); - return targetMessage; - } - - List processedArguments = new List(); - patternMatches = processedArguments; - - foreach (Match match in Pattern.Matches(targetMessage)) - { - var arg = match.Groups["arg"].Value; - - int notUsed; - if (!int.TryParse(arg, out notUsed)) - { - int argumentIndex = processedArguments.IndexOf(arg); - if (argumentIndex == -1) - { - argumentIndex = processedArguments.Count; - processedArguments.Add(arg); - } - - targetMessage = ReplaceFirst(targetMessage, match.Value, - "{" + argumentIndex + match.Groups["format"].Value + "}"); - } - } - try - { - return string.Format(CultureInfo.InvariantCulture, targetMessage, formatParameters); - } - catch (FormatException ex) - { - throw new FormatException("The input string '" + targetMessage + "' could not be formatted using string.Format", ex); - } - } - } - - internal static class TypeExtensions - { - internal static ConstructorInfo GetConstructorPortable(this Type type, params Type[] types) - { -#if LIBLOG_PORTABLE - return type.GetTypeInfo().DeclaredConstructors.FirstOrDefault - (constructor => - constructor.GetParameters() - .Select(parameter => parameter.ParameterType) - .SequenceEqual(types)); -#else - return type.GetConstructor(types); -#endif - } - - internal static MethodInfo GetMethodPortable(this Type type, string name) - { -#if LIBLOG_PORTABLE - return type.GetRuntimeMethods().SingleOrDefault(m => m.Name == name); -#else - return type.GetMethod(name); -#endif - } - - internal static MethodInfo GetMethodPortable(this Type type, string name, params Type[] types) - { -#if LIBLOG_PORTABLE - return type.GetRuntimeMethod(name, types); -#else - return type.GetMethod(name, types); -#endif - } - - internal static PropertyInfo GetPropertyPortable(this Type type, string name) - { -#if LIBLOG_PORTABLE - return type.GetRuntimeProperty(name); -#else - return type.GetProperty(name); -#endif - } - - internal static IEnumerable GetFieldsPortable(this Type type) - { -#if LIBLOG_PORTABLE - return type.GetRuntimeFields(); -#else - return type.GetFields(); -#endif - } - - internal static Type GetBaseTypePortable(this Type type) - { -#if LIBLOG_PORTABLE - return type.GetTypeInfo().BaseType; -#else - return type.BaseType; -#endif - } - -#if LIBLOG_PORTABLE - internal static MethodInfo GetGetMethod(this PropertyInfo propertyInfo) - { - return propertyInfo.GetMethod; - } - - internal static MethodInfo GetSetMethod(this PropertyInfo propertyInfo) - { - return propertyInfo.SetMethod; - } -#endif - -#if !LIBLOG_PORTABLE - internal static object CreateDelegate(this MethodInfo methodInfo, Type delegateType) - { - return Delegate.CreateDelegate(delegateType, methodInfo); - } -#endif - - internal static Assembly GetAssemblyPortable(this Type type) - { -#if LIBLOG_PORTABLE - return type.GetTypeInfo().Assembly; -#else - return type.Assembly; -#endif - } - } - - internal class DisposableAction : IDisposable - { - private readonly Action _onDispose; - - public DisposableAction(Action onDispose = null) - { - _onDispose = onDispose; - } - - public void Dispose() - { - if(_onDispose != null) - { - _onDispose(); - } - } - } -} diff --git a/src/GitTools.Core/GitTools.Core.NET45/GitTools.Core.NET45.csproj b/src/GitTools.Core/GitTools.Core.NET45/GitTools.Core.NET45.csproj deleted file mode 100644 index 23e7969..0000000 --- a/src/GitTools.Core/GitTools.Core.NET45/GitTools.Core.NET45.csproj +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - Debug - AnyCPU - {66295D7C-58FD-4641-AEAB-3DF7EA8FA4D2} - Library - Properties - GitTools - GitTools.Core - v4.5 - 512 - 5 - - - - - true - full - false - ..\..\..\output\Debug\GitTools.Core\net45\ - TRACE;DEBUG - prompt - 4 - ..\..\..\output\Debug\GitTools.Core\net45\GitTools.Core.xml - true - 1591,414 - - - pdbonly - true - ..\..\..\output\Release\GitTools.Core\net45\ - TRACE - prompt - 4 - 1591 - true - ..\..\..\output\Release\GitTools.Core\net45\GitTools.Core.xml - - - - ..\..\packages\LibGit2Sharp.0.23.0-pre20160922233542\lib\net40\LibGit2Sharp.dll - True - - - - - - - - - - - - Properties\SolutionAssemblyInfo.cs - - - - - - - - - - - - - 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}. - - - - - \ No newline at end of file diff --git a/src/GitTools.Core/GitTools.Core.NET45/GitTools.Core.NET45.v2.ncrunchproject b/src/GitTools.Core/GitTools.Core.NET45/GitTools.Core.NET45.v2.ncrunchproject deleted file mode 100644 index cdfbdeb62b94ed1a21f6f85dec6e376a397e23a7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2726 zcmb_e%TDV+4E6d-`~!b*VT10XsuUgz7Kn-#v4)VAK$DBdPEtlF1$HrTD63hVwUS^9g^?z{s;> z$ll@%Pt*2qX>H=np+5yKqC8iWj8_c1E8Tg)&J1sbXjF=R0#x)N#koZ<%H4GuMrJbs zngUku2S>CWyKS`?jtCft;=i0CvpLXYh(N4aVe~xD9MCd*&pNla)nO>uhv*~gC0j?Y**DuZhe?=)fYE1W3V+EZ z-_b7NS=U;#N;a1_+x03))TGKNzP`6Uf4eG z^`GGMHMm_OSL~O87rYnoz7c5@3QRcT45!sFX^X=J7!d9Z?99~8=^g3ari9&4)qyFr qPMJvKzMZ_;4;{ - /// Indicates that the value of the marked element could be null sometimes, - /// so the check for null is necessary before its usage. - /// - /// - /// [CanBeNull] public object Test() { return null; } - /// public void UseTest() { - /// var p = Test(); - /// var s = p.ToString(); // Warning: Possible 'System.NullReferenceException' - /// } - /// - [AttributeUsage( - AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | - AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event)] - internal sealed class CanBeNullAttribute : Attribute { } - - /// - /// Indicates that the value of the marked element could never be null. - /// - /// - /// [NotNull] public object Foo() { - /// return null; // Warning: Possible 'null' assignment - /// } - /// - [AttributeUsage( - AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | - AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event)] - internal sealed class NotNullAttribute : Attribute { } - - /// - /// Can be appplied to symbols of types derived from IEnumerable as well as to symbols of Task - /// and Lazy classes to indicate that the value of a collection item, of the Task.Result property - /// or of the Lazy.Value property can never be null. - /// - [AttributeUsage( - AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | - AttributeTargets.Delegate | AttributeTargets.Field)] - internal sealed class ItemNotNullAttribute : Attribute { } - - /// - /// Can be appplied to symbols of types derived from IEnumerable as well as to symbols of Task - /// and Lazy classes to indicate that the value of a collection item, of the Task.Result property - /// or of the Lazy.Value property can be null. - /// - [AttributeUsage( - AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | - AttributeTargets.Delegate | AttributeTargets.Field)] - internal sealed class ItemCanBeNullAttribute : Attribute { } - - /// - /// Indicates that the marked method builds string by format pattern and (optional) arguments. - /// Parameter, which contains format string, should be given in constructor. The format string - /// should be in -like form. - /// - /// - /// [StringFormatMethod("message")] - /// public void ShowError(string message, params object[] args) { /* do something */ } - /// public void Foo() { - /// ShowError("Failed: {0}"); // Warning: Non-existing argument in format string - /// } - /// - [AttributeUsage( - AttributeTargets.Constructor | AttributeTargets.Method | - AttributeTargets.Property | AttributeTargets.Delegate)] - internal sealed class StringFormatMethodAttribute : Attribute - { - /// - /// Specifies which parameter of an annotated method should be treated as format-string - /// - public StringFormatMethodAttribute(string formatParameterName) - { - FormatParameterName = formatParameterName; - } - - public string FormatParameterName { get; private set; } - } - - /// - /// For a parameter that is expected to be one of the limited set of values. - /// Specify fields of which type should be used as values for this parameter. - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field)] - internal sealed class ValueProviderAttribute : Attribute - { - public ValueProviderAttribute(string name) - { - Name = name; - } - - [NotNull] - public string Name { get; private set; } - } - - /// - /// Indicates that the function argument should be string literal and match one - /// of the parameters of the caller function. For example, ReSharper annotates - /// the parameter of . - /// - /// - /// public void Foo(string param) { - /// if (param == null) - /// throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol - /// } - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class InvokerParameterNameAttribute : Attribute { } - - /// - /// Indicates that the method is contained in a type that implements - /// System.ComponentModel.INotifyPropertyChanged interface and this method - /// is used to notify that some property value changed. - /// - /// - /// The method should be non-static and conform to one of the supported signatures: - /// - /// NotifyChanged(string) - /// NotifyChanged(params string[]) - /// NotifyChanged{T}(Expression{Func{T}}) - /// NotifyChanged{T,U}(Expression{Func{T,U}}) - /// SetProperty{T}(ref T, T, string) - /// - /// - /// - /// public class Foo : INotifyPropertyChanged { - /// public event PropertyChangedEventHandler PropertyChanged; - /// [NotifyPropertyChangedInvocator] - /// protected virtual void NotifyChanged(string propertyName) { ... } - /// - /// private string _name; - /// public string Name { - /// get { return _name; } - /// set { _name = value; NotifyChanged("LastName"); /* Warning */ } - /// } - /// } - /// - /// Examples of generated notifications: - /// - /// NotifyChanged("Property") - /// NotifyChanged(() => Property) - /// NotifyChanged((VM x) => x.Property) - /// SetProperty(ref myField, value, "Property") - /// - /// - [AttributeUsage(AttributeTargets.Method)] - internal sealed class NotifyPropertyChangedInvocatorAttribute : Attribute - { - public NotifyPropertyChangedInvocatorAttribute() { } - public NotifyPropertyChangedInvocatorAttribute(string parameterName) - { - ParameterName = parameterName; - } - - public string ParameterName { get; private set; } - } - - /// - /// Describes dependency between method input and output. - /// - /// - ///

Function Definition Table syntax:

- /// - /// FDT ::= FDTRow [;FDTRow]* - /// FDTRow ::= Input => Output | Output <= Input - /// Input ::= ParameterName: Value [, Input]* - /// Output ::= [ParameterName: Value]* {halt|stop|void|nothing|Value} - /// Value ::= true | false | null | notnull | canbenull - /// - /// If method has single input parameter, it's name could be omitted.
- /// Using halt (or void/nothing, which is the same) - /// for method output means that the methos doesn't return normally.
- /// canbenull annotation is only applicable for output parameters.
- /// You can use multiple [ContractAnnotation] for each FDT row, - /// or use single attribute with rows separated by semicolon.
- ///
- /// - /// - /// [ContractAnnotation("=> halt")] - /// public void TerminationMethod() - /// - /// - /// [ContractAnnotation("halt <= condition: false")] - /// public void Assert(bool condition, string text) // regular assertion method - /// - /// - /// [ContractAnnotation("s:null => true")] - /// public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty() - /// - /// - /// // A method that returns null if the parameter is null, - /// // and not null if the parameter is not null - /// [ContractAnnotation("null => null; notnull => notnull")] - /// public object Transform(object data) - /// - /// - /// [ContractAnnotation("s:null=>false; =>true,result:notnull; =>false, result:null")] - /// public bool TryParse(string s, out Person result) - /// - /// - [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] - internal sealed class ContractAnnotationAttribute : Attribute - { - public ContractAnnotationAttribute([NotNull] string contract) - : this(contract, false) - { } - - public ContractAnnotationAttribute([NotNull] string contract, bool forceFullStates) - { - Contract = contract; - ForceFullStates = forceFullStates; - } - - public string Contract { get; private set; } - public bool ForceFullStates { get; private set; } - } - - /// - /// Indicates that marked element should be localized or not. - /// - /// - /// [LocalizationRequiredAttribute(true)] - /// public class Foo { - /// private string str = "my string"; // Warning: Localizable string - /// } - /// - [AttributeUsage(AttributeTargets.All)] - internal sealed class LocalizationRequiredAttribute : Attribute - { - public LocalizationRequiredAttribute() : this(true) { } - public LocalizationRequiredAttribute(bool required) - { - Required = required; - } - - public bool Required { get; private set; } - } - - /// - /// Indicates that the value of the marked type (or its derivatives) - /// cannot be compared using '==' or '!=' operators and Equals() - /// should be used instead. However, using '==' or '!=' for comparison - /// with null is always permitted. - /// - /// - /// [CannotApplyEqualityOperator] - /// class NoEquality { } - /// class UsesNoEquality { - /// public void Test() { - /// var ca1 = new NoEquality(); - /// var ca2 = new NoEquality(); - /// if (ca1 != null) { // OK - /// bool condition = ca1 == ca2; // Warning - /// } - /// } - /// } - /// - [AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Struct)] - internal sealed class CannotApplyEqualityOperatorAttribute : Attribute { } - - /// - /// When applied to a target attribute, specifies a requirement for any type marked - /// with the target attribute to implement or inherit specific type or types. - /// - /// - /// [BaseTypeRequired(typeof(IComponent)] // Specify requirement - /// public class ComponentAttribute : Attribute { } - /// [Component] // ComponentAttribute requires implementing IComponent interface - /// public class MyComponent : IComponent { } - /// - [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] - [BaseTypeRequired(typeof(Attribute))] - internal sealed class BaseTypeRequiredAttribute : Attribute - { - public BaseTypeRequiredAttribute([NotNull] Type baseType) - { - BaseType = baseType; - } - - [NotNull] - public Type BaseType { get; private set; } - } - - /// - /// Indicates that the marked symbol is used implicitly (e.g. via reflection, in external library), - /// so this symbol will not be marked as unused (as well as by other usage inspections). - /// - [AttributeUsage(AttributeTargets.All)] - internal sealed class UsedImplicitlyAttribute : Attribute - { - public UsedImplicitlyAttribute() - : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) - { } - - public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags) - : this(useKindFlags, ImplicitUseTargetFlags.Default) - { } - - public UsedImplicitlyAttribute(ImplicitUseTargetFlags targetFlags) - : this(ImplicitUseKindFlags.Default, targetFlags) - { } - - public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags) - { - UseKindFlags = useKindFlags; - TargetFlags = targetFlags; - } - - public ImplicitUseKindFlags UseKindFlags { get; private set; } - public ImplicitUseTargetFlags TargetFlags { get; private set; } - } - - /// - /// Should be used on attributes and causes ReSharper to not mark symbols marked with such attributes - /// as unused (as well as by other usage inspections) - /// - [AttributeUsage(AttributeTargets.Class | AttributeTargets.GenericParameter)] - internal sealed class MeansImplicitUseAttribute : Attribute - { - public MeansImplicitUseAttribute() - : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) - { } - - public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags) - : this(useKindFlags, ImplicitUseTargetFlags.Default) - { } - - public MeansImplicitUseAttribute(ImplicitUseTargetFlags targetFlags) - : this(ImplicitUseKindFlags.Default, targetFlags) - { } - - public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags) - { - UseKindFlags = useKindFlags; - TargetFlags = targetFlags; - } - - [UsedImplicitly] - public ImplicitUseKindFlags UseKindFlags { get; private set; } - [UsedImplicitly] - public ImplicitUseTargetFlags TargetFlags { get; private set; } - } - - [Flags] - internal enum ImplicitUseKindFlags - { - Default = Access | Assign | InstantiatedWithFixedConstructorSignature, - /// Only entity marked with attribute considered used. - Access = 1, - /// Indicates implicit assignment to a member. - Assign = 2, - /// - /// Indicates implicit instantiation of a type with fixed constructor signature. - /// That means any unused constructor parameters won't be reported as such. - /// - InstantiatedWithFixedConstructorSignature = 4, - /// Indicates implicit instantiation of a type. - InstantiatedNoFixedConstructorSignature = 8, - } - - /// - /// Specify what is considered used implicitly when marked - /// with or . - /// - [Flags] - internal enum ImplicitUseTargetFlags - { - Default = Itself, - Itself = 1, - /// Members of entity marked with attribute are considered used. - Members = 2, - /// Entity marked with attribute and all its members considered used. - WithMembers = Itself | Members - } - - /// - /// This attribute is intended to mark publicly available API - /// which should not be removed and so is treated as used. - /// - [MeansImplicitUse(ImplicitUseTargetFlags.WithMembers)] - internal sealed class PublicAPIAttribute : Attribute - { - public PublicAPIAttribute() { } - public PublicAPIAttribute([NotNull] string comment) - { - Comment = comment; - } - - public string Comment { get; private set; } - } - - /// - /// Tells code analysis engine if the parameter is completely handled when the invoked method is on stack. - /// If the parameter is a delegate, indicates that delegate is executed while the method is executed. - /// If the parameter is an enumerable, indicates that it is enumerated while the method is executed. - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class InstantHandleAttribute : Attribute { } - - /// - /// Indicates that a method does not make any observable state changes. - /// The same as System.Diagnostics.Contracts.PureAttribute. - /// - /// - /// [Pure] private int Multiply(int x, int y) { return x * y; } - /// public void Foo() { - /// const int a = 2, b = 2; - /// Multiply(a, b); // Waring: Return value of pure method is not used - /// } - /// - [AttributeUsage(AttributeTargets.Method)] - internal sealed class PureAttribute : Attribute { } - - /// - /// Indicates that a parameter is a path to a file or a folder within a web project. - /// Path can be relative or absolute, starting from web root (~). - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class PathReferenceAttribute : Attribute - { - public PathReferenceAttribute() { } - public PathReferenceAttribute([PathReference] string basePath) - { - BasePath = basePath; - } - - public string BasePath { get; private set; } - } - - /// - /// An extension method marked with this attribute is processed by ReSharper code completion - /// as a 'Source Template'. When extension method is completed over some expression, it's source code - /// is automatically expanded like a template at call site. - /// - /// - /// Template method body can contain valid source code and/or special comments starting with '$'. - /// Text inside these comments is added as source code when the template is applied. Template parameters - /// can be used either as additional method parameters or as identifiers wrapped in two '$' signs. - /// Use the attribute to specify macros for parameters. - /// - /// - /// In this example, the 'forEach' method is a source template available over all values - /// of enumerable types, producing ordinary C# 'foreach' statement and placing caret inside block: - /// - /// [SourceTemplate] - /// public static void forEach<T>(this IEnumerable<T> xs) { - /// foreach (var x in xs) { - /// //$ $END$ - /// } - /// } - /// - /// - [AttributeUsage(AttributeTargets.Method)] - internal sealed class SourceTemplateAttribute : Attribute { } - - /// - /// Allows specifying a macro for a parameter of a source template. - /// - /// - /// You can apply the attribute on the whole method or on any of its additional parameters. The macro expression - /// is defined in the property. When applied on a method, the target - /// template parameter is defined in the property. To apply the macro silently - /// for the parameter, set the property value = -1. - /// - /// - /// Applying the attribute on a source template method: - /// - /// [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")] - /// public static void forEach<T>(this IEnumerable<T> collection) { - /// foreach (var item in collection) { - /// //$ $END$ - /// } - /// } - /// - /// Applying the attribute on a template method parameter: - /// - /// [SourceTemplate] - /// public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) { - /// /*$ var $x$Id = "$newguid$" + x.ToString(); - /// x.DoSomething($x$Id); */ - /// } - /// - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method, AllowMultiple = true)] - internal sealed class MacroAttribute : Attribute - { - /// - /// Allows specifying a macro that will be executed for a source template - /// parameter when the template is expanded. - /// - public string Expression { get; set; } - - /// - /// Allows specifying which occurrence of the target parameter becomes editable when the template is deployed. - /// - /// - /// If the target parameter is used several times in the template, only one occurrence becomes editable; - /// other occurrences are changed synchronously. To specify the zero-based index of the editable occurrence, - /// use values >= 0. To make the parameter non-editable when the template is expanded, use -1. - /// > - public int Editable { get; set; } - - /// - /// Identifies the target parameter of a source template if the - /// is applied on a template method. - /// - public string Target { get; set; } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - internal sealed class AspMvcAreaMasterLocationFormatAttribute : Attribute - { - public AspMvcAreaMasterLocationFormatAttribute(string format) - { - Format = format; - } - - public string Format { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - internal sealed class AspMvcAreaPartialViewLocationFormatAttribute : Attribute - { - public AspMvcAreaPartialViewLocationFormatAttribute(string format) - { - Format = format; - } - - public string Format { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - internal sealed class AspMvcAreaViewLocationFormatAttribute : Attribute - { - public AspMvcAreaViewLocationFormatAttribute(string format) - { - Format = format; - } - - public string Format { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - internal sealed class AspMvcMasterLocationFormatAttribute : Attribute - { - public AspMvcMasterLocationFormatAttribute(string format) - { - Format = format; - } - - public string Format { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - internal sealed class AspMvcPartialViewLocationFormatAttribute : Attribute - { - public AspMvcPartialViewLocationFormatAttribute(string format) - { - Format = format; - } - - public string Format { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - internal sealed class AspMvcViewLocationFormatAttribute : Attribute - { - public AspMvcViewLocationFormatAttribute(string format) - { - Format = format; - } - - public string Format { get; private set; } - } - - /// - /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter - /// is an MVC action. If applied to a method, the MVC action name is calculated - /// implicitly from the context. Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String). - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] - internal sealed class AspMvcActionAttribute : Attribute - { - public AspMvcActionAttribute() { } - public AspMvcActionAttribute(string anonymousProperty) - { - AnonymousProperty = anonymousProperty; - } - - public string AnonymousProperty { get; private set; } - } - - /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC area. - /// Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String). - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class AspMvcAreaAttribute : Attribute - { - public AspMvcAreaAttribute() { } - public AspMvcAreaAttribute(string anonymousProperty) - { - AnonymousProperty = anonymousProperty; - } - - public string AnonymousProperty { get; private set; } - } - - /// - /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is - /// an MVC controller. If applied to a method, the MVC controller name is calculated - /// implicitly from the context. Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String, String). - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] - internal sealed class AspMvcControllerAttribute : Attribute - { - public AspMvcControllerAttribute() { } - public AspMvcControllerAttribute(string anonymousProperty) - { - AnonymousProperty = anonymousProperty; - } - - public string AnonymousProperty { get; private set; } - } - - /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC Master. Use this attribute - /// for custom wrappers similar to System.Web.Mvc.Controller.View(String, String). - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class AspMvcMasterAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC model type. Use this attribute - /// for custom wrappers similar to System.Web.Mvc.Controller.View(String, Object). - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class AspMvcModelTypeAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is an MVC - /// partial view. If applied to a method, the MVC partial view name is calculated implicitly - /// from the context. Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper, String). - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] - internal sealed class AspMvcPartialViewAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. Allows disabling inspections for MVC views within a class or a method. - /// - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] - internal sealed class AspMvcSupressViewErrorAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC display template. - /// Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.DisplayExtensions.DisplayForModel(HtmlHelper, String). - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class AspMvcDisplayTemplateAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC editor template. - /// Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.EditorExtensions.EditorForModel(HtmlHelper, String). - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class AspMvcEditorTemplateAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC template. - /// Use this attribute for custom wrappers similar to - /// System.ComponentModel.DataAnnotations.UIHintAttribute(System.String). - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class AspMvcTemplateAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter - /// is an MVC view. If applied to a method, the MVC view name is calculated implicitly - /// from the context. Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Controller.View(Object). - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] - internal sealed class AspMvcViewAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. When applied to a parameter of an attribute, - /// indicates that this parameter is an MVC action name. - /// - /// - /// [ActionName("Foo")] - /// public ActionResult Login(string returnUrl) { - /// ViewBag.ReturnUrl = Url.Action("Foo"); // OK - /// return RedirectToAction("Bar"); // Error: Cannot resolve action - /// } - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property)] - internal sealed class AspMvcActionSelectorAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field)] - internal sealed class HtmlElementAttributesAttribute : Attribute - { - public HtmlElementAttributesAttribute() { } - public HtmlElementAttributesAttribute(string name) - { - Name = name; - } - - public string Name { get; private set; } - } - - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)] - internal sealed class HtmlAttributeValueAttribute : Attribute - { - public HtmlAttributeValueAttribute([NotNull] string name) - { - Name = name; - } - - [NotNull] - public string Name { get; private set; } - } - - /// - /// Razor attribute. Indicates that a parameter or a method is a Razor section. - /// Use this attribute for custom wrappers similar to - /// System.Web.WebPages.WebPageBase.RenderSection(String). - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] - internal sealed class RazorSectionAttribute : Attribute { } - - /// - /// Indicates how method, constructor invocation or property access - /// over collection type affects content of the collection. - /// - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Property)] - internal sealed class CollectionAccessAttribute : Attribute - { - public CollectionAccessAttribute(CollectionAccessType collectionAccessType) - { - CollectionAccessType = collectionAccessType; - } - - public CollectionAccessType CollectionAccessType { get; private set; } - } - - [Flags] - internal enum CollectionAccessType - { - /// Method does not use or modify content of the collection. - None = 0, - /// Method only reads content of the collection but does not modify it. - Read = 1, - /// Method can change content of the collection but does not add new elements. - ModifyExistingContent = 2, - /// Method can add new elements to the collection. - UpdatedContent = ModifyExistingContent | 4 - } - - /// - /// Indicates that the marked method is assertion method, i.e. it halts control flow if - /// one of the conditions is satisfied. To set the condition, mark one of the parameters with - /// attribute. - /// - [AttributeUsage(AttributeTargets.Method)] - internal sealed class AssertionMethodAttribute : Attribute { } - - /// - /// Indicates the condition parameter of the assertion method. The method itself should be - /// marked by attribute. The mandatory argument of - /// the attribute is the assertion type. - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class AssertionConditionAttribute : Attribute - { - public AssertionConditionAttribute(AssertionConditionType conditionType) - { - ConditionType = conditionType; - } - - public AssertionConditionType ConditionType { get; private set; } - } - - /// - /// Specifies assertion type. If the assertion method argument satisfies the condition, - /// then the execution continues. Otherwise, execution is assumed to be halted. - /// - internal enum AssertionConditionType - { - /// Marked parameter should be evaluated to true. - IS_TRUE = 0, - /// Marked parameter should be evaluated to false. - IS_FALSE = 1, - /// Marked parameter should be evaluated to null value. - IS_NULL = 2, - /// Marked parameter should be evaluated to not null value. - IS_NOT_NULL = 3, - } - - /// - /// Indicates that the marked method unconditionally terminates control flow execution. - /// For example, it could unconditionally throw exception. - /// - [Obsolete("Use [ContractAnnotation('=> halt')] instead")] - [AttributeUsage(AttributeTargets.Method)] - internal sealed class TerminatesProgramAttribute : Attribute { } - - /// - /// Indicates that method is pure LINQ method, with postponed enumeration (like Enumerable.Select, - /// .Where). This annotation allows inference of [InstantHandle] annotation for parameters - /// of delegate type by analyzing LINQ method chains. - /// - [AttributeUsage(AttributeTargets.Method)] - internal sealed class LinqTunnelAttribute : Attribute { } - - /// - /// Indicates that IEnumerable, passed as parameter, is not enumerated. - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class NoEnumerationAttribute : Attribute { } - - /// - /// Indicates that parameter is regular expression pattern. - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class RegexPatternAttribute : Attribute { } - - /// - /// XAML attribute. Indicates the type that has ItemsSource property and should be treated - /// as ItemsControl-derived type, to enable inner items DataContext type resolve. - /// - [AttributeUsage(AttributeTargets.Class)] - internal sealed class XamlItemsControlAttribute : Attribute { } - - /// - /// XAML attibute. Indicates the property of some BindingBase-derived type, that - /// is used to bind some item of ItemsControl-derived type. This annotation will - /// enable the DataContext type resolve for XAML bindings for such properties. - /// - /// - /// Property should have the tree ancestor of the ItemsControl type or - /// marked with the attribute. - /// - [AttributeUsage(AttributeTargets.Property)] - internal sealed class XamlItemBindingOfItemsControlAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] - internal sealed class AspChildControlTypeAttribute : Attribute - { - public AspChildControlTypeAttribute(string tagName, Type controlType) - { - TagName = tagName; - ControlType = controlType; - } - - public string TagName { get; private set; } - public Type ControlType { get; private set; } - } - - [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)] - internal sealed class AspDataFieldAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)] - internal sealed class AspDataFieldsAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Property)] - internal sealed class AspMethodPropertyAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] - internal sealed class AspRequiredAttributeAttribute : Attribute - { - public AspRequiredAttributeAttribute([NotNull] string attribute) - { - Attribute = attribute; - } - - public string Attribute { get; private set; } - } - - [AttributeUsage(AttributeTargets.Property)] - internal sealed class AspTypePropertyAttribute : Attribute - { - public bool CreateConstructorReferences { get; private set; } - - public AspTypePropertyAttribute(bool createConstructorReferences) - { - CreateConstructorReferences = createConstructorReferences; - } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - internal sealed class RazorImportNamespaceAttribute : Attribute - { - public RazorImportNamespaceAttribute(string name) - { - Name = name; - } - - public string Name { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - internal sealed class RazorInjectionAttribute : Attribute - { - public RazorInjectionAttribute(string type, string fieldName) - { - Type = type; - FieldName = fieldName; - } - - public string Type { get; private set; } - public string FieldName { get; private set; } - } - - [AttributeUsage(AttributeTargets.Method)] - internal sealed class RazorHelperCommonAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Property)] - internal sealed class RazorLayoutAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Method)] - internal sealed class RazorWriteLiteralMethodAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Method)] - internal sealed class RazorWriteMethodAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class RazorWriteMethodParameterAttribute : Attribute { } - - /// - /// Prevents the Member Reordering feature from tossing members of the marked class. - /// - /// - /// The attribute must be mentioned in your member reordering patterns - /// - [AttributeUsage(AttributeTargets.All)] - internal sealed class NoReorder : Attribute { } -} \ No newline at end of file diff --git a/src/GitTools.Core/GitTools.Core.NET45/packages.config b/src/GitTools.Core/GitTools.Core.NET45/packages.config deleted file mode 100644 index 4893e8d..0000000 --- a/src/GitTools.Core/GitTools.Core.NET45/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/GitTools.Core/GitTools.Core.Shared/GitTools.Core.Shared.projitems b/src/GitTools.Core/GitTools.Core.Shared/GitTools.Core.Shared.projitems deleted file mode 100644 index 50bc512..0000000 --- a/src/GitTools.Core/GitTools.Core.Shared/GitTools.Core.Shared.projitems +++ /dev/null @@ -1,35 +0,0 @@ - - - - $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - true - c4b449df-3e78-4f3b-81a8-de0dc5827532 - - - GitTools - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/GitTools.Core/GitTools.Core.Shared/GitTools.Core.Shared.shproj b/src/GitTools.Core/GitTools.Core.Shared/GitTools.Core.Shared.shproj deleted file mode 100644 index fcc0a93..0000000 --- a/src/GitTools.Core/GitTools.Core.Shared/GitTools.Core.Shared.shproj +++ /dev/null @@ -1,13 +0,0 @@ - - - - c4b449df-3e78-4f3b-81a8-de0dc5827532 - 14.0 - - - - - - - - diff --git a/src/GitTools.Core/GitTools.Core.csproj b/src/GitTools.Core/GitTools.Core.csproj new file mode 100644 index 0000000..3985d17 --- /dev/null +++ b/src/GitTools.Core/GitTools.Core.csproj @@ -0,0 +1,18 @@ + + + + netstandard1.3 + + + + + TRACE;DEBUG;LIBLOG_PORTABLE;NETSTANDARD1_0; + + + + + + + + + \ No newline at end of file diff --git a/src/GitTools.Core/GitTools.Core.nuspec b/src/GitTools.Core/GitTools.Core.nuspec index c0058dc..1324514 100644 --- a/src/GitTools.Core/GitTools.Core.nuspec +++ b/src/GitTools.Core/GitTools.Core.nuspec @@ -15,7 +15,7 @@ https://github.com/GitTools/GitTools.Core/blob/master/LICENSE https://raw.github.com/GitTools/GitTools.Core/master/GitTools_logo.png - + diff --git a/src/GitTools.Core/GitTools.Core.Shared/Helpers/ProcessHelper.cs b/src/GitTools.Core/Helpers/ProcessHelper.cs similarity index 100% rename from src/GitTools.Core/GitTools.Core.Shared/Helpers/ProcessHelper.cs rename to src/GitTools.Core/Helpers/ProcessHelper.cs diff --git a/src/GitTools.Core/GitTools.Core.Shared/IO/FileSystem.cs b/src/GitTools.Core/IO/FileSystem.cs similarity index 100% rename from src/GitTools.Core/GitTools.Core.Shared/IO/FileSystem.cs rename to src/GitTools.Core/IO/FileSystem.cs diff --git a/src/GitTools.Core/GitTools.Core.Shared/IO/Helpers/DeleteHelper.cs b/src/GitTools.Core/IO/Helpers/DeleteHelper.cs similarity index 100% rename from src/GitTools.Core/GitTools.Core.Shared/IO/Helpers/DeleteHelper.cs rename to src/GitTools.Core/IO/Helpers/DeleteHelper.cs diff --git a/src/GitTools.Core/GitTools.Core.Shared/IO/Interfaces/IFileSystem.cs b/src/GitTools.Core/IO/Interfaces/IFileSystem.cs similarity index 100% rename from src/GitTools.Core/GitTools.Core.Shared/IO/Interfaces/IFileSystem.cs rename to src/GitTools.Core/IO/Interfaces/IFileSystem.cs diff --git a/src/GitTools.Core/GitTools.Core.Shared/IO/TemporaryFilesContext.cs b/src/GitTools.Core/IO/TemporaryFilesContext.cs similarity index 100% rename from src/GitTools.Core/GitTools.Core.Shared/IO/TemporaryFilesContext.cs rename to src/GitTools.Core/IO/TemporaryFilesContext.cs diff --git a/src/GitTools.Core/GitTools.Core.NET40/App_Packages/LibLog.4.2/LibLog.cs b/src/GitTools.Core/LibLog.4.2/LibLog.cs similarity index 95% rename from src/GitTools.Core/GitTools.Core.NET40/App_Packages/LibLog.4.2/LibLog.cs rename to src/GitTools.Core/LibLog.4.2/LibLog.cs index 4cee6a3..0d18b39 100644 --- a/src/GitTools.Core/GitTools.Core.NET40/App_Packages/LibLog.4.2/LibLog.cs +++ b/src/GitTools.Core/LibLog.4.2/LibLog.cs @@ -3,7 +3,7 @@ // // https://github.com/damianh/LibLog //=============================================================================== -// Copyright © 2011-2015 Damian Hickey. All rights reserved. +// Copyright © 2011-2015 Damian Hickey. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -46,7 +46,7 @@ // If you copied this file manually, you need to change all "YourRootNameSpace" so not to clash with other libraries // that use LibLog #if LIBLOG_PROVIDERS_ONLY -namespace GitTools.LibLog +namespace GitTools.Logging #else namespace GitTools.Logging #endif @@ -54,7 +54,7 @@ namespace GitTools.Logging using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; #if LIBLOG_PROVIDERS_ONLY - using GitTools.LibLog.LogProviders; + using GitTools.Logging.LibLog.LogProviders; #else using GitTools.Logging.LogProviders; #endif @@ -98,7 +98,7 @@ interface ILog /// /// To check IsEnabled call Log with only LogLevel and check the return value, no event will be written. /// - bool Log(LogLevel logLevel, Func messageFunc, Exception exception = null, params object[] formatParameters ); + bool Log(LogLevel logLevel, Func messageFunc, Exception exception = null, params object[] formatParameters); } #endif @@ -121,6 +121,9 @@ enum LogLevel } #if !LIBLOG_PROVIDERS_ONLY +#if !LIBLOG_PORTABLE + [ExcludeFromCodeCoverage] +#endif #if LIBLOG_PUBLIC public #else @@ -178,6 +181,16 @@ public static void Debug(this ILog logger, string message) } } + public static void Debug(this ILog logger, string message, params object[] args) + { + logger.DebugFormat(message, args); + } + + public static void Debug(this ILog logger, Exception exception, string message, params object[] args) + { + logger.DebugException(message, exception, args); + } + public static void DebugFormat(this ILog logger, string message, params object[] args) { if (logger.IsDebugEnabled()) @@ -216,6 +229,16 @@ public static void Error(this ILog logger, string message) } } + public static void Error(this ILog logger, string message, params object[] args) + { + logger.ErrorFormat(message, args); + } + + public static void Error(this ILog logger, Exception exception, string message, params object[] args) + { + logger.ErrorException(message, exception, args); + } + public static void ErrorFormat(this ILog logger, string message, params object[] args) { if (logger.IsErrorEnabled()) @@ -245,6 +268,16 @@ public static void Fatal(this ILog logger, string message) } } + public static void Fatal(this ILog logger, string message, params object[] args) + { + logger.FatalFormat(message, args); + } + + public static void Fatal(this ILog logger, Exception exception, string message, params object[] args) + { + logger.FatalException(message, exception, args); + } + public static void FatalFormat(this ILog logger, string message, params object[] args) { if (logger.IsFatalEnabled()) @@ -275,6 +308,16 @@ public static void Info(this ILog logger, string message) } } + public static void Info(this ILog logger, string message, params object[] args) + { + logger.InfoFormat(message, args); + } + + public static void Info(this ILog logger, Exception exception, string message, params object[] args) + { + logger.InfoException(message, exception, args); + } + public static void InfoFormat(this ILog logger, string message, params object[] args) { if (logger.IsInfoEnabled()) @@ -305,6 +348,16 @@ public static void Trace(this ILog logger, string message) } } + public static void Trace(this ILog logger, string message, params object[] args) + { + logger.TraceFormat(message, args); + } + + public static void Trace(this ILog logger, Exception exception, string message, params object[] args) + { + logger.TraceException(message, exception, args); + } + public static void TraceFormat(this ILog logger, string message, params object[] args) { if (logger.IsTraceEnabled()) @@ -335,6 +388,16 @@ public static void Warn(this ILog logger, string message) } } + public static void Warn(this ILog logger, string message, params object[] args) + { + logger.WarnFormat(message, args); + } + + public static void Warn(this ILog logger, Exception exception, string message, params object[] args) + { + logger.WarnException(message, exception, args); + } + public static void WarnFormat(this ILog logger, string message, params object[] args) { if (logger.IsWarnEnabled()) @@ -414,6 +477,9 @@ interface ILogProvider /// /// Provides a mechanism to create instances of objects. /// +#if !LIBLOG_PORTABLE + [ExcludeFromCodeCoverage] +#endif #if LIBLOG_PROVIDERS_ONLY internal #else @@ -588,31 +654,31 @@ static IDisposable OpenMappedContext(string key, string value) #if LIBLOG_PROVIDERS_ONLY private #else - internal + internal #endif delegate bool IsLoggerAvailable(); #if LIBLOG_PROVIDERS_ONLY private #else - internal + internal #endif delegate ILogProvider CreateLogProvider(); #if LIBLOG_PROVIDERS_ONLY private #else - internal + internal #endif static readonly List> LogProviderResolvers = - new List> - { + new List> + { new Tuple(SerilogLogProvider.IsLoggerAvailable, () => new SerilogLogProvider()), new Tuple(NLogLogProvider.IsLoggerAvailable, () => new NLogLogProvider()), new Tuple(Log4NetLogProvider.IsLoggerAvailable, () => new Log4NetLogProvider()), new Tuple(EntLibLogProvider.IsLoggerAvailable, () => new EntLibLogProvider()), new Tuple(LoupeLogProvider.IsLoggerAvailable, () => new LoupeLogProvider()), - }; + }; #if !LIBLOG_PROVIDERS_ONLY private static void RaiseOnCurrentLogProviderSet() @@ -653,6 +719,9 @@ internal static ILogProvider ResolveLogProvider() } #if !LIBLOG_PROVIDERS_ONLY +#if !LIBLOG_PORTABLE + [ExcludeFromCodeCoverage] +#endif internal class NoOpLogger : ILog { internal static readonly NoOpLogger Instance = new NoOpLogger(); @@ -666,6 +735,9 @@ public bool Log(LogLevel logLevel, Func messageFunc, Exception exception } #if !LIBLOG_PROVIDERS_ONLY +#if !LIBLOG_PORTABLE + [ExcludeFromCodeCoverage] +#endif internal class LoggerExecutionWrapper : ILog { private readonly Logger _logger; @@ -714,7 +786,7 @@ public bool Log(LogLevel logLevel, Func messageFunc, Exception exception } #if LIBLOG_PROVIDERS_ONLY -namespace GitTools.LibLog.LogProviders +namespace GitTools.Logging.LibLog.LogProviders #else namespace GitTools.Logging.LogProviders #endif @@ -734,6 +806,9 @@ namespace GitTools.Logging.LogProviders #endif using System.Text.RegularExpressions; +#if !LIBLOG_PORTABLE + [ExcludeFromCodeCoverage] +#endif internal abstract class LogProviderBase : ILogProvider { protected delegate IDisposable OpenNdc(string message); @@ -774,6 +849,9 @@ protected virtual OpenMdc GetOpenMdcMethod() } } +#if !LIBLOG_PORTABLE + [ExcludeFromCodeCoverage] +#endif internal class NLogLogProvider : LogProviderBase { private readonly Func _getLoggerByNameDelegate; @@ -855,6 +933,9 @@ private static Func GetGetLoggerMethodCall() return Expression.Lambda>(methodCall, nameParam).Compile(); } +#if !LIBLOG_PORTABLE + [ExcludeFromCodeCoverage] +#endif internal class NLogLogger { private readonly dynamic _logger; @@ -959,7 +1040,7 @@ public bool Log(LogLevel logLevel, Func messageFunc, Exception exception return false; } - if(exception != null) + if (exception != null) { return LogException(logLevel, messageFunc, exception); } @@ -1117,6 +1198,9 @@ private object TranslateLevel(LogLevel logLevel) } } +#if !LIBLOG_PORTABLE + [ExcludeFromCodeCoverage] +#endif internal class Log4NetLogProvider : LogProviderBase { private readonly Func _getLoggerByNameDelegate; @@ -1225,6 +1309,9 @@ private static Func GetGetLoggerMethodCall() return Expression.Lambda>(methodCall, nameParam).Compile(); } +#if !LIBLOG_PORTABLE + [ExcludeFromCodeCoverage] +#endif internal class Log4NetLogger { private readonly dynamic _logger; @@ -1423,7 +1510,7 @@ public bool Log(LogLevel logLevel, Func messageFunc, Exception exception } } #else - s_callerStackBoundaryType = typeof (LoggerExecutionWrapper); + s_callerStackBoundaryType = typeof(LoggerExecutionWrapper); #endif } } @@ -1492,6 +1579,9 @@ private object TranslateLevel(LogLevel logLevel) } } +#if !LIBLOG_PORTABLE + [ExcludeFromCodeCoverage] +#endif internal class EntLibLogProvider : LogProviderBase { private const string TypeTemplate = "Microsoft.Practices.EnterpriseLibrary.Logging.{0}, Microsoft.Practices.EnterpriseLibrary.Logging"; @@ -1598,16 +1688,19 @@ private static MemberInitExpression GetWriteLogExpression(Expression message, Expression.Bind(entryType.GetPropertyPortable("Severity"), severityParameter), Expression.Bind( entryType.GetPropertyPortable("TimeStamp"), - Expression.Property(null, typeof (DateTime).GetPropertyPortable("UtcNow"))), + Expression.Property(null, typeof(DateTime).GetPropertyPortable("UtcNow"))), Expression.Bind( entryType.GetPropertyPortable("Categories"), Expression.ListInit( - Expression.New(typeof (List)), - typeof (List).GetMethodPortable("Add", typeof (string)), + Expression.New(typeof(List)), + typeof(List).GetMethodPortable("Add", typeof(string)), logNameParameter))); return memberInit; } +#if !LIBLOG_PORTABLE + [ExcludeFromCodeCoverage] +#endif internal class EntLibLogger { private readonly string _loggerName; @@ -1666,6 +1759,9 @@ private static int MapSeverity(LogLevel logLevel) } } +#if !LIBLOG_PORTABLE + [ExcludeFromCodeCoverage] +#endif internal class SerilogLogProvider : LogProviderBase { private readonly Func _getLoggerByNameDelegate; @@ -1709,11 +1805,11 @@ protected override OpenMdc GetOpenMdcMethod() private static Func GetPushProperty() { - Type ndcContextType = Type.GetType("Serilog.Context.LogContext, Serilog") ?? + Type ndcContextType = Type.GetType("Serilog.Context.LogContext, Serilog") ?? Type.GetType("Serilog.Context.LogContext, Serilog.FullNetFx"); MethodInfo pushPropertyMethod = ndcContextType.GetMethodPortable( - "PushProperty", + "PushProperty", typeof(string), typeof(object), typeof(bool)); @@ -1730,7 +1826,7 @@ private static Func GetPushProperty() valueParam, destructureObjectParam) .Compile(); - + return (key, value) => pushProperty(key, value, false); } @@ -1748,7 +1844,7 @@ private static Func GetForContextMethodCall() ParameterExpression destructureObjectsParam = Expression.Parameter(typeof(bool), "destructureObjects"); MethodCallExpression methodCall = Expression.Call(null, method, new Expression[] { - propertyNameParam, + propertyNameParam, valueParam, destructureObjectsParam }); @@ -1761,6 +1857,9 @@ private static Func GetForContextMethodCall() return name => func("SourceContext", name, false); } +#if !LIBLOG_PORTABLE + [ExcludeFromCodeCoverage] +#endif internal class SerilogLogger { private readonly object _logger; @@ -1819,7 +1918,7 @@ static SerilogLogger() messageParam, propertyValuesParam); var expression = Expression.Lambda>( - writeMethodExp, + writeMethodExp, instanceParam, levelParam, messageParam, @@ -1828,7 +1927,7 @@ static SerilogLogger() // Action WriteException = // (logger, level, exception, message) => { ((ILogger)logger).Write(level, exception, message, new object[]); } - MethodInfo writeExceptionMethodInfo = loggerType.GetMethodPortable("Write", + MethodInfo writeExceptionMethodInfo = loggerType.GetMethodPortable("Write", logEventLevelType, typeof(Exception), typeof(string), @@ -1842,7 +1941,7 @@ static SerilogLogger() messageParam, propertyValuesParam); WriteException = Expression.Lambda>( - writeMethodExp, + writeMethodExp, instanceParam, levelParam, exceptionParam, @@ -1911,6 +2010,9 @@ private static object TranslateLevel(LogLevel logLevel) } } +#if !LIBLOG_PORTABLE + [ExcludeFromCodeCoverage] +#endif internal class LoupeLogProvider : LogProviderBase { /// @@ -1978,13 +2080,16 @@ private static WriteDelegate GetLogWriteDelegate() MethodInfo method = logManagerType.GetMethodPortable( "Write", - logMessageSeverityType, typeof(string), typeof(int), typeof(Exception), typeof(bool), + logMessageSeverityType, typeof(string), typeof(int), typeof(Exception), typeof(bool), logWriteModeType, typeof(string), typeof(string), typeof(string), typeof(string), typeof(object[])); var callDelegate = (WriteDelegate)method.CreateDelegate(typeof(WriteDelegate)); return callDelegate; } +#if !LIBLOG_PORTABLE + [ExcludeFromCodeCoverage] +#endif internal class LoupeLogger { private const string LogSystem = "LibLog"; @@ -2043,6 +2148,9 @@ private static int ToLogMessageSeverity(LogLevel logLevel) } } +#if !LIBLOG_PORTABLE + [ExcludeFromCodeCoverage] +#endif internal static class TraceEventTypeValues { internal static readonly Type Type; @@ -2070,6 +2178,9 @@ static TraceEventTypeValues() } } +#if !LIBLOG_PORTABLE + [ExcludeFromCodeCoverage] +#endif internal static class LogMessageFormatter { //private static readonly Regex Pattern = new Regex(@"\{@?\w{1,}\}"); @@ -2154,6 +2265,9 @@ public static string FormatStructuredMessage(string targetMessage, object[] form } } +#if !LIBLOG_PORTABLE + [ExcludeFromCodeCoverage] +#endif internal static class TypeExtensions { internal static ConstructorInfo GetConstructorPortable(this Type type, params Type[] types) @@ -2243,6 +2357,9 @@ internal static Assembly GetAssemblyPortable(this Type type) } } +#if !LIBLOG_PORTABLE + [ExcludeFromCodeCoverage] +#endif internal class DisposableAction : IDisposable { private readonly Action _onDispose; @@ -2254,7 +2371,7 @@ public DisposableAction(Action onDispose = null) public void Dispose() { - if(_onDispose != null) + if (_onDispose != null) { _onDispose(); } diff --git a/src/GitTools.Core/GitTools.Core.Shared/Logging/Extensions/LogExtensions.cs b/src/GitTools.Core/Logging/Extensions/LogExtensions.cs similarity index 100% rename from src/GitTools.Core/GitTools.Core.Shared/Logging/Extensions/LogExtensions.cs rename to src/GitTools.Core/Logging/Extensions/LogExtensions.cs diff --git a/src/GitTools.Core/Pollyfill/SerializableAttribute.cs b/src/GitTools.Core/Pollyfill/SerializableAttribute.cs new file mode 100644 index 0000000..82ed059 --- /dev/null +++ b/src/GitTools.Core/Pollyfill/SerializableAttribute.cs @@ -0,0 +1,9 @@ +#if !NET40 +namespace System.Runtime.Serialization +{ + public class SerializableAttribute : Attribute + { + } + } +#endif + From b8179f891429a625d214d6bec3cfd7ed12f9f6ba Mon Sep 17 00:00:00 2001 From: Peder Husom Date: Mon, 3 Jul 2017 08:24:29 +0200 Subject: [PATCH 2/7] Removed SerializationInfo, not used --- src/GitTools.Core/Exceptions/WarningException.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/GitTools.Core/Exceptions/WarningException.cs b/src/GitTools.Core/Exceptions/WarningException.cs index fff3cc6..0fb19a9 100644 --- a/src/GitTools.Core/Exceptions/WarningException.cs +++ b/src/GitTools.Core/Exceptions/WarningException.cs @@ -10,11 +10,5 @@ public WarningException(string message) : base(message) { } - - - protected WarningException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } } \ No newline at end of file From ebe431ab2ee7d17a0a262f28eb24cae59399f96f Mon Sep 17 00:00:00 2001 From: Peder Husom Date: Mon, 3 Jul 2017 08:25:13 +0200 Subject: [PATCH 3/7] Added newer version of JetBrains.Annotations --- src/GitTools.Core/GitTools.Core.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/GitTools.Core/GitTools.Core.csproj b/src/GitTools.Core/GitTools.Core.csproj index 3985d17..a1cdc36 100644 --- a/src/GitTools.Core/GitTools.Core.csproj +++ b/src/GitTools.Core/GitTools.Core.csproj @@ -10,6 +10,7 @@ + From 5b60228f7394d5bee4a39a5c09d1aaab318289c9 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Fri, 28 Jul 2017 16:50:06 +0100 Subject: [PATCH 4/7] NetStandard Build --- .travis.yml | 19 +++- appveyor.yml | 23 ++-- .../Git/GitRepositoryHelperTests.cs | 3 + .../GitTools.Core.Tests.csproj | 100 ++++++------------ .../Properties/AssemblyInfo.cs | 4 - src/GitTools.Core.Tests/app.config | 4 +- src/GitTools.Core.Tests/packages.config | 10 -- src/GitTools.Core.sln | 14 +-- src/GitTools.Core/Diposable.cs | 2 +- .../Exceptions/GitToolsException.cs | 9 ++ .../Exceptions/WarningException.cs | 7 ++ src/GitTools.Core/Git/DynamicRepositories.cs | 2 +- .../AuthenticationInfoExtensions.cs | 2 +- .../Git/Extensions/LibGitExtensions.cs | 6 +- .../Git/Helpers/GitRepositoryHelper.cs | 2 +- src/GitTools.Core/Git/RepositoryLoader.cs | 2 +- src/GitTools.Core/GitTools.Core.csproj | 69 +++++++++++- src/GitTools.Core/Helpers/ProcessHelper.cs | 8 +- src/GitTools.Core/IO/TemporaryFilesContext.cs | 2 +- .../Pollyfill/SerializableAttribute.cs | 9 -- 20 files changed, 171 insertions(+), 126 deletions(-) delete mode 100644 src/GitTools.Core.Tests/Properties/AssemblyInfo.cs delete mode 100644 src/GitTools.Core.Tests/packages.config delete mode 100644 src/GitTools.Core/Pollyfill/SerializableAttribute.cs diff --git a/.travis.yml b/.travis.yml index ad7c609..b159a85 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,21 @@ language: csharp solution: src/GitTools.Core.sln sudo: false +dotnet: 1.0.3 +dist: trusty +mono: none +addons: + apt: + sources: + - sourceline: 'deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main' + key_url: 'https://apt-mo.trafficmanager.net/keys/microsoft.asc' + packages: + - dotnet-dev-1.0.3 install: # - sudo nuget update -self - - nuget restore src/GitTools.Core.sln - - nuget install NUnit.Runners -Version 3.2.1 -OutputDirectory ./src/packages + - dotnet restore "./src/GitTools.Core.sln" script: - - xbuild ./src/GitTools.Core.sln /property:Configuration="Debug" /verbosity:detailed - - mono --debug --runtime=v4.0.30319 ./src/packages/NUnit.ConsoleRunner.3.2.1/tools/nunit3-console.exe ./output/debug/GitTools.Core.Tests/net45/GitTools.Core.Tests.dll -where "cat != NoMono" + - dotnet restore "./src/GitTools.Core.Tests/GitTools.Core.Tests.csproj" /p:TargetFramework=netcoreapp1.1 /verbosity:detailed + - dotnet build "./src/GitTools.Core.Tests/GitTools.Core.Tests.csproj" --configuration Debug --framework netcoreapp1.1 /verbosity:detailed + - dotnet test ".src/GitTools.Core.Tests/GitTools.Core.Tests.csproj" --framework netcoreapp1.1 + # - mono --debug --runtime=v4.0.30319 %userprofile%.nuget/packages/nunit.consolerunner/3.6.1/tools/nunit3-console.exe ./output/debug/GitTools.Core.Tests/net45/GitTools.Core.Tests.dll -where "cat != NoMono" diff --git a/appveyor.yml b/appveyor.yml index 4dc2c7c..0e59d5e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,27 +1,28 @@ +environment: + path_to_sln: src/GitTools.Core.sln + install: - choco install gitversion.portable -pre -y - cinst gitlink -y -platform: - - Any CPU - -configuration: - - Release +platform: Any CPU +configuration: Release +image: Visual Studio 2017 assembly_info: patch: false before_build: - - nuget restore src\ - ps: gitversion /l console /output buildserver /updateAssemblyInfo src\SolutionAssemblyInfo.cs + - cmd: msbuild %path_to_sln% /t:restore /p:PackageVersion=%GitVersion_NuGetVersion% /p:Configuration=Release /p:Platform="Any CPU" -build: - project: src\GitTools.Core.sln +build_script: + - cmd: msbuild %path_to_sln% /t:Build /p:Configuration=Release /p:Platform="Any CPU" after_build: - - cmd: gitlink . -u https://github.com/gittools/gittools.core -b %APPVEYOR_REPO_BRANCH% -s %APPVEYOR_REPO_COMMIT% -f src\GitTools.Core.sln - - cmd: nuget pack src\GitTools.Core\GitTools.Core.nuspec -BasePath output\%CONFIGURATION%\GitTools.Core\ -version "%GitVersion_NuGetVersion%" + - cmd: gitlink . -u https://github.com/gittools/gittools.core -b %APPVEYOR_REPO_BRANCH% -s %APPVEYOR_REPO_COMMIT% -f %path_to_sln% + - cmd: msbuild %path_to_sln% /t:Pack /p:PackageVersion=%GitVersion_NuGetVersion% /p:PackageOutputPath="%APPVEYOR_BUILD_FOLDER%" - cmd: appveyor PushArtifact "GitTools.Core.%GitVersion_NuGetVersion%.nupkg" cache: - - src\packages -> **\packages.config # preserve "packages" directory in the root of build folder but will reset it if packages.config is modified + - src\packages -> **\packages.config # preserve "packages" directory in the root of build folder but will reset it if packages.config is modified \ No newline at end of file diff --git a/src/GitTools.Core.Tests/Git/GitRepositoryHelperTests.cs b/src/GitTools.Core.Tests/Git/GitRepositoryHelperTests.cs index e5a77ba..db79be5 100644 --- a/src/GitTools.Core.Tests/Git/GitRepositoryHelperTests.cs +++ b/src/GitTools.Core.Tests/Git/GitRepositoryHelperTests.cs @@ -219,7 +219,10 @@ public void GitHubFlowMajorRelease() fixture.ApplyTag("2.0.0"); // fixture.AssertFullSemver("2.0.0"); fixture.MakeACommit(); + +#if !NETCOREAPP1_1 fixture.Repository.DumpGraph(); +#endif // fixture.AssertFullSemver("2.0.1+1"); } } diff --git a/src/GitTools.Core.Tests/GitTools.Core.Tests.csproj b/src/GitTools.Core.Tests/GitTools.Core.Tests.csproj index b3ab6c9..afad382 100644 --- a/src/GitTools.Core.Tests/GitTools.Core.Tests.csproj +++ b/src/GitTools.Core.Tests/GitTools.Core.Tests.csproj @@ -1,26 +1,19 @@  - - - + Debug AnyCPU - {0834BE9B-5CDE-4CAB-A683-C70A7D91450B} + Library - Properties - GitTools.Tests - GitTools.Core.Tests - v4.5 - 512 - 5 - - + net46 + netcoreapp1.1;net46 + true full false - ..\..\output\debug\GitTools.Core.Tests\net45\ + ..\..\output\debug\GitTools.Core.Tests\$(TargetFramework)\ TRACE;DEBUG prompt 4 @@ -30,68 +23,45 @@ pdbonly true - ..\..\output\release\GitTools.Core.Tests\net45\ + ..\..\output\release\GitTools.Core.Tests\$(TargetFramework)\ TRACE prompt 4 true 1591 - - - False - ..\packages\Atlassian.SDK.2.5.0\lib\Atlassian.Jira.dll - - - ..\packages\GitTools.Testing.1.1.1-beta0001\lib\net4\GitTools.Testing.dll - True - - - ..\packages\LibGit2Sharp.0.23.0-pre20160922233542\lib\net40\LibGit2Sharp.dll - True - - - ..\packages\NUnit.3.5.0\lib\net45\nunit.framework.dll - True - - - ..\packages\Shouldly.2.8.2\lib\net40\Shouldly.dll - True - - - - - - - - - + + + + + + + + - - - Properties\SolutionAssemblyInfo.cs - - - - - - - + + + - - - + + + + + + - - - - - - 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}. - - - + + + + + + + + + + + + Library + netstandard1.3;net45;net40 + + GitTools.Core + GitTools.Core + GitTools Contributors + https://github.com/GitTools/GitTools.Core + false + git tools + Core library for GitTools + Copyright GitTools 2015. + https://github.com/GitTools/GitTools.Core/blob/master/LICENSE + https://raw.github.com/GitTools/GitTools.Core/master/GitTools_logo.png - - TRACE;DEBUG;LIBLOG_PORTABLE;NETSTANDARD1_0; + + + TRACE;NET45;NETDESKTOP + + + TRACE;NET40;NETDESKTOP + + + + TRACE;LIBLOG_PORTABLE;NETSTANDARD1_3; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/GitTools.Core/Helpers/ProcessHelper.cs b/src/GitTools.Core/Helpers/ProcessHelper.cs index f962a09..2e57085 100644 --- a/src/GitTools.Core/Helpers/ProcessHelper.cs +++ b/src/GitTools.Core/Helpers/ProcessHelper.cs @@ -1,5 +1,6 @@ +#if !NETSTANDARD1_3 namespace GitTools -{ +{ using System; using System.Collections.Generic; using System.ComponentModel; @@ -7,6 +8,7 @@ namespace GitTools using System.IO; using System.Runtime.InteropServices; using System.Threading; + public static class ProcessHelper { @@ -209,4 +211,6 @@ void IDisposable.Dispose() static extern int SetErrorMode(int newMode); } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/src/GitTools.Core/IO/TemporaryFilesContext.cs b/src/GitTools.Core/IO/TemporaryFilesContext.cs index 7ebbe81..afc8430 100644 --- a/src/GitTools.Core/IO/TemporaryFilesContext.cs +++ b/src/GitTools.Core/IO/TemporaryFilesContext.cs @@ -6,7 +6,7 @@ public class TemporaryFilesContext : IDisposable { - private static readonly ILog Log = LogProvider.GetCurrentClassLogger(); + static readonly ILog Log = LogProvider.GetLogger(typeof(TemporaryFilesContext)); private readonly Guid _randomGuid = Guid.NewGuid(); private readonly string _rootDirectory; diff --git a/src/GitTools.Core/Pollyfill/SerializableAttribute.cs b/src/GitTools.Core/Pollyfill/SerializableAttribute.cs deleted file mode 100644 index 82ed059..0000000 --- a/src/GitTools.Core/Pollyfill/SerializableAttribute.cs +++ /dev/null @@ -1,9 +0,0 @@ -#if !NET40 -namespace System.Runtime.Serialization -{ - public class SerializableAttribute : Attribute - { - } - } -#endif - From 2732832970e3295022b5f3a9f4cd0af70ae07011 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Fri, 28 Jul 2017 16:57:02 +0100 Subject: [PATCH 5/7] Travis build script fix. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b159a85..f40937c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,5 +17,5 @@ install: script: - dotnet restore "./src/GitTools.Core.Tests/GitTools.Core.Tests.csproj" /p:TargetFramework=netcoreapp1.1 /verbosity:detailed - dotnet build "./src/GitTools.Core.Tests/GitTools.Core.Tests.csproj" --configuration Debug --framework netcoreapp1.1 /verbosity:detailed - - dotnet test ".src/GitTools.Core.Tests/GitTools.Core.Tests.csproj" --framework netcoreapp1.1 + - dotnet test "./src/GitTools.Core.Tests/GitTools.Core.Tests.csproj" --framework netcoreapp1.1 # - mono --debug --runtime=v4.0.30319 %userprofile%.nuget/packages/nunit.consolerunner/3.6.1/tools/nunit3-console.exe ./output/debug/GitTools.Core.Tests/net45/GitTools.Core.Tests.dll -where "cat != NoMono" From c0b40be79b3a0efb34a572af88ac9c5fdc3cc798 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Fri, 28 Jul 2017 17:19:54 +0100 Subject: [PATCH 6/7] Travis - try to filter out NoMono tests --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f40937c..8893245 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,5 +17,5 @@ install: script: - dotnet restore "./src/GitTools.Core.Tests/GitTools.Core.Tests.csproj" /p:TargetFramework=netcoreapp1.1 /verbosity:detailed - dotnet build "./src/GitTools.Core.Tests/GitTools.Core.Tests.csproj" --configuration Debug --framework netcoreapp1.1 /verbosity:detailed - - dotnet test "./src/GitTools.Core.Tests/GitTools.Core.Tests.csproj" --framework netcoreapp1.1 + - dotnet test "./src/GitTools.Core.Tests/GitTools.Core.Tests.csproj" --framework netcoreapp1.1 --filter TestCategory!=NoMono # - mono --debug --runtime=v4.0.30319 %userprofile%.nuget/packages/nunit.consolerunner/3.6.1/tools/nunit3-console.exe ./output/debug/GitTools.Core.Tests/net45/GitTools.Core.Tests.dll -where "cat != NoMono" From 63ee2ac91991a69f7268c4c37f82648081a07269 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Fri, 28 Jul 2017 17:25:27 +0100 Subject: [PATCH 7/7] Fixed issue with incorrect Platform in csproj --- .../GitTools.Core.Tests.csproj | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/GitTools.Core.Tests/GitTools.Core.Tests.csproj b/src/GitTools.Core.Tests/GitTools.Core.Tests.csproj index afad382..0073876 100644 --- a/src/GitTools.Core.Tests/GitTools.Core.Tests.csproj +++ b/src/GitTools.Core.Tests/GitTools.Core.Tests.csproj @@ -2,7 +2,7 @@ Debug - AnyCPU + Any CPU Library net46 @@ -11,24 +11,15 @@ true - full - false + full ..\..\output\debug\GitTools.Core.Tests\$(TargetFramework)\ - TRACE;DEBUG - prompt - 4 - true - 1591,1701 + TRACE;DEBUG pdbonly true ..\..\output\release\GitTools.Core.Tests\$(TargetFramework)\ - TRACE - prompt - 4 - true - 1591 + TRACE