summaryrefslogtreecommitdiff
path: root/src/SMAPI.ModBuildConfig.Analyzer
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI.ModBuildConfig.Analyzer')
-rw-r--r--src/SMAPI.ModBuildConfig.Analyzer/NetFieldAnalyzer.cs16
-rw-r--r--src/SMAPI.ModBuildConfig.Analyzer/ObsoleteFieldAnalyzer.cs6
-rw-r--r--src/SMAPI.ModBuildConfig.Analyzer/Properties/AssemblyInfo.cs4
-rw-r--r--src/SMAPI.ModBuildConfig.Analyzer/SMAPI.ModBuildConfig.Analyzer.csproj (renamed from src/SMAPI.ModBuildConfig.Analyzer/StardewModdingAPI.ModBuildConfig.Analyzer.csproj)13
-rw-r--r--src/SMAPI.ModBuildConfig.Analyzer/tools/install.ps158
-rw-r--r--src/SMAPI.ModBuildConfig.Analyzer/tools/uninstall.ps165
6 files changed, 17 insertions, 145 deletions
diff --git a/src/SMAPI.ModBuildConfig.Analyzer/NetFieldAnalyzer.cs b/src/SMAPI.ModBuildConfig.Analyzer/NetFieldAnalyzer.cs
index f2608348..a9b981bd 100644
--- a/src/SMAPI.ModBuildConfig.Analyzer/NetFieldAnalyzer.cs
+++ b/src/SMAPI.ModBuildConfig.Analyzer/NetFieldAnalyzer.cs
@@ -135,22 +135,22 @@ namespace StardewModdingAPI.ModBuildConfig.Analyzer
private readonly DiagnosticDescriptor AvoidImplicitNetFieldCastRule = new DiagnosticDescriptor(
id: "AvoidImplicitNetFieldCast",
title: "Netcode types shouldn't be implicitly converted",
- messageFormat: "This implicitly converts '{0}' from {1} to {2}, but {1} has unintuitive implicit conversion rules. Consider comparing against the actual value instead to avoid bugs. See https://smapi.io/buildmsg/avoid-implicit-net-field-cast for details.",
+ messageFormat: "This implicitly converts '{0}' from {1} to {2}, but {1} has unintuitive implicit conversion rules. Consider comparing against the actual value instead to avoid bugs. See https://smapi.io/package/avoid-implicit-net-field-cast for details.",
category: "SMAPI.CommonErrors",
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true,
- helpLinkUri: "https://smapi.io/buildmsg/avoid-implicit-net-field-cast"
+ helpLinkUri: "https://smapi.io/package/avoid-implicit-net-field-cast"
);
/// <summary>The diagnostic info for an avoidable net field access.</summary>
private readonly DiagnosticDescriptor AvoidNetFieldRule = new DiagnosticDescriptor(
id: "AvoidNetField",
title: "Avoid Netcode types when possible",
- messageFormat: "'{0}' is a {1} field; consider using the {2} property instead. See https://smapi.io/buildmsg/avoid-net-field for details.",
+ messageFormat: "'{0}' is a {1} field; consider using the {2} property instead. See https://smapi.io/package/avoid-net-field for details.",
category: "SMAPI.CommonErrors",
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true,
- helpLinkUri: "https://smapi.io/buildmsg/avoid-net-field"
+ helpLinkUri: "https://smapi.io/package/avoid-net-field"
);
@@ -199,7 +199,7 @@ namespace StardewModdingAPI.ModBuildConfig.Analyzer
/*********
** Private methods
*********/
- /// <summary>Analyse a member access syntax node and add a diagnostic message if applicable.</summary>
+ /// <summary>Analyze a member access syntax node and add a diagnostic message if applicable.</summary>
/// <param name="context">The analysis context.</param>
/// <returns>Returns whether any warnings were added.</returns>
private void AnalyzeMemberAccess(SyntaxNodeAnalysisContext context)
@@ -231,7 +231,7 @@ namespace StardewModdingAPI.ModBuildConfig.Analyzer
});
}
- /// <summary>Analyse an explicit cast or 'x as y' node and add a diagnostic message if applicable.</summary>
+ /// <summary>Analyze an explicit cast or 'x as y' node and add a diagnostic message if applicable.</summary>
/// <param name="context">The analysis context.</param>
/// <returns>Returns whether any warnings were added.</returns>
private void AnalyzeCast(SyntaxNodeAnalysisContext context)
@@ -248,7 +248,7 @@ namespace StardewModdingAPI.ModBuildConfig.Analyzer
});
}
- /// <summary>Analyse a binary comparison syntax node and add a diagnostic message if applicable.</summary>
+ /// <summary>Analyze a binary comparison syntax node and add a diagnostic message if applicable.</summary>
/// <param name="context">The analysis context.</param>
/// <returns>Returns whether any warnings were added.</returns>
private void AnalyzeBinaryComparison(SyntaxNodeAnalysisContext context)
@@ -288,7 +288,7 @@ namespace StardewModdingAPI.ModBuildConfig.Analyzer
}
/// <summary>Handle exceptions raised while analyzing a node.</summary>
- /// <param name="node">The node being analysed.</param>
+ /// <param name="node">The node being analyzed.</param>
/// <param name="action">The callback to invoke.</param>
private void HandleErrors(SyntaxNode node, Action action)
{
diff --git a/src/SMAPI.ModBuildConfig.Analyzer/ObsoleteFieldAnalyzer.cs b/src/SMAPI.ModBuildConfig.Analyzer/ObsoleteFieldAnalyzer.cs
index f1a3ef75..d071f0c1 100644
--- a/src/SMAPI.ModBuildConfig.Analyzer/ObsoleteFieldAnalyzer.cs
+++ b/src/SMAPI.ModBuildConfig.Analyzer/ObsoleteFieldAnalyzer.cs
@@ -27,11 +27,11 @@ namespace StardewModdingAPI.ModBuildConfig.Analyzer
["AvoidObsoleteField"] = new DiagnosticDescriptor(
id: "AvoidObsoleteField",
title: "Reference to obsolete field",
- messageFormat: "The '{0}' field is obsolete and should be replaced with '{1}'. See https://smapi.io/buildmsg/avoid-obsolete-field for details.",
+ messageFormat: "The '{0}' field is obsolete and should be replaced with '{1}'. See https://smapi.io/package/avoid-obsolete-field for details.",
category: "SMAPI.CommonErrors",
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true,
- helpLinkUri: "https://smapi.io/buildmsg/avoid-obsolete-field"
+ helpLinkUri: "https://smapi.io/package/avoid-obsolete-field"
)
};
@@ -67,7 +67,7 @@ namespace StardewModdingAPI.ModBuildConfig.Analyzer
/*********
** Private methods
*********/
- /// <summary>Analyse a syntax node and add a diagnostic message if it references an obsolete field.</summary>
+ /// <summary>Analyze a syntax node and add a diagnostic message if it references an obsolete field.</summary>
/// <param name="context">The analysis context.</param>
private void AnalyzeObsoleteFields(SyntaxNodeAnalysisContext context)
{
diff --git a/src/SMAPI.ModBuildConfig.Analyzer/Properties/AssemblyInfo.cs b/src/SMAPI.ModBuildConfig.Analyzer/Properties/AssemblyInfo.cs
deleted file mode 100644
index 1cc41000..00000000
--- a/src/SMAPI.ModBuildConfig.Analyzer/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,4 +0,0 @@
-using System.Reflection;
-
-[assembly: AssemblyTitle("SMAPI.ModBuildConfig.Analyzer")]
-[assembly: AssemblyDescription("")]
diff --git a/src/SMAPI.ModBuildConfig.Analyzer/StardewModdingAPI.ModBuildConfig.Analyzer.csproj b/src/SMAPI.ModBuildConfig.Analyzer/SMAPI.ModBuildConfig.Analyzer.csproj
index 1d8d7227..3659e25a 100644
--- a/src/SMAPI.ModBuildConfig.Analyzer/StardewModdingAPI.ModBuildConfig.Analyzer.csproj
+++ b/src/SMAPI.ModBuildConfig.Analyzer/SMAPI.ModBuildConfig.Analyzer.csproj
@@ -1,19 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>netstandard1.3</TargetFramework>
- <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
+ <AssemblyName>SMAPI.ModBuildConfig.Analyzer</AssemblyName>
+ <RootNamespace>StardewModdingAPI.ModBuildConfig.Analyzer</RootNamespace>
+ <Version>3.0.0</Version>
+ <TargetFramework>netstandard2.0</TargetFramework>
+ <LangVersion>latest</LangVersion>
<IncludeBuildOutput>false</IncludeBuildOutput>
<OutputPath>bin</OutputPath>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
- <Compile Include="..\..\build\GlobalAssemblyInfo.cs" Link="Properties\GlobalAssemblyInfo.cs" />
- </ItemGroup>
-
- <ItemGroup>
- <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="2.8.2" PrivateAssets="all" />
+ <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="2.10.0" PrivateAssets="all" />
<PackageReference Update="NETStandard.Library" PrivateAssets="all" />
</ItemGroup>
diff --git a/src/SMAPI.ModBuildConfig.Analyzer/tools/install.ps1 b/src/SMAPI.ModBuildConfig.Analyzer/tools/install.ps1
deleted file mode 100644
index ff051759..00000000
--- a/src/SMAPI.ModBuildConfig.Analyzer/tools/install.ps1
+++ /dev/null
@@ -1,58 +0,0 @@
-param($installPath, $toolsPath, $package, $project)
-
-if($project.Object.SupportsPackageDependencyResolution)
-{
- if($project.Object.SupportsPackageDependencyResolution())
- {
- # Do not install analyzers via install.ps1, instead let the project system handle it.
- return
- }
-}
-
-$analyzersPaths = Join-Path (Join-Path (Split-Path -Path $toolsPath -Parent) "analyzers") * -Resolve
-
-foreach($analyzersPath in $analyzersPaths)
-{
- if (Test-Path $analyzersPath)
- {
- # Install the language agnostic analyzers.
- foreach ($analyzerFilePath in Get-ChildItem -Path "$analyzersPath\*.dll" -Exclude *.resources.dll)
- {
- if($project.Object.AnalyzerReferences)
- {
- $project.Object.AnalyzerReferences.Add($analyzerFilePath.FullName)
- }
- }
- }
-}
-
-# $project.Type gives the language name like (C# or VB.NET)
-$languageFolder = ""
-if($project.Type -eq "C#")
-{
- $languageFolder = "cs"
-}
-if($project.Type -eq "VB.NET")
-{
- $languageFolder = "vb"
-}
-if($languageFolder -eq "")
-{
- return
-}
-
-foreach($analyzersPath in $analyzersPaths)
-{
- # Install language specific analyzers.
- $languageAnalyzersPath = join-path $analyzersPath $languageFolder
- if (Test-Path $languageAnalyzersPath)
- {
- foreach ($analyzerFilePath in Get-ChildItem -Path "$languageAnalyzersPath\*.dll" -Exclude *.resources.dll)
- {
- if($project.Object.AnalyzerReferences)
- {
- $project.Object.AnalyzerReferences.Add($analyzerFilePath.FullName)
- }
- }
- }
-}
diff --git a/src/SMAPI.ModBuildConfig.Analyzer/tools/uninstall.ps1 b/src/SMAPI.ModBuildConfig.Analyzer/tools/uninstall.ps1
deleted file mode 100644
index 4bed3337..00000000
--- a/src/SMAPI.ModBuildConfig.Analyzer/tools/uninstall.ps1
+++ /dev/null
@@ -1,65 +0,0 @@
-param($installPath, $toolsPath, $package, $project)
-
-if($project.Object.SupportsPackageDependencyResolution)
-{
- if($project.Object.SupportsPackageDependencyResolution())
- {
- # Do not uninstall analyzers via uninstall.ps1, instead let the project system handle it.
- return
- }
-}
-
-$analyzersPaths = Join-Path (Join-Path (Split-Path -Path $toolsPath -Parent) "analyzers") * -Resolve
-
-foreach($analyzersPath in $analyzersPaths)
-{
- # Uninstall the language agnostic analyzers.
- if (Test-Path $analyzersPath)
- {
- foreach ($analyzerFilePath in Get-ChildItem -Path "$analyzersPath\*.dll" -Exclude *.resources.dll)
- {
- if($project.Object.AnalyzerReferences)
- {
- $project.Object.AnalyzerReferences.Remove($analyzerFilePath.FullName)
- }
- }
- }
-}
-
-# $project.Type gives the language name like (C# or VB.NET)
-$languageFolder = ""
-if($project.Type -eq "C#")
-{
- $languageFolder = "cs"
-}
-if($project.Type -eq "VB.NET")
-{
- $languageFolder = "vb"
-}
-if($languageFolder -eq "")
-{
- return
-}
-
-foreach($analyzersPath in $analyzersPaths)
-{
- # Uninstall language specific analyzers.
- $languageAnalyzersPath = join-path $analyzersPath $languageFolder
- if (Test-Path $languageAnalyzersPath)
- {
- foreach ($analyzerFilePath in Get-ChildItem -Path "$languageAnalyzersPath\*.dll" -Exclude *.resources.dll)
- {
- if($project.Object.AnalyzerReferences)
- {
- try
- {
- $project.Object.AnalyzerReferences.Remove($analyzerFilePath.FullName)
- }
- catch
- {
-
- }
- }
- }
- }
-}