Skip to content

Commit

Permalink
* fix all violations of Roslyn analyzer rules and ReSharper inspectio…
Browse files Browse the repository at this point in the history
…n @ c#
  • Loading branch information
n0099 committed Jun 10, 2024
1 parent 9fea275 commit 328e6aa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions c#/crawler/src/Db/Post/PostWithContentAndAuthorExpGrade.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
// ReSharper disable PropertyCanBeMadeInitOnly.Global

Check warning on line 1 in c#/crawler/src/Db/Post/PostWithContentAndAuthorExpGrade.cs

View workflow job for this annotation

GitHub Actions / ReSharper

"[AD0001] Analyzer 'Microsoft.CodeAnalysis.CodeStyle.CSharpFormattingAnalyzer' threw an exception of type 'System.TypeLoadException' with message 'Could not load type 'Microsoft.CodeAnalysis.SyntaxList' from assembly 'Microsoft.CodeAnalysis, Version=42.42.42.42, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.'. Exception occurred with following context: Compilation: tbm.Crawler SyntaxTree: /home/runner/work/open-tbm/open-tbm/c#/crawler/src/Db/Post/PostWithContentAndAuthorExpGrade.cs System.TypeLoadException: Could not load type 'Microsoft.CodeAnalysis.SyntaxList' from assembly 'Microsoft.CodeAnalysis, Version=42.42.42.42, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. at Microsoft.CodeAnalysis.CSharp.Extensions.MemberDeclarationSyntaxExtensions.GetAttributes(MemberDeclarationSyntax member) at Microsoft.CodeAnalysis.CSharp.Formatting.FormattingHelpers.GetFirstAndLastMemberDeclarationTokensAfterAttributes(MemberDeclarationSyntax node) at Microsoft.CodeAnalysis.CSharp.Formatting.SuppressFormattingRule.AddSpecificNodesSuppressOperations(List`1 list, SyntaxNode node) at Microsoft.CodeAnalysis.Formatting.Rules.NextSuppressOperationAction.Invoke() at Microsoft.CodeAnalysis.CSharp.Formatting.ElasticTriviaFormattingRule.AddSuppressOperations(List`1 list, SyntaxNode node, NextSuppressOperationAction& nextOperation) at Microsoft.CodeAnalysis.Formatting.Rules.NextSuppressOperationAction.Invoke() at Microsoft.CodeAnalysis.CSharp.Formatting.SpacingFormattingRule.AddSuppressOperations(List`1 list, SyntaxNode node, NextSuppressOperationAction& nextOperation) at Microsoft.CodeAnalysis.Formatting.Rules.NextSuppressOperationAction.Invoke() at Microsoft.CodeAnalysis.CSharp.Formatting.WrappingFormattingRule.AddSuppressOperations(List`1 list, SyntaxNode node, NextSuppressOperationAction& nextOperation) at Microsoft.CodeAnalysis.Formatting.ChainedFormattingRules.AddSuppressOperations(List`1 list, SyntaxNode currentNode) at Microsoft.CodeAnalysis.Formatting.AbstractFormatEngine.AddOperations[T](SegmentedList`1 operations, List`1 scratch, SyntaxNode node, Action`2 addOperations) at Microsoft.CodeAnalysis.Formatting.AbstractFormatEngine.CreateNodeOperations(CancellationToken cancellationToken) at Microsoft.CodeAnalysis.Formatting.AbstractFormatEngine.Format(CancellationToken cancellationToken) at Microsoft.CodeAnalysis.Formatting.AbstractSyntaxFormatting.GetFormattingResult(SyntaxNode node, IEnumerable`1 spans, SyntaxFormattingOptions options, IEnumerable`1 rules, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.CodeStyle.FormattingAnalyzerHelper.AnalyzeSyntaxTree(SyntaxTreeAnalysisContext context, ISyntaxFormatting formattingProvider, DiagnosticDescriptor descriptor, SyntaxFormattingOptions options) at Microsoft.CodeAnalysis.CodeStyle.AbstractFormattingAnalyzer.<>c__DisplayClass4_0.<InitializeWorker>b__1(SyntaxTreeAnalysisContext treeContext) at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c.<ExecuteSyntaxTreeActions>b__50_1(ValueTuple`2 data) in Z:\BuildAgent\work\3b7ce003563d6f8f\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 590 at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken) in Z:\BuildAgent\work\3b7ce003563d6f8f\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1185 ----- Suppress the following diagnostics to disable this analyzer: IDE0055" on /home/runner/work/open-tbm/open-tbm/c#/crawler/src/Db/Post/PostWithContentAndAuthorExpGrade.cs
// ReSharper disable UnusedAutoPropertyAccessor.Global
namespace tbm.Crawler.Db.Post;

#pragma warning disable AV1000 // Type name contains the word 'and', which suggests it has multiple purposes
public abstract class PostWithContentAndAuthorExpGrade : PostWithAuthorExpGrade
#pragma warning restore AV1000 // Type name contains the word 'and', which suggests it has multiple purposes
{
[NotMapped] public byte[]? Content { get; set; }

Expand Down
1 change: 1 addition & 0 deletions c#/shared/src/Db/TbmDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ private static void ManipulateCommand(DbCommand command) =>
"RETURNING pg_current_xact_id()::xid");
}
}

public class TbmDbContext<TModelCacheKeyFactory>(ILogger<TbmDbContext<TModelCacheKeyFactory>> logger)
: TbmDbContext(logger)
where TModelCacheKeyFactory : class, IModelCacheKeyFactory
Expand Down
2 changes: 1 addition & 1 deletion c#/shared/src/TransformEntityWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async Task SaveThenLog(int processedCount, Process currentProcess)
logger.LogTrace("processedEntityCount:{} updatedEntityCount:{} elapsed:{}ms processMemory:{}MiB exceptions:{}",
processedCount, updatedEntityCount,
stopwatch.ElapsedMilliseconds,
currentProcess.PrivateMemorySize64 / 1024 / 1024,
currentProcess.PrivateMemorySize64 / 1024f / 1024,
JsonSerializer.Serialize(exceptions, JsonSerializerOptions));
stopwatch.Restart();
}
Expand Down

0 comments on commit 328e6aa

Please sign in to comment.