Fix MSBuild task so that the generated code is included in the compilation#745
Conversation
….MSBuild.Tests project
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughReplaces the previous BeforeBuild target with a UsingTask and a new RefitterGenerate target run before CoreCompile; RefitterGenerateTask now exposes GeneratedFiles to MSBuild, the project compiles only those generated files, README updated, task enhanced for multi-file outputs, and test script switched to dotnet CLI. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Dev as Developer
participant MSB as MSBuild
participant Tgt as Target: RefitterGenerate
participant Task as RefitterGenerateTask
participant CLI as refitter.dll
participant FS as File System
participant Csc as C# Compiler
Dev->>MSB: build
MSB->>Tgt: invoke BeforeTargets=CoreCompile
Tgt->>Task: Execute(ProjectFileDirectory, DisableLogging)
Task->>CLI: run refitter CLI (resolve path)
CLI-->>FS: write generated files
Task->>FS: determine expected outputs (parse .refitter)
FS-->>Task: return existing generated file paths
Task-->>Tgt: Output GeneratedFiles -> @(RefitterGeneratedFiles)
Tgt->>MSB: update Compile Include=@(RefitterGeneratedFiles)
MSB->>Csc: compile @(RefitterGeneratedFiles)
Csc-->>MSB: artifacts
MSB-->>Dev: build complete
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Pre-merge checks (2 passed, 1 warning)❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Poem
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. ✨ Finishing touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the MSBuild integration for Refitter by making the code generation process more precise and reliable. Instead of including all .cs files in compilation, the MSBuild task now dynamically determines and includes only the files actually generated by Refitter.
Key changes:
- Enhanced MSBuild task to expose generated files as an output parameter and parse
.refitterconfiguration files to predict outputs - Updated MSBuild targets to use explicit task declaration and include only generated files in compilation
- Improved test scripts to use
dotnetCLI commands consistently
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
test/MSBuild/build.ps1 |
Updated to use dotnet CLI commands and simplified the test workflow |
src/Refitter.MSBuild/RefitterGenerateTask.cs |
Added logic to parse .refitter files, predict generated outputs, and expose them via GeneratedFiles output parameter |
src/Refitter.MSBuild/Refitter.MSBuild.targets |
Updated target to use explicit UsingTask declaration and include only generated files in compilation |
src/Refitter.MSBuild/README.md |
Updated documentation to reflect new MSBuild integration pattern |
README.md |
Updated MSBuild section with new target and task usage examples |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #745 +/- ##
==========================================
- Coverage 98.52% 95.47% -3.06%
==========================================
Files 60 60
Lines 2918 2982 +64
==========================================
- Hits 2875 2847 -28
- Misses 4 102 +98
+ Partials 39 33 -6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 11
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (5)
src/Refitter.MSBuild/RefitterGenerateTask.cs (3)
11-16: Add XML docs and mark required MSBuild inputs/outputs.Public APIs need XML docs. Also, ProjectFileDirectory should be required, and GeneratedFiles should be initialized to an empty array to avoid nulls.
- public string ProjectFileDirectory { get; set; } + /// <summary>Absolute path to the project directory where .refitter files will be scanned.</summary> + [Required] + public string ProjectFileDirectory { get; set; } = string.Empty; @@ - [Output] - public ITaskItem[] GeneratedFiles { get; set; } + /// <summary>MSBuild output items containing absolute paths to generated files.</summary> + [Output] + public ITaskItem[] GeneratedFiles { get; set; } = Array.Empty<ITaskItem>();
18-46: Fail the task when generation fails instead of always returning true.Currently Execute() always returns true, even if the CLI is missing or exits with a non-zero code. This can silently produce incomplete builds.
- public override bool Execute() + public override bool Execute() { @@ - var generatedFiles = new List<string>(); + var generatedFiles = new List<string>(); + var hadErrors = false; @@ - var generated = TryExecuteRefitter(file); + var generated = TryExecuteRefitter(file); if (generated != null) { generatedFiles.AddRange(generated); } + else + { + hadErrors = true; + } } @@ - TryLogCommandLine($"Generated {GeneratedFiles.Length} files"); - - return true; + TryLogCommandLine($"Generated {GeneratedFiles.Length} files"); + return !hadErrors; }
101-121: Check process exit code and fail on non-zero.If the CLI fails, we should log and propagate a failure rather than quietly returning no files.
process.Start(); process.BeginErrorReadLine(); process.BeginOutputReadLine(); process.WaitForExit(); + if (process.ExitCode != 0) + { + TryLogError($"Refitter CLI exited with code {process.ExitCode} for settings file: {file}"); + throw new InvalidOperationException($"Refitter CLI failed with exit code {process.ExitCode}."); + }src/Refitter.MSBuild/README.md (2)
56-58: Fix invalid JSON example (missing comma after outputFolder)Copy-paste will fail without this comma.
Apply:
- "outputFolder": "../CustomOutput" // Optional. Default=./Generated + "outputFolder": "../CustomOutput", // Optional. Default=./Generated "outputFilename": "RefitInterface.cs", // Optional. Default=Output.cs for CLI tool
151-151: Spelling/wording: multipleIinterfaces → multipleInterfaces; sentence casingApply:
-- `operationNameTemplate` - Generate operation names using pattern. This must contain the string {operationName}. An example usage of this could be `{operationName}Async` to suffix all method names with Async. When using `"multipleIinterfaces": "ByEndpoint"`, This is name of the Execute() method in the interface +- `operationNameTemplate` - Generate operation names using pattern. This must contain the string {operationName}. An example usage of this could be `{operationName}Async` to suffix all method names with Async. When using `"multipleInterfaces": "ByEndpoint"`, this is the name of the Execute() method in the interface
🧹 Nitpick comments (5)
src/Refitter.MSBuild/RefitterGenerateTask.cs (3)
123-125: Consider returning expected paths even if not yet on disk, and let MSBuild handle missing files.Filtering to File.Exists here may hide generation gaps. Alternatively, keep as-is but add a warning when an expected file is missing to aid diagnostics.
238-254: Drop ad-hoc regex helpers once proper JSON parsing is in place.If you adopt System.Text.Json above, these helpers become unnecessary.
70-84: Path probing: consider packaging invariants instead of dev-only paths.The dev-time Debug path guesses are helpful locally but fragile in CI. Prefer resolving refitter.dll relative to the task assembly for packaged scenarios, and only conditionally probe dev paths behind an environment flag (e.g., REFITTER_DEV=1).
test/MSBuild/build.ps1 (1)
14-15: Confirm intent to run vs. build; -filelogger is a build arg.-dotnet run builds and executes the app; if you only need to validate compilation, prefer dotnet build. Also, -filelogger is an MSBuild logger switch; it may be ignored by run.
-dotnet run -v d -filelogger +dotnet build -v d -filelogger +# If you also need to execute afterward: +# dotnet run --no-build -v dsrc/Refitter.MSBuild/README.md (1)
3-3: Minor grammar polish“tasks that include” and “client” (lowercase) read better.
Apply:
-Refitter is available as custom MSBuild tasks that includes the Refitter CLI executable for generating a REST API Client using the [Refit](https://github.com/reactiveui/refit) library. +Refitter provides custom MSBuild tasks that include the Refitter CLI executable for generating a REST API client using the [Refit](https://github.com/reactiveui/refit) library.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
README.md(1 hunks)src/Refitter.MSBuild/README.md(1 hunks)src/Refitter.MSBuild/Refitter.MSBuild.targets(1 hunks)src/Refitter.MSBuild/RefitterGenerateTask.cs(5 hunks)test/MSBuild/build.ps1(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
README.md
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Update README.md when adding new CLI options or features
Files:
README.md
**/*.cs
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.cs: Follow existing C# coding conventions defined in .editorconfig
Use PascalCase for public members and camelCase for parameters and local variables
Use meaningful variable and method names
Keep methods focused with single responsibility
Files:
src/Refitter.MSBuild/RefitterGenerateTask.cs
src/{Refitter,Refitter.Core,Refitter.SourceGenerator,Refitter.MSBuild}/**/*.cs
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Include XML documentation for public APIs
Files:
src/Refitter.MSBuild/RefitterGenerateTask.cs
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
PR: christianhelle/refitter#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-13T18:27:12.292Z
Learning: Applies to src/{Refitter,Refitter.Core,Refitter.SourceGenerator,Refitter.MSBuild}/**/*.cs : Include XML documentation for public APIs
Learnt from: CR
PR: christianhelle/refitter#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-13T18:27:12.292Z
Learning: Before committing, run 'dotnet format src/Refitter.sln' and ensure 'dotnet format --verify-no-changes' passes
Learnt from: CR
PR: christianhelle/refitter#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-13T18:27:12.292Z
Learning: Applies to src/{Refitter.Tests,Refitter.SourceGenerator.Tests}/**/*.cs : All new code must include unit tests following the Refitter.Tests.Examples pattern (xUnit [Fact], assertions, and compile check)
Learnt from: CR
PR: christianhelle/refitter#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-13T18:27:12.292Z
Learning: Applies to src/Refitter.Core/RefitInterfaceGenerator.cs : When adding a new CLI option, implement the generation logic in RefitInterfaceGenerator
📚 Learning: 2025-08-13T18:27:12.292Z
Learnt from: CR
PR: christianhelle/refitter#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-13T18:27:12.292Z
Learning: Before committing, run 'dotnet format src/Refitter.sln' and ensure 'dotnet format --verify-no-changes' passes
Applied to files:
test/MSBuild/build.ps1README.mdsrc/Refitter.MSBuild/Refitter.MSBuild.targetssrc/Refitter.MSBuild/README.md
📚 Learning: 2025-08-13T18:27:12.292Z
Learnt from: CR
PR: christianhelle/refitter#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-13T18:27:12.292Z
Learning: Applies to src/{Refitter,Refitter.Core,Refitter.SourceGenerator,Refitter.MSBuild}/**/*.cs : Include XML documentation for public APIs
Applied to files:
README.mdsrc/Refitter.MSBuild/Refitter.MSBuild.targetssrc/Refitter.MSBuild/RefitterGenerateTask.cssrc/Refitter.MSBuild/README.md
📚 Learning: 2025-08-13T18:27:12.292Z
Learnt from: CR
PR: christianhelle/refitter#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-13T18:27:12.292Z
Learning: Applies to src/{Refitter.Tests,Refitter.SourceGenerator.Tests}/**/*.cs : All new code must include unit tests following the Refitter.Tests.Examples pattern (xUnit [Fact], assertions, and compile check)
Applied to files:
src/Refitter.MSBuild/Refitter.MSBuild.targetssrc/Refitter.MSBuild/RefitterGenerateTask.cssrc/Refitter.MSBuild/README.md
📚 Learning: 2025-08-13T18:27:12.292Z
Learnt from: CR
PR: christianhelle/refitter#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-13T18:27:12.292Z
Learning: Applies to src/Refitter.Core/RefitInterfaceGenerator.cs : When adding a new CLI option, implement the generation logic in RefitInterfaceGenerator
Applied to files:
src/Refitter.MSBuild/RefitterGenerateTask.cs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: 👌 Verify build
- GitHub Check: 👌 Verify build
- GitHub Check: 👌 Verify build
- GitHub Check: script
- GitHub Check: Analyze (csharp)
🔇 Additional comments (5)
test/MSBuild/build.ps1 (1)
4-4: LGTM: clearing global packages for a clean test environment.This matches the intent to ensure the local package is used.
src/Refitter.MSBuild/README.md (2)
13-15: LGTM on task invocation and Output mappingThe Output->ItemName mapping matches the new GeneratedFiles contract.
17-17: Confirm no lingering Compile globs remain elsewhereIf any other target still includes **/*.cs from the generated output folders, you may double-include files. Please verify.
src/Refitter.MSBuild/Refitter.MSBuild.targets (2)
9-11: LGTM on Output mappingItem output wiring to @(RefitterGeneratedFiles) is correct.
13-13: Verify no other Compile includes pick up stray filesEnsure no other imported targets still glob generated folders (to avoid duplicates).
|
|
||
| Refitter is available as custom MSBuild tasks that includes the Refitter CLI executable for generating a REST API Client using the [Refit](https://github.com/reactiveui/refit) library. Refitter can generate the Refit interface from OpenAPI specifications. Refitter could format the generated Refit interface to be managed by [Apizr](https://www.apizr.net) (v6+) and generate some registration helpers too. | ||
|
|
||
| The MSBuild package includes a custom `.target` file which executes the `RefitterGenerateTask` custom task and looks something like this: |
There was a problem hiding this comment.
Typo: .target → .targets
File extension should be .targets.
Apply:
-The MSBuild package includes a custom `.target` file which executes the `RefitterGenerateTask` custom task and looks something like this:
+The MSBuild package includes a custom `.targets` file which executes the `RefitterGenerateTask` custom task and looks like this:📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| The MSBuild package includes a custom `.target` file which executes the `RefitterGenerateTask` custom task and looks something like this: | |
| The MSBuild package includes a custom `.targets` file which executes the `RefitterGenerateTask` custom task and looks like this: |
🤖 Prompt for AI Agents
In src/Refitter.MSBuild/README.md around line 5, update the typo where the file
extension is written as ".target" to the correct ".targets"; edit the sentence
so it reads ".targets" (and scan the file for any other occurrences of ".target"
to correct to ".targets" if present).
| AssemblyFile="$(MSBuildThisFileDirectory)Refitter.MSBuild.dll" | ||
| Condition="Exists('$(MSBuildThisFileDirectory)Refitter.MSBuild.dll')" /> | ||
| <Target Name="RefitterGenerate" BeforeTargets="BeforeCompile"> | ||
| <RefitterGenerateTask ProjectFileDirectory="$(MSBuildProjectDirectory)" |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Use CoreCompile (and CompileDesignTime) instead of BeforeCompile
BeforeCompile isn’t a standard target; your task may never run. Hook into CoreCompile; add CompileDesignTime so IDE design-time builds see generated files.
Apply:
-<Target Name="RefitterGenerate" BeforeTargets="BeforeCompile">
+<Target Name="RefitterGenerate" BeforeTargets="CoreCompile;CompileDesignTime"
+ Condition=" '$(IsCrossTargetingBuild)' != 'true' and Exists('$(MSBuildThisFileDirectory)Refitter.MSBuild.dll')">📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| <Target Name="RefitterGenerate" BeforeTargets="BeforeCompile"> | |
| <Target Name="RefitterGenerate" BeforeTargets="CoreCompile;CompileDesignTime" | |
| Condition=" '$(IsCrossTargetingBuild)' != 'true' and Exists('$(MSBuildThisFileDirectory)Refitter.MSBuild.dll')"> |
🤖 Prompt for AI Agents
In src/Refitter.MSBuild/README.md around line 11, the MSBuild Target uses
BeforeCompile which is not a standard target and can prevent the task from
running; update the Target's BeforeTargets to hook into CoreCompile and
CompileDesignTime instead so the task runs in normal and design-time builds
(replace BeforeCompile with BeforeTargets="CoreCompile;CompileDesignTime").
| <UsingTask TaskName="RefitterGenerateTask" | ||
| AssemblyFile="$(MSBuildThisFileDirectory)Refitter.MSBuild.dll" | ||
| Condition="Exists('$(MSBuildThisFileDirectory)Refitter.MSBuild.dll')" /> |
There was a problem hiding this comment.
Fully qualify TaskName for reliability
Avoid ambiguous or unresolvable types.
Apply:
- <UsingTask TaskName="RefitterGenerateTask"
+ <UsingTask TaskName="Refitter.MSBuild.RefitterGenerateTask"
AssemblyFile="$(MSBuildThisFileDirectory)Refitter.MSBuild.dll"
Condition="Exists('$(MSBuildThisFileDirectory)Refitter.MSBuild.dll')" />📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| <UsingTask TaskName="RefitterGenerateTask" | |
| AssemblyFile="$(MSBuildThisFileDirectory)Refitter.MSBuild.dll" | |
| Condition="Exists('$(MSBuildThisFileDirectory)Refitter.MSBuild.dll')" /> | |
| <UsingTask TaskName="Refitter.MSBuild.RefitterGenerateTask" | |
| AssemblyFile="$(MSBuildThisFileDirectory)Refitter.MSBuild.dll" | |
| Condition="Exists('$(MSBuildThisFileDirectory)Refitter.MSBuild.dll')" /> |
🤖 Prompt for AI Agents
In src/Refitter.MSBuild/Refitter.MSBuild.targets around lines 3 to 5, the
UsingTask uses an unqualified TaskName "RefitterGenerateTask" which can lead to
ambiguous or unresolvable task types; update TaskName to the fully-qualified
type name including its namespace (for example
NamespaceName.RefitterGenerateTask) so MSBuild can reliably locate the type in
the Refitter.MSBuild.dll, leaving AssemblyFile and Condition unchanged.
| private List<string> StartProcess(string file) | ||
| { | ||
| // First, determine what files will be generated by parsing the .refitter file | ||
| var expectedFiles = GetExpectedGeneratedFiles(file); | ||
|
|
||
| var assembly = Assembly.GetExecutingAssembly(); | ||
| var packageFolder = Path.GetDirectoryName(assembly.Location); | ||
| var seperator = Path.DirectorySeparatorChar; | ||
|
|
||
| // Try multiple possible locations for the Refitter CLI | ||
| var refitterDll = $"{packageFolder}{seperator}..{seperator}refitter.dll"; | ||
|
|
||
| // For development scenarios, try relative to the MSBuild project location |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Use ArgumentList and proper quoting; fix typo in variable name.
String-building Arguments will break with spaces and invites subtle bugs. Prefer ProcessStartInfo.ArgumentList. Also rename 'seperator' → 'separator'.
- var packageFolder = Path.GetDirectoryName(assembly.Location);
- var seperator = Path.DirectorySeparatorChar;
+ var packageFolder = Path.GetDirectoryName(assembly.Location);
+ var separator = Path.DirectorySeparatorChar;
@@
- var refitterDll = $"{packageFolder}{seperator}..{seperator}refitter.dll";
+ var refitterDll = $"{packageFolder}{separator}..{separator}refitter.dll";And below (see next comment) replace Arguments with ArgumentList.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| private List<string> StartProcess(string file) | |
| { | |
| // First, determine what files will be generated by parsing the .refitter file | |
| var expectedFiles = GetExpectedGeneratedFiles(file); | |
| var assembly = Assembly.GetExecutingAssembly(); | |
| var packageFolder = Path.GetDirectoryName(assembly.Location); | |
| var seperator = Path.DirectorySeparatorChar; | |
| // Try multiple possible locations for the Refitter CLI | |
| var refitterDll = $"{packageFolder}{seperator}..{seperator}refitter.dll"; | |
| // For development scenarios, try relative to the MSBuild project location | |
| private List<string> StartProcess(string file) | |
| { | |
| // First, determine what files will be generated by parsing the .refitter file | |
| var expectedFiles = GetExpectedGeneratedFiles(file); | |
| var assembly = Assembly.GetExecutingAssembly(); | |
| var packageFolder = Path.GetDirectoryName(assembly.Location); | |
| var separator = Path.DirectorySeparatorChar; | |
| // Try multiple possible locations for the Refitter CLI | |
| var refitterDll = $"{packageFolder}{separator}..{separator}refitter.dll"; | |
| // For development scenarios, try relative to the MSBuild project location |
| if (!File.Exists(refitterDll)) | ||
| { | ||
| TryLogError($"Refitter CLI not found at: {refitterDll}"); | ||
| TryLogError($"Assembly location: {assembly.Location}"); | ||
| TryLogError($"Package folder: {packageFolder}"); | ||
| return new List<string>(); | ||
| } | ||
|
|
There was a problem hiding this comment.
Treat missing CLI as a hard failure.
Returning an empty list hides the root cause and keeps the build green.
- TryLogError($"Refitter CLI not found at: {refitterDll}");
- TryLogError($"Assembly location: {assembly.Location}");
- TryLogError($"Package folder: {packageFolder}");
- return new List<string>();
+ TryLogError($"Refitter CLI not found at: {refitterDll}");
+ TryLogError($"Assembly location: {assembly.Location}");
+ TryLogError($"Package folder: {packageFolder}");
+ throw new FileNotFoundException("Refitter CLI not found.", refitterDll);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (!File.Exists(refitterDll)) | |
| { | |
| TryLogError($"Refitter CLI not found at: {refitterDll}"); | |
| TryLogError($"Assembly location: {assembly.Location}"); | |
| TryLogError($"Package folder: {packageFolder}"); | |
| return new List<string>(); | |
| } | |
| if (!File.Exists(refitterDll)) | |
| { | |
| TryLogError($"Refitter CLI not found at: {refitterDll}"); | |
| TryLogError($"Assembly location: {assembly.Location}"); | |
| TryLogError($"Package folder: {packageFolder}"); | |
| throw new FileNotFoundException("Refitter CLI not found.", refitterDll); | |
| } |
🤖 Prompt for AI Agents
In src/Refitter.MSBuild/RefitterGenerateTask.cs around lines 91 to 98, the code
currently logs missing Refitter CLI and then returns an empty list, which masks
the failure and keeps the build green; change this to a hard failure by throwing
an exception (e.g., FileNotFoundException) after logging the error(s) so the
build fails visibly — include the paths (refitterDll, assembly.Location,
packageFolder) in the exception message to aid diagnostics.
| dotnet build -c release ../../src/Refitter.MSBuild/Refitter.MSBuild.csproj | ||
| dotnet pack -c release ../../src/Refitter.MSBuild/Refitter.MSBuild.csproj -o . | ||
| nuget add .\Refitter.MSBuild.1.0.0.nupkg -source . | ||
| dotnet add package .\Refitter.MSBuild.1.0.0.nupkg --source . |
There was a problem hiding this comment.
Invalid command: dotnet add package does not accept a .nupkg path.
This will fail. Use the package ID and point to the folder as a source (the pack step already put the .nupkg in .).
-dotnet add package .\Refitter.MSBuild.1.0.0.nupkg --source .
+# Register current folder as a source (optional if you pass --source . each time)
+# dotnet nuget add source . --name LocalRefitter
+dotnet add package Refitter.MSBuild --source .🤖 Prompt for AI Agents
In test/MSBuild/build.ps1 around line 12, the script incorrectly calls "dotnet
add package" with a .nupkg file path which is invalid; replace that call with
"dotnet add package" using the package ID and optionally the version, and point
--source to the folder containing the .nupkg (e.g. use the package ID
Refitter.MSBuild and --version 1.0.0 with --source .) so the CLI pulls the
package from the local folder.
|
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/Refitter.MSBuild/RefitterGenerateTask.cs (2)
61-74: Fix argument quoting and spaces; use ArgumentList; rename variable typoCurrent string-based args will break on paths with spaces; also “seperator” is misspelled.
- var expectedFiles = GetExpectedGeneratedFiles(file); + var expectedFiles = GetExpectedGeneratedFiles(file); var assembly = Assembly.GetExecutingAssembly(); var packageFolder = Path.GetDirectoryName(assembly.Location); - var seperator = Path.DirectorySeparatorChar; - var refitterDll = $"{packageFolder}{seperator}..{seperator}refitter.dll"; - - var args = $"{refitterDll} --settings-file {file}"; - if (DisableLogging) - { - args += " --no-logging"; - } + var separator = Path.DirectorySeparatorChar; + var refitterDll = $"{packageFolder}{separator}..{separator}refitter.dll"; @@ - TryLogCommandLine($"Starting dotnet {args}"); + var startInfo = new ProcessStartInfo + { + FileName = "dotnet", + WorkingDirectory = Path.GetDirectoryName(file)!, + RedirectStandardOutput = true, + RedirectStandardError = true, + UseShellExecute = false, + CreateNoWindow = true, + }; + startInfo.ArgumentList.Add(refitterDll); + startInfo.ArgumentList.Add("--settings-file"); + startInfo.ArgumentList.Add(file); + if (DisableLogging) + startInfo.ArgumentList.Add("--no-logging"); + + TryLogCommandLine($"Starting: dotnet {string.Join(' ', startInfo.ArgumentList)}"); - using var process = new Process - { - StartInfo = new ProcessStartInfo - { - FileName = "dotnet", - Arguments = args, - WorkingDirectory = Path.GetDirectoryName(file)!, - RedirectStandardOutput = true, - RedirectStandardError = true, - RedirectStandardInput = true, - UseShellExecute = false, - CreateNoWindow = true, - } - }; + using var process = new Process { StartInfo = startInfo };Also applies to: 83-99
100-109: Fail on non-zero exit code and surface errorsCurrently, generator failures are ignored.
process.Start(); process.BeginErrorReadLine(); process.BeginOutputReadLine(); process.WaitForExit(); - - // Return the list of files that should have been generated - return expectedFiles.Where(File.Exists).ToList(); + if (process.ExitCode != 0) + { + throw new InvalidOperationException($"Refitter CLI exited with code {process.ExitCode} for settings file '{file}'."); + } + // Return the list of files that should have been generated + return expectedFiles.Where(File.Exists).ToList();
♻️ Duplicate comments (6)
src/Refitter.MSBuild/Refitter.MSBuild.targets (2)
3-5: Fully qualify TaskName to avoid task resolution issuesUse the fully qualified type to make MSBuild reliably locate the task.
- <UsingTask TaskName="RefitterGenerateTask" + <UsingTask TaskName="Refitter.MSBuild.RefitterGenerateTask" AssemblyFile="$(MSBuildThisFileDirectory)Refitter.MSBuild.dll" Condition="Exists('$(MSBuildThisFileDirectory)Refitter.MSBuild.dll')" />
7-15: Guard the target and run for design-time buildsAdd CompileDesignTime and guard to skip cross-targeting outer build and missing DLL; otherwise IDEs won’t see generated files and builds may fail if the DLL isn’t present.
- <Target Name="RefitterGenerate" BeforeTargets="CoreCompile"> + <Target Name="RefitterGenerate" + BeforeTargets="CoreCompile;CompileDesignTime" + Condition=" '$(IsCrossTargetingBuild)' != 'true' and Exists('$(MSBuildThisFileDirectory)Refitter.MSBuild.dll')">src/Refitter.MSBuild/RefitterGenerateTask.cs (4)
42-44: Prefer using/alias over fully qualified TaskItemImproves readability and matches common MSBuild task style.
- GeneratedFiles = generatedFiles.Select(f => new Microsoft.Build.Utilities.TaskItem(f)).ToArray(); + GeneratedFiles = generatedFiles.Select(f => new TaskItem(f)).ToArray();Add at top:
+using TaskItem = Microsoft.Build.Utilities.TaskItem;
75-82: Treat missing CLI as a hard failureDon’t keep the build green when the generator is absent.
- TryLogError($"Refitter CLI not found at: {refitterDll}"); - TryLogError($"Assembly location: {assembly.Location}"); - TryLogError($"Package folder: {packageFolder}"); - return new List<string>(); + TryLogError($"Refitter CLI not found at: {refitterDll}"); + TryLogError($"Assembly location: {assembly.Location}"); + TryLogError($"Package folder: {packageFolder}"); + throw new FileNotFoundException("Refitter CLI not found.", refitterDll);
111-184: Replace brittle regex JSON parsing with System.Text.Json; honor flags like generateClients/ContractsRegex will break with comments, formatting, or nested structures and can miscompute outputs.
- private List<string> GetExpectedGeneratedFiles(string refitterFilePath) + private List<string> GetExpectedGeneratedFiles(string refitterFilePath) { try { var refitterFileDirectory = Path.GetDirectoryName(refitterFilePath) ?? string.Empty; - var refitterContent = File.ReadAllText(refitterFilePath); - - // Parse JSON properties using simple regex patterns - var outputFolder = ExtractJsonStringValue(refitterContent, "outputFolder"); - var outputFilename = ExtractJsonStringValue(refitterContent, "outputFilename"); - var generateMultipleFiles = ExtractJsonBoolValue(refitterContent, "generateMultipleFiles"); - var contractsOutputFolder = ExtractJsonStringValue(refitterContent, "contractsOutputFolder"); - var hasDependencyInjectionSettings = refitterContent.Contains("\"dependencyInjectionSettings\""); + var refitterContent = File.ReadAllText(refitterFilePath); + using var doc = System.Text.Json.JsonDocument.Parse( + refitterContent, + new System.Text.Json.JsonDocumentOptions { AllowTrailingCommas = true, CommentHandling = System.Text.Json.JsonCommentHandling.Skip }); + var root = doc.RootElement; + + string? outputFolder = root.TryGetProperty("outputFolder", out var of) ? of.GetString() : null; + string? outputFilename = root.TryGetProperty("outputFilename", out var ofn) ? ofn.GetString() : null; + string? contractsOutputFolder = root.TryGetProperty("contractsOutputFolder", out var cof) ? cof.GetString() : null; + bool generateMultipleFiles = root.TryGetProperty("generateMultipleFiles", out var gmf) && gmf.GetBoolean(); + bool generateClients = !root.TryGetProperty("generateClients", out var gc) || gc.GetBoolean(); + bool generateContracts = !root.TryGetProperty("generateContracts", out var gct) || gct.GetBoolean(); + bool hasDependencyInjectionSettings = root.TryGetProperty("dependencyInjectionSettings", out _); @@ - if (!string.IsNullOrWhiteSpace(contractsOutputFolder)) - { - generateMultipleFiles = true; - } + if (!string.IsNullOrWhiteSpace(contractsOutputFolder)) + generateMultipleFiles = true; @@ - if (string.IsNullOrWhiteSpace(outputFilename)) + if (string.IsNullOrWhiteSpace(outputFilename)) { var refitterFileName = Path.GetFileNameWithoutExtension(refitterFilePath); outputFilename = $"{refitterFileName}.cs"; } @@ - if (generateMultipleFiles) + if (generateMultipleFiles) { // Multiple files mode var baseOutputFolder = !string.IsNullOrWhiteSpace(outputFolder) ? outputFolder : "./Generated"; var interfaceOutputPath = Path.GetFullPath(Path.Combine(refitterFileDirectory, baseOutputFolder, "RefitInterfaces.cs")); var contractsOutputPath = Path.GetFullPath(Path.Combine(refitterFileDirectory, - !string.IsNullOrWhiteSpace(contractsOutputFolder) ? contractsOutputFolder : baseOutputFolder, + !string.IsNullOrWhiteSpace(contractsOutputFolder) ? contractsOutputFolder : baseOutputFolder, "Contracts.cs")); var diOutputPath = Path.GetFullPath(Path.Combine(refitterFileDirectory, baseOutputFolder, "DependencyInjection.cs")); - generatedFiles.Add(interfaceOutputPath); - generatedFiles.Add(contractsOutputPath); + if (generateClients) generatedFiles.Add(interfaceOutputPath); + if (generateContracts) generatedFiles.Add(contractsOutputPath); // DependencyInjection.cs is only generated if dependencyInjectionSettings are specified - if (hasDependencyInjectionSettings) + if (hasDependencyInjectionSettings && generateClients) { generatedFiles.Add(diOutputPath); } } else { // Single file mode string outputPath; if (!string.IsNullOrWhiteSpace(outputFolder)) { // outputFolder is specified outputPath = Path.GetFullPath(Path.Combine(refitterFileDirectory, outputFolder, outputFilename)); } else { // No outputFolder specified - generate in current directory (default behavior) outputPath = Path.GetFullPath(Path.Combine(refitterFileDirectory, outputFilename)); } generatedFiles.Add(outputPath); }
222-239: Remove fragile regex helpers once System.Text.Json is usedThese become unnecessary after switching to JsonDocument.
- private static string? ExtractJsonStringValue(string json, string propertyName) - { - // Simple regex to extract string values from JSON - // Pattern: "propertyName": "value" or "propertyName":"value" - var pattern = $@"""{Regex.Escape(propertyName)}""\s*:\s*""([^""]*)"""; - var match = Regex.Match(json, pattern, RegexOptions.IgnoreCase); - return match.Success ? match.Groups[1].Value : null; - } - - private static bool ExtractJsonBoolValue(string json, string propertyName) - { - // Simple regex to extract boolean values from JSON - // Pattern: "propertyName": true or "propertyName":false - var pattern = $@"""{Regex.Escape(propertyName)}""\s*:\s*(true|false)"; - var match = Regex.Match(json, pattern, RegexOptions.IgnoreCase); - return match.Success && string.Equals(match.Groups[1].Value, "true", StringComparison.OrdinalIgnoreCase); - } + // Regex helpers removed after switching to System.Text.Json.
🧹 Nitpick comments (2)
src/Refitter.MSBuild/Refitter.MSBuild.targets (1)
13-14: Include only when items exist (minor)Avoid adding an empty Include.
- <Compile Include="@(RefitterGeneratedFiles)" /> + <Compile Include="@(RefitterGeneratedFiles)" Condition=" '@(RefitterGeneratedFiles)' != '' " />src/Refitter.MSBuild/RefitterGenerateTask.cs (1)
11-17: Add XML docs and mark required inputsPublic API in src/Refitter.MSBuild should be documented; also mark ProjectFileDirectory as required to fail fast if missing.
public class RefitterGenerateTask : MSBuildTask { - public string ProjectFileDirectory { get; set; } + /// <summary>Absolute path to the project directory used to discover .refitter files.</summary> + [Required] + public string ProjectFileDirectory { get; set; } - public bool DisableLogging { get; set; } + /// <summary>Disables Refitter CLI logging when true.</summary> + public bool DisableLogging { get; set; } - [Output] - public ITaskItem[] GeneratedFiles { get; set; } + /// <summary>Files generated by Refitter and included in compilation.</summary> + [Output] + public ITaskItem[] GeneratedFiles { get; set; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/Refitter.MSBuild/Refitter.MSBuild.targets(1 hunks)src/Refitter.MSBuild/RefitterGenerateTask.cs(6 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.cs
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.cs: Follow existing C# coding conventions defined in .editorconfig
Use PascalCase for public members and camelCase for parameters and local variables
Use meaningful variable and method names
Keep methods focused with single responsibility
Files:
src/Refitter.MSBuild/RefitterGenerateTask.cs
src/{Refitter,Refitter.Core,Refitter.SourceGenerator,Refitter.MSBuild}/**/*.cs
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Include XML documentation for public APIs
Files:
src/Refitter.MSBuild/RefitterGenerateTask.cs
🧠 Learnings (6)
📓 Common learnings
Learnt from: CR
PR: christianhelle/refitter#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-13T18:27:12.292Z
Learning: Before committing, run 'dotnet format src/Refitter.sln' and ensure 'dotnet format --verify-no-changes' passes
Learnt from: CR
PR: christianhelle/refitter#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-13T18:27:12.292Z
Learning: Applies to src/{Refitter.Tests,Refitter.SourceGenerator.Tests}/**/*.cs : All new code must include unit tests following the Refitter.Tests.Examples pattern (xUnit [Fact], assertions, and compile check)
📚 Learning: 2025-08-13T18:27:12.292Z
Learnt from: CR
PR: christianhelle/refitter#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-13T18:27:12.292Z
Learning: Applies to src/{Refitter,Refitter.Core,Refitter.SourceGenerator,Refitter.MSBuild}/**/*.cs : Include XML documentation for public APIs
Applied to files:
src/Refitter.MSBuild/RefitterGenerateTask.cssrc/Refitter.MSBuild/Refitter.MSBuild.targets
📚 Learning: 2025-08-13T18:27:12.292Z
Learnt from: CR
PR: christianhelle/refitter#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-13T18:27:12.292Z
Learning: Applies to src/{Refitter.Tests,Refitter.SourceGenerator.Tests}/**/*.cs : All new code must include unit tests following the Refitter.Tests.Examples pattern (xUnit [Fact], assertions, and compile check)
Applied to files:
src/Refitter.MSBuild/RefitterGenerateTask.cssrc/Refitter.MSBuild/Refitter.MSBuild.targets
📚 Learning: 2025-08-13T18:27:12.292Z
Learnt from: CR
PR: christianhelle/refitter#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-13T18:27:12.292Z
Learning: Applies to src/Refitter.Core/RefitInterfaceGenerator.cs : When adding a new CLI option, implement the generation logic in RefitInterfaceGenerator
Applied to files:
src/Refitter.MSBuild/RefitterGenerateTask.cs
📚 Learning: 2025-08-13T18:27:12.292Z
Learnt from: CR
PR: christianhelle/refitter#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-13T18:27:12.292Z
Learning: Applies to src/Refitter/GenerateCommand.cs : When adding a new CLI option, update GenerateCommand.cs with new command-line arguments
Applied to files:
src/Refitter.MSBuild/RefitterGenerateTask.cs
📚 Learning: 2025-08-13T18:27:12.292Z
Learnt from: CR
PR: christianhelle/refitter#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-13T18:27:12.292Z
Learning: Before committing, run 'dotnet format src/Refitter.sln' and ensure 'dotnet format --verify-no-changes' passes
Applied to files:
src/Refitter.MSBuild/RefitterGenerateTask.cssrc/Refitter.MSBuild/Refitter.MSBuild.targets
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: 👌 Verify build
- GitHub Check: 👌 Verify build
- GitHub Check: script
- GitHub Check: 👌 Verify build
- GitHub Check: Analyze (csharp)
| return true; | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Return failure when errors are logged
MSBuild tasks should return false on error to stop the build.
- return true;
+ return !Log.HasLoggedErrors;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| return true; | |
| } | |
| return !Log.HasLoggedErrors; | |
| } |
🤖 Prompt for AI Agents
In src/Refitter.MSBuild/RefitterGenerateTask.cs around lines 45-46, the Execute
method currently always returns true; change it to return false when MSBuild
errors were logged so the build stops. Replace the unconditional return true
with a return that checks the task logger (e.g. return !Log.HasLoggedErrors or
return !(this.Log?.HasLoggedErrors ?? false)) so the method returns false if any
errors were logged.
Updated [refitter](https://github.com/christianhelle/refitter) from 1.4.0 to 1.7.0. <details> <summary>Release notes</summary> _Sourced from [refitter's releases](https://github.com/christianhelle/refitter/releases)._ ## 1.7.0 ## What's Changed * Fix Multipart file array support by @christianhelle in christianhelle/refitter#784 * Add option to remove `[JsonConverter(typeof(JsonStringEnumConverter))]` from generated contracts by @christianhelle in christianhelle/refitter#786 * Improve OpenAPI Description handling by @christianhelle in christianhelle/refitter#787 * Update Smoke Tests workflow trigger by @christianhelle in christianhelle/refitter#791 * Add support for customizing the default Integer format by @christianhelle in christianhelle/refitter#792 * NSwag v14.6.2 by @christianhelle in christianhelle/refitter#800 ## New Contributors: - @christophdebaene - @7amou3 - @HGCollier **Full Changelog**: christianhelle/refitter@1.6.5...1.7.0 ## 1.6.5 ## What's Changed * Do not remove colon from url paths, verify they're not present in operation names by @eoma-knowit in christianhelle/refitter#765 * Add ability to skip-validation + simplify Unicode logging by @david-pw in christianhelle/refitter#767 * Use NSwag's built-in System.Text.Json polymorphic serialization by @0xced in christianhelle/refitter#772 ## New Contributors * @eoma-knowit made their first contribution in christianhelle/refitter#765 * @david-pw made their first contribution in christianhelle/refitter#767 * @0xced made their first contribution in christianhelle/refitter#772 **Full Changelog**: christianhelle/refitter@1.6.4...1.6.5 ## 1.6.4 ## What's Changed * Fix SonarCloud maintainability issues - eliminate code duplication and improve code quality in christianhelle/refitter#753 * Update --operation-name-template implementation to replace all {operationName} instances with Execute by @christianhelle in christianhelle/refitter#759 **Full Changelog**: christianhelle/refitter@1.6.3...1.6.4 ## 1.6.3 ## What's Changed * Fix MSBuild task so that the generated code is included in the compilation by @christianhelle in christianhelle/refitter#745 * Add support for systems running only .NET 9.0 (without .NET 8.0) in Refitter.MSBuild by @christianhelle in christianhelle/refitter#746 * Introduce --simple-output CLI argument by @christianhelle in christianhelle/refitter#751 **Full Changelog**: christianhelle/refitter@1.6.2...1.6.3 ## 1.6.2 ## What's Changed * docs: add @SWarnberg as a contributor for bug by @allcontributors[bot] in christianhelle/refitter#714 * docs: add @lilinus as a contributor for bug by @allcontributors[bot] in christianhelle/refitter#717 * Fix missing namespace import by @christianhelle in christianhelle/refitter#718 * Fix match path on cmd prompt by @christianhelle in christianhelle/refitter#719 * Fix table alignments in CLI Output by @christianhelle in christianhelle/refitter#720 * NSwag v14.5.0 by @renovate[bot] in christianhelle/refitter#722 * Add comprehensive GitHub Copilot instructions for Refitter repository by @Copilot in christianhelle/refitter#725 * Bump actions/checkout from 4 to 5 by @dependabot[bot] in christianhelle/refitter#727 * chore(deps): update dependency polly to 8.6.2 by @renovate[bot] in christianhelle/refitter#716 * chore(deps): update dependency microsoft.extensions.http.resilience to 9.8.0 by @renovate[bot] in christianhelle/refitter#728 * ASCII Art Title by @christianhelle in christianhelle/refitter#729 **Full Changelog**: christianhelle/refitter@1.6.1...1.6.2 ## 1.6.1 ## What's Changed * Update dependency Refitter.SourceGenerator to 1.6.0 by @renovate in christianhelle/refitter#704 * Add console output screenshots to documentation by @christianhelle in christianhelle/refitter#705 * docs: add @sb-chericks as a contributor for ideas, and bug by @allcontributors in christianhelle/refitter#707 * chore(deps): update dependency xunit.runner.visualstudio to 3.1.1 by @renovate in christianhelle/refitter#708 * Ensure that Refit interfaces have a XML docs by @christianhelle in christianhelle/refitter#709 **Full Changelog**: christianhelle/refitter@1.6.0...1.6.1 ## 1.6.0 **Implemented enhancements:** - fix missing schema for dictionary keys [\#697](christianhelle/refitter#697) @kirides - Fancy CLI output using Spectre Console [\#695](christianhelle/refitter#695) @christianhelle **Fixed bugs:** - \[Bug\] Refitter generates invalid \[Range\] attribute for decimal properties starting from v1.5.2 [\#668](christianhelle/refitter#668) @tommieemeli - Generates Content-Type: multipart/form-data Header which breaks Multipart uploads [\#654](christianhelle/refitter#654) @dbhjoh @jaroslaw-dutka **Closed issues:** - Improve documentation [\#700](christianhelle/refitter#700) **Merged pull requests:** - Update dependency Polly to 8.6.1 [\#703](christianhelle/refitter#703) ([renovate[bot]](https://github.com/apps/renovate)) - Update dependency Swashbuckle.AspNetCore to v9 [\#702](christianhelle/refitter#702) ([renovate[bot]](https://github.com/apps/renovate)) - Fix typos and grammar issues in documentation [\#701](christianhelle/refitter#701) ([Copilot](https://github.com/apps/copilot-swe-agent)) - Update dotnet monorepo [\#699](christianhelle/refitter#699) ([renovate[bot]](https://github.com/apps/renovate)) - Update dependency Polly to 8.6.0 [\#698](christianhelle/refitter#698) ([renovate[bot]](https://github.com/apps/renovate)) - Update dependency Refitter.SourceGenerator to 1.5.6 [\#696](christianhelle/refitter#696) ([renovate[bot]](https://github.com/apps/renovate)) - Update dependency Microsoft.NET.Test.Sdk to 17.14.1 [\#692](christianhelle/refitter#692) ([renovate[bot]](https://github.com/apps/renovate)) - Update dependency Swashbuckle.AspNetCore to 8.1.4 [\#691](christianhelle/refitter#691) ([renovate[bot]](https://github.com/apps/renovate)) See [Full Changelog](christianhelle/refitter@1.5.6...1.6.0) ## 1.5.6 ## What's Changed * Use fully qualified type name in Class template by @velvolue in christianhelle/refitter#686 * Add .NET 9.0 to Target Frameworks by @christianhelle in christianhelle/refitter#690 * Do not add both [Multipart] and "Content-Type: multipart/form-data" by @jaroslaw-dutka in christianhelle/refitter#693 ## Merged pull requests * chore(deps): update dependency refitter.sourcegenerator to 1.5.5 by @renovate in christianhelle/refitter#671 * docs: add MrScottyTay as a contributor for bug by @allcontributors in christianhelle/refitter#673 * chore(deps): update dotnet monorepo by @renovate in christianhelle/refitter#674 * chore(deps): update dependency microsoft.build.utilities.core to 17.14.7 by @renovate in christianhelle/refitter#675 * chore(deps): update dependency microsoft.build.utilities.core to 17.14.8 by @renovate in christianhelle/refitter#676 * chore(deps): update dependency microsoft.net.test.sdk to 17.14.0 by @renovate in christianhelle/refitter#680 * Add Contribution Guidelines by @copilot-swe-agent in christianhelle/refitter#679 * chore(deps): update dependency swashbuckle.aspnetcore to 8.1.2 by @renovate in christianhelle/refitter#682 * docs: add velvolue as a contributor for bug by @allcontributors in christianhelle/refitter#687 * Use fully qualified type name in Class template by @velvolue in christianhelle/refitter#686 * Resolve build warnings and add TreatWarningsAsErrors by @copilot-swe-agent in christianhelle/refitter#689 * Add .NET 9.0 to Target Frameworks by @christianhelle in christianhelle/refitter#690 * Do not add both [Multipart] and "Content-Type: multipart/form-data" by @jaroslaw-dutka in christianhelle/refitter#693 **Full Changelog**: christianhelle/refitter@1.5.5...1.5.6 ## 1.5.5 ## What's Changed - Using CollectionFormats other than Multi [\#640](christianhelle/refitter#640) (@ebarnard) - Add collection format option to CLI tool documentation [\#664](christianhelle/refitter#664) (@christianhelle) - Made Security Header Parameters safe for C\# when unsafe characters are present [\#663](christianhelle/refitter#663) (@AragornHL) ## Merged pull requests: - chore\(deps\): update dependency xunit.runner.visualstudio to 3.1.0 [\#670](christianhelle/refitter#670) ([renovate[bot]](https://github.com/apps/renovate)) - docs: add tommieemeli as a contributor for bug [\#669](christianhelle/refitter#669) ([allcontributors[bot]](https://github.com/apps/allcontributors)) - Update nswag monorepo to 14.4.0 [\#665](christianhelle/refitter#665) ([renovate[bot]](https://github.com/apps/renovate)) - chore\(deps\): update dependency refitter.sourcegenerator to 1.5.4 [\#662](christianhelle/refitter#662) ([renovate[bot]](https://github.com/apps/renovate)) **Full Changelog**: christianhelle/refitter@1.5.4...1.5.5 ## 1.5.4 ## What's Changed - Adding security schemes to the api interface generator [\#106](christianhelle/refitter#106) - Response type handling to only use 2XX range [\#661](christianhelle/refitter#661) ([christianhelle](https://github.com/christianhelle)) - Add support for 2XX and Default Response Objects [\#660](christianhelle/refitter#660) ([christianhelle](https://github.com/christianhelle)) - Add Header Parameters for Security Schemes [\#653](christianhelle/refitter#653) ([AragornHL](https://github.com/AragornHL)) ## Merged Pull Requests: * chore(deps): update dependency refitter.sourcegenerator to 1.5.3 by @renovate in christianhelle/refitter#645 * chore(deps): update dependency swashbuckle.aspnetcore to 8.1.0 by @renovate in christianhelle/refitter#646 * chore(deps): update dependency exceptionless to 6.1.0 by @renovate in christianhelle/refitter#647 * chore(deps): update dependency spectre.console.cli to 0.50.0 by @renovate in christianhelle/refitter#649 * chore(deps): update dotnet monorepo to 9.0.4 by @renovate in christianhelle/refitter#648 * chore(deps): update dependency microsoft.extensions.http.resilience to 9.4.0 by @renovate in christianhelle/refitter#650 * chore(deps): update dependency swashbuckle.aspnetcore to 8.1.1 by @renovate in christianhelle/refitter#651 * Add Header Parameters for Security Schemes by @AragornHL in christianhelle/refitter#653 * docs: add @AragornHL as a contributor for code by @allcontributors in christianhelle/refitter#655 * docs: add @kmfd3s as a contributor for code by @allcontributors in christianhelle/refitter#656 * Update smoke tests to generate authentication headers by @christianhelle in christianhelle/refitter#657 * docs: add @pfeigl as a contributor for bug by @allcontributors in christianhelle/refitter#659 * Add support for 2XX and Default Response Objects by @christianhelle in christianhelle/refitter#660 * Response type handling to only use 2XX range by @christianhelle in christianhelle/refitter#661 ## New Contributors * @AragornHL made their first contribution in christianhelle/refitter#653 **Full Changelog**: christianhelle/refitter@1.5.3...1.5.4 ## 1.5.3 **Implemented enhancements:** - Naming properties problem [\#641](christianhelle/refitter#641) - Allow comments in .refitter Configuration [\#631](christianhelle/refitter#631) - NSwag v14.3.0 [\#644](christianhelle/refitter#644) ([renovate[bot]](https://github.com/apps/renovate)) - Convert properties with underscores to PascalCase [\#643](christianhelle/refitter#643) ([christianhelle](https://github.com/christianhelle)) - Add support for deserializing JSON with comments and update tests [\#637](christianhelle/refitter#637) ([sebastian-wachsmuth](https://github.com/sebastian-wachsmuth)) - Temporary fix for Source Generator when running in Visual Studio [\#634](christianhelle/refitter#634) ([christianhelle](https://github.com/christianhelle)) - JSON Schema generator for documentation [\#623](christianhelle/refitter#623) ([christianhelle](https://github.com/christianhelle)) - Fix missing Content-Type \[Headers\] [\#619](christianhelle/refitter#619) ([christianhelle](https://github.com/christianhelle)) - Fix invalid characters in generated XML docs [\#607](christianhelle/refitter#607) ([christianhelle](https://github.com/christianhelle)) - Add support for custom DateTimeFormat [\#604](christianhelle/refitter#604) ([christianhelle](https://github.com/christianhelle)) - Fix ISO date format handling when dateFormat is defined in settings file [\#603](christianhelle/refitter#603) ([christianhelle](https://github.com/christianhelle)) **Fixed bugs:** - Doesn't add Content-Type request header when body is plain JSON string [\#617](christianhelle/refitter#617) - Broken xml doc when swagger descriptions contains "\<" or "\>" characters [\#605](christianhelle/refitter#605) - date-time parameters are encoded as date when iso8601 is used [\#599](christianhelle/refitter#599) **Closed issues:** - OpenAPI Schema and Authorization Attributes [\#629](christianhelle/refitter#629) **Merged pull requests:** - docs: add @lowern1ght as a contributor for bug [\#642](christianhelle/refitter#642) ([allcontributors[bot]](https://github.com/apps/allcontributors)) - docs: add @qrzychu as a contributor for bug [\#639](christianhelle/refitter#639) ([allcontributors[bot]](https://github.com/apps/allcontributors)) - docs: add @sebastian-wachsmuth as a contributor for code [\#638](christianhelle/refitter#638) ([allcontributors[bot]](https://github.com/apps/allcontributors)) - Update dependency Swashbuckle.AspNetCore to v8 [\#633](christianhelle/refitter#633) ([renovate[bot]](https://github.com/apps/renovate)) - Update dotnet monorepo [\#630](christianhelle/refitter#630) ([renovate[bot]](https://github.com/apps/renovate)) - Update dependency Atc.Test to 1.1.18 [\#628](christianhelle/refitter#628) ([renovate[bot]](https://github.com/apps/renovate)) - Update dependency Swashbuckle.AspNetCore to 7.3.1 [\#626](christianhelle/refitter#626) ([renovate[bot]](https://github.com/apps/renovate)) - Update dependency Swashbuckle.AspNetCore to 7.3.0 [\#624](christianhelle/refitter#624) ([renovate[bot]](https://github.com/apps/renovate)) - chore\(deps\): update dependency fluentassertions to 7.2.0 [\#622](christianhelle/refitter#622) ([renovate[bot]](https://github.com/apps/renovate)) - chore\(deps\): update dependency apizr.integrations.fusillade to 6.4.2 [\#621](christianhelle/refitter#621) ([renovate[bot]](https://github.com/apps/renovate)) - docs: add @Metziell as a contributor for bug [\#620](christianhelle/refitter#620) ([allcontributors[bot]](https://github.com/apps/allcontributors)) - docs: add @Fargekritt as a contributor for bug [\#618](christianhelle/refitter#618) ([allcontributors[bot]](https://github.com/apps/allcontributors)) - chore\(deps\): update dependency apizr.integrations.automapper to 6.4.2 [\#616](christianhelle/refitter#616) ([renovate[bot]](https://github.com/apps/renovate)) - chore\(deps\): update dependency apizr.extensions.microsoft.caching to 6.4.2 [\#615](christianhelle/refitter#615) ([renovate[bot]](https://github.com/apps/renovate)) - chore\(deps\): update dependency microsoft.applicationinsights.windowsserver to 2.23.0 [\#614](christianhelle/refitter#614) ([renovate[bot]](https://github.com/apps/renovate)) - chore\(deps\): update dependency microsoft.build.utilities.core to 17.13.9 [\#612](christianhelle/refitter#612) ([renovate[bot]](https://github.com/apps/renovate)) - chore\(deps\): update dotnet monorepo [\#611](christianhelle/refitter#611) ([renovate[bot]](https://github.com/apps/renovate)) - chore\(deps\): update dependency microsoft.net.test.sdk to 17.13.0 [\#610](christianhelle/refitter#610) ([renovate[bot]](https://github.com/apps/renovate)) - chore\(deps\): update dependency xunit.runner.visualstudio to 3.0.2 [\#609](christianhelle/refitter#609) ([renovate[bot]](https://github.com/apps/renovate)) - chore\(deps\): update dependency polly to 8.5.2 [\#608](christianhelle/refitter#608) ([renovate[bot]](https://github.com/apps/renovate)) - docs: add @wocasella as a contributor for bug [\#606](christianhelle/refitter#606) ([allcontributors[bot]](https://github.com/apps/allcontributors)) - chore\(deps\): update dependency refitter.sourcegenerator to 1.5.2 [\#602](christianhelle/refitter#602) ([renovate[bot]](https://github.com/apps/renovate)) - chore\(deps\): update dependency atc.test to 1.1.17 [\#592](christianhelle/refitter#592) ([renovate[bot]](https://github.com/apps/renovate)) - chore\(deps\): update dependency h.generators.extensions to 1.24.2 [\#581](christianhelle/refitter#581) ([renovate[bot]](https://github.com/apps/renovate)) ... (truncated) ## 1.5.2 ## Implemented enhancements: - Fix date formatting for date-time types christianhelle/refitter#600 - Proper support for multipart form christianhelle/refitter#595 ## Fixed bugs: - date-time parameters are encoded as date when iso8601 is used christianhelle/refitter#599 - \[FromForm\] parameter on minimal api doesn't get generated on Interface christianhelle/refitter#515 ## Merged pull requests: * chore(deps): update dependency coverlet.collector to 6.0.4 by @renovate in christianhelle/refitter#594 * Proper support for multipart form by @jaroslaw-dutka in christianhelle/refitter#595 * docs: add jaroslaw-dutka as a contributor for code by @allcontributors in christianhelle/refitter#596 * chore(deps): update dependency refitter.sourcegenerator to 1.5.0 by @renovate in christianhelle/refitter#593 * Remove dependency on System.Text.Json by @christianhelle in christianhelle/refitter#597 * chore(deps): update dependency refitter.sourcegenerator to 1.5.1 by @renovate in christianhelle/refitter#598 * docs: add maksionkin as a contributor for bug by @allcontributors in christianhelle/refitter#601 * Fix date formatting for date-time types by @christianhelle in christianhelle/refitter#600 ## New Contributors * @jaroslaw-dutka made their first contribution in christianhelle/refitter#595 * @maksionkin reported their first issue in christianhelle/refitter#599 **Full Changelog**: christianhelle/refitter@1.5.0...1.5.2 ## 1.5.0 ## Implemented enhancements: - Fix incorrect error message shown due to Spectre.Console parsing [\#585](christianhelle/refitter#585) ([christianhelle](https://github.com/christianhelle)) - Return null when object subtype is not found [\#577](christianhelle/refitter#577) ([velvolue](https://github.com/velvolue)) - Discard unused union types/inheritance types via config [\#575](christianhelle/refitter#575) ([kirides](https://github.com/kirides)) - Show Deserializaton Errors from Source Generator [\#572](christianhelle/refitter#572) ([christianhelle](https://github.com/christianhelle)) - Limit Exceptionless telemetry [\#564](christianhelle/refitter#564) ([christianhelle](https://github.com/christianhelle)) - Added simple logic to make most identifier strings valid [\#562](christianhelle/refitter#562) ([Fargekritt](https://github.com/Fargekritt)) - Fix -v|--version CLI tool argument [\#561](christianhelle/refitter#561) ([christianhelle](https://github.com/christianhelle)) - Less strict OpenAPI Validation rules [\#558](christianhelle/refitter#558) ([christianhelle](https://github.com/christianhelle)) - Added support for custom date format [\#554](christianhelle/refitter#554) ([Fargekritt](https://github.com/Fargekritt)) - Add support for disabling telemetry in MSBuild task [\#550](christianhelle/refitter#550) ([christianhelle](https://github.com/christianhelle)) - MSBuild Custom Task [\#548](christianhelle/refitter#548) ([christianhelle](https://github.com/christianhelle)) - Generate IDisposable Refit Interfaces [\#543](christianhelle/refitter#543) ([christianhelle](https://github.com/christianhelle)) - Clients implementing IDisposable interface [\#541](christianhelle/refitter#541) ([shubinp](https://github.com/shubinp)) - \[Apizr\] Deprecated Optional package removed from code & doc [\#539](christianhelle/refitter#539) ([JeremyBP](https://github.com/JeremyBP)) - Add PropertyNameGenerator as an optional Parameter [\#516](christianhelle/refitter#516) - NSwag v14.2.0 [\#532](christianhelle/refitter#532) ([renovate[bot]](https://github.com/apps/renovate)) - added options for a custom Name Generators [\#517](christianhelle/refitter#517) ([fsamiec](https://github.com/fsamiec)) ## Fixed bugs: - "Error: Could not find color or style 'System.String'." [\#583](christianhelle/refitter#583) - Source generator errors are hidden [\#568](christianhelle/refitter#568) - Refitter -v not showing version number [\#560](christianhelle/refitter#560) - Not so nice behavior when generating client with trim-unused-schema [\#557](christianhelle/refitter#557) - Two almost identical routes that fail at validation. [\#551](christianhelle/refitter#551) - Code Generator creates unsafe interface method names [\#360](christianhelle/refitter#360) ## Closed issues: - How to use in class library? [\#534](christianhelle/refitter#534) - \[ISSUE\]\[1.2.1-preview.54\] Some impediments using CLI version. Is not enough for my needs? [\#450](christianhelle/refitter#450) ## Merged Pull Requests * chore(deps): update dependency refitter.sourcegenerator to 1.4.0 by @renovate in christianhelle/refitter#513 * chore(deps): update dependency swashbuckle.aspnetcore to 6.9.0 by @renovate in christianhelle/refitter#514 * added options for a custom Name Generators by @fsamiec in christianhelle/refitter#517 * docs: add fsamiec as a contributor for code by @allcontributors in christianhelle/refitter#518 * chore(deps): update refit monorepo to v8 (major) by @renovate in christianhelle/refitter#519 * docs: add fabioloreggian as a contributor for bug by @allcontributors in christianhelle/refitter#521 * chore(deps): update dependency fluentassertions to 6.12.2 by @renovate in christianhelle/refitter#523 * chore(deps): update dependency polly to 8.5.0 by @renovate in christianhelle/refitter#525 * chore(deps): update dependency swashbuckle.aspnetcore to v7 by @renovate in christianhelle/refitter#526 * chore(deps): update dependency h.generators.extensions to 1.24.0 by @renovate in christianhelle/refitter#528 * chore(deps): update dotnet monorepo to v9 (major) by @renovate in christianhelle/refitter#527 * NSwag v14.2.0 by @renovate in christianhelle/refitter#532 * chore(deps): update dependency microsoft.net.test.sdk to 17.12.0 by @renovate in christianhelle/refitter#531 * chore(deps): update dependency refitter.sourcegenerator to 1.4.1 by @renovate in christianhelle/refitter#533 * docs: add geometrikal as a contributor for bug by @allcontributors in christianhelle/refitter#535 ... (truncated) Commits viewable in [compare view](christianhelle/refitter@1.4.0...1.7.0). </details> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>


This pull request makes significant improvements to the
Refitter.MSBuildpackage by enhancing its MSBuild integration. The main change is that the MSBuild task now dynamically determines which files are generated by Refitter and only includes those files in the compilation, rather than including all.csfiles. This results in more precise and reliable builds, especially for projects using multiple output files or custom output folders. Additionally, the code now parses.refitterconfiguration files to predict generated outputs, and the documentation and test scripts have been updated accordingly.MSBuild Task Improvements:
Refitter.MSBuild.targets) now uses an explicit<UsingTask>declaration and a new target name (RefitterGenerate) that runs before compilation, not before build. The target collects only the files generated byRefitterGenerateTaskand includes them in compilation, instead of including all**/*.csfiles.RefitterGenerateTaskclass now exposes an[Output]propertyGeneratedFilesthat contains the list of generated files, which is passed to MSBuild. The task parses.refitterfiles to determine expected outputs based on configuration (single/multiple file mode, output folders, dependency injection settings), and only those files are included in the build. [1] [2] [3] [4]Documentation Updates:
README.mdfiles (both root andsrc/Refitter.MSBuild/README.md) have been updated to reflect the new MSBuild integration pattern, showing the new target, task usage, and correct<Compile Include="@(RefitterGeneratedFiles)" />syntax. [1] [2]Developer Experience and Test Script Improvements:
test/MSBuild/build.ps1) has been updated to usedotnetCLI commands for package management, and to reflect the new build and run workflow.These changes make the package more robust, predictable, and user-friendly for both developers and CI environments.
Summary by CodeRabbit
New Features
Documentation
Tests