Skip to content
Open
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
4 changes: 4 additions & 0 deletions Frends.MicrosoftSQL.ExecuteQueryToFile/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [2.2.0] - 2026-01-14
### Fixed
- Fix unloading assembly

## [2.1.0] - 2024-12-16
### Added
- Added Microsoft.SqlServer.Types dependency so that SqlGeography and SqlGeometry typed objects can be handled.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
namespace Frends.MicrosoftSQL.ExecuteQueryToFile.Enums;
#pragma warning disable CS1591 // Self-explanatory
/// <summary>
/// File encoding used to encode the file.
/// </summary>
public enum FileEncoding
{
UTF8,
ANSI,
ASCII,
Unicode,
Other,
}
namespace Frends.MicrosoftSQL.ExecuteQueryToFile.Enums;

#pragma warning disable CS1591 // Self-explanatory

/// <summary>
/// File encoding used to encode the file.
/// </summary>
public enum FileEncoding
{
UTF8,
ANSI,
ASCII,
Unicode,
Other,
}

#pragma warning restore CS1591 // Self-explanatory
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
namespace Frends.MicrosoftSQL.ExecuteQueryToFile.Enums;
#pragma warning disable CS1591 // Self-explanatory
/// <summary>
/// Enumeration for output format.
/// </summary>
public enum ReturnFormat
{
CSV,
}
namespace Frends.MicrosoftSQL.ExecuteQueryToFile.Enums;

#pragma warning disable CS1591 // Self-explanatory

/// <summary>
/// Enumeration for output format.
/// </summary>
public enum ReturnFormat
{
CSV,
}

#pragma warning restore CS1591 // Self-explanatory
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
namespace Frends.MicrosoftSQL.ExecuteQueryToFile;

using System;
using System;
using System.ComponentModel;
using System.Data;
using System.Reflection;
using System.Runtime.Loader;
using System.Threading;
using System.Threading.Tasks;
using Frends.MicrosoftSQL.ExecuteQueryToFile.Definitions;
using Frends.MicrosoftSQL.ExecuteQueryToFile.Enums;
using Microsoft.Data.SqlClient;

namespace Frends.MicrosoftSQL.ExecuteQueryToFile;

/// <summary>
/// Main class of the Task.
/// </summary>
public static class MicrosoftSQL
{
static MicrosoftSQL()
{
var currentAssembly = Assembly.GetExecutingAssembly();
var currentContext = AssemblyLoadContext.GetLoadContext(currentAssembly);

if (currentContext != null)
{
currentContext.Unloading += OnPluginUnloadingRequested;
}
}

/// <summary>
/// Frends Task for executing Microsoft SQL queries into a file.
/// [Documentation](https://tasks.frends.com/tasks/frends-tasks/Frends.MicrosoftSQL.ExecuteQueryToFile).
Expand All @@ -25,6 +38,7 @@ public static class MicrosoftSQL
public static async Task<Result> ExecuteQueryToFile([PropertyTab] Input input, [PropertyTab] Options options, CancellationToken cancellationToken)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# First, let's find the Result class definition
ast-grep --pattern 'class Result {
  $$$
}'

Repository: FrendsPlatform/Frends.MicrosoftSQL

Length of output: 60


🏁 Script executed:

#!/bin/bash
# Search for Result class definition
rg "class Result|record Result|struct Result" -t cs --max-count 20

Repository: FrendsPlatform/Frends.MicrosoftSQL

Length of output: 638


🏁 Script executed:

#!/bin/bash
# Read the Result class definition
cat -n "Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile/Definitions/Result.cs"

Repository: FrendsPlatform/Frends.MicrosoftSQL

Length of output: 1183


🏁 Script executed:

#!/bin/bash
# Check another Result class to compare
cat -n "Frends.MicrosoftSQL.ExecuteQuery/Frends.MicrosoftSQL.ExecuteQuery/Definitions/Result.cs"

