Skip to content
Draft
Show file tree
Hide file tree
Changes from 9 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
8 changes: 8 additions & 0 deletions docs/list-of-diagnostics.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ if desired.
| `EXTEXP0016` | Hosting integration testing experiments |
| `EXTEXP0017` | Contextual options experiments |
| `EXTEXP0018` | HybridCache experiments |
| `MEAI0001` | Image generation experiments |
| `MEAI0002` | Speech-to-text experiments |
| `MEAI0003` | Hosted MCP server experiments |
| `MEAI0004` | Function approval experiments |
| `MEAI0005` | Tool reduction experiments |
| `MEAI0006` | Chat reduction experiments |
| `MEAI0007` | Response continuations experiments |
| `MEAI0008` | Code interpreter experiments |

# Obsoletions

Expand Down
2 changes: 1 addition & 1 deletion eng/MSBuild/LegacySupport.props
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<Compile Include="$(MSBuildThisFileDirectory)\..\..\src\LegacySupport\TaskWaitAsync\*.cs" LinkBase="LegacySupport\TaskWaitAsync" />
</ItemGroup>

<ItemGroup Condition="'$(InjectExperimentalAttributeOnLegacy)' == 'true' AND ('$(TargetFramework)' == 'net462' or '$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'netstandard2.1' or '$(TargetFramework)' == 'netcoreapp3.1' or '$(TargetFramework)' == 'net6.0' or '$(TargetFramework)' == 'net7.0')">
<ItemGroup Condition="'$(InjectExperimentalAttributeOnLegacy)' == 'true' AND ('$(TargetFramework)' == 'net462' or '$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'netstandard2.1' or '$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net9.0')">
<Compile Include="$(MSBuildThisFileDirectory)\..\..\src\LegacySupport\ExperimentalAttribute\*.cs" LinkBase="LegacySupport\ExperimentalAttribute" />
</ItemGroup>

Expand Down
11 changes: 10 additions & 1 deletion src/LegacySupport/ExperimentalAttribute/ExperimentalAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#if !NET8_0_OR_GREATER
#if !NET10_0_OR_GREATER

#pragma warning disable CS0436 // Type conflicts with imported type
Copy link
Member

Choose a reason for hiding this comment

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

@copilot The changes needed to get ExperimentalAttribute flowing through everywhere are not worth it.

Revert the changes to the attribute, all places where the new type redefinition suppression was needed, remove the Message definitions for the new diagnostics, and do not inject the experimental attribute anywhere new that is no longer needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted the ExperimentalAttribute polyfill changes, removed Message definitions from DiagnosticIds.cs, and removed Message property from all Experimental attributes in cfb2285. The polyfill is now back to targeting !NET8_0_OR_GREATER without the Message property, and the MEAI experimental attributes use only the diagnostic ID and UrlFormat.


namespace System.Diagnostics.CodeAnalysis;

Expand Down Expand Up @@ -42,6 +44,11 @@ public ExperimentalAttribute(string diagnosticId)
/// </remarks>
public string DiagnosticId { get; }

/// <summary>
/// Gets or sets an optional message associated with the experimental attribute.
/// </summary>
public string? Message { get; set; }

/// <summary>
/// Gets or sets the URL for corresponding documentation.
/// The API accepts a format string instead of an actual URL, creating a generic URL that includes the diagnostic ID.
Expand All @@ -53,4 +60,6 @@ public ExperimentalAttribute(string diagnosticId)
#pragma warning restore S3996 // URI properties should not be strings
}

#pragma warning restore CS0436

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using Microsoft.Shared.DiagnosticIds;

namespace Microsoft.Extensions.AI;

Expand Down Expand Up @@ -180,7 +181,7 @@ protected ChatOptions(ChatOptions? other)
/// If the implementation does not support background responses, this property will be ignored.
/// </para>
/// </remarks>
[Experimental("MEAI001")]
[Experimental(DiagnosticIds.Experiments.ResponseContinuations, Message = DiagnosticIds.Experiments.ResponseContinuationsMessage, UrlFormat = DiagnosticIds.UrlFormat)]
[JsonIgnore]
public bool? AllowBackgroundResponses { get; set; }

