Initial commit of Dependify

This commit is contained in:
David Kaya
2017-09-09 22:45:06 +02:00
parent 456bcf1fa7
commit b5626dadb1
17 changed files with 602 additions and 0 deletions

54
Dependify.sln Normal file
View File

@@ -0,0 +1,54 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26124.0
MinimumVisualStudioVersion = 15.0.26124.0
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{782FBD9E-6CF9-4521-ADE7-DCEC2D916FDF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dependify", "src\Dependify\Dependify.csproj", "{011819CE-229A-48D1-99A7-25A6D5DD5CA4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dependify.Test", "src\Dependify.Test\Dependify.Test.csproj", "{BD19041B-FC13-456A-9F3E-7823B9EF5E70}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{011819CE-229A-48D1-99A7-25A6D5DD5CA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{011819CE-229A-48D1-99A7-25A6D5DD5CA4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{011819CE-229A-48D1-99A7-25A6D5DD5CA4}.Debug|x64.ActiveCfg = Debug|x64
{011819CE-229A-48D1-99A7-25A6D5DD5CA4}.Debug|x64.Build.0 = Debug|x64
{011819CE-229A-48D1-99A7-25A6D5DD5CA4}.Debug|x86.ActiveCfg = Debug|x86
{011819CE-229A-48D1-99A7-25A6D5DD5CA4}.Debug|x86.Build.0 = Debug|x86
{011819CE-229A-48D1-99A7-25A6D5DD5CA4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{011819CE-229A-48D1-99A7-25A6D5DD5CA4}.Release|Any CPU.Build.0 = Release|Any CPU
{011819CE-229A-48D1-99A7-25A6D5DD5CA4}.Release|x64.ActiveCfg = Release|x64
{011819CE-229A-48D1-99A7-25A6D5DD5CA4}.Release|x64.Build.0 = Release|x64
{011819CE-229A-48D1-99A7-25A6D5DD5CA4}.Release|x86.ActiveCfg = Release|x86
{011819CE-229A-48D1-99A7-25A6D5DD5CA4}.Release|x86.Build.0 = Release|x86
{BD19041B-FC13-456A-9F3E-7823B9EF5E70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BD19041B-FC13-456A-9F3E-7823B9EF5E70}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BD19041B-FC13-456A-9F3E-7823B9EF5E70}.Debug|x64.ActiveCfg = Debug|x64
{BD19041B-FC13-456A-9F3E-7823B9EF5E70}.Debug|x64.Build.0 = Debug|x64
{BD19041B-FC13-456A-9F3E-7823B9EF5E70}.Debug|x86.ActiveCfg = Debug|x86
{BD19041B-FC13-456A-9F3E-7823B9EF5E70}.Debug|x86.Build.0 = Debug|x86
{BD19041B-FC13-456A-9F3E-7823B9EF5E70}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BD19041B-FC13-456A-9F3E-7823B9EF5E70}.Release|Any CPU.Build.0 = Release|Any CPU
{BD19041B-FC13-456A-9F3E-7823B9EF5E70}.Release|x64.ActiveCfg = Release|x64
{BD19041B-FC13-456A-9F3E-7823B9EF5E70}.Release|x64.Build.0 = Release|x64
{BD19041B-FC13-456A-9F3E-7823B9EF5E70}.Release|x86.ActiveCfg = Release|x86
{BD19041B-FC13-456A-9F3E-7823B9EF5E70}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{011819CE-229A-48D1-99A7-25A6D5DD5CA4} = {782FBD9E-6CF9-4521-ADE7-DCEC2D916FDF}
{BD19041B-FC13-456A-9F3E-7823B9EF5E70} = {782FBD9E-6CF9-4521-ADE7-DCEC2D916FDF}
EndGlobalSection
EndGlobal

209
Dependify.sln.DotSettings Normal file
View File

@@ -0,0 +1,209 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/CodeAnnotations/NamespacesWithAnnotations/=ClientUi_002EAnnotations/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Emin_002Ejs/@EntryIndexedValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=FlexiSpooler/@EntryIndexedValue">&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;Profile name="FlexiSpooler"&gt;&lt;RemoveCodeRedundancies&gt;True&lt;/RemoveCodeRedundancies&gt;&lt;CSMakeFieldReadonly&gt;True&lt;/CSMakeFieldReadonly&gt;&lt;CSMakeAutoPropertyGetOnly&gt;True&lt;/CSMakeAutoPropertyGetOnly&gt;&lt;CSEnforceVarKeywordUsageSettings&gt;True&lt;/CSEnforceVarKeywordUsageSettings&gt;&lt;CSOptimizeUsings&gt;&lt;OptimizeUsings&gt;True&lt;/OptimizeUsings&gt;&lt;EmbraceInRegion&gt;False&lt;/EmbraceInRegion&gt;&lt;RegionName&gt;&lt;/RegionName&gt;&lt;/CSOptimizeUsings&gt;&lt;CSShortenReferences&gt;True&lt;/CSShortenReferences&gt;&lt;CSReformatCode&gt;True&lt;/CSReformatCode&gt;&lt;CSharpFormatDocComments&gt;True&lt;/CSharpFormatDocComments&gt;&lt;/Profile&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/CodeCleanup/SilentCleanupProfile/@EntryValue">FlexiSpooler</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ACCESSOR_DECLARATION_BRACES/@EntryValue">END_OF_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ACCESSOR_OWNER_DECLARATION_BRACES/@EntryValue">END_OF_LINE</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_BINARY_EXPRESSIONS_CHAIN/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALLOW_COMMENT_AFTER_LBRACE/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue">END_OF_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/CASE_BLOCK_BRACES/@EntryValue">END_OF_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/EMPTY_BLOCK_STYLE/@EntryValue">TOGETHER_SAME_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_FIXED_BRACES_STYLE/@EntryValue">ALWAYS_REMOVE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_FOR_BRACES_STYLE/@EntryValue">ALWAYS_REMOVE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_FOREACH_BRACES_STYLE/@EntryValue">ALWAYS_REMOVE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_IFELSE_BRACES_STYLE/@EntryValue">ALWAYS_REMOVE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_USING_BRACES_STYLE/@EntryValue">ALWAYS_REMOVE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_WHILE_BRACES_STYLE/@EntryValue">ALWAYS_REMOVE</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_NESTED_FIXED_STMT/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_NESTED_USINGS_STMT/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INITIALIZER_BRACES/@EntryValue">END_OF_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INVOCABLE_DECLARATION_BRACES/@EntryValue">END_OF_LINE</s:String>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_BLANK_LINES_IN_CODE/@EntryValue">1</s:Int64>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_BLANK_LINES_IN_DECLARATIONS/@EntryValue">1</s:Int64>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/OTHER_BRACES/@EntryValue">END_OF_LINE</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_CATCH_ON_NEW_LINE/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_ELSE_ON_NEW_LINE/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_FIELD_ATTRIBUTE_ON_SAME_LINE/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_FINALLY_ON_NEW_LINE/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_ACCESSOR_ATTRIBUTE_ON_SAME_LINE/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SIMPLE_EMBEDDED_STATEMENT_STYLE/@EntryValue">LINE_BREAK</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_AFTER_TYPECAST_PARENTHESES/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_AROUND_ARROW_OP/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_AROUND_MULTIPLICATIVE_OP/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_BEFORE_COLON_IN_CASE/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_BEFORE_SIZEOF_PARENTHESES/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_BEFORE_TYPEOF_PARENTHESES/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_WITHIN_SINGLE_LINE_ARRAY_INITIALIZER_BRACES/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/STICK_COMMENT/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/TYPE_DECLARATION_BRACES/@EntryValue">END_OF_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_FOR_STMT_HEADER_STYLE/@EntryValue">WRAP_IF_LONG</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_CHAINED_METHOD_CALLS/@EntryValue">WRAP_IF_LONG</s:String>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_LIMIT/@EntryValue">150</s:Int64>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_LINES/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_LINQ_EXPRESSIONS/@EntryValue">WRAP_IF_LONG</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_MULTIPLE_DECLARATION_STYLE/@EntryValue">WRAP_IF_LONG</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_MULTIPLE_TYPE_PARAMEER_CONSTRAINTS_STYLE/@EntryValue">WRAP_IF_LONG</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_OBJECT_AND_COLLECTION_INITIALIZER_STYLE/@EntryValue">WRAP_IF_LONG</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_TERNARY_EXPR_STYLE/@EntryValue">WRAP_IF_LONG</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/XmlDocFormatter/IndentSubtags/@EntryValue">RemoveIndent</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/XmlDocFormatter/IndentTagContent/@EntryValue">RemoveIndent</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/XmlDocFormatter/TagSpaceBeforeHeaderEnd1/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/XmlDocFormatter/WrapLongLines/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/XmlDocFormatter/WRAP_LINES/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CSharpFileLayoutPatterns/Pattern/@EntryValue">&lt;?xml version="1.0" encoding="utf-16"?&gt;&#xD;
&lt;Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns"&gt;&#xD;
&lt;TypePattern DisplayName="COM interfaces or structs"&gt;&#xD;
&lt;TypePattern.Match&gt;&#xD;
&lt;Or&gt;&#xD;
&lt;And&gt;&#xD;
&lt;Kind Is="Interface" /&gt;&#xD;
&lt;Or&gt;&#xD;
&lt;HasAttribute Name="System.Runtime.InteropServices.InterfaceTypeAttribute" /&gt;&#xD;
&lt;HasAttribute Name="System.Runtime.InteropServices.ComImport" /&gt;&#xD;
&lt;/Or&gt;&#xD;
&lt;/And&gt;&#xD;
&lt;Kind Is="Struct" /&gt;&#xD;
&lt;/Or&gt;&#xD;
&lt;/TypePattern.Match&gt;&#xD;
&lt;/TypePattern&gt;&#xD;
&lt;TypePattern DisplayName="NUnit Test Fixtures" RemoveRegions="All"&gt;&#xD;
&lt;TypePattern.Match&gt;&#xD;
&lt;And&gt;&#xD;
&lt;Kind Is="Class" /&gt;&#xD;
&lt;HasAttribute Name="NUnit.Framework.TestFixtureAttribute" Inherited="True" /&gt;&#xD;
&lt;HasAttribute Name="NUnit.Framework.TestCaseFixtureAttribute" Inherited="True" /&gt;&#xD;
&lt;/And&gt;&#xD;
&lt;/TypePattern.Match&gt;&#xD;
&lt;Entry DisplayName="Setup/Teardown Methods"&gt;&#xD;
&lt;Entry.Match&gt;&#xD;
&lt;And&gt;&#xD;
&lt;Kind Is="Method" /&gt;&#xD;
&lt;Or&gt;&#xD;
&lt;HasAttribute Name="NUnit.Framework.SetUpAttribute" Inherited="True" /&gt;&#xD;
&lt;HasAttribute Name="NUnit.Framework.TearDownAttribute" Inherited="True" /&gt;&#xD;
&lt;HasAttribute Name="NUnit.Framework.FixtureSetUpAttribute" Inherited="True" /&gt;&#xD;
&lt;HasAttribute Name="NUnit.Framework.FixtureTearDownAttribute" Inherited="True" /&gt;&#xD;
&lt;/Or&gt;&#xD;
&lt;/And&gt;&#xD;
&lt;/Entry.Match&gt;&#xD;
&lt;/Entry&gt;&#xD;
&lt;Entry DisplayName="All other members" /&gt;&#xD;
&lt;Entry Priority="100" DisplayName="Test Methods"&gt;&#xD;
&lt;Entry.Match&gt;&#xD;
&lt;And&gt;&#xD;
&lt;Kind Is="Method" /&gt;&#xD;
&lt;HasAttribute Name="NUnit.Framework.TestAttribute" /&gt;&#xD;
&lt;/And&gt;&#xD;
&lt;/Entry.Match&gt;&#xD;
&lt;Entry.SortBy&gt;&#xD;
&lt;Name /&gt;&#xD;
&lt;/Entry.SortBy&gt;&#xD;
&lt;/Entry&gt;&#xD;
&lt;/TypePattern&gt;&#xD;
&lt;TypePattern DisplayName="Default Pattern"&gt;&#xD;
&lt;Entry DisplayName="Nested Types"&gt;&#xD;
&lt;Entry.Match&gt;&#xD;
&lt;Kind Is="Type" /&gt;&#xD;
&lt;/Entry.Match&gt;&#xD;
&lt;/Entry&gt;&#xD;
&lt;Entry Priority="100" DisplayName="Public Delegates"&gt;&#xD;
&lt;Entry.Match&gt;&#xD;
&lt;And&gt;&#xD;
&lt;Access Is="Public" /&gt;&#xD;
&lt;Kind Is="Delegate" /&gt;&#xD;
&lt;/And&gt;&#xD;
&lt;/Entry.Match&gt;&#xD;
&lt;Entry.SortBy&gt;&#xD;
&lt;Name /&gt;&#xD;
&lt;/Entry.SortBy&gt;&#xD;
&lt;/Entry&gt;&#xD;
&lt;Entry Priority="100" DisplayName="Public Enums"&gt;&#xD;
&lt;Entry.Match&gt;&#xD;
&lt;And&gt;&#xD;
&lt;Access Is="Public" /&gt;&#xD;
&lt;Kind Is="Enum" /&gt;&#xD;
&lt;/And&gt;&#xD;
&lt;/Entry.Match&gt;&#xD;
&lt;Entry.SortBy&gt;&#xD;
&lt;Name /&gt;&#xD;
&lt;/Entry.SortBy&gt;&#xD;
&lt;/Entry&gt;&#xD;
&lt;Entry DisplayName="Static Fields and Constants"&gt;&#xD;
&lt;Entry.Match&gt;&#xD;
&lt;Or&gt;&#xD;
&lt;Kind Is="Constant" /&gt;&#xD;
&lt;And&gt;&#xD;
&lt;Kind Is="Field" /&gt;&#xD;
&lt;Static /&gt;&#xD;
&lt;/And&gt;&#xD;
&lt;/Or&gt;&#xD;
&lt;/Entry.Match&gt;&#xD;
&lt;Entry.SortBy&gt;&#xD;
&lt;Kind Order="Constant Field" /&gt;&#xD;
&lt;/Entry.SortBy&gt;&#xD;
&lt;/Entry&gt;&#xD;
&lt;Entry DisplayName="Fields"&gt;&#xD;
&lt;Entry.Match&gt;&#xD;
&lt;And&gt;&#xD;
&lt;Kind Is="Field" /&gt;&#xD;
&lt;Not&gt;&#xD;
&lt;Static /&gt;&#xD;
&lt;/Not&gt;&#xD;
&lt;/And&gt;&#xD;
&lt;/Entry.Match&gt;&#xD;
&lt;Entry.SortBy&gt;&#xD;
&lt;Readonly /&gt;&#xD;
&lt;Name /&gt;&#xD;
&lt;/Entry.SortBy&gt;&#xD;
&lt;/Entry&gt;&#xD;
&lt;Entry DisplayName="Properties, Indexers"&gt;&#xD;
&lt;Entry.Match&gt;&#xD;
&lt;Or&gt;&#xD;
&lt;Kind Is="Property" /&gt;&#xD;
&lt;Kind Is="Indexer" /&gt;&#xD;
&lt;/Or&gt;&#xD;
&lt;/Entry.Match&gt;&#xD;
&lt;/Entry&gt;&#xD;
&lt;Entry DisplayName="Constructors"&gt;&#xD;
&lt;Entry.Match&gt;&#xD;
&lt;Kind Is="Constructor" /&gt;&#xD;
&lt;/Entry.Match&gt;&#xD;
&lt;Entry.SortBy&gt;&#xD;
&lt;Static /&gt;&#xD;
&lt;/Entry.SortBy&gt;&#xD;
&lt;/Entry&gt;&#xD;
&lt;Entry Priority="100" DisplayName="Interface Implementations"&gt;&#xD;
&lt;Entry.Match&gt;&#xD;
&lt;And&gt;&#xD;
&lt;Kind Is="Member" /&gt;&#xD;
&lt;ImplementsInterface /&gt;&#xD;
&lt;/And&gt;&#xD;
&lt;/Entry.Match&gt;&#xD;
&lt;Entry.SortBy&gt;&#xD;
&lt;ImplementsInterface Immediate="True" /&gt;&#xD;
&lt;/Entry.SortBy&gt;&#xD;
&lt;/Entry&gt;&#xD;
&lt;Entry DisplayName="All other members" /&gt;&#xD;
&lt;/TypePattern&gt;&#xD;
&lt;/Patterns&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateConstants/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=bb3a058d_002D2c91_002D42a0_002D8428_002De9c9cc4b488a/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static, Instance" AccessRightKinds="Protected" Description=""&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;Kind Name="CONSTANT_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpAttributeForSingleLineMethodUpgrade/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAlwaysTreatStructAsNotReorderableMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002EXml_002ECodeStyle_002EFormatSettingsUpgrade_002EXmlMoveToCommonFormatterSettingsUpgrade/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EUnitTestFramework_002ESettings_002EMigrations_002ERemoveBuildPolicyAlwaysMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/UnitTesting/SaveSessionState/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/UnitTesting/SeparateAppDomainPerAssembly/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/Environment/UnitTesting/ShadowCopy/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/Housekeeping/UnitTestingMru/UnitTestSessionDefault/PlatformType/@EntryValue">x64</s:String>
<s:String x:Key="/Default/Housekeeping/UnitTestingMru/UnitTestSessionDefault/PlatformVersion/@EntryValue">v4_5</s:String></wpf:ResourceDictionary>

5
global.json Normal file
View File

@@ -0,0 +1,5 @@
{
"sdk": {
"version": "2.0.0"
}
}

View File

@@ -0,0 +1,67 @@
using System;
using Dependify;
using Dependify.Attributes;
using ShouldRegisterScoped;
using ShouldRegisterSingleton;
using ShouldRegisterTransient;
public interface IInterface { }
public interface IInterface2 { }
namespace ShouldRegisterTransient {
[RegisterTransient]
public class ImplementationTransient : IInterface { }
}
namespace ShouldRegisterScoped {
[RegisterScoped]
public class ImplementationScoped : IInterface { }
}
namespace ShouldRegisterSingleton {
[RegisterSingleton]
public class ImplementationSingleton : IInterface { }
}
namespace ShouldRegisterOneTransient {
[RegisterTransient(typeof(IInterface2))]
public class ImplementationTransientOneInterface : IInterface, IInterface2 { }
}
namespace ShouldRegisterOneScoped {
[RegisterScoped(typeof(IInterface2))]
public class ImplementationScopedOneInterface : IInterface, IInterface2 { }
}
namespace ShouldRegisterOneSingleton {
[RegisterSingleton(typeof(IInterface2))]
public class ImplementationSingletonOneInterface : IInterface, IInterface2 { }
}
namespace ShouldRegisterFactoryTransient {
public class TransientFactory {
[RegisterTransientFactory(typeof(IInterface))]
public static ImplementationTransient CreateImplementationTransient(IServiceProvider provider) {
return new ImplementationTransient();
}
}
}
namespace ShouldRegisterFactoryScoped {
public class ScopedFactory {
[RegisterScopedFactory(typeof(IInterface))]
public static ImplementationScoped CreateImplementationTransient(IServiceProvider provider) {
return new ImplementationScoped();
}
}
}
namespace ShouldRegisterFactorySingleton {
public class SingletonFactory {
[RegisterSingletonFactory(typeof(IInterface))]
public static ImplementationSingleton CreateImplementationTransient(IServiceProvider provider) {
return new ImplementationSingleton();
}
}
}

View File

@@ -0,0 +1,45 @@
using System;
using System.Linq;
using Microsoft.Extensions.DependencyInjection;
using NUnit.Framework;
using ShouldRegisterOneScoped;
using ShouldRegisterOneSingleton;
using ShouldRegisterOneTransient;
using ShouldRegisterScoped;
using ShouldRegisterSingleton;
using ShouldRegisterTransient;
namespace Dependify.Test {
[TestFixture]
public class RegisterAttributeTests {
[TestCase(nameof(ShouldRegisterTransient), typeof(ImplementationTransient), typeof(IInterface), ServiceLifetime.Transient)]
[TestCase(nameof(ShouldRegisterSingleton), typeof(ImplementationSingleton), typeof(IInterface), ServiceLifetime.Singleton)]
[TestCase(nameof(ShouldRegisterScoped), typeof(ImplementationScoped), typeof(IInterface), ServiceLifetime.Scoped)]
[TestCase(nameof(ShouldRegisterOneTransient), typeof(ImplementationTransientOneInterface), typeof(IInterface2), ServiceLifetime.Transient)]
[TestCase(nameof(ShouldRegisterOneSingleton), typeof(ImplementationSingletonOneInterface), typeof(IInterface2), ServiceLifetime.Singleton)]
[TestCase(nameof(ShouldRegisterOneScoped), typeof(ImplementationScopedOneInterface), typeof(IInterface2), ServiceLifetime.Scoped)]
public void RegisterAttribute_RegistersClass_WhenDefined(string @namespace, Type classType, Type interfaceType, ServiceLifetime serviceLifetime) {
IServiceCollection services = new ServiceCollection();
services.AutoRegister(@namespace);
var service = services.First();
Assert.AreEqual(1, services.Count);
Assert.AreEqual(interfaceType, service.ServiceType);
Assert.AreEqual(classType, service.ImplementationType);
Assert.AreEqual(serviceLifetime, service.Lifetime);
}
[TestCase(nameof(ShouldRegisterFactoryTransient), typeof(ImplementationTransient), typeof(IInterface), ServiceLifetime.Transient)]
[TestCase(nameof(ShouldRegisterFactorySingleton), typeof(ImplementationSingleton), typeof(IInterface), ServiceLifetime.Singleton)]
[TestCase(nameof(ShouldRegisterFactoryScoped), typeof(ImplementationScoped), typeof(IInterface), ServiceLifetime.Scoped)]
public void RegisterFactoryAttribute_RegistersFactoryForInterface_WhenDefined(string @namespace, Type classType, Type interfaceType, ServiceLifetime serviceLifetime) {
IServiceCollection services = new ServiceCollection();
services.AutoRegister(@namespace);
var service = services.First();
Assert.AreEqual(1, services.Count);
Assert.AreEqual(interfaceType, service.ServiceType);
Assert.NotNull(service.ImplementationFactory);
Assert.AreEqual(serviceLifetime, service.Lifetime);
}
}
}

View File

@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="dotnet-test-nunit" Version="3.4.0-beta-3" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0-preview-20170628-02" />
<PackageReference Include="NUnit" Version="3.8.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Dependify\Dependify.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
namespace Dependify.Attributes {
[AttributeUsage(AttributeTargets.Class)]
public abstract class Register : Attribute {
public IEnumerable<Type> InterfaceTypes { get; }
protected Register() { }
protected Register(params Type[] interfaceTypes) {
InterfaceTypes = interfaceTypes;
}
}
}

View File

@@ -0,0 +1,12 @@
using System;
namespace Dependify.Attributes {
[AttributeUsage(AttributeTargets.Method)]
public abstract class RegisterFactory : Attribute {
public Type ReturnType { get; }
protected RegisterFactory(Type returnType) {
ReturnType = returnType;
}
}
}

View File

@@ -0,0 +1,10 @@
using System;
namespace Dependify.Attributes {
[AttributeUsage(AttributeTargets.Class)]
public class RegisterScoped : Register {
public RegisterScoped() { }
public RegisterScoped(params Type[] interfaceTypes) : base(interfaceTypes) { }
}
}

View File

@@ -0,0 +1,8 @@
using System;
namespace Dependify.Attributes {
[AttributeUsage(AttributeTargets.Method)]
public class RegisterScopedFactory : RegisterFactory {
public RegisterScopedFactory(Type returnType) : base(returnType) { }
}
}

View File

@@ -0,0 +1,10 @@
using System;
namespace Dependify.Attributes {
[AttributeUsage(AttributeTargets.Class)]
public class RegisterSingleton : Register {
public RegisterSingleton() { }
public RegisterSingleton(params Type[] interfaceTypes) : base(interfaceTypes) { }
}
}

View File

@@ -0,0 +1,8 @@
using System;
namespace Dependify.Attributes {
[AttributeUsage(AttributeTargets.Method)]
public class RegisterSingletonFactory : RegisterFactory {
public RegisterSingletonFactory(Type returnType) : base(returnType) { }
}
}

View File

@@ -0,0 +1,10 @@
using System;
namespace Dependify.Attributes {
[AttributeUsage(AttributeTargets.Class)]
public class RegisterTransient : Register {
public RegisterTransient() { }
public RegisterTransient(params Type[] interfaceTypes) : base(interfaceTypes) { }
}
}

View File

@@ -0,0 +1,8 @@
using System;
namespace Dependify.Attributes {
[AttributeUsage(AttributeTargets.Method)]
public class RegisterTransientFactory : RegisterFactory {
public RegisterTransientFactory(Type returnType) : base(returnType) { }
}
}

View File

@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Helpers" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Dependify.Attributes;
using Dependify.Utilities;
using Microsoft.Extensions.DependencyInjection;
namespace Dependify {
// ReSharper disable once InconsistentNaming
public static class IServiceCollectionExtensions {
public static IServiceCollection AutoRegister(this IServiceCollection services) {
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
services.AddFactories(DependifyUtils.GetFactoryMethods(assemblies));
services.AddClasses(DependifyUtils.GetClassTypes(assemblies));
return services;
}
public static IServiceCollection AutoRegister(this IServiceCollection services, params Assembly[] assemblies) {
services.AddFactories(DependifyUtils.GetFactoryMethods(assemblies));
services.AddClasses(DependifyUtils.GetClassTypes(assemblies));
return services;
}
public static IServiceCollection AutoRegister(this IServiceCollection services, string @namespace) {
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
services.AddFactories(DependifyUtils.GetFactoryMethodsFromNamespace(assemblies, @namespace));
services.AddClasses(DependifyUtils.GetClassTypesFromNamespace(assemblies, @namespace));
return services;
}
internal static IServiceCollection AddFactories(this IServiceCollection services, IEnumerable<MethodInfo> methodInfos) {
foreach (var methodInfo in methodInfos) {
var factoryAttribute = methodInfo.GetCustomAttributes<RegisterFactory>(true).First();
var factoryAttributeType = factoryAttribute.GetType();
var factoryReturnType = factoryAttribute.ReturnType;
if (factoryAttributeType == typeof(RegisterTransientFactory))
services.AddTransient(factoryReturnType, DependifyUtils.GetFactoryMethod(methodInfo));
if (factoryAttributeType == typeof(RegisterScopedFactory))
services.AddScoped(factoryReturnType, DependifyUtils.GetFactoryMethod(methodInfo));
if (factoryAttributeType == typeof(RegisterSingletonFactory))
services.AddSingleton(factoryReturnType, DependifyUtils.GetFactoryMethod(methodInfo));
}
return services;
}
internal static void AddClasses(this IServiceCollection services, IEnumerable<Type> classTypes) {
foreach (var classType in classTypes) {
var classAttributes = classType.GetCustomAttributes<Register>(true);
foreach (var classAttribute in classAttributes) {
var registrationType = classAttribute.GetType();
var interfaceTypes = classAttribute.InterfaceTypes == null || !classAttribute.InterfaceTypes.Any() ? classType.GetInterfaces() : classAttribute.InterfaceTypes;
foreach (var interfaceType in interfaceTypes) {
if (registrationType == typeof(RegisterTransient))
services.AddTransient(interfaceType, classType);
if (registrationType == typeof(RegisterScoped))
services.AddScoped(interfaceType, classType);
if (registrationType == typeof(RegisterSingleton))
services.AddSingleton(interfaceType, classType);
}
}
}
}
}
}

View File

@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Dependify.Attributes;
namespace Dependify.Utilities {
internal static class DependifyUtils {
internal static IEnumerable<MethodInfo> GetFactoryMethods(IEnumerable<Assembly> assemblies) {
return assemblies
.SelectMany(assembly => assembly.GetTypes())
.Where(type => type.IsClass)
.SelectMany(MethodsWithAttribute);
}
internal static IEnumerable<MethodInfo> GetFactoryMethodsFromNamespace(IEnumerable<Assembly> assemblies, string @namespace) {
return assemblies
.SelectMany(assembly => assembly.GetTypes())
.Where(type => type.IsClass && (type.Namespace?.StartsWith(@namespace)).GetValueOrDefault())
.SelectMany(MethodsWithAttribute);
}
private static IEnumerable<MethodInfo> MethodsWithAttribute(Type type) {
return type.GetMethods(BindingFlags.Static | BindingFlags.Public)
.Where(methodInfo => methodInfo.GetCustomAttributes<RegisterFactory>(true).Any());
}
internal static Func<IServiceProvider, object> GetFactoryMethod(MethodInfo factoryMethodInfo) {
if (!IsFactoryMethod(factoryMethodInfo))
throw new ArgumentException($"{factoryMethodInfo.Name} is not a factory method. ");
return (Func<IServiceProvider, object>)Delegate.CreateDelegate(typeof(Func<IServiceProvider, object>), factoryMethodInfo);
bool IsFactoryMethod(MethodInfo methodInfo) {
var methodParameters = methodInfo.GetParameters();
return methodParameters.Length == 1 && methodParameters.First().ParameterType == typeof(IServiceProvider);
}
}
internal static IEnumerable<Type> GetClassTypes(IEnumerable<Assembly> assemblies) {
return assemblies.SelectMany(assembly => assembly.GetTypes()).Where(type => type.IsClass);
}
internal static IEnumerable<Type> GetClassTypesFromNamespace(IEnumerable<Assembly> assemblies, string @namespace) {
return assemblies.SelectMany(assembly => assembly.GetTypes()).Where(type => type.IsClass && (type.Namespace?.StartsWith(@namespace)).GetValueOrDefault());
}
}
}