Repository: FrendsPlatform/Frends.MicrosoftSQL

Length of output: 1825


Result class missing required Success and Error properties.

The Result class is missing required properties per the coding guidelines. It currently has task-specific return values (EntriesWritten, Path, FileName) but lacks:

  • Success (bool) — required for all task result classes
  • Error object with Message and AdditionalInfo — required for error handling

Compare with ExecuteQuery.Result which correctly implements Success, ErrorMessage, and task-specific data. Align ExecuteQueryToFile.Result to match this pattern.

🧰 Tools
🪛 GitHub Actions: ExecuteQueryToFile_build_test

[error] 38-38: FT0011: Class should include a 'Success' property


[error] 38-38: FT0011: Class should include a 'Error' property

🤖 Prompt for AI Agents
In
`@Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile.cs`
at line 38, The Result class for ExecuteQueryToFile is missing the required
Success bool and Error object; update the ExecuteQueryToFile.Result type to
include a public bool Success property and an Error property (object/class) with
Message and AdditionalInfo fields, while keeping existing task-specific
properties (EntriesWritten, Path, FileName); mirror the shape used by
ExecuteQuery.Result (or reuse its Error type) so callers can check Success and
read Error.Message/Error.AdditionalInfo when failures occur.

{
Result result = new();

using (var sqlConnection = new SqlConnection(input.ConnectionString))
{
await sqlConnection.OpenAsync(cancellationToken);
Expand Down Expand Up @@ -59,10 +73,16 @@ public static async Task<Result> ExecuteQueryToFile([PropertyTab] Input input, [
case ReturnFormat.CSV:
var csvWriter = new CsvFileWriter(command, input, options.CsvOptions);
result = await csvWriter.SaveQueryToCSV(cancellationToken);

break;
}
}

return result;
}
}

private static void OnPluginUnloadingRequested(AssemblyLoadContext obj)
{
obj.Unloading -= OnPluginUnloadingRequested;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>Latest</LangVersion>
<Version>2.1.0</Version>
<Version>2.2.0</Version>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Step 1: Find and display the full .csproj file
echo "=== Frends.MicrosoftSQL.ExecuteQueryToFile.csproj content ===" 
find . -name "Frends.MicrosoftSQL.ExecuteQueryToFile.csproj" -type f -exec cat {} \;

Repository: FrendsPlatform/Frends.MicrosoftSQL

Length of output: 2042


🏁 Script executed:

#!/bin/bash
# Step 2: Find the Result class definition
echo "=== Searching for Result class definition ===" 
find . -path "*/Frends.MicrosoftSQL.ExecuteQueryToFile/*" -name "*.cs" -type f | head -20

Repository: FrendsPlatform/Frends.MicrosoftSQL

Length of output: 1798


🏁 Script executed:

#!/bin/bash
cat ./Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile/Definitions/Result.cs

Repository: FrendsPlatform/Frends.MicrosoftSQL

Length of output: 931


Version bump and .csproj configuration look correct.

The version increment from 2.1.0 to 2.2.0 follows semantic versioning, and all .csproj requirements are met:

  • TargetFramework: net6.0 ✓
  • Version, Authors (Frends), Description, RepositoryUrl all present ✓
  • PackageLicenseExpression: MIT ✓
  • GenerateDocumentationFile: true ✓

However, the Result class in Definitions/Result.cs is missing the required Success and Error properties that are referenced in the pipeline failures (FT0011). Add these properties to the Result class definition before merging.

🤖 Prompt for AI Agents
In
`@Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile.csproj`
at line 6, The Result class in Definitions/Result.cs is missing the public
properties referenced by the pipeline; add public bool Success { get; set; } and
public string Error { get; set; } to the Result class (ensure they are public
auto-properties on the Result type so existing callers/serialization continue to
work).

<Authors>Frends</Authors>
<Copyright>Frends</Copyright>
<Company>Frends</Company>
Expand Down
Loading