Skip to content

Commit

Permalink
Add Package project
Browse files Browse the repository at this point in the history
  • Loading branch information
Hixon10 committed Feb 4, 2024
1 parent 6e18931 commit 113fd0c
Show file tree
Hide file tree
Showing 8 changed files with 621 additions and 6 deletions.
16 changes: 16 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project>
<PropertyGroup>
<!-- Projects have to opt in to be packed -->
<IsPackable>false</IsPackable>
<Version>0.2.0</Version>
<PackageVersion>$(Version)</PackageVersion>
<Authors>Denis</Authors>
<PackageTags>C# Roslyn detector of Newtonsoft.Json usage</PackageTags>
<PackageProjectUrl>https://github.com/Hixon10/NewtonsoftJsonUsageAnalyzer</PackageProjectUrl>
<RepositoryUrl>https://github.com/Hixon10/NewtonsoftJsonUsageAnalyzer</RepositoryUrl>
<PackageOutputPath>$(MSBuildThisFileDirectory)bin\$(Configuration)\</PackageOutputPath>
<!-- General settings -->
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
</PropertyGroup>
</Project>
6 changes: 6 additions & 0 deletions NewtonsoftJsonUsageAnalyzer.sln
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NewtonsoftJsonUsageAnalyzer
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NewtonsoftJsonUsageAnalyzer.Tests", "NewtonsoftJsonUsageAnalyzer\NewtonsoftJsonUsageAnalyzer.Tests\NewtonsoftJsonUsageAnalyzer.Tests.csproj", "{E20EF578-BFA0-4DD8-895A-07927A684A66}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NewtonsoftJsonUsageAnalyzer.Package", "NewtonsoftJsonUsageAnalyzer\NewtonsoftJsonUsageAnalyzer.Package\NewtonsoftJsonUsageAnalyzer.Package.csproj", "{35E1679F-B1CD-42A1-9CB7-CB9341E39D44}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -24,5 +26,9 @@ Global
{E20EF578-BFA0-4DD8-895A-07927A684A66}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E20EF578-BFA0-4DD8-895A-07927A684A66}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E20EF578-BFA0-4DD8-895A-07927A684A66}.Release|Any CPU.Build.0 = Release|Any CPU
{35E1679F-B1CD-42A1-9CB7-CB9341E39D44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{35E1679F-B1CD-42A1-9CB7-CB9341E39D44}.Debug|Any CPU.Build.0 = Debug|Any CPU
{35E1679F-B1CD-42A1-9CB7-CB9341E39D44}.Release|Any CPU.ActiveCfg = Release|Any CPU
{35E1679F-B1CD-42A1-9CB7-CB9341E39D44}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<IncludeBuildOutput>false</IncludeBuildOutput>
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<IsPackable>true</IsPackable>
</PropertyGroup>

<PropertyGroup>
<PackageId>NewtonsoftJsonUsageAnalyzer</PackageId>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Description>A roslyn analyzer, which allows to detect and fail builds, which use Newtonsoft.Json library</Description>
<DevelopmentDependency>true</DevelopmentDependency>
<NoPackageAnalysis>true</NoPackageAnalysis>
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);_AddAnalyzersToOutput</TargetsForTfmSpecificContentInPackage>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\NewtonsoftJsonUsageAnalyzer\NewtonsoftJsonUsageAnalyzer.csproj" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\LICENSE" Pack="true" PackagePath="" />
<None Include="..\..\README.md" Pack="true" PackagePath="" />
<None Update="tools\*.ps1" CopyToOutputDirectory="PreserveNewest" Pack="true" PackagePath="" />
</ItemGroup>

<Target Name="_AddAnalyzersToOutput">
<ItemGroup>
<TfmSpecificPackageFile Include="$(OutputPath)\NewtonsoftJsonUsageAnalyzer.dll" PackagePath="analyzers/dotnet/cs" />
</ItemGroup>
</Target>

</Project>

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; Shipped analyzer releases
; https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md

## Release 0.1.0.2
## Release 0.2.0

### New Rules

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<IsRoslynComponent>true</IsRoslynComponent>

<RootNamespace>NewtonsoftJsonUsageAnalyzer</RootNamespace>
<AssemblyName>NewtonsoftJsonUsageAnalyzer</AssemblyName>
<!-- Avoid ID conflicts with the package project. -->
<PackageId>*$(MSBuildProjectFile)*</PackageId>
</PropertyGroup>

<ItemGroup>
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Newtonsoft.Json Usage Analyzer

[![NuGet](https://buildstats.info/nuget/NewtonsoftJsonUsageAnalyzer?includePreReleases=true)](https://www.nuget.org/packages/NewtonsoftJsonUsageAnalyzer/)

A roslyn analyzer, which allows to detect and fail builds, which use `Newtonsoft.Json` library.

## Motivation
Expand All @@ -12,14 +14,18 @@ In these cases, it is needed to have some way to detect usage of `Newtonsoft.Jso

In a nutshell, you have 3 ways, how to use it:

1. You can attach this analyzer per specific project(s) (e.g., [NewtonsoftJsonUsageAnalyzer.Sample.csproj](https://github.com/Hixon10/NewtonsoftJsonUsageAnalyzer/blob/main/NewtonsoftJsonUsageAnalyzer/NewtonsoftJsonUsageAnalyzer.Sample/NewtonsoftJsonUsageAnalyzer.Sample.csproj)):
1. You can use a nuget package with this analyzer:
```
dotnet add package NewtonsoftJsonUsageAnalyzer --version 0.2.0
```
2. You can attach this analyzer per specific project(s) (e.g., [NewtonsoftJsonUsageAnalyzer.Sample.csproj](https://github.com/Hixon10/NewtonsoftJsonUsageAnalyzer/blob/main/NewtonsoftJsonUsageAnalyzer/NewtonsoftJsonUsageAnalyzer.Sample/NewtonsoftJsonUsageAnalyzer.Sample.csproj)):
```
<ItemGroup>
<ProjectReference Include="..\NewtonsoftJsonUsageAnalyzer\NewtonsoftJsonUsageAnalyzer.csproj"
OutputItemType="Analyzer" ReferenceOutputAssembly="false"/>
</ItemGroup>
```
2. You can attach this analyzer [globally](https://www.meziantou.net/referencing-an-analyzer-from-a-project.htm) via `Directory.Build.props`:
3. You can attach this analyzer [globally](https://www.meziantou.net/referencing-an-analyzer-from-a-project.htm) via `Directory.Build.props`:
```
<Project>
<ItemGroup>
Expand All @@ -31,7 +37,6 @@ In a nutshell, you have 3 ways, how to use it:
</ItemGroup>
</Project>
```
3. You can use a nuget package with this analyzer (TODO: upload to nuget)

## Example of NS0001

Expand Down

0 comments on commit 113fd0c

Please sign in to comment.