Skip to content

Commit

Permalink
Add Meziantou.Analyzer.Annotations package
Browse files Browse the repository at this point in the history
  • Loading branch information
meziantou committed Jul 27, 2023
1 parent f8a35f4 commit a500838
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ jobs:

- run: dotnet restore src/Meziantou.Analyzer.pack.csproj
- run: dotnet pack src/Meziantou.Analyzer.pack.csproj --configuration Release --no-build /p:Version=${{ needs.compute_package_version.outputs.package_version }}
- run: dotnet pack src/Meziantou.Analyzer.Annotations.csproj --configuration Release

- uses: actions/upload-artifact@v3
with:
Expand Down
3 changes: 1 addition & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@
<RepositoryUrl>https://github.com/meziantou/Meziantou.Analyzer.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageIcon>icon.png</PackageIcon>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)\icon.png" Pack="true" PackagePath="" />
<None Include="$(MSBuildThisFileDirectory)\LICENSE.txt" Pack="true" PackagePath="" />
<None Include="$(MSBuildThisFileDirectory)\README.md" Pack="true" PackagePath="" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 6 additions & 0 deletions Meziantou.Analyzer.sln
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ListDotNetTypes", "src\List
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Meziantou.Analyzer.pack", "src\Meziantou.Analyzer.pack.csproj", "{6AB20B80-DE7F-4EB3-8A8B-E5C902F06438}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Meziantou.Analyzer.Annotations", "src\Meziantou.Analyzer.Annotations\Meziantou.Analyzer.Annotations.csproj", "{6C3D4314-A2E3-498F-A2C3-AC10E714A498}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -51,6 +53,10 @@ Global
{6AB20B80-DE7F-4EB3-8A8B-E5C902F06438}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6AB20B80-DE7F-4EB3-8A8B-E5C902F06438}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6AB20B80-DE7F-4EB3-8A8B-E5C902F06438}.Release|Any CPU.Build.0 = Release|Any CPU
{6C3D4314-A2E3-498F-A2C3-AC10E714A498}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6C3D4314-A2E3-498F-A2C3-AC10E714A498}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6C3D4314-A2E3-498F-A2C3-AC10E714A498}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6C3D4314-A2E3-498F-A2C3-AC10E714A498}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
22 changes: 22 additions & 0 deletions src/Meziantou.Analyzer.Annotations/Annotations.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma warning disable IDE0060
#pragma warning disable IDE0290
#pragma warning disable CA1019
#nullable disable

namespace Meziantou.Analyzer.Annotations
{
[System.Diagnostics.Conditional("MEZIANTOU_ANALYZER_ANNOTATIONS")]
[System.AttributeUsage(System.AttributeTargets.Parameter)]
public sealed class RequireNamedArgumentAttribute : System.Attribute
{
public RequireNamedArgumentAttribute() { }
public RequireNamedArgumentAttribute(bool isRequired) { }
}

[System.Diagnostics.Conditional("MEZIANTOU_ANALYZER_ANNOTATIONS")]
[System.AttributeUsage(System.AttributeTargets.Assembly, AllowMultiple = true, Inherited = false)]
public sealed class StructuredLogFieldAttribute : System.Attribute
{
public StructuredLogFieldAttribute(string parameterName, params System.Type[] allowedTypes) { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard1.0;netstandard2.0</TargetFrameworks>
<Version>1.0.0</Version>
<AssemblyVersion>1.0.0</AssemblyVersion>
<Description>Annotations to configure Meziantou.Analyzer</Description>
</PropertyGroup>

<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="" />
</ItemGroup>

<ItemGroup>
<PackageReference Remove="Meziantou.Polyfill" />
</ItemGroup>

</Project>
3 changes: 3 additions & 0 deletions src/Meziantou.Analyzer.Annotations/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Meziantou.Analyzer.Annotations help configuring some rules by annotating your code.

All usages of Meziantou.Analyzer.Annotations attributes are erased from metadata by default, which means no actual binary reference to 'Meziantou.Analyzer.Annotations.dll' assembly is produced. If you need to preserve these attributes in metadata, just define 'MEZIANTOU_ANALYZER_ANNOTATIONS' conditional compilation symbol in your projects.
4 changes: 4 additions & 0 deletions src/Meziantou.Analyzer/Meziantou.Analyzer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
<AdditionalFiles Include="$(MSBuildThisFileDirectory)\BannedSymbols.txt" />
</ItemGroup>

<ItemGroup>
<None Include="../../README.md" Pack="true" PackagePath="" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.3.4">
Expand Down

0 comments on commit a500838

Please sign in to comment.