From a500838cbd6986c3b1f03c2d40e0843c1123141d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9rald=20Barr=C3=A9?= Date: Wed, 26 Jul 2023 20:33:29 -0400 Subject: [PATCH] Add Meziantou.Analyzer.Annotations package --- .github/workflows/ci.yml | 1 + Directory.Build.props | 3 +-- Meziantou.Analyzer.sln | 6 +++++ .../Annotations.cs | 22 +++++++++++++++++++ .../Meziantou.Analyzer.Annotations.csproj | 18 +++++++++++++++ src/Meziantou.Analyzer.Annotations/README.md | 3 +++ .../Meziantou.Analyzer.csproj | 4 ++++ 7 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 src/Meziantou.Analyzer.Annotations/Annotations.cs create mode 100644 src/Meziantou.Analyzer.Annotations/Meziantou.Analyzer.Annotations.csproj create mode 100644 src/Meziantou.Analyzer.Annotations/README.md diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 45b218c9f..a5b0de366 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: diff --git a/Directory.Build.props b/Directory.Build.props index ba9b04377..f6ba3558b 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -24,14 +24,13 @@ https://github.com/meziantou/Meziantou.Analyzer.git git icon.png - LICENSE.txt + MIT README.md - diff --git a/Meziantou.Analyzer.sln b/Meziantou.Analyzer.sln index 0e5135f07..9a82b47b9 100644 --- a/Meziantou.Analyzer.sln +++ b/Meziantou.Analyzer.sln @@ -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 @@ -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 diff --git a/src/Meziantou.Analyzer.Annotations/Annotations.cs b/src/Meziantou.Analyzer.Annotations/Annotations.cs new file mode 100644 index 000000000..abd6d5876 --- /dev/null +++ b/src/Meziantou.Analyzer.Annotations/Annotations.cs @@ -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) { } + } +} diff --git a/src/Meziantou.Analyzer.Annotations/Meziantou.Analyzer.Annotations.csproj b/src/Meziantou.Analyzer.Annotations/Meziantou.Analyzer.Annotations.csproj new file mode 100644 index 000000000..6bbbb7cde --- /dev/null +++ b/src/Meziantou.Analyzer.Annotations/Meziantou.Analyzer.Annotations.csproj @@ -0,0 +1,18 @@ + + + + netstandard1.0;netstandard2.0 + 1.0.0 + 1.0.0 + Annotations to configure Meziantou.Analyzer + + + + + + + + + + + diff --git a/src/Meziantou.Analyzer.Annotations/README.md b/src/Meziantou.Analyzer.Annotations/README.md new file mode 100644 index 000000000..4fb6b5b71 --- /dev/null +++ b/src/Meziantou.Analyzer.Annotations/README.md @@ -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. diff --git a/src/Meziantou.Analyzer/Meziantou.Analyzer.csproj b/src/Meziantou.Analyzer/Meziantou.Analyzer.csproj index addba2b50..45666d3ab 100644 --- a/src/Meziantou.Analyzer/Meziantou.Analyzer.csproj +++ b/src/Meziantou.Analyzer/Meziantou.Analyzer.csproj @@ -23,6 +23,10 @@ + + + +