Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<RootNamespace>Contoso.WebApi</RootNamespace>
</PropertyGroup>

<!-- Additional project-specific analyzers (on top of 2 global analyzers from Directory.Build.props) -->
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.2" />
<PackageReference Include="Roslynator.Analyzers" Version="4.7.0" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.16.0.82469" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.127" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
namespace AnalyzerHeavy;
using Microsoft.Extensions.Logging;

/// <summary>
/// A class with enough code to make analyzers do meaningful work.
/// </summary>
public class HeavyClass
namespace Contoso.WebApi;

public class DataService
{
private readonly ILogger<DataService> _logger;

public DataService(ILogger<DataService> logger)
{
_logger = logger;
}

private readonly Dictionary<string, List<int>> _data = new();

public void AddValues(string key, params int[] values)
Expand All @@ -28,6 +34,7 @@ public IReadOnlyDictionary<string, int> GetCounts()

public string GenerateReport()
{
_logger.LogInformation("Generating report for {Count} keys", _data.Count);
var sb = new System.Text.StringBuilder();
foreach (var (key, values) in _data)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<!-- Enforce code style analysis for every project in the repo -->
<PropertyGroup>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<AnalysisLevel>latest-recommended</AnalysisLevel>
Comment thread
JanKrivanek marked this conversation as resolved.
</PropertyGroup>

<!-- Global analyzers — applied to ALL projects, including tests -->
<ItemGroup>
<GlobalPackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0" />
<GlobalPackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
Expand Down
22 changes: 11 additions & 11 deletions tests/dotnet-msbuild/build-perf-diagnostics/eval.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
scenarios:
- name: "Analyze analyzer performance impact on builds"
prompt: "Build this project and analyze its build performance. Review the full build infrastructure including Directory.Build.props. Identify bottlenecks and suggest specific MSBuild property configurations to improve dev inner loop build times while preserving CI quality enforcement."
- name: "Diagnose slow build for a small project"
prompt: >-
This .NET project's build time is unacceptable for its size.
Systematically diagnose where build time is being spent and recommend
targeted fixes.
setup:
copy_test_files: true
assertions:
- type: "output_contains"
value: "RunAnalyzers"
- type: "output_matches"
pattern: "(analyzer|Analyzer)"
pattern: "(RunAnalyzers|analyzer|Analyzer)"
Comment thread
JanKrivanek marked this conversation as resolved.
rubric:
- "Identified all analyzer packages including those from GlobalPackageReference in Directory.Build.props"
- "Explained that analyzers significantly increase Csc compilation time"
- "Suggested using RunAnalyzers property to conditionally disable analyzers during dev inner loop"
- "Identified EnforceCodeStyleInBuild should be conditional on CI, not always true"
- "Solution preserves full analyzer enforcement in CI pipelines while speeding dev builds"
timeout: 160
- "Identified that Roslyn analyzers are consuming a disproportionate share of build time"
- "Found analyzer packages in both Directory.Build.props (GlobalPackageReference) and the project file"
- "Recommended using RunAnalyzers property to conditionally disable analyzers in the dev inner loop"
- "Proposed making EnforceCodeStyleInBuild conditional on CI environment while preserving enforcement in CI pipelines"
Comment thread
JanKrivanek marked this conversation as resolved.
timeout: 360
Loading