Skip to content

Commit 7615c5c

Browse files
committed
starting from release 1.4.1345
1 parent 30eb831 commit 7615c5c

File tree

94 files changed

+3985
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+3985
-0
lines changed

.editorconfig

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8-bom
6+
end_of_line = crlf
7+
8+
[*.cs]
9+
indent_style = space
10+
indent_size = 4
11+
insert_final_newline = true
12+
trim_trailing_whitespace = true
13+
14+
[*.{xml,xsl,xslt,xsd,vsct,scmp,html}]
15+
indent_style = space
16+
indent_size = 2
17+
insert_final_newline = true
18+
trim_trailing_whitespace = true
19+
20+
[*.{json}]
21+
indent_style = space
22+
indent_size = 4
23+
insert_final_newline = true
24+
trim_trailing_whitespace = true
25+
26+
[*.sql]
27+
indent_style = space
28+
indent_size = 4
29+
insert_final_newline = true
30+
trim_trailing_whitespace = true
31+
32+
[*.{csproj,sqlproj,rptproj}]
33+
indent_style = space
34+
indent_size = 2
35+
insert_final_newline = true
36+
trim_trailing_whitespace = true

.runsettings

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RunSettings>
3+
<ResultsDirectory>.\TestResults</ResultsDirectory>
4+
<TestSessionTimeout>10000</TestSessionTimeout>
5+
6+
<DataCollectionRunSettings>
7+
<DataCollectors>
8+
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
9+
<Configuration>
10+
<CodeCoverage>
11+
12+
<ModulePaths>
13+
<Include></Include>
14+
15+
<Exclude>
16+
<ModulePath>.*tests\.dll</ModulePath>
17+
<ModulePath>.*nunit.*</ModulePath>
18+
<ModulePath>.*humanizer.*</ModulePath>
19+
</Exclude>
20+
</ModulePaths>
21+
22+
<CompanyNames>
23+
<Exclude>
24+
<CompanyName>.*microsoft.*</CompanyName>
25+
</Exclude>
26+
</CompanyNames>
27+
28+
<!-- Match attributes on any code element: -->
29+
<Attributes>
30+
<Exclude>
31+
<!-- Don't forget "Attribute" at the end of the name -->
32+
<Attribute>^System\.Diagnostics\.DebuggerHiddenAttribute$</Attribute>
33+
<Attribute>^System\.Diagnostics\.DebuggerNonUserCodeAttribute$</Attribute>
34+
<Attribute>^System\.CodeDom\.Compiler\.GeneratedCodeAttribute$</Attribute>
35+
<Attribute>^System\.Diagnostics\.CodeAnalysis\.ExcludeFromCodeCoverageAttribute$</Attribute>
36+
</Exclude>
37+
</Attributes>
38+
39+
<UseVerifiableInstrumentation>True</UseVerifiableInstrumentation>
40+
<AllowLowIntegrityProcesses>True</AllowLowIntegrityProcesses>
41+
<CollectFromChildProcesses>True</CollectFromChildProcesses>
42+
</CodeCoverage>
43+
</Configuration>
44+
</DataCollector>
45+
</DataCollectors>
46+
</DataCollectionRunSettings>
47+
48+
<NUnit>
49+
<UseParentFQNForParemetrizedTests>true</UseParentFQNForParemetrizedTests>
50+
<UseNUnitIdforTestCaseId>true</UseNUnitIdforTestCaseId>
51+
</NUnit>
52+
</RunSettings>

