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
Expand Up @@ -74,7 +74,7 @@ public override void Initialize(AnalysisContext context)
return;
}

var baseTool = symCtx.Compilation.GetTypeByMetadataName("Azure.Sdk.Tools.Cli.Contract.MCPTool");
var baseTool = symCtx.Compilation.GetTypeByMetadataName("Azure.Sdk.Tools.Cli.Contract.MCPToolBase");
if (baseTool != null && InheritsFrom(named, baseTool))
{
implementations.Add(named);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private static bool IsValidReturnType(ITypeSymbol returnType, Compilation compil
}

// Check if it implements Response (look in Azure.Sdk.Tools.Cli.Models namespace)
var responseType = compilation.GetTypeByMetadataName("Azure.Sdk.Tools.Cli.Models.Response");
var responseType = compilation.GetTypeByMetadataName("Azure.Sdk.Tools.Cli.Models.CommandResponse");
if (responseType != null && InheritsFromOrImplements(returnType, responseType))
{
return true;
Expand Down
6 changes: 3 additions & 3 deletions tools/azsdk-cli/Azure.Sdk.Tools.Cli.Analyzer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public async Task<Response> ProcessData(string myArg)

## Overview

The `EnforceToolsListAnalyzer` ensures that every class inheriting from `MCPTool` is properly registered in the `SharedOptions.ToolsList` static list, otherwise they will not be loaded at startup.
The `EnforceToolsListAnalyzer` ensures that every class inheriting from `MCPToolBase` is properly registered in the `SharedOptions.ToolsList` static list, otherwise they will not be loaded at startup.

All non-abstract classes that inherit from `Azure.Sdk.Tools.Cli.Contract.MCPTool` must be included as `typeof(ClassName)` entries in the `SharedOptions.ToolsList` static field (`Azure.Sdk.Tools.Cli/Commands/SharedOptions.cs`).

Expand All @@ -72,7 +72,7 @@ When you encounter MCP002 violations:
// 1. Tool implementation
public class MyCustomTool : MCPTool
{
public override Command GetCommand() { /* implementation */ }
protected override Command GetCommand() { /* implementation */ }
public override Task HandleCommand(InvocationContext ctx, CancellationToken ct) { /* implementation */ }
}

Expand All @@ -92,7 +92,7 @@ public static readonly List<Type> ToolsList = [
The `EnforceToolsReturnTypesAnalyzer` ensures that all public non-static methods in classes within
the `Azure.Sdk.Tools.Cli.Tools` namespace return only approved types at compile time.

This excludes inherited methods `GetCommand`, `HandleCommand`, etc.
This excludes inherited methods `GetCommand`, `GetCommands`, `HandleCommand`, etc.

## Allowed Return Types

Expand Down

This file was deleted.

11 changes: 0 additions & 11 deletions tools/azsdk-cli/Azure.Sdk.Tools.Cli.Contract/CommandGroup.cs

This file was deleted.

33 changes: 0 additions & 33 deletions tools/azsdk-cli/Azure.Sdk.Tools.Cli.Contract/MCPTool.cs

This file was deleted.

9 changes: 0 additions & 9 deletions tools/azsdk-cli/Azure.Sdk.Tools.Cli.Contract/README.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,31 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Azure.Sdk.Tools.Cli.Contract\Azure.Sdk.Tools.Cli.Contract.csproj" />
<ProjectReference Include="..\Azure.Sdk.Tools.Cli\Azure.Sdk.Tools.Cli.csproj" />
<ProjectReference Include="../Azure.Sdk.Tools.Cli/Azure.Sdk.Tools.Cli.csproj" />
</ItemGroup>

<ItemGroup>
<Using Include="NUnit.Framework" />
</ItemGroup>

<ItemGroup>
<None Include="TestAssets\**\*" CopyToOutputDirectory="PreserveNewest" />
<None Include="TestAssets/**/*" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<ItemGroup>
<None Include="..\Azure.Sdk.Tools.Cli\Templates\ReadMeGenerator\README-template.go.md" Link="TestAssets\README-template.go.md">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<ItemGroup>
<None Include="../Azure.Sdk.Tools.Cli/Templates/ReadMeGenerator/README-template.go.md" Link="TestAssets/README-template.go.md">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<None Update="TypeSpecTestData\specification\testcontoso\Contoso.Management\employee.tsp">
<None Update="TypeSpecTestData/specification/testcontoso/Contoso.Management/employee.tsp">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="TypeSpecTestData\specification\testcontoso\Contoso.Management\main.tsp">
<None Update="TypeSpecTestData/specification/testcontoso/Contoso.Management/main.tsp">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="TypeSpecTestData\specification\testcontoso\Contoso.Management\tspconfig.yaml">
<None Update="TypeSpecTestData/specification/testcontoso/Contoso.Management/tspconfig.yaml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ namespace Azure.Sdk.Tools.Cli.Tests.Helpers;

internal class OutputHelperTests
{
private readonly string summary = "a test summary";
private readonly List<LogEntry> errors =
[
new LogEntry
private readonly string summary = "a test summary";
private readonly List<LogEntry> errors =
[
new LogEntry
{
File = "file1",
Line = 1,
Expand All @@ -20,13 +20,13 @@ internal class OutputHelperTests
Line = 2,
Message = "message2"
}
];
private readonly string suggestedFix = "a test suggested fix";
];
private readonly string suggestedFix = "a test suggested fix";

[Test]
public void TestTypedJsonOutput()
{
var json = @"{
[Test]
public void TestTypedJsonOutput()
{
var json = @"{
""summary"": ""a test summary"",
""errors"": [
{
Expand All @@ -43,23 +43,23 @@ public void TestTypedJsonOutput()
""suggested_fix"": ""a test suggested fix""
}";

var output = new OutputHelper(OutputModes.Json);
var formatted = output.ValidateAndFormat<LogAnalysisResponse>(json);
var output = new OutputHelper(OutputHelper.OutputModes.Json);
var formatted = output.ValidateAndFormat<LogAnalysisResponse>(json);

Assert.That(formatted, Is.EqualTo(json));
}
Assert.That(formatted, Is.EqualTo(json));
}

[Test]
public void TestPlainTextOutput()
{
var response = new LogAnalysisResponse
[Test]
public void TestPlainTextOutput()
{
Summary = summary,
Errors = errors,
SuggestedFix = suggestedFix
};
var response = new LogAnalysisResponse
{
Summary = summary,
Errors = errors,
SuggestedFix = suggestedFix
};

var expectedStr = @"
var expectedStr = @"
### Summary:
a test summary

Expand All @@ -74,9 +74,9 @@ a test suggested fix
message2
".TrimStart();

var output = new OutputHelper(OutputModes.Plain);
var formatted = output.Format(response);
var output = new OutputHelper(OutputHelper.OutputModes.Plain);
var formatted = output.Format(response);

Assert.That(formatted, Is.EqualTo(expectedStr));
}
Assert.That(formatted, Is.EqualTo(expectedStr));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Runtime.InteropServices;
using Azure.Sdk.Tools.Cli.Helpers;
using Azure.Sdk.Tools.Cli.Services;
using Azure.Sdk.Tools.Cli.Tests.TestHelpers;
using Microsoft.Extensions.Logging.Abstractions;
using Moq;

Expand Down Expand Up @@ -59,7 +58,7 @@ package main
import (
"github.com/Azure/azure-sdk-for-go/sdk/messaging/azservicebus" // an unused dep we're going to remove
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
)
)

func main() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
Expand Down Expand Up @@ -95,7 +94,7 @@ await File.WriteAllTextAsync(Path.Combine(GoPackageDir, "main.go"), """
package main

import (
)
)

func main() {
syntax error
Expand All @@ -117,11 +116,11 @@ await File.WriteAllTextAsync(Path.Combine(GoPackageDir, "main.go"), """
package main

import (
)
)

func unusedFunc() {}

func main() {
func main() {
}
""");

Expand Down
Loading
Loading