Expand All @@ -195,7 +196,7 @@ protected ChatOptions(ChatOptions? other)
/// can be polled for completion by obtaining the token from the <see cref="ChatResponse.ContinuationToken"/> property
/// and passing it to this property on subsequent calls to <see cref="IChatClient.GetResponseAsync"/>.
/// </remarks>
[Experimental("MEAI001")]
[Experimental(DiagnosticIds.Experiments.ResponseContinuations, Message = DiagnosticIds.Experiments.ResponseContinuationsMessage, UrlFormat = DiagnosticIds.UrlFormat)]
[JsonIgnore]
public ResponseContinuationToken? ContinuationToken { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using Microsoft.Shared.DiagnosticIds;
using Microsoft.Shared.Diagnostics;

namespace Microsoft.Extensions.AI;
Expand Down Expand Up @@ -100,7 +101,7 @@ public IList<ChatMessage> Messages
/// to poll for completion.
/// </para>
/// </remarks>
[Experimental("MEAI001")]
[Experimental(DiagnosticIds.Experiments.ResponseContinuations, Message = DiagnosticIds.Experiments.ResponseContinuationsMessage, UrlFormat = DiagnosticIds.UrlFormat)]
[JsonIgnore]
public ResponseContinuationToken? ContinuationToken { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using Microsoft.Shared.DiagnosticIds;

namespace Microsoft.Extensions.AI;

Expand Down Expand Up @@ -170,7 +171,7 @@ public IList<AIContent> Contents
/// to resume streaming from the point of interruption.
/// </para>
/// </remarks>
[Experimental("MEAI001")]
[Experimental(DiagnosticIds.Experiments.ResponseContinuations, Message = DiagnosticIds.Experiments.ResponseContinuationsMessage, UrlFormat = DiagnosticIds.UrlFormat)]
[JsonIgnore]
public ResponseContinuationToken? ContinuationToken { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Shared.DiagnosticIds;

namespace Microsoft.Extensions.AI;

/// <summary>
/// Represents a reducer capable of shrinking the size of a list of chat messages.
/// </summary>
[Experimental("MEAI001")]
[Experimental(DiagnosticIds.Experiments.ChatReduction, Message = DiagnosticIds.Experiments.ChatReductionMessage, UrlFormat = DiagnosticIds.UrlFormat)]
public interface IChatReducer
{
/// <summary>Reduces the size of a list of chat messages.</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Shared.DiagnosticIds;

namespace Microsoft.Extensions.AI;

Expand All @@ -13,7 +14,7 @@ namespace Microsoft.Extensions.AI;
/// This content type represents when a hosted AI service invokes a code interpreter tool.
/// It is informational only and represents the call itself, not the result.
/// </remarks>
[Experimental("MEAI001")]
[Experimental(DiagnosticIds.Experiments.CodeInterpreter, Message = DiagnosticIds.Experiments.CodeInterpreterMessage, UrlFormat = DiagnosticIds.UrlFormat)]
public sealed class CodeInterpreterToolCallContent : AIContent
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@

using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Shared.DiagnosticIds;

namespace Microsoft.Extensions.AI;

/// <summary>
/// Represents the result of a code interpreter tool invocation by a hosted service.
/// </summary>
[Experimental("MEAI001")]
[Experimental(DiagnosticIds.Experiments.CodeInterpreter, Message = DiagnosticIds.Experiments.CodeInterpreterMessage, UrlFormat = DiagnosticIds.UrlFormat)]
public sealed class CodeInterpreterToolResultContent : AIContent
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@

using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Shared.DiagnosticIds;
using Microsoft.Shared.Diagnostics;

namespace Microsoft.Extensions.AI;

/// <summary>
/// Represents a request for user approval of a function call.
/// </summary>
[Experimental("MEAI001")]
[Experimental(DiagnosticIds.Experiments.FunctionApprovals, Message = DiagnosticIds.Experiments.FunctionApprovalsMessage, UrlFormat = DiagnosticIds.UrlFormat)]
public sealed class FunctionApprovalRequestContent : UserInputRequestContent
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@

using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Shared.DiagnosticIds;
using Microsoft.Shared.Diagnostics;

namespace Microsoft.Extensions.AI;

/// <summary>
/// Represents a response to a function approval request.
/// </summary>
[Experimental("MEAI001")]
[Experimental(DiagnosticIds.Experiments.FunctionApprovals, Message = DiagnosticIds.Experiments.FunctionApprovalsMessage, UrlFormat = DiagnosticIds.UrlFormat)]
public sealed class FunctionApprovalResponseContent : UserInputResponseContent
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics.CodeAnalysis;
using Microsoft.Shared.DiagnosticIds;

namespace Microsoft.Extensions.AI;

/// <summary>
/// Represents the invocation of an image generation tool call by a hosted service.
/// </summary>
[Experimental("MEAI001")]
[Experimental(DiagnosticIds.Experiments.ImageGeneration, Message = DiagnosticIds.Experiments.ImageGenerationMessage, UrlFormat = DiagnosticIds.UrlFormat)]
public sealed class ImageGenerationToolCallContent : AIContent
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Shared.DiagnosticIds;

namespace Microsoft.Extensions.AI;

Expand All @@ -13,7 +14,7 @@ namespace Microsoft.Extensions.AI;
/// This content type represents when a hosted AI service invokes an image generation tool.
/// It is informational only and represents the call itself, not the result.
/// </remarks>
[Experimental("MEAI001")]
[Experimental(DiagnosticIds.Experiments.ImageGeneration, Message = DiagnosticIds.Experiments.ImageGenerationMessage, UrlFormat = DiagnosticIds.UrlFormat)]
public sealed class ImageGenerationToolResultContent : AIContent
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@

using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Shared.DiagnosticIds;
using Microsoft.Shared.Diagnostics;

namespace Microsoft.Extensions.AI;

/// <summary>
/// Represents a request for user approval of an MCP server tool call.
/// </summary>
[Experimental("MEAI001")]
[Experimental(DiagnosticIds.Experiments.McpServers, Message = DiagnosticIds.Experiments.McpServersMessage, UrlFormat = DiagnosticIds.UrlFormat)]
public sealed class McpServerToolApprovalRequestContent : UserInputRequestContent
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@

using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Shared.DiagnosticIds;

namespace Microsoft.Extensions.AI;

/// <summary>
/// Represents a response to an MCP server tool approval request.
/// </summary>
[Experimental("MEAI001")]
[Experimental(DiagnosticIds.Experiments.McpServers, Message = DiagnosticIds.Experiments.McpServersMessage, UrlFormat = DiagnosticIds.UrlFormat)]
public sealed class McpServerToolApprovalResponseContent : UserInputResponseContent
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Shared.DiagnosticIds;
using Microsoft.Shared.Diagnostics;

namespace Microsoft.Extensions.AI;
Expand All @@ -15,7 +16,7 @@ namespace Microsoft.Extensions.AI;
/// This content type is used to represent an invocation of an MCP server tool by a hosted service.
/// It is informational only.
/// </remarks>
[Experimental("MEAI001")]
[Experimental(DiagnosticIds.Experiments.McpServers, Message = DiagnosticIds.Experiments.McpServersMessage, UrlFormat = DiagnosticIds.UrlFormat)]
public sealed class McpServerToolCallContent : AIContent
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Shared.DiagnosticIds;
using Microsoft.Shared.Diagnostics;

namespace Microsoft.Extensions.AI;
Expand All @@ -15,7 +16,7 @@ namespace Microsoft.Extensions.AI;
/// This content type is used to represent the result of an invocation of an MCP server tool by a hosted service.
/// It is informational only.
/// </remarks>
[Experimental("MEAI001")]
[Experimental(DiagnosticIds.Experiments.McpServers, Message = DiagnosticIds.Experiments.McpServersMessage, UrlFormat = DiagnosticIds.UrlFormat)]
public sealed class McpServerToolResultContent : AIContent
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using Microsoft.Shared.DiagnosticIds;
using Microsoft.Shared.Diagnostics;

namespace Microsoft.Extensions.AI;

/// <summary>
/// Represents a request for user input.
/// </summary>
[Experimental("MEAI001")]
[Experimental(DiagnosticIds.Experiments.FunctionApprovals, Message = DiagnosticIds.Experiments.FunctionApprovalsMessage, UrlFormat = DiagnosticIds.UrlFormat)]
[JsonPolymorphic(TypeDiscriminatorPropertyName = "$type")]
[JsonDerivedType(typeof(FunctionApprovalRequestContent), "functionApprovalRequest")]
[JsonDerivedType(typeof(McpServerToolApprovalRequestContent), "mcpServerToolApprovalRequest")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using Microsoft.Shared.DiagnosticIds;
using Microsoft.Shared.Diagnostics;

namespace Microsoft.Extensions.AI;

/// <summary>
/// Represents the response to a request for user input.
/// </summary>
[Experimental("MEAI001")]
[Experimental(DiagnosticIds.Experiments.FunctionApprovals, Message = DiagnosticIds.Experiments.FunctionApprovalsMessage, UrlFormat = DiagnosticIds.UrlFormat)]
[JsonPolymorphic(TypeDiscriminatorPropertyName = "$type")]
[JsonDerivedType(typeof(FunctionApprovalResponseContent), "functionApprovalResponse")]
[JsonDerivedType(typeof(McpServerToolApprovalResponseContent), "mcpServerToolApprovalResponse")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Shared.DiagnosticIds;

namespace Microsoft.Extensions.AI;

Expand All @@ -14,7 +15,7 @@ namespace Microsoft.Extensions.AI;
/// This class simply augments an <see cref="AIFunction"/> with an indication that approval is required before invocation.
/// It does not enforce the requirement for user approval; it is the responsibility of the invoker to obtain that approval before invoking the function.
/// </remarks>
[Experimental("MEAI001")]
[Experimental(DiagnosticIds.Experiments.FunctionApprovals, Message = DiagnosticIds.Experiments.FunctionApprovalsMessage, UrlFormat = DiagnosticIds.UrlFormat)]
public sealed class ApprovalRequiredAIFunction : DelegatingAIFunction
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Shared.DiagnosticIds;

namespace Microsoft.Extensions.AI;

Expand All @@ -12,7 +13,7 @@ namespace Microsoft.Extensions.AI;
/// <remarks>
/// Use <see cref="HostedMcpServerToolApprovalMode.AlwaysRequire"/> to get an instance of <see cref="HostedMcpServerToolAlwaysRequireApprovalMode"/>.
/// </remarks>
[Experimental("MEAI001")]
[Experimental(DiagnosticIds.Experiments.McpServers, Message = DiagnosticIds.Experiments.McpServersMessage, UrlFormat = DiagnosticIds.UrlFormat)]
[DebuggerDisplay(nameof(AlwaysRequire))]
public sealed class HostedMcpServerToolAlwaysRequireApprovalMode : HostedMcpServerToolApprovalMode
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using Microsoft.Shared.DiagnosticIds;

namespace Microsoft.Extensions.AI;

Expand All @@ -14,7 +15,7 @@ namespace Microsoft.Extensions.AI;
/// The predefined values <see cref="AlwaysRequire" />, and <see cref="NeverRequire"/> are provided to specify handling for all tools.
/// To specify approval behavior for individual tool names, use <see cref="RequireSpecific(IList{string}, IList{string})"/>.
/// </remarks>
[Experimental("MEAI001")]
[Experimental(DiagnosticIds.Experiments.McpServers, Message = DiagnosticIds.Experiments.McpServersMessage, UrlFormat = DiagnosticIds.UrlFormat)]
[JsonPolymorphic(TypeDiscriminatorPropertyName = "$type")]
[JsonDerivedType(typeof(HostedMcpServerToolNeverRequireApprovalMode), typeDiscriminator: "never")]
[JsonDerivedType(typeof(HostedMcpServerToolAlwaysRequireApprovalMode), typeDiscriminator: "always")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Shared.DiagnosticIds;

namespace Microsoft.Extensions.AI;

Expand All @@ -12,7 +13,7 @@ namespace Microsoft.Extensions.AI;
/// <remarks>
/// Use <see cref="HostedMcpServerToolApprovalMode.NeverRequire"/> to get an instance of <see cref="HostedMcpServerToolNeverRequireApprovalMode"/>.
/// </remarks>
[Experimental("MEAI001")]
[Experimental(DiagnosticIds.Experiments.McpServers, Message = DiagnosticIds.Experiments.McpServersMessage, UrlFormat = DiagnosticIds.UrlFormat)]
[DebuggerDisplay(nameof(NeverRequire))]
public sealed class HostedMcpServerToolNeverRequireApprovalMode : HostedMcpServerToolApprovalMode
{
Expand Down
Loading
Loading