.stylecop/StyleCop.ruleset

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RuleSet Name="StyleCopeRules" Description="StyleCopeRules custom ruleset" ToolsVersion="15.0">
3+
<IncludeAll Action="Warning" />
4+
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
5+
<Rule Id="SA0001" Action="None"> <!-- docs generation disabled --> </Rule>
6+
<Rule Id="SA1101" Action="None"> <!-- locals not prefixed with this. --> </Rule>
7+
<Rule Id="SA1122" Action="None"> <!-- use string.Empty --> </Rule>
8+
<Rule Id="SA1128" Action="None"> <!-- constructor initializer on same line --> </Rule>
9+
<Rule Id="SA1131" Action="None"> <!-- constant on left side of comparison --> </Rule>
10+
<Rule Id="SA1200" Action="None"> <!-- directive not within namespace --> </Rule>
11+
<Rule Id="SA1208" Action="None"> <!-- using order --> </Rule>
12+
<Rule Id="SA1502" Action="None"> <!-- {} on single line --> </Rule>
13+
<Rule Id="SA1515" Action="None"> <!-- blank line before single-line comment --> </Rule>
14+
<Rule Id="SA1600" Action="None"> <!-- element missing docs --> </Rule>
15+
<Rule Id="SA1602" Action="Warning"> <!-- enumeration items documented --> </Rule>
16+
<Rule Id="SA1633" Action="None"> <!-- file missing header comment --> </Rule>
17+
<Rule Id="SA1642" Action="None"> <!-- constructor docs standard text --> </Rule>
18+
<Rule Id="SA1305" Action="Warning"> <!-- hungarian notation --> </Rule>
19+
</Rules>
20+
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
21+
<Rule Id="CA1813" Action="None"> <!-- seal class if possible --> </Rule>
22+
<Rule Id="CS1591" Action="None"> <!-- missing xml docs for public elements --> </Rule>
23+
</Rules>
24+
<Rules AnalyzerId="DiagnosticSuppressors" RuleNamespace="NUnit.NUnitAnalyzers">
25+
<Rule Id="NUnit2045" Action="None"> <!-- Use Assert.Multiple --> </Rule>
26+
</Rules>
27+
</RuleSet>

.stylecop/stylecop.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
3+
"settings": {
4+
"namingRules": {
5+
"allowedHungarianPrefixes": [ "on", "db", "fk", "pk" ],
6+
},
7+
},
8+
}

Directory.build.props

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Project>
2+
<PropertyGroup>
3+
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory).stylecop\StyleCop.ruleset</CodeAnalysisRuleSet>
4+
<RunSettingsFilePath>$(MSBuildThisFileDirectory).runsettings</RunSettingsFilePath>
5+
<RestoreConfigFile>$(MSBuildThisFileDirectory)NuGet.Config</RestoreConfigFile>
6+
<RestoreIgnoreFailedSources>true</RestoreIgnoreFailedSources>
7+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
8+
<DisableSystemTextJsonSourceGenerator>true</DisableSystemTextJsonSourceGenerator>
9+
<TreatWarningsAsErrors Condition=" '$(ContinuousIntegrationBuild)' == 'true' ">true</TreatWarningsAsErrors>
10+
<NoWarn>NU1801</NoWarn>
11+
<NoWarn>NU1601</NoWarn>
12+
</PropertyGroup>
13+
<ItemGroup>
14+
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
15+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
16+
<PrivateAssets>all</PrivateAssets>
17+
</PackageReference>
18+
<AdditionalFiles Include="$(MSBuildThisFileDirectory).stylecop\stylecop.json" Visible="false" />
19+
<None Include="$(MSBuildProjectDirectory)\packages.lock.json" Visible="false" />
20+
</ItemGroup>
21+
</Project>

NuGet.Config

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<config>
4+
<add key="globalPackagesFolder" value=".\packages"/>
5+
<add key="dependencyVersion" value="Highest"/>
6+
</config>
7+
<activePackageSource>
8+
<add key="All" value="(Aggregate source)"/>
9+
</activePackageSource>
10+
</configuration>

