.NET: Re-enable ImplicitUsings in samples and clean up NoWarns (#1060)

* Re-enable ImplicitUsings in samples and clean up NoWarns

* Fix dotnet format

* More dotnet format

* More dotnet format

---------

Co-authored-by: Chris <66376200+crickman@users.noreply.github.com>
This commit is contained in:
Stephen Toub
2025-10-01 19:37:03 +00:00
committed by GitHub
co-authored by Chris
parent 0fef277c70
commit a414461570
192 changed files with 100 additions and 345 deletions
@@ -12,7 +12,7 @@ internal sealed class CompilerFeatureRequiredAttribute : Attribute
{
public CompilerFeatureRequiredAttribute(string featureName)
{
FeatureName = featureName;
this.FeatureName = featureName;
}
/// <summary>
@@ -35,7 +35,7 @@ public abstract class AIAgent
/// agent instances in multi-agent scenarios. They should remain stable for the lifetime
/// of the agent instance.
/// </remarks>
public virtual string Id => _id;
public virtual string Id => this._id;
/// <summary>
/// Gets the human-readable name of the agent.
@@ -20,7 +20,7 @@ public class AIAgentMetadata
/// </param>
public AIAgentMetadata(string? providerName = null)
{
ProviderName = providerName;
this.ProviderName = providerName;
}
/// <summary>
@@ -136,7 +136,7 @@ public abstract class AIContextProvider
/// <exception cref="ArgumentNullException"><paramref name="requestMessages"/> is <see langword="null"/>.</exception>
public InvokingContext(IEnumerable<ChatMessage> requestMessages)
{
RequestMessages = requestMessages ?? throw new ArgumentNullException(nameof(requestMessages));
this.RequestMessages = requestMessages ?? throw new ArgumentNullException(nameof(requestMessages));
}
/// <summary>
@@ -166,7 +166,7 @@ public abstract class AIContextProvider
/// <exception cref="ArgumentNullException"><paramref name="requestMessages"/> is <see langword="null"/>.</exception>
public InvokedContext(IEnumerable<ChatMessage> requestMessages)
{
RequestMessages = requestMessages ?? throw new ArgumentNullException(nameof(requestMessages));
this.RequestMessages = requestMessages ?? throw new ArgumentNullException(nameof(requestMessages));
}
/// <summary>
@@ -17,9 +17,6 @@ using System.Text.Json.Serialization.Metadata;
using Microsoft.Shared.Diagnostics;
using Microsoft.Extensions.AI;
#pragma warning disable S109 // Magic numbers should not be used
#pragma warning disable S1121 // Assignments should not be made from within sub-expressions
namespace Microsoft.Agents.AI;
/// <summary>
@@ -8,9 +8,6 @@ using System.Threading.Tasks;
using Microsoft.Extensions.AI;
using Microsoft.Shared.Diagnostics;
#pragma warning disable S109 // Magic numbers should not be used
#pragma warning disable S1121 // Assignments should not be made from within sub-expressions
namespace Microsoft.Agents.AI;
/// <summary>
@@ -13,7 +13,7 @@ public class AgentThreadMetadata
/// <param name="conversationId">The unique identifier for the conversation, if available.</param>
public AgentThreadMetadata(string? conversationId)
{
ConversationId = conversationId;
this.ConversationId = conversationId;
}
/// <summary>
@@ -4,7 +4,7 @@
<TargetFrameworks>$(ProjectsTargetFrameworks)</TargetFrameworks>
<TargetFrameworks Condition="'$(Configuration)' == 'Debug'">$(ProjectsDebugTargetFrameworks)</TargetFrameworks>
<RootNamespace>Microsoft.Agents.AI</RootNamespace>
<NoWarn>$(NoWarn);CA1716;IDE0009;MEAI001</NoWarn>
<NoWarn>$(NoWarn);MEAI001</NoWarn>
<VersionSuffix>preview</VersionSuffix>
</PropertyGroup>
@@ -5,7 +5,6 @@
<TargetFrameworks Condition="'$(Configuration)' == 'Debug'">$(ProjectsDebugTargetFrameworks)</TargetFrameworks>
<VersionSuffix>preview</VersionSuffix>
<ImplicitUsings>enable</ImplicitUsings>
<NoWarn>$(NoWarn);IDE0009;</NoWarn>
</PropertyGroup>
<Import Project="$(RepoRoot)/dotnet/nuget/nuget-package.props" />
@@ -3,7 +3,6 @@
<PropertyGroup>
<TargetFrameworks>$(ProjectsCoreTargetFrameworks)</TargetFrameworks>
<TargetFrameworks Condition="'$(Configuration)' == 'Debug'">$(ProjectsCoreTargetFrameworks)</TargetFrameworks>
<NoWarn>$(NoWarn);IDE1006;IDE0130;NU1504</NoWarn>
<RootNamespace>Microsoft.Agents.AI.Hosting.A2A.AspNetCore</RootNamespace>
<VersionSuffix>preview</VersionSuffix>
</PropertyGroup>
@@ -3,7 +3,6 @@
<PropertyGroup>
<TargetFrameworks>$(ProjectsCoreTargetFrameworks)</TargetFrameworks>
<TargetFrameworks Condition="'$(Configuration)' == 'Debug'">$(ProjectsCoreTargetFrameworks)</TargetFrameworks>
<NoWarn>$(NoWarn);IDE1006;IDE0130;NU1504</NoWarn>
<RootNamespace>Microsoft.Agents.AI.Hosting.A2A</RootNamespace>
<VersionSuffix>preview</VersionSuffix>
</PropertyGroup>
@@ -4,7 +4,7 @@
<TargetFrameworks>$(ProjectsTargetFrameworks)</TargetFrameworks>
<TargetFrameworks Condition="'$(Configuration)' == 'Debug'">$(ProjectsDebugTargetFrameworks)</TargetFrameworks>
<VersionSuffix>preview</VersionSuffix>
<NoWarn>$(NoWarn);IDE0009;OPENAI001;</NoWarn>
<NoWarn>$(NoWarn);OPENAI001;</NoWarn>
<ImplicitUsings>enable</ImplicitUsings>
<InjectSharedThrow>true</InjectSharedThrow>
</PropertyGroup>
@@ -12,8 +12,6 @@ using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Shared.Diagnostics;
#pragma warning disable S3358 // Ternary operators should not be nested
namespace Microsoft.Agents.AI;
/// <summary>