Skip to content

Commit

Permalink
Merge branch 'hotfix/0.1.1' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
AdmiringWorm committed Sep 11, 2020
2 parents a29cf6e + 5fac065 commit 86b34e5
Show file tree
Hide file tree
Showing 13 changed files with 112 additions and 53 deletions.
6 changes: 0 additions & 6 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
"commands": [
"dotnet-cake"
]
},
"dotnet-t4": {
"version": "2.0.5",
"commands": [
"t4"
]
}
}
}
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ indent_size = 2
indent_style = space
trim_trailing_whitespace = false

[*.yml]
[*.{yml,yaml}]
indent_size = 2
indent_style = space

Expand Down
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

*.md text whitespace=-blank-at-eol,-indent-with-non-tab,tab-in-indent
*.yml text whitespace=-indent-with-non-tab,tab-in-indent
*.yaml text whitespace=-indent-with-non-tab,tab-in-indent
dotnet-tools.json text whitespace=-indent-with-non-tab,tab-in-indent

# While these are text files, we should still treat them as binaries
Expand Down
43 changes: 43 additions & 0 deletions GitReleaseManager.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Configuration values used when creating new releases
create:
include-footer: false
footer-heading: ''
footer-content: ''
footer-includes-milestone: false
milestone-replace-text: ''
include-sha-section: true
sha-section-heading: SHA256 Hashes of the release artifacts
sha-section-line-format: '- `{1} {0}`'
allow-update-to-published: false
# Configuration values used when exporting release notes
export:
include-created-date-in-title: false
created-date-string-format: ''
perform-regex-removal: false
regex-text: ''
multiline-regex: false
# Configuration values used when closing a milestone
close:
# Whether to add comments to issues closed and with the published milestone release.
use-issue-comments: true
issue-comment: |-
:tada: This issue has been resolved in version {milestone} :tada:
The release is available on:
- [GitHub release](https://github.com/{owner}/{repository}/releases/tag/{milestone})
Your **[GitReleaseManager](https://github.com/GitTools/GitReleaseManager)** bot :package::rocket:
# The labels that will be used to include issues in release notes.
issue-labels-include:
- Breaking change
- Bug
- Documentation
- Feature
- Improvement
# The labels that will NOT be used when including issues in release notes.
issue-labels-exclude:
- Build
- Internal Refactoring
# Overrides default pluralization and header names for specific labels.
issue-labels-alias: []
25 changes: 3 additions & 22 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#load nuget:https://ci.appveyor.com/nuget/cake-recipe?package=Cake.Recipe&version=2.0.0-alpha0433&prerelease
#tool nuget:?package=NuGet.CommandLine&version=5.6.0
#tool dotnet:?package=dotnet-t4&version=2.0.5

Environment.SetVariableNames();

Expand Down Expand Up @@ -53,29 +54,9 @@ ToolSettings.SetToolPreprocessorDirectives(

Task("Transform-Text-Templates")
.IsDependeeOf("DotNetCore-Build")
.Does(() =>
.DoesForEach(GetFiles("src/**/*.tt"), (file) =>
{
var ttFiles = GetFiles("src/**/*.tt");
int exitCode = 0;
foreach (var file in ttFiles)
{
Information("Transforming Text Template: '{0}'", file.GetFilename());
int newexitcode = StartProcess("dotnet",
new ProcessSettings {
Arguments = new ProcessArgumentBuilder()
.Append("t4")
.AppendQuoted(file.ToString())
});
if (exitCode == 0)
exitCode = newexitcode;
}
if (exitCode != 0)
{
throw new Exception("Text Template transformation failed");
}
TransformTemplate(file);
});


Expand Down
11 changes: 11 additions & 0 deletions demo/Cake.TestAddin/PartialTestAddinAliases.One.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Cake.TestAddin
{
[Core.Annotations.CakeAliasCategory("REPLACE_ME")]
public static partial class PartialTestAddinAliases
{
}
}
10 changes: 10 additions & 0 deletions demo/Cake.TestAddin/PartialTestAddinAliases.Two.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Cake.TestAddin
{
public static partial class PartialTestAddinAliases
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<PropertyGroup>
<!-- I am lazy, so I don't want to update the year every time a new year comes around -->
<StartYear>2019</StartYear>
<StartYear>2020</StartYear>
<EndYear>$([System.DateTime]::Today.Year)</EndYear>
<FullYear Condition="'$(StartYear)'=='$(EndYear)'">$(StartYear)</FullYear>
<FullYear Condition="'$(StartYear)'!='$(EndYear)'">$(StartYear)-$(EndYear)</FullYear>
Expand All @@ -26,7 +26,7 @@
Requires Visual Studio 2019 and MSBuild 16.4 or higher.
</Description>
<Copyright>Copyright © $(FullYear) - $(Authors.Replace(';', ','))</Copyright>
<PackageTags>Cake.Addin.Analyzer, analyzers, cake, cake-contrib</PackageTags>
<PackageTags>Cake.Addin.Analyzer, analyzers, cake, cake-addin</PackageTags>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
<NoPackageAnalysis>true</NoPackageAnalysis>
Expand Down
32 changes: 16 additions & 16 deletions src/Cake.Addin.Analyzer.Rules/Rules/AliasClassCategoryRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ namespace Cake.Addin.Analyzer.Rules
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class AliasClassCategoryRule : BaseRule
{
private const string CakeAliasCategoryAttribute = "Cake.Core.Annotations.CakeAliasCategoryAttribute";

public AliasClassCategoryRule()
: base(
Identifiers.AliasClassCategoryRule,
Expand All @@ -23,34 +25,32 @@ public AliasClassCategoryRule()
}

protected override void RegisterActions(AnalysisContext context)
=> context.RegisterSyntaxNodeAction(AnalyzeClassNode, SyntaxKind.ClassDeclaration);
=> context.RegisterSymbolAction(AnalyzeClassSymbol, SymbolKind.NamedType);

private void AnalyzeClassNode(SyntaxNodeAnalysisContext obj)
private void AnalyzeClassSymbol(SymbolAnalysisContext obj)
{
if (!(obj.Node is ClassDeclarationSyntax classDeclaration))
if (!(obj.Symbol is INamedTypeSymbol symbol) || symbol.TypeKind != TypeKind.Class)
{
return;
}

var identifier = classDeclaration.Identifier;
var identifierText = identifier.Text;
if (!identifierText.EndsWith("Alias", StringComparison.OrdinalIgnoreCase) &&
!identifierText.EndsWith("Aliases", StringComparison.OrdinalIgnoreCase))
var name = symbol.Name;

if (!name.EndsWith("Alias", StringComparison.OrdinalIgnoreCase) &&
!name.EndsWith("Aliases", StringComparison.OrdinalIgnoreCase))
{
return;
}

if (classDeclaration.AttributeLists.Any())
var attributes = symbol.GetAttributes();

var hasAttribute = attributes.Any(a => HasExpectedAttribute(obj, a, CakeAliasCategoryAttribute));

if (!hasAttribute)
{
var attributes = classDeclaration.AttributeLists.SelectMany(al => al.Attributes);
if (attributes.Any(a => HasExpectedAttribute(obj, a, "Cake.Core.Annotations.CakeAliasCategoryAttribute")))
{
return;
}
var diagnostic = Diagnostic.Create(Rule, symbol.Locations[0], symbol.Name);
obj.ReportDiagnostic(diagnostic);
}

var diagnostic = Diagnostic.Create(Rule, identifier.GetLocation(), identifierText);
obj.ReportDiagnostic(diagnostic);
}
}
}
7 changes: 7 additions & 0 deletions src/Cake.Addin.Analyzer.Rules/Rules/BaseRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ protected static bool HasExpectedAttribute(SyntaxNodeAnalysisContext obj, Attrib
return ti.ConvertedType!.Equals(metaType, SymbolEqualityComparer.Default);
}

protected static bool HasExpectedAttribute(SymbolAnalysisContext obj, AttributeData attribute, string qualifiedTypeName)
{
var metaType = obj.Compilation.GetTypeByMetadataName(qualifiedTypeName);

return attribute.AttributeClass.Equals(metaType, SymbolEqualityComparer.Default);
}

protected static bool HasExpectedParameter(SyntaxNodeAnalysisContext context, ParameterSyntax parameter, string qualifiedTypeName)
{
var ti = context.SemanticModel.GetTypeInfo(parameter.Type!);
Expand Down
12 changes: 6 additions & 6 deletions src/Cake.Addin.Analyzer.Tests/Cake.Addin.Analyzer.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="16.7.1" Condition="$(TargetFramework.StartsWith('net4')) AND '$(OS)' == 'Unix'" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="3.4.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.NUnit" Version="1.0.1-beta1.*" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.NUnit" Version="1.0.1-beta1.*" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeRefactoring.Testing.NUnit" Version="1.0.1-beta1.*" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.Analyzer.Testing.NUnit" Version="1.0.1-beta1.*" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.CodeFix.Testing.NUnit" Version="1.0.1-beta1.*" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.CodeRefactoring.Testing.NUnit" Version="1.0.1-beta1.*" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.NUnit" Version="1.0.1-beta1.20461.1" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.NUnit" Version="1.0.1-beta1.20461.1" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeRefactoring.Testing.NUnit" Version="1.0.1-beta1.20461.1" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.Analyzer.Testing.NUnit" Version="1.0.1-beta1.20461.1" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.CodeFix.Testing.NUnit" Version="1.0.1-beta1.20461.1" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.CodeRefactoring.Testing.NUnit" Version="1.0.1-beta1.20461.1" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public async Task ShouldApplyCodeFix(string test, string fix)
[TestCase(TestTemplates.AliasClassCategory.HaveCakeAliasCategoryQualified, TestName = "UsingQualifiedShouldBeValid")]
[TestCase(TestTemplates.AliasClassCategory.HaveCakeAliasCategorySimplified, TestName = "UsingSimplifiedShouldBeValid")]
[TestCase(TestTemplates.EmptyGeneralClass, TestName = "NonAliasClassShouldBeValid")]
[TestCase(TestTemplates.AliasClassCategory.HaveCakeAliasCategoryPartialClass, TestName = "UsingSimplifiedShouldBeValidOnPartialClasses")]
public async Task ShouldBeValid(string test)
=> await VerifyCS.VerifyAnalyzerAsync(test);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Cake.Core;
using Cake.Core.Annotations;

public static partial class Aliases
{
}

[CakeAliasCategory("Test Category")]
public static partial class Aliases
{
}

0 comments on commit 86b34e5

Please sign in to comment.