TeamTools.Linter.CommandLine.sln

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.33529.622
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamTools.Common.Linting", ".\TeamTools.TSQL.Common\TeamTools.Common.Linting.csproj", "{F5EFD6E9-B19C-4230-B7C1-8AA1E37FFF63}"
7+
EndProject
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamTools.TSQL.Linter.CommandLine", ".\TeamTools.TSQL.Linter.CommandLine\TeamTools.TSQL.Linter.CommandLine.csproj", "{1843A7A7-94A2-4146-B6D5-DDCFB9F42C5D}"
9+
EndProject
10+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamTools.TSQL.Linter.CommandLineTests", ".\TeamTools.TSQL.Linter.CommandLineTests\TeamTools.TSQL.Linter.CommandLineTests.csproj", "{A617E267-3D43-499D-9B6B-5B08B266ACB9}"
11+
EndProject
12+
Global
13+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
14+
Debug|Any CPU = Debug|Any CPU
15+
Release|Any CPU = Release|Any CPU
16+
Test|Any CPU = Test|Any CPU
17+
EndGlobalSection
18+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
19+
{F5EFD6E9-B19C-4230-B7C1-8AA1E37FFF63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20+
{F5EFD6E9-B19C-4230-B7C1-8AA1E37FFF63}.Debug|Any CPU.Build.0 = Debug|Any CPU
21+
{F5EFD6E9-B19C-4230-B7C1-8AA1E37FFF63}.Release|Any CPU.ActiveCfg = Release|Any CPU
22+
{F5EFD6E9-B19C-4230-B7C1-8AA1E37FFF63}.Release|Any CPU.Build.0 = Release|Any CPU
23+
{F5EFD6E9-B19C-4230-B7C1-8AA1E37FFF63}.Test|Any CPU.ActiveCfg = Test|Any CPU
24+
{F5EFD6E9-B19C-4230-B7C1-8AA1E37FFF63}.Test|Any CPU.Build.0 = Test|Any CPU
25+
{1843A7A7-94A2-4146-B6D5-DDCFB9F42C5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26+
{1843A7A7-94A2-4146-B6D5-DDCFB9F42C5D}.Debug|Any CPU.Build.0 = Debug|Any CPU
27+
{1843A7A7-94A2-4146-B6D5-DDCFB9F42C5D}.Release|Any CPU.ActiveCfg = Release|Any CPU
28+
{1843A7A7-94A2-4146-B6D5-DDCFB9F42C5D}.Release|Any CPU.Build.0 = Release|Any CPU
29+
{1843A7A7-94A2-4146-B6D5-DDCFB9F42C5D}.Test|Any CPU.ActiveCfg = Test|Any CPU
30+
{1843A7A7-94A2-4146-B6D5-DDCFB9F42C5D}.Test|Any CPU.Build.0 = Test|Any CPU
31+
{A617E267-3D43-499D-9B6B-5B08B266ACB9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
32+
{A617E267-3D43-499D-9B6B-5B08B266ACB9}.Debug|Any CPU.Build.0 = Debug|Any CPU
33+
{A617E267-3D43-499D-9B6B-5B08B266ACB9}.Release|Any CPU.ActiveCfg = Release|Any CPU
34+
{A617E267-3D43-499D-9B6B-5B08B266ACB9}.Release|Any CPU.Build.0 = Release|Any CPU
35+
{A617E267-3D43-499D-9B6B-5B08B266ACB9}.Test|Any CPU.ActiveCfg = Test|Any CPU
36+
{A617E267-3D43-499D-9B6B-5B08B266ACB9}.Test|Any CPU.Build.0 = Test|Any CPU
37+
EndGlobalSection
38+
GlobalSection(SolutionProperties) = preSolution
39+
HideSolutionNode = FALSE
40+
EndGlobalSection
41+
GlobalSection(ExtensibilityGlobals) = postSolution
42+
SolutionGuid = {51CE96F8-460C-4706-95DE-A197EC9DA7FD}
43+
EndGlobalSection
44+
EndGlobal
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
using Newtonsoft.Json.Linq;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.IO;
5+
using System.Linq;
6+
7+
namespace TeamTools.Common.Linting
8+
{
9+
public class AppConfigLoader : IAppConfigLoader
10+
{
11+
private const string PluginListConfigNode = "plugins";
12+
private const string IgnoredFoldersConfigNode = "ignore.folders";
13+
private const string IgnoredFileExtensionsConfigNode = "ignore.extensions";
14+
private readonly IFileSystemWrapper fileSystem;
15+
private string rootPath;
16+
17+
public AppConfigLoader(IFileSystemWrapper fileSystem, IAssemblyWrapper assembly)
18+
{
19+
this.fileSystem = fileSystem;
20+
this.rootPath = assembly.GetExecutingPath();
21+
}
22+
23+
public IDictionary<string, PluginInfo> Plugins { get; } = new Dictionary<string, PluginInfo>(StringComparer.OrdinalIgnoreCase);
24+
25+
public ICollection<string> IgnoredFolders { get; } = new SortedSet<string>(StringComparer.OrdinalIgnoreCase);
26+
27+
public ICollection<string> IgnoredExtensions { get; } = new SortedSet<string>(StringComparer.OrdinalIgnoreCase);
28+
29+
public void Load(TextReader config)
30+
{
31+
Plugins.Clear();
32+
33+
if (TryParseJson(config.ReadToEnd(), out JToken json))
34+
{
35+
ExtractPlugins(json);
36+
ExtractIgnores(json);
37+
}
38+
else
39+
{
40+
throw new FormatException("Config is not a valid JSON");
41+
}
42+
}
43+
44+
public void LoadFromFile(string filePath)
45+
{
46+
if (!fileSystem.FileExists(filePath))
47+
{
48+
throw new FileNotFoundException("Config file not found: " + filePath);
49+
}
50+
51+
// switching to relative to config file path
52+
rootPath = Path.GetDirectoryName(filePath);
53+
54+
using (var src = fileSystem.OpenFile(filePath))
55+
{
56+
Load(src);
57+
}
58+
}
59+
60+
private static bool TryParseJson(string jsonString, out JToken token)
61+
{
62+
try
63+
{
64+
token = JToken.Parse(jsonString);
65+
return true;
66+
}
67+
catch
68+
{
69+
token = null;
70+
return false;
71+
}
72+
}
73+
74+
private void ExtractPlugins(JToken jsonObject)
75+
{
76+
var plugins = jsonObject.SelectTokens(".." + PluginListConfigNode).ToList();
77+
78+
foreach (var plugin in plugins)
79+
{
80+
foreach (var jsonToken in plugin.Children())
81+
{
82+
var prop = (JProperty)jsonToken;
83+
84+
var pluginOptions = prop.Value.ToObject<Dictionary<string, string>>();
85+
86+
pluginOptions.TryGetValue("docsBasePath", out string docsBasePath);
87+
pluginOptions.TryGetValue("docsBaseUrl", out string docsBaseUrl);
88+
89+
if (pluginOptions.TryGetValue("dll", out string pluginPath)
90+
&& pluginOptions.TryGetValue("config", out string pluginConfigPath))
91+
{
92+
Plugins.Add(
93+
prop.Name,
94+
new PluginInfo
95+
{
96+
AssemblyPath = fileSystem.MakeAbsolutePath(rootPath, pluginPath),
97+
ConfigPath = fileSystem.MakeAbsolutePath(rootPath, pluginConfigPath),
98+
BaseDocsPath = fileSystem.MakeAbsolutePath(rootPath, docsBasePath),
99+
BaseDocsUrl = docsBaseUrl,
100+
});
101+
}
102+
}
103+
}
104+
}
105+
106+
private void ExtractIgnores(JToken jsonObject)
107+
{
108+
FillIgnoreList(IgnoredFolders, jsonObject, ".." + IgnoredFoldersConfigNode);
109+
FillIgnoreList(IgnoredExtensions, jsonObject, ".." + IgnoredFileExtensionsConfigNode);
110+
}
111+
112+
private void FillIgnoreList(ICollection<string> ignoreCollection, JToken jsonObject, string path)
113+
{
114+
ignoreCollection.Clear();
115+
foreach (string value in ExtractListFromJson(jsonObject, path))
116+
{
117+
ignoreCollection.Add(value);
118+
}
119+
}
120+
121+
private IEnumerable<string> ExtractListFromJson(JToken jsonObject, string path)
122+
{
123+
return jsonObject
124+
.SelectTokens(path)
125+
.ToList()
126+
.ToList()
127+
.Children()
128+
.Select(jt => ((JValue)jt).Value.ToString())
129+
.Distinct();
130+
}
131+
}
132+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
using System.Linq;
3+
4+
namespace TeamTools.Common.Linting
5+
{
6+
public static class AttributeExtension
7+
{
8+
public static TValue GetAttributeValue<TAttribute, TValue>(
9+
this Type type,
10+
Func<TAttribute, TValue> valueSelector)
11+
where TAttribute : Attribute
12+
{
13+
if (type.GetCustomAttributes(typeof(TAttribute), true).FirstOrDefault() is TAttribute att)
14+
{
15+
return valueSelector(att);
16+
}
17+
18+
return default;
19+
}
20+
}
21+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
3+
namespace TeamTools.Common.Linting
4+
{
5+
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
6+
public sealed class DataTypeAttribute : Attribute
7+
{
8+
public DataTypeAttribute(string dataTypeName)
9+
{
10+
if (string.IsNullOrEmpty(dataTypeName))
11+
{
12+
throw new ArgumentNullException(nameof(dataTypeName));
13+
}
14+
15+
this.DataTypeName = dataTypeName;
16+
}
17+
18+
public string DataTypeName { get; private set; }
19+
}
20+
}

0 commit comments

Comments
 (0)