diff --git a/docs/ai/ai-extensions.md b/docs/ai/ai-extensions.md index 61f7622aa8c95..45a0e8da778a1 100644 --- a/docs/ai/ai-extensions.md +++ b/docs/ai/ai-extensions.md @@ -45,10 +45,10 @@ IChatClient client =     new AzureAIInferenceChatClient(...); ``` -Then, regardless of the provider you're using, you can send requests by calling , as follows: +Then, regardless of the provider you're using, you can send requests by calling , as follows: ```csharp -var response = await chatClient.CompleteAsync( +var response = await chatClient.GetResponseAsync(       "Translate the following text into Pig Latin: I love .NET and AI"); Console.WriteLine(response.Message); diff --git a/docs/ai/how-to/snippets/content-filtering/AIContentFiltering.csproj b/docs/ai/how-to/snippets/content-filtering/AIContentFiltering.csproj index bd79a4df023fa..7491520c71161 100644 --- a/docs/ai/how-to/snippets/content-filtering/AIContentFiltering.csproj +++ b/docs/ai/how-to/snippets/content-filtering/AIContentFiltering.csproj @@ -10,8 +10,8 @@ - - + + diff --git a/docs/ai/how-to/snippets/content-filtering/Program.cs b/docs/ai/how-to/snippets/content-filtering/Program.cs index f6537d51e3969..12542d600e70b 100644 --- a/docs/ai/how-to/snippets/content-filtering/Program.cs +++ b/docs/ai/how-to/snippets/content-filtering/Program.cs @@ -9,11 +9,11 @@ try { - ChatCompletion completion = await client.CompleteAsync("YOUR_PROMPT"); + ChatResponse completion = await client.GetResponseAsync("YOUR_PROMPT"); Console.WriteLine(completion.Message); -} -catch (Exception e) +} +catch (Exception e) { Console.WriteLine(e.Message); } diff --git a/docs/ai/how-to/snippets/hosted-app-auth/Program.cs b/docs/ai/how-to/snippets/hosted-app-auth/Program.cs index deb2850199b8e..3d14a3f6aa051 100644 --- a/docs/ai/how-to/snippets/hosted-app-auth/Program.cs +++ b/docs/ai/how-to/snippets/hosted-app-auth/Program.cs @@ -40,7 +40,7 @@ app.MapGet("/test-prompt", async (IChatClient chatClient) => { - return await chatClient.CompleteAsync("Test prompt", new ChatOptions()); + return await chatClient.GetResponseAsync("Test prompt", new ChatOptions()); }) .WithName("Test prompt"); diff --git a/docs/ai/how-to/snippets/hosted-app-auth/hosted-app-auth.csproj b/docs/ai/how-to/snippets/hosted-app-auth/hosted-app-auth.csproj index 47419885dd408..ce616f605ade8 100644 --- a/docs/ai/how-to/snippets/hosted-app-auth/hosted-app-auth.csproj +++ b/docs/ai/how-to/snippets/hosted-app-auth/hosted-app-auth.csproj @@ -11,9 +11,9 @@ - - - + + + diff --git a/docs/ai/quickstarts/snippets/build-chat-app/azure-openai/ChatAppAI.csproj b/docs/ai/quickstarts/snippets/build-chat-app/azure-openai/ChatAppAI.csproj index a955030574851..5638d8c175ccd 100644 --- a/docs/ai/quickstarts/snippets/build-chat-app/azure-openai/ChatAppAI.csproj +++ b/docs/ai/quickstarts/snippets/build-chat-app/azure-openai/ChatAppAI.csproj @@ -11,7 +11,7 @@ - + diff --git a/docs/ai/quickstarts/snippets/build-chat-app/azure-openai/Program.cs b/docs/ai/quickstarts/snippets/build-chat-app/azure-openai/Program.cs index c6031d83718f5..880ebfced7741 100644 --- a/docs/ai/quickstarts/snippets/build-chat-app/azure-openai/Program.cs +++ b/docs/ai/quickstarts/snippets/build-chat-app/azure-openai/Program.cs @@ -41,7 +41,7 @@ the local nature on the hikes when making a recommendation. At the end of your Console.WriteLine("AI Response:"); var response = ""; await foreach (var item in - chatClient.CompleteStreamingAsync(chatHistory)) + chatClient.GetStreamingResponseAsync(chatHistory)) { Console.Write(item.Text); response += item.Text; diff --git a/docs/ai/quickstarts/snippets/build-chat-app/openai/ExtensionsOpenAI.csproj b/docs/ai/quickstarts/snippets/build-chat-app/openai/ExtensionsOpenAI.csproj index d8716dcf01257..ce77307cc2764 100644 --- a/docs/ai/quickstarts/snippets/build-chat-app/openai/ExtensionsOpenAI.csproj +++ b/docs/ai/quickstarts/snippets/build-chat-app/openai/ExtensionsOpenAI.csproj @@ -8,7 +8,7 @@ - + diff --git a/docs/ai/quickstarts/snippets/build-chat-app/openai/Program.cs b/docs/ai/quickstarts/snippets/build-chat-app/openai/Program.cs index 12e694e1ab8c8..522af1ec7be10 100644 --- a/docs/ai/quickstarts/snippets/build-chat-app/openai/Program.cs +++ b/docs/ai/quickstarts/snippets/build-chat-app/openai/Program.cs @@ -40,7 +40,7 @@ the local nature on the hikes when making a recommendation. At the end of your Console.WriteLine("AI Response:"); var response = ""; await foreach (var item in - chatClient.CompleteStreamingAsync(chatHistory)) + chatClient.GetStreamingResponseAsync(chatHistory)) { Console.Write(item.Text); response += item.Text; diff --git a/docs/ai/quickstarts/snippets/function-calling/openai/FunctionCallingAI.csproj b/docs/ai/quickstarts/snippets/function-calling/openai/FunctionCallingAI.csproj index 25478e6270ca6..001dab80d6808 100644 --- a/docs/ai/quickstarts/snippets/function-calling/openai/FunctionCallingAI.csproj +++ b/docs/ai/quickstarts/snippets/function-calling/openai/FunctionCallingAI.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/docs/ai/quickstarts/snippets/function-calling/openai/Program.cs b/docs/ai/quickstarts/snippets/function-calling/openai/Program.cs index c57da3c4c3275..dfee28be36956 100644 --- a/docs/ai/quickstarts/snippets/function-calling/openai/Program.cs +++ b/docs/ai/quickstarts/snippets/function-calling/openai/Program.cs @@ -2,18 +2,17 @@ using Microsoft.Extensions.Configuration; using OpenAI; -var config = new ConfigurationBuilder().AddUserSecrets().Build(); -string model = config["ModelName"]; -string key = config["OpenAIKey"]; +IConfigurationRoot config = new ConfigurationBuilder().AddUserSecrets().Build(); +string? model = config["ModelName"]; +string? key = config["OpenAIKey"]; IChatClient client = - new ChatClientBuilder() - .UseFunctionInvocation() - .Use( - new OpenAIClient(key) - .AsChatClient(model)); + new ChatClientBuilder(new OpenAIClient(key).AsChatClient(model ?? "gpt-4o")) + .UseFunctionInvocation() + .Build(); -// Add a new plugin with a local .NET function that should be available to the AI model +// Add a new plugin with a local .NET function +// that should be available to the AI model. var chatOptions = new ChatOptions { Tools = [AIFunctionFactory.Create((string location, string unit) => @@ -25,16 +24,16 @@ "Get the current weather in a given location")] }; -// System prompt to provide context +// System prompt to provide context. List chatHistory = [new(ChatRole.System, """ You are a hiking enthusiast who helps people discover fun hikes in their area. You are upbeat and friendly. """)]; -// Weather conversation relevant to the registered function +// Weather conversation relevant to the registered function. chatHistory.Add(new ChatMessage(ChatRole.User, "I live in Montreal and I'm looking for a moderate intensity hike. What's the current weather like? ")); Console.WriteLine($"{chatHistory.Last().Role} >>> {chatHistory.Last()}"); -var response = await client.CompleteAsync(chatHistory, chatOptions); +ChatResponse response = await client.GetResponseAsync(chatHistory, chatOptions); chatHistory.Add(new ChatMessage(ChatRole.Assistant, response.Message.Contents)); Console.WriteLine($"{chatHistory.Last().Role} >>> {chatHistory.Last()}"); diff --git a/docs/ai/quickstarts/snippets/local-ai/Program.cs b/docs/ai/quickstarts/snippets/local-ai/Program.cs index ec8b1468712cc..5e0a731fca0e3 100644 --- a/docs/ai/quickstarts/snippets/local-ai/Program.cs +++ b/docs/ai/quickstarts/snippets/local-ai/Program.cs @@ -1,6 +1,6 @@ using Microsoft.Extensions.AI; -IChatClient chatClient = +IChatClient chatClient = new OllamaChatClient(new Uri("http://localhost:11434/"), "phi3:mini"); // Start the conversation with context for the AI model @@ -17,11 +17,11 @@ Console.WriteLine("AI Response:"); var response = ""; await foreach (var item in - chatClient.CompleteStreamingAsync(chatHistory)) + chatClient.GetStreamingResponseAsync(chatHistory)) { Console.Write(item.Text); response += item.Text; } chatHistory.Add(new ChatMessage(ChatRole.Assistant, response)); Console.WriteLine(); -} \ No newline at end of file +} diff --git a/docs/ai/quickstarts/snippets/local-ai/ollama.csproj b/docs/ai/quickstarts/snippets/local-ai/ollama.csproj index 347a4259f003d..27429efffe7d8 100644 --- a/docs/ai/quickstarts/snippets/local-ai/ollama.csproj +++ b/docs/ai/quickstarts/snippets/local-ai/ollama.csproj @@ -8,7 +8,7 @@ - + diff --git a/docs/ai/quickstarts/snippets/prompt-completion/azure-openai/ExtensionsAzureOpenAI.csproj b/docs/ai/quickstarts/snippets/prompt-completion/azure-openai/ExtensionsAzureOpenAI.csproj index 4b2e15935d47a..c17559bfd06dd 100644 --- a/docs/ai/quickstarts/snippets/prompt-completion/azure-openai/ExtensionsAzureOpenAI.csproj +++ b/docs/ai/quickstarts/snippets/prompt-completion/azure-openai/ExtensionsAzureOpenAI.csproj @@ -10,7 +10,7 @@ - + diff --git a/docs/ai/quickstarts/snippets/prompt-completion/azure-openai/Program.cs b/docs/ai/quickstarts/snippets/prompt-completion/azure-openai/Program.cs index 43e83dd1bf561..907980bc69520 100644 --- a/docs/ai/quickstarts/snippets/prompt-completion/azure-openai/Program.cs +++ b/docs/ai/quickstarts/snippets/prompt-completion/azure-openai/Program.cs @@ -20,5 +20,5 @@ Console.WriteLine($"user >>> {prompt}"); // Submit the prompt and print out the response -ChatCompletion response = await client.CompleteAsync(prompt, new ChatOptions { MaxOutputTokens = 400 }); +ChatResponse response = await client.GetResponseAsync(prompt, new ChatOptions { MaxOutputTokens = 400 }); Console.WriteLine($"assistant >>> {response}"); diff --git a/docs/ai/quickstarts/snippets/prompt-completion/openai/ExtensionsOpenAI.csproj b/docs/ai/quickstarts/snippets/prompt-completion/openai/ExtensionsOpenAI.csproj index d8716dcf01257..ce77307cc2764 100644 --- a/docs/ai/quickstarts/snippets/prompt-completion/openai/ExtensionsOpenAI.csproj +++ b/docs/ai/quickstarts/snippets/prompt-completion/openai/ExtensionsOpenAI.csproj @@ -8,7 +8,7 @@ - + diff --git a/docs/ai/quickstarts/snippets/prompt-completion/openai/Program.cs b/docs/ai/quickstarts/snippets/prompt-completion/openai/Program.cs index e4f234697acb3..ebc4a3a660c83 100644 --- a/docs/ai/quickstarts/snippets/prompt-completion/openai/Program.cs +++ b/docs/ai/quickstarts/snippets/prompt-completion/openai/Program.cs @@ -2,9 +2,9 @@ using Microsoft.Extensions.Configuration; using OpenAI; -var config = new ConfigurationBuilder().AddUserSecrets().Build(); -string model = config["ModelName"]; -string key = config["OpenAIKey"]; +IConfigurationRoot config = new ConfigurationBuilder().AddUserSecrets().Build(); +string? model = config["ModelName"]; +string? key = config["OpenAIKey"]; // Create the IChatClient IChatClient client = @@ -19,5 +19,5 @@ Console.WriteLine($"user >>> {prompt}"); // Submit the prompt and print out the response -ChatCompletion response = await client.CompleteAsync(prompt, new ChatOptions { MaxOutputTokens = 400 }); +ChatResponse response = await client.GetResponseAsync(prompt, new ChatOptions { MaxOutputTokens = 400 }); Console.WriteLine($"assistant >>> {response}"); diff --git a/docs/azure/includes/dotnet-all.md b/docs/azure/includes/dotnet-all.md index 52fccfd2d0b10..1282548e75ac8 100644 --- a/docs/azure/includes/dotnet-all.md +++ b/docs/azure/includes/dotnet-all.md @@ -103,7 +103,7 @@ | Storage - Files Share | NuGet [12.21.0](https://www.nuget.org/packages/Azure.Storage.Files.Shares/12.21.0)
NuGet [12.22.0-beta.1](https://www.nuget.org/packages/Azure.Storage.Files.Shares/12.22.0-beta.1) | [docs](/dotnet/api/overview/azure/Storage.Files.Shares-readme) | GitHub [12.21.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Files.Shares_12.21.0/sdk/storage/Azure.Storage.Files.Shares/)
GitHub [12.22.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Files.Shares_12.22.0-beta.1/sdk/storage/Azure.Storage.Files.Shares/) | | Storage - Queues | NuGet [12.21.0](https://www.nuget.org/packages/Azure.Storage.Queues/12.21.0)
NuGet [12.22.0-beta.1](https://www.nuget.org/packages/Azure.Storage.Queues/12.22.0-beta.1) | [docs](/dotnet/api/overview/azure/Storage.Queues-readme) | GitHub [12.21.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Queues_12.21.0/sdk/storage/Azure.Storage.Queues/)
GitHub [12.22.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Queues_12.22.0-beta.1/sdk/storage/Azure.Storage.Queues/) | | Synapse - AccessControl | NuGet [1.0.0-preview.5](https://www.nuget.org/packages/Azure.Analytics.Synapse.AccessControl/1.0.0-preview.5) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.AccessControl-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-preview.5](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.AccessControl_1.0.0-preview.5/sdk/synapse/Azure.Analytics.Synapse.AccessControl/) | -| Synapse - Artifacts | NuGet [1.0.0-preview.20](https://www.nuget.org/packages/Azure.Analytics.Synapse.Artifacts/1.0.0-preview.20) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.Artifacts-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-preview.20](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.Artifacts_1.0.0-preview.20/sdk/synapse/Azure.Analytics.Synapse.Artifacts/) | +| Synapse - Artifacts | NuGet [1.0.0-preview.21](https://www.nuget.org/packages/Azure.Analytics.Synapse.Artifacts/1.0.0-preview.21) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.Artifacts-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-preview.21](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.Artifacts_1.0.0-preview.21/sdk/synapse/Azure.Analytics.Synapse.Artifacts/) | | Synapse - Managed Private Endpoints | NuGet [1.0.0-beta.5](https://www.nuget.org/packages/Azure.Analytics.Synapse.ManagedPrivateEndpoints/1.0.0-beta.5) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.ManagedPrivateEndpoints-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.5](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.ManagedPrivateEndpoints_1.0.0-beta.5/sdk/synapse/Azure.Analytics.Synapse.ManagedPrivateEndpoints/) | | Synapse - Monitoring | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.Analytics.Synapse.Monitoring/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.Monitoring-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.Monitoring_1.0.0-beta.3/sdk/synapse/Azure.Analytics.Synapse.Monitoring/) | | Synapse - Spark | NuGet [1.0.0-preview.8](https://www.nuget.org/packages/Azure.Analytics.Synapse.Spark/1.0.0-preview.8) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.Spark-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-preview.8](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.Spark_1.0.0-preview.8/sdk/synapse/Azure.Analytics.Synapse.Spark/) | @@ -188,7 +188,7 @@ | Resource Management - Chaos | NuGet [1.0.0](https://www.nuget.org/packages/Azure.ResourceManager.Chaos/1.0.0)
NuGet [1.1.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager.Chaos/1.1.0-beta.1) | [docs](/dotnet/api/overview/azure/ResourceManager.Chaos-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Chaos_1.0.0/sdk/chaos/Azure.ResourceManager.Chaos/)
GitHub [1.1.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Chaos_1.1.0-beta.1/sdk/chaos/Azure.ResourceManager.Chaos/) | | Resource Management - Cognitive Services | NuGet [1.4.0](https://www.nuget.org/packages/Azure.ResourceManager.CognitiveServices/1.4.0) | [docs](/dotnet/api/overview/azure/ResourceManager.CognitiveServices-readme) | GitHub [1.4.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.CognitiveServices_1.4.0/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/) | | Resource Management - Communication | NuGet [1.2.0](https://www.nuget.org/packages/Azure.ResourceManager.Communication/1.2.0) | [docs](/dotnet/api/overview/azure/ResourceManager.Communication-readme) | GitHub [1.2.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Communication_1.2.0/sdk/communication/Azure.ResourceManager.Communication/) | -| Resource Management - Compute | NuGet [1.7.0](https://www.nuget.org/packages/Azure.ResourceManager.Compute/1.7.0) | [docs](/dotnet/api/overview/azure/ResourceManager.Compute-readme) | GitHub [1.7.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Compute_1.7.0/sdk/compute/Azure.ResourceManager.Compute/) | +| Resource Management - Compute | NuGet [1.8.0](https://www.nuget.org/packages/Azure.ResourceManager.Compute/1.8.0) | [docs](/dotnet/api/overview/azure/ResourceManager.Compute-readme) | GitHub [1.8.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Compute_1.8.0/sdk/compute/Azure.ResourceManager.Compute/) | | Resource Management - Computefleet | NuGet [1.0.0](https://www.nuget.org/packages/Azure.ResourceManager.ComputeFleet/1.0.0) | [docs](/dotnet/api/overview/azure/ResourceManager.ComputeFleet-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.ComputeFleet_1.0.0/sdk/computefleet/Azure.ResourceManager.ComputeFleet/) | | Resource Management - Computeschedule | NuGet [1.0.0](https://www.nuget.org/packages/Azure.ResourceManager.ComputeSchedule/1.0.0) | [docs](/dotnet/api/overview/azure/ResourceManager.ComputeSchedule-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.ComputeSchedule_1.0.0/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/) | | Resource Management - Confidential Ledger | NuGet [1.0.1](https://www.nuget.org/packages/Azure.ResourceManager.ConfidentialLedger/1.0.1)
NuGet [1.1.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.ConfidentialLedger/1.1.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.ConfidentialLedger-readme) | GitHub [1.0.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.ConfidentialLedger_1.0.1/sdk/confidentialledger/Azure.ResourceManager.ConfidentialLedger/)
GitHub [1.1.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.ConfidentialLedger_1.1.0-beta.4/sdk/confidentialledger/Azure.ResourceManager.ConfidentialLedger/) | @@ -287,7 +287,7 @@ | Resource Management - Monitor | NuGet [1.3.1](https://www.nuget.org/packages/Azure.ResourceManager.Monitor/1.3.1)
NuGet [1.4.0-beta.2](https://www.nuget.org/packages/Azure.ResourceManager.Monitor/1.4.0-beta.2) | [docs](/dotnet/api/overview/azure/ResourceManager.Monitor-readme) | GitHub [1.3.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Monitor_1.3.1/sdk/monitor/Azure.ResourceManager.Monitor/)
GitHub [1.4.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Monitor_1.4.0-beta.2/sdk/monitor/Azure.ResourceManager.Monitor/) | | Resource Management - MySQL | NuGet [1.1.0](https://www.nuget.org/packages/Azure.ResourceManager.MySql/1.1.0) | [docs](/dotnet/api/overview/azure/ResourceManager.MySql-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.MySql_1.1.0/sdk/mysql/Azure.ResourceManager.MySql/) | | Resource Management - Neonpostgres | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager.NeonPostgres/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/ResourceManager.NeonPostgres-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.NeonPostgres_1.0.0-beta.1/sdk/neonpostgres/Azure.ResourceManager.NeonPostgres/) | -| Resource Management - NetApp Files | NuGet [1.8.0](https://www.nuget.org/packages/Azure.ResourceManager.NetApp/1.8.0) | [docs](/dotnet/api/overview/azure/ResourceManager.NetApp-readme) | GitHub [1.8.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.NetApp_1.8.0/sdk/netapp/Azure.ResourceManager.NetApp/) | +| Resource Management - NetApp Files | NuGet [1.9.0](https://www.nuget.org/packages/Azure.ResourceManager.NetApp/1.9.0) | [docs](/dotnet/api/overview/azure/ResourceManager.NetApp-readme) | GitHub [1.9.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.NetApp_1.9.0/sdk/netapp/Azure.ResourceManager.NetApp/) | | Resource Management - Network | NuGet [1.10.0](https://www.nuget.org/packages/Azure.ResourceManager.Network/1.10.0)
NuGet [1.11.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager.Network/1.11.0-beta.1) | [docs](/dotnet/api/overview/azure/ResourceManager.Network-readme) | GitHub [1.10.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Network_1.10.0/sdk/network/Azure.ResourceManager.Network/)
GitHub [1.11.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Network_1.11.0-beta.1/sdk/network/Azure.ResourceManager.Network/) | | Resource Management - Network Cloud | NuGet [1.1.0](https://www.nuget.org/packages/Azure.ResourceManager.NetworkCloud/1.1.0) | [docs](/dotnet/api/overview/azure/ResourceManager.NetworkCloud-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.NetworkCloud_1.1.0/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/) | | Resource Management - Network Function | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.NetworkFunction/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.NetworkFunction-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.NetworkFunction_1.0.0-beta.4/sdk/networkfunction/Azure.ResourceManager.NetworkFunction/) | diff --git a/docs/azure/includes/dotnet-new.md b/docs/azure/includes/dotnet-new.md index 59b2809fa90ee..84d5553f604cd 100644 --- a/docs/azure/includes/dotnet-new.md +++ b/docs/azure/includes/dotnet-new.md @@ -107,7 +107,7 @@ | Storage - Files Share | NuGet [12.21.0](https://www.nuget.org/packages/Azure.Storage.Files.Shares/12.21.0)
NuGet [12.22.0-beta.1](https://www.nuget.org/packages/Azure.Storage.Files.Shares/12.22.0-beta.1) | [docs](/dotnet/api/overview/azure/Storage.Files.Shares-readme) | GitHub [12.21.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Files.Shares_12.21.0/sdk/storage/Azure.Storage.Files.Shares/)
GitHub [12.22.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Files.Shares_12.22.0-beta.1/sdk/storage/Azure.Storage.Files.Shares/) | | Storage - Queues | NuGet [12.21.0](https://www.nuget.org/packages/Azure.Storage.Queues/12.21.0)
NuGet [12.22.0-beta.1](https://www.nuget.org/packages/Azure.Storage.Queues/12.22.0-beta.1) | [docs](/dotnet/api/overview/azure/Storage.Queues-readme) | GitHub [12.21.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Queues_12.21.0/sdk/storage/Azure.Storage.Queues/)
GitHub [12.22.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Queues_12.22.0-beta.1/sdk/storage/Azure.Storage.Queues/) | | Synapse - AccessControl | NuGet [1.0.0-preview.5](https://www.nuget.org/packages/Azure.Analytics.Synapse.AccessControl/1.0.0-preview.5) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.AccessControl-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-preview.5](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.AccessControl_1.0.0-preview.5/sdk/synapse/Azure.Analytics.Synapse.AccessControl/) | -| Synapse - Artifacts | NuGet [1.0.0-preview.20](https://www.nuget.org/packages/Azure.Analytics.Synapse.Artifacts/1.0.0-preview.20) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.Artifacts-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-preview.20](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.Artifacts_1.0.0-preview.20/sdk/synapse/Azure.Analytics.Synapse.Artifacts/) | +| Synapse - Artifacts | NuGet [1.0.0-preview.21](https://www.nuget.org/packages/Azure.Analytics.Synapse.Artifacts/1.0.0-preview.21) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.Artifacts-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-preview.21](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.Artifacts_1.0.0-preview.21/sdk/synapse/Azure.Analytics.Synapse.Artifacts/) | | Synapse - Managed Private Endpoints | NuGet [1.0.0-beta.5](https://www.nuget.org/packages/Azure.Analytics.Synapse.ManagedPrivateEndpoints/1.0.0-beta.5) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.ManagedPrivateEndpoints-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.5](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.ManagedPrivateEndpoints_1.0.0-beta.5/sdk/synapse/Azure.Analytics.Synapse.ManagedPrivateEndpoints/) | | Synapse - Monitoring | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.Analytics.Synapse.Monitoring/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.Monitoring-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.Monitoring_1.0.0-beta.3/sdk/synapse/Azure.Analytics.Synapse.Monitoring/) | | Synapse - Spark | NuGet [1.0.0-preview.8](https://www.nuget.org/packages/Azure.Analytics.Synapse.Spark/1.0.0-preview.8) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.Spark-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-preview.8](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.Spark_1.0.0-preview.8/sdk/synapse/Azure.Analytics.Synapse.Spark/) | @@ -194,7 +194,7 @@ | Resource Management - Chaos | NuGet [1.0.0](https://www.nuget.org/packages/Azure.ResourceManager.Chaos/1.0.0)
NuGet [1.1.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager.Chaos/1.1.0-beta.1) | [docs](/dotnet/api/overview/azure/ResourceManager.Chaos-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Chaos_1.0.0/sdk/chaos/Azure.ResourceManager.Chaos/)
GitHub [1.1.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Chaos_1.1.0-beta.1/sdk/chaos/Azure.ResourceManager.Chaos/) | | Resource Management - Cognitive Services | NuGet [1.4.0](https://www.nuget.org/packages/Azure.ResourceManager.CognitiveServices/1.4.0) | [docs](/dotnet/api/overview/azure/ResourceManager.CognitiveServices-readme) | GitHub [1.4.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.CognitiveServices_1.4.0/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/) | | Resource Management - Communication | NuGet [1.2.0](https://www.nuget.org/packages/Azure.ResourceManager.Communication/1.2.0) | [docs](/dotnet/api/overview/azure/ResourceManager.Communication-readme) | GitHub [1.2.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Communication_1.2.0/sdk/communication/Azure.ResourceManager.Communication/) | -| Resource Management - Compute | NuGet [1.7.0](https://www.nuget.org/packages/Azure.ResourceManager.Compute/1.7.0) | [docs](/dotnet/api/overview/azure/ResourceManager.Compute-readme) | GitHub [1.7.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Compute_1.7.0/sdk/compute/Azure.ResourceManager.Compute/) | +| Resource Management - Compute | NuGet [1.8.0](https://www.nuget.org/packages/Azure.ResourceManager.Compute/1.8.0) | [docs](/dotnet/api/overview/azure/ResourceManager.Compute-readme) | GitHub [1.8.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Compute_1.8.0/sdk/compute/Azure.ResourceManager.Compute/) | | Resource Management - Computefleet | NuGet [1.0.0](https://www.nuget.org/packages/Azure.ResourceManager.ComputeFleet/1.0.0) | [docs](/dotnet/api/overview/azure/ResourceManager.ComputeFleet-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.ComputeFleet_1.0.0/sdk/computefleet/Azure.ResourceManager.ComputeFleet/) | | Resource Management - Computeschedule | NuGet [1.0.0](https://www.nuget.org/packages/Azure.ResourceManager.ComputeSchedule/1.0.0) | [docs](/dotnet/api/overview/azure/ResourceManager.ComputeSchedule-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.ComputeSchedule_1.0.0/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/) | | Resource Management - Confidential Ledger | NuGet [1.0.1](https://www.nuget.org/packages/Azure.ResourceManager.ConfidentialLedger/1.0.1)
NuGet [1.1.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.ConfidentialLedger/1.1.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.ConfidentialLedger-readme) | GitHub [1.0.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.ConfidentialLedger_1.0.1/sdk/confidentialledger/Azure.ResourceManager.ConfidentialLedger/)
GitHub [1.1.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.ConfidentialLedger_1.1.0-beta.4/sdk/confidentialledger/Azure.ResourceManager.ConfidentialLedger/) | @@ -294,7 +294,7 @@ | Resource Management - Monitor | NuGet [1.3.1](https://www.nuget.org/packages/Azure.ResourceManager.Monitor/1.3.1)
NuGet [1.4.0-beta.2](https://www.nuget.org/packages/Azure.ResourceManager.Monitor/1.4.0-beta.2) | [docs](/dotnet/api/overview/azure/ResourceManager.Monitor-readme) | GitHub [1.3.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Monitor_1.3.1/sdk/monitor/Azure.ResourceManager.Monitor/)
GitHub [1.4.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Monitor_1.4.0-beta.2/sdk/monitor/Azure.ResourceManager.Monitor/) | | Resource Management - MySQL | NuGet [1.1.0](https://www.nuget.org/packages/Azure.ResourceManager.MySql/1.1.0) | [docs](/dotnet/api/overview/azure/ResourceManager.MySql-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.MySql_1.1.0/sdk/mysql/Azure.ResourceManager.MySql/) | | Resource Management - Neonpostgres | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager.NeonPostgres/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/ResourceManager.NeonPostgres-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.NeonPostgres_1.0.0-beta.1/sdk/neonpostgres/Azure.ResourceManager.NeonPostgres/) | -| Resource Management - NetApp Files | NuGet [1.8.0](https://www.nuget.org/packages/Azure.ResourceManager.NetApp/1.8.0) | [docs](/dotnet/api/overview/azure/ResourceManager.NetApp-readme) | GitHub [1.8.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.NetApp_1.8.0/sdk/netapp/Azure.ResourceManager.NetApp/) | +| Resource Management - NetApp Files | NuGet [1.9.0](https://www.nuget.org/packages/Azure.ResourceManager.NetApp/1.9.0) | [docs](/dotnet/api/overview/azure/ResourceManager.NetApp-readme) | GitHub [1.9.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.NetApp_1.9.0/sdk/netapp/Azure.ResourceManager.NetApp/) | | Resource Management - Network | NuGet [1.10.0](https://www.nuget.org/packages/Azure.ResourceManager.Network/1.10.0)
NuGet [1.11.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager.Network/1.11.0-beta.1) | [docs](/dotnet/api/overview/azure/ResourceManager.Network-readme) | GitHub [1.10.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Network_1.10.0/sdk/network/Azure.ResourceManager.Network/)
GitHub [1.11.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Network_1.11.0-beta.1/sdk/network/Azure.ResourceManager.Network/) | | Resource Management - Network Analytics | NuGet [1.0.0](https://www.nuget.org/packages/Azure.ResourceManager.NetworkAnalytics/1.0.0) | [docs](/dotnet/api/overview/azure/ResourceManager.NetworkAnalytics-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.NetworkAnalytics_1.0.0/sdk/networkanalytics/Azure.ResourceManager.NetworkAnalytics/) | | Resource Management - Network Cloud | NuGet [1.1.0](https://www.nuget.org/packages/Azure.ResourceManager.NetworkCloud/1.1.0) | [docs](/dotnet/api/overview/azure/ResourceManager.NetworkCloud-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.NetworkCloud_1.1.0/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/) | diff --git a/docs/core/additional-tools/dotnet-coverage.md b/docs/core/additional-tools/dotnet-coverage.md index 2c1c765f4ba0d..a68eb1d3cea73 100644 --- a/docs/core/additional-tools/dotnet-coverage.md +++ b/docs/core/additional-tools/dotnet-coverage.md @@ -6,7 +6,7 @@ ms.topic: reference --- # dotnet-coverage code coverage utility -**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions +**This article applies to:** ✔️ .NET 8 SDK and later versions ## Synopsis @@ -593,9 +593,8 @@ Hello, World! If you don't want to use the `instrument` command, then the files to be instrumented can be specified using `--include-files` option as follows: ```console -D:\examples\ConsoleApp> dotnet-coverage collect --include-files .\bin\Debug\net7.0\*.dll dotnet run -Microsoft (R) Code Coverage Command Line Tool (x64) -Copyright (c) Microsoft Corporation. All rights reserved. +D:\examples\ConsoleApp> dotnet-coverage collect --include-files .\bin\Debug\net9.0\*.dll dotnet run +dotnet-coverage v17.14.1.0 [win-x64 - .NET 9.0.2] SessionId: 57862ec0-e512-49a5-8b66-2804174680fc Hello, World! @@ -618,8 +617,7 @@ In this case, first binary needs to be instrumented as follows: ```console D:\examples\ConsoleApp> dotnet-coverage instrument .\bin\Debug\net7.0\ConsoleApp.dll -Microsoft (R) Code Coverage Command Line Tool (x64) -Copyright (c) Microsoft Corporation. All rights reserved. +dotnet-coverage v17.14.1.0 [win-x64 - .NET 9.0.2] Input file successfully instrumented. ``` @@ -628,8 +626,7 @@ Then you can collect code coverage as follows: ```console D:\examples\ConsoleApp> dotnet-coverage collect .\bin\Debug\net7.0\ConsoleApp.exe -Microsoft (R) Code Coverage Command Line Tool (x64) -Copyright (c) Microsoft Corporation. All rights reserved. +dotnet-coverage v17.14.1.0 [win-x64 - .NET 9.0.2] SessionId: a09e6bef-ff64-4b5f-8bb8-fc495ebb50ba Hello, World! @@ -642,8 +639,7 @@ In this case, you can completely separate coverage collection from running your ```console D:\examples\ConsoleApp> dotnet-coverage instrument --session-id 73c34ce5-501c-4369-a4cb-04d31427d1a4 .\bin\Debug\net7.0\ConsoleApp.dll -Microsoft (R) Code Coverage Command Line Tool (x64) -Copyright (c) Microsoft Corporation. All rights reserved. +dotnet-coverage v17.14.1.0 [win-x64 - .NET 9.0.2] Input file successfully instrumented. ``` @@ -655,8 +651,7 @@ In the second step, you need to start coverage collector as follows: ```console D:\examples\ConsoleApp> dotnet-coverage collect --session-id 73c34ce5-501c-4369-a4cb-04d31427d1a4 --server-mode -Microsoft (R) Code Coverage Command Line Tool (x64) -Copyright (c) Microsoft Corporation. All rights reserved. +dotnet-coverage v17.14.1.0 [win-x64 - .NET 9.0.2] SessionId: 73c34ce5-501c-4369-a4cb-04d31427d1a4 ``` @@ -672,8 +667,7 @@ Finally, the collector can be closed as follows: ```console D:\examples\ConsoleApp> dotnet-coverage shutdown 73c34ce5-501c-4369-a4cb-04d31427d1a4 -Microsoft (R) Code Coverage Command Line Tool (x64) -Copyright (c) Microsoft Corporation. All rights reserved. +dotnet-coverage v17.14.1.0 [win-x64 - .NET 9.0.2] ``` ### Settings diff --git a/docs/core/compatibility/7.0.md b/docs/core/compatibility/7.0.md index a128ffe432d82..43307543e7472 100644 --- a/docs/core/compatibility/7.0.md +++ b/docs/core/compatibility/7.0.md @@ -9,77 +9,77 @@ no-loc: [Blazor, Razor, Kestrel] If you're migrating an app to .NET 7, the breaking changes listed here might affect you. Changes are grouped by technology area, such as ASP.NET Core or Windows Forms. -[!INCLUDE [binary-source-compat](includes/binary-source-compat.md)] +[!INCLUDE [binary-source-behavioral](includes/binary-source-behavioral.md)] ## ASP.NET Core -| Title | Binary compatible | Source compatible | -|-------|:-----------------:|:-----------------:| -| [API controller actions try to infer parameters from DI](aspnet-core/7.0/api-controller-action-parameters-di.md) | ✔️ | ❌ | -| [ASPNET-prefixed environment variable precedence](aspnet-core/7.0/environment-variable-precedence.md) | ✔️ | ✔️ | -| [AuthenticateAsync for remote auth providers](aspnet-core/7.0/authenticateasync-anonymous-request.md) | ✔️ | ❌ | -| [Authentication in WebAssembly apps](aspnet-core/7.0/wasm-app-authentication.md) | ❌ | ✔️ | -| [Default authentication scheme](aspnet-core/7.0/default-authentication-scheme.md) | ❌ | ✔️ | -| [Event IDs for some Microsoft.AspNetCore.Mvc.Core log messages changed](aspnet-core/7.0/microsoft-aspnetcore-mvc-core-log-event-ids.md) | ❌ | ✔️ | -| [Fallback file endpoints](aspnet-core/7.0/fallback-file-endpoints.md) | ❌ | ✔️ | -| [IHubClients and IHubCallerClients hide members](aspnet-core/7.0/ihubclients-ihubcallerclients.md) | ✔️ | ❌ | -| [Kestrel: Default HTTPS binding removed](aspnet-core/7.0/https-binding-kestrel.md) | ❌ | ✔️ | -| [Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv and libuv.dll removed](aspnet-core/7.0/libuv-transport-dll-removed.md) | ❌ | ❌ | -| [Microsoft.Data.SqlClient updated to 4.0.1](aspnet-core/7.0/microsoft-data-sqlclient-updated-to-4-0-1.md) | ✔️ | ❌ | -| [Middleware no longer defers to endpoint with null request delegate](aspnet-core/7.0/middleware-null-requestdelegate.md) | ❌ | ✔️ | -| [MVC's detection of an empty body in model binding changed](aspnet-core/7.0/mvc-empty-body-model-binding.md) | ❌ | ✔️ | -| [Output caching API changes](aspnet-core/7.0/output-caching-renames.md) | ❌ | ❌ | -| [SignalR Hub methods try to resolve parameters from DI](aspnet-core/7.0/signalr-hub-method-parameters-di.md) | ✔️ | ❌ | +| Title | Type of change | +|-----------------------------------------------------------------------------------------------------------------------------------------|:--------------------------:| +| [API controller actions try to infer parameters from DI](aspnet-core/7.0/api-controller-action-parameters-di.md) | Source incompatible | +| [ASPNET-prefixed environment variable precedence](aspnet-core/7.0/environment-variable-precedence.md) | Behavioral change | +| [AuthenticateAsync for remote auth providers](aspnet-core/7.0/authenticateasync-anonymous-request.md) | Source incompatible | +| [Authentication in WebAssembly apps](aspnet-core/7.0/wasm-app-authentication.md) | Binary incompatible | +| [Default authentication scheme](aspnet-core/7.0/default-authentication-scheme.md) | Binary incompatible | +| [Event IDs for some Microsoft.AspNetCore.Mvc.Core log messages changed](aspnet-core/7.0/microsoft-aspnetcore-mvc-core-log-event-ids.md) | Binary incompatible | +| [Fallback file endpoints](aspnet-core/7.0/fallback-file-endpoints.md) | Binary incompatible | +| [IHubClients and IHubCallerClients hide members](aspnet-core/7.0/ihubclients-ihubcallerclients.md) | Source incompatible | +| [Kestrel: Default HTTPS binding removed](aspnet-core/7.0/https-binding-kestrel.md) | Binary incompatible | +| [Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv and libuv.dll removed](aspnet-core/7.0/libuv-transport-dll-removed.md) | Binary/source incompatible | +| [Microsoft.Data.SqlClient updated to 4.0.1](aspnet-core/7.0/microsoft-data-sqlclient-updated-to-4-0-1.md) | Source incompatible | +| [Middleware no longer defers to endpoint with null request delegate](aspnet-core/7.0/middleware-null-requestdelegate.md) | Binary incompatible | +| [MVC's detection of an empty body in model binding changed](aspnet-core/7.0/mvc-empty-body-model-binding.md) | Binary incompatible | +| [Output caching API changes](aspnet-core/7.0/output-caching-renames.md) | Binary/source incompatible | +| [SignalR Hub methods try to resolve parameters from DI](aspnet-core/7.0/signalr-hub-method-parameters-di.md) | Source incompatible | ## Core .NET libraries -| Title | Binary compatible | Source compatible | -|-------|:-----------------:|:-----------------:| -| [API obsoletions with default diagnostic ID](core-libraries/7.0/obsolete-apis-with-default-diagnostic.md) | ✔️ | ❌ | -| [API obsoletions with non-default diagnostic IDs](core-libraries/7.0/obsolete-apis-with-custom-diagnostics.md) | ✔️ | ❌ | -| [Asterisk no longer accepted for assembly name attributes](core-libraries/7.0/assembly-name-wildcard.md) | ✔️ | ✔️ | -| [BinaryFormatter serialization APIs produce compiler errors](serialization/7.0/binaryformatter-apis-produce-errors.md) | ✔️ | ❌ | -| [BrotliStream no longer allows undefined CompressionLevel values](core-libraries/7.0/brotlistream-ctor.md) | ❌ | ✔️ | -| [C++/CLI projects in Visual Studio](core-libraries/7.0/cpluspluscli-compiler-version.md) | ✔️ | ❌ | -| [Changes to reflection invoke API exceptions](core-libraries/7.0/reflection-invoke-exceptions.md) | ❌ | ✔️ | -| [Collectible Assembly in non-collectible AssemblyLoadContext](core-libraries/7.0/collectible-assemblies.md) | ❌ | ✔️ | -| [DateTime addition methods precision change](core-libraries/7.0/datetime-add-precision.md) | ✔️ | ✔️ | -| [Equals method behavior change for NaN](core-libraries/7.0/equals-nan.md) | ❌ | ✔️ | -| [EventSource callback behavior](core-libraries/6.0/eventsource-callback.md) | ✔️ | ✔️ | -| [Generic type constraint on PatternContext\](core-libraries/7.0/patterncontext-generic-constraint.md) | ❌ | ❌ | -| [Legacy FileStream strategy removed](core-libraries/7.0/filestream-compat-switch.md) | ❌ | ✔️ | -| [Library support for older frameworks](core-libraries/7.0/old-framework-support.md) | ❌ | ❌ | -| [Maximum precision for numeric format strings](core-libraries/7.0/max-precision-numeric-format-strings.md) | ❌ | ✔️ | -| [Regex patterns with ranges corrected](core-libraries/7.0/regex-ranges.md) | ✔️ | ✔️ | -| [SerializationFormat.Binary is obsolete](serialization/7.0/serializationformat-binary.md) | ❌ | ❌ | -| [System.Drawing.Common config switch removed](core-libraries/7.0/system-drawing.md) | ✔️ | ✔️ | -| [System.Runtime.CompilerServices.Unsafe NuGet package](core-libraries/7.0/unsafe-package.md) | ✔️ | ✔️ | -| [Time fields on symbolic links](core-libraries/7.0/symbolic-link-timestamps.md) | ❌ | ✔️ | -| [Tracking linked cache entries](core-libraries/7.0/memorycache-tracking.md) | ❌ | ✔️ | -| [Validate CompressionLevel for BrotliStream](core-libraries/7.0/compressionlevel-validation.md) | ❌ | ✔️ | +| Title | Type of change | +|------------------------------------------------------------------------------------------------------------------------|:--------------------------:| +| [API obsoletions with default diagnostic ID](core-libraries/7.0/obsolete-apis-with-default-diagnostic.md) | Source incompatible | +| [API obsoletions with non-default diagnostic IDs](core-libraries/7.0/obsolete-apis-with-custom-diagnostics.md) | Source incompatible | +| [Asterisk no longer accepted for assembly name attributes](core-libraries/7.0/assembly-name-wildcard.md) | Behavioral change | +| [BinaryFormatter serialization APIs produce compiler errors](serialization/7.0/binaryformatter-apis-produce-errors.md) | Source incompatible | +| [BrotliStream no longer allows undefined CompressionLevel values](core-libraries/7.0/brotlistream-ctor.md) | Binary incompatible | +| [C++/CLI projects in Visual Studio](core-libraries/7.0/cpluspluscli-compiler-version.md) | Source incompatible | +| [Changes to reflection invoke API exceptions](core-libraries/7.0/reflection-invoke-exceptions.md) | Binary incompatible | +| [Collectible Assembly in non-collectible AssemblyLoadContext](core-libraries/7.0/collectible-assemblies.md) | Binary incompatible | +| [DateTime addition methods precision change](core-libraries/7.0/datetime-add-precision.md) | Behavioral change | +| [Equals method behavior change for NaN](core-libraries/7.0/equals-nan.md) | Binary incompatible | +| [EventSource callback behavior](core-libraries/6.0/eventsource-callback.md) | Behavioral change | +| [Generic type constraint on PatternContext\](core-libraries/7.0/patterncontext-generic-constraint.md) | Binary/source incompatible | +| [Legacy FileStream strategy removed](core-libraries/7.0/filestream-compat-switch.md) | Binary incompatible | +| [Library support for older frameworks](core-libraries/7.0/old-framework-support.md) | Binary/source incompatible | +| [Maximum precision for numeric format strings](core-libraries/7.0/max-precision-numeric-format-strings.md) | Binary incompatible | +| [Regex patterns with ranges corrected](core-libraries/7.0/regex-ranges.md) | Behavioral change | +| [SerializationFormat.Binary is obsolete](serialization/7.0/serializationformat-binary.md) | Binary/source incompatible | +| [System.Drawing.Common config switch removed](core-libraries/7.0/system-drawing.md) | Behavioral change | +| [System.Runtime.CompilerServices.Unsafe NuGet package](core-libraries/7.0/unsafe-package.md) | Behavioral change | +| [Time fields on symbolic links](core-libraries/7.0/symbolic-link-timestamps.md) | Binary incompatible | +| [Tracking linked cache entries](core-libraries/7.0/memorycache-tracking.md) | Binary incompatible | +| [Validate CompressionLevel for BrotliStream](core-libraries/7.0/compressionlevel-validation.md) | Binary incompatible | ## Configuration -| Title | Binary compatible | Source compatible | -| - | :-: | :-: | -| [System.diagnostics entry in app.config](configuration/7.0/diagnostics-config-section.md) | ❌ | ✔️ | +| Title | Type of change | +|-------------------------------------------------------------------------------------------|:-------------------:| +| [System.diagnostics entry in app.config](configuration/7.0/diagnostics-config-section.md) | Binary incompatible | ## Cryptography -| Title | Binary compatible | Source compatible | -| - | :-: | :-: | -| [Decrypting EnvelopedCms doesn't double unwrap](cryptography/7.0/decrypt-envelopedcms.md) | ❌ | ✔️ | -| [Dynamic X509ChainPolicy verification time](cryptography/7.0/x509chainpolicy-verification-time.md) | ❌ | ✔️ | -| [X500DistinguishedName parsing of friendly names](cryptography/7.0/x500-distinguished-names.md) | ❌ | ✔️ | +| Title | Type of change | +|----------------------------------------------------------------------------------------------------|:-------------------:| +| [Decrypting EnvelopedCms doesn't double unwrap](cryptography/7.0/decrypt-envelopedcms.md) | Binary incompatible | +| [Dynamic X509ChainPolicy verification time](cryptography/7.0/x509chainpolicy-verification-time.md) | Binary incompatible | +| [X500DistinguishedName parsing of friendly names](cryptography/7.0/x500-distinguished-names.md) | Binary incompatible | ## Deployment -| Title | Binary compatible | Source compatible | -| - | :-: | :-: | -| [All assemblies trimmed by default](deployment/7.0/trim-all-assemblies.md) | ✔️ | ❌ | -| [Multi-level lookup is disabled](deployment/7.0/multilevel-lookup.md) | ❌ | ✔️ | -| [x86 host path on 64-bit Windows](deployment/7.0/x86-host-path.md) | ✔️ | ✔️ | -| [TrimmerDefaultAction is deprecated](deployment/7.0/deprecated-trimmer-default-action.md) | ✔️ | ❌ | +| Title | Type of change | +|-------------------------------------------------------------------------------------------|:-------------------:| +| [All assemblies trimmed by default](deployment/7.0/trim-all-assemblies.md) | Source incompatible | +| [Multi-level lookup is disabled](deployment/7.0/multilevel-lookup.md) | Binary incompatible | +| [x86 host path on 64-bit Windows](deployment/7.0/x86-host-path.md) | Behavioral change | +| [TrimmerDefaultAction is deprecated](deployment/7.0/deprecated-trimmer-default-action.md) | Source incompatible | ## Entity Framework Core @@ -87,87 +87,86 @@ If you're migrating an app to .NET 7, the breaking changes listed here might aff ## Extensions -| Title | Binary compatible | Source compatible | -| - | :-: | :-: | -| [Binding config to dictionary extends values](extensions/7.0/config-bind-dictionary.md) | ✔️ | ✔️ | -| [ContentRootPath for apps launched by Windows Shell](extensions/7.0/contentrootpath-hosted-app.md) | ❌ | ✔️ | -| [Environment variable prefixes](extensions/7.0/environment-variable-prefix.md) | ❌ | ✔️ | +| Title | Type of change | +|----------------------------------------------------------------------------------------------------|:-------------------:| +| [Binding config to dictionary extends values](extensions/7.0/config-bind-dictionary.md) | Behavioral change | +| [ContentRootPath for apps launched by Windows Shell](extensions/7.0/contentrootpath-hosted-app.md) | Binary incompatible | +| [Environment variable prefixes](extensions/7.0/environment-variable-prefix.md) | Binary incompatible | ## Globalization -| Title | Binary compatible | Source compatible | -| - | :-: | :-: | -| [Globalization APIs use ICU libraries on Windows Server](globalization/7.0/icu-globalization-api.md) | ❌ | ✔️ | +| Title | Type of change | +|------------------------------------------------------------------------------------------------------|:-------------------:| +| [Globalization APIs use ICU libraries on Windows Server](globalization/7.0/icu-globalization-api.md) | Binary incompatible | ## Interop -| Title | Binary compatible | Source compatible | -| - | :-: | :-: | -| [RuntimeInformation.OSArchitecture under emulation](interop/7.0/osarchitecture-emulation.md) | ❌ | ✔️ | +| Title | Type of change | +|----------------------------------------------------------------------------------------------|:-------------------:| +| [RuntimeInformation.OSArchitecture under emulation](interop/7.0/osarchitecture-emulation.md) | Binary incompatible | ## .NET MAUI -| Title | Binary compatible | Source compatible | -| - | :-: | :-: | -| [Constructors accept base interface instead of concrete type](maui/7.0/mauiwebviewnavigationdelegate-constructor.md) | ❌ | ✔️ | -| [Flow direction helper methods removed](maui/7.0/flow-direction-apis-removed.md) | ❌ | ❌ | -| [New UpdateBackground parameter](maui/7.0/updatebackground-parameter.md) | ❌ | ✔️ | -| [ScrollToRequest property renamed](maui/7.0/scrolltorequest-property-rename.md) | ❌ | ❌ | -| [Some Windows APIs are removed](maui/7.0/iwindowstatemanager-apis-removed.md) | ❌ | ❌ | +| Title | Type of change | +|----------------------------------------------------------------------------------------------------------------------|:--------------------------:| +| [Constructors accept base interface instead of concrete type](maui/7.0/mauiwebviewnavigationdelegate-constructor.md) | Binary incompatible | +| [Flow direction helper methods removed](maui/7.0/flow-direction-apis-removed.md) | Binary/source incompatible | +| [New UpdateBackground parameter](maui/7.0/updatebackground-parameter.md) | Binary incompatible | +| [ScrollToRequest property renamed](maui/7.0/scrolltorequest-property-rename.md) | Binary/source incompatible | +| [Some Windows APIs are removed](maui/7.0/iwindowstatemanager-apis-removed.md) | Binary/source incompatible | ## Networking -| Title | Binary compatible | Source compatible | -| - | :-: | :-: | -| [AllowRenegotiation default is false](networking/7.0/allowrenegotiation-default.md) | ❌ | ❌ | -| [Custom ping payloads on Linux](networking/7.0/ping-custom-payload-linux.md) | ❌ | ✔️ | -| [Socket.End methods don't throw ObjectDisposedException](networking/7.0/socket-end-closed-sockets.md) | ❌ | ✔️ | +| Title | Type of change | +|-------------------------------------------------------------------------------------------------------|:--------------------------:| +| [AllowRenegotiation default is false](networking/7.0/allowrenegotiation-default.md) | Binary/source incompatible | +| [Custom ping payloads on Linux](networking/7.0/ping-custom-payload-linux.md) | Binary incompatible | +| [Socket.End methods don't throw ObjectDisposedException](networking/7.0/socket-end-closed-sockets.md) | Binary incompatible | ## SDK and MSBuild -| Title | Binary compatible | Source compatible | -| - | :-: | :-: | -| [Automatic RuntimeIdentifier for certain projects](sdk/7.0/automatic-runtimeidentifier.md) | ✔️ | ❌ | -| [Automatic RuntimeIdentifier for publish only](sdk/7.0/automatic-rid-publish-only.md) | ❌ | ❌ | -| [CLI console output uses UTF-8](sdk/8.0/console-encoding.md) | ❌ | ❌ | -| [Console encoding not UTF-8 after completion](sdk/8.0/console-encoding-fix.md) | ❌ | ✔️ | -| [MSBuild serialization of custom types in .NET 7](sdk/7.0/custom-serialization.md) | ❌ | ❌ | -| [Side-by-side SDK installations](sdk/7.0/side-by-side-install.md) | ❌ | ❌ | -| [Tool manifests in root folder](sdk/7.0/manifest-search.md) | ✔️ | ✔️ | -| [Version requirements for .NET 7 SDK](sdk/7.0/vs-msbuild-version.md) | ✔️ | ✔️ | -| [dotnet test: switch `-a` to alias `--arch` instead of `--test-adapter-path`](https://github.com/dotnet/sdk/issues/21389) | ❌ | ❌ | -| [dotnet test: switch `-r` to alias `--runtime` instead of `--results-dir`](https://github.com/dotnet/sdk/issues/21952) | ❌ | ❌ | -| [`--output` option no longer is valid for solution-level commands](sdk/7.0/solution-level-output-no-longer-valid.md) | ❌ | ❌ | -| [SDK no longer calls ResolvePackageDependencies](sdk/7.0/resolvepackagedependencies.md) | ✔️ | ❌ | +| Title | Type of change | +|---------------------------------------------------------------------------------------------------------------------------|:--------------------------:| +| [Automatic RuntimeIdentifier for publish only](sdk/7.0/automatic-rid-publish-only.md) | Binary/source incompatible | +| [CLI console output uses UTF-8](sdk/8.0/console-encoding.md) | Binary/source incompatible | +| [Console encoding not UTF-8 after completion](sdk/8.0/console-encoding-fix.md) | Binary incompatible | +| [MSBuild serialization of custom types in .NET 7](sdk/7.0/custom-serialization.md) | Binary/source incompatible | +| [Side-by-side SDK installations](sdk/7.0/side-by-side-install.md) | Binary/source incompatible | +| [Tool manifests in root folder](sdk/7.0/manifest-search.md) | Behavioral change | +| [Version requirements for .NET 7 SDK](sdk/7.0/vs-msbuild-version.md) | Behavioral change | +| [dotnet test: switch `-a` to alias `--arch` instead of `--test-adapter-path`](https://github.com/dotnet/sdk/issues/21389) | Binary/source incompatible | +| [dotnet test: switch `-r` to alias `--runtime` instead of `--results-dir`](https://github.com/dotnet/sdk/issues/21952) | Binary/source incompatible | +| [`--output` option no longer is valid for solution-level commands](sdk/7.0/solution-level-output-no-longer-valid.md) | Binary/source incompatible | +| [SDK no longer calls ResolvePackageDependencies](sdk/7.0/resolvepackagedependencies.md) | Source incompatible | ## Serialization -| Title | Binary compatible | Source compatible | -| - | :-: | :-: | -| [DataContractSerializer retains sign when deserializing -0](serialization/7.0/datacontractserializer-negative-sign.md) | ❌ | ✔️ | -| [Deserialize Version type with leading or trailing whitespace](serialization/7.0/deserialize-version-with-whitespace.md) | ❌ | ✔️ | -| [JsonSerializerOptions copy constructor includes JsonSerializerContext](serialization/7.0/jsonserializeroptions-copy-constructor.md) | ❌ | ✔️ | -| [Polymorphic serialization for object types](serialization/7.0/polymorphic-serialization.md) | ❌ | ✔️ | -| [System.Text.Json source generator fallback](serialization/7.0/reflection-fallback.md) | ❌ | ✔️ | +| Title | Type of change | +|--------------------------------------------------------------------------------------------------------------------------------------|:-------------------:| +| [DataContractSerializer retains sign when deserializing -0](serialization/7.0/datacontractserializer-negative-sign.md) | Binary incompatible | +| [Deserialize Version type with leading or trailing whitespace](serialization/7.0/deserialize-version-with-whitespace.md) | Binary incompatible | +| [JsonSerializerOptions copy constructor includes JsonSerializerContext](serialization/7.0/jsonserializeroptions-copy-constructor.md) | Binary incompatible | +| [Polymorphic serialization for object types](serialization/7.0/polymorphic-serialization.md) | Binary incompatible | +| [System.Text.Json source generator fallback](serialization/7.0/reflection-fallback.md) | Binary incompatible | ## Windows Forms -| Title | Binary compatible | Source compatible | -| - | :-: | :-: | -| [Obsoletions and warnings](windows-forms/7.0/obsolete-apis.md) | ✔️ | ❌ | -| [Some APIs throw ArgumentNullException](windows-forms/7.0/apis-throw-argumentnullexception.md) | ❌ | ✔️ | +| Title | Type of change | +|------------------------------------------------------------------------------------------------|:-------------------:| +| [Obsoletions and warnings](windows-forms/7.0/obsolete-apis.md) | Source incompatible | +| [Some APIs throw ArgumentNullException](windows-forms/7.0/apis-throw-argumentnullexception.md) | Binary incompatible | ## WPF -| Title | Binary compatible | Source compatible | Backwards compatible | -| - | :-: | :-: | :-: | -| [Restored drag-and-drop operations behavior on text editors](wpf/7.0/drag-and-drop.md) | ✔️ | ✔️ | ❌ | +| Title | Type of change | +|----------------------------------------------------------------------------------------|:-----------------:| +| [Restored drag-and-drop operations behavior on text editors](wpf/7.0/drag-and-drop.md) | Behavioral change | ## XML and XSLT -| Title | Binary compatible | Source compatible | -| - | :-: | :-: | -| [XmlSecureResolver is obsolete](xml/7.0/xmlsecureresolver-obsolete.md) | ❌ | ❌ | +| Title | Type of change | +|------------------------------------------------------------------------|:--------------------------:| +| [XmlSecureResolver is obsolete](xml/7.0/xmlsecureresolver-obsolete.md) | Binary/source incompatible | ## See also diff --git a/docs/core/extensions/artificial-intelligence.md b/docs/core/extensions/artificial-intelligence.md index 87189676658d4..8ad669af2a732 100644 --- a/docs/core/extensions/artificial-intelligence.md +++ b/docs/core/extensions/artificial-intelligence.md @@ -67,13 +67,13 @@ The following subsections show specific `IChatClient` usage examples: ### Request chat completion -To request a completion, call the method. The request is composed of one or more messages, each of which is composed of one or more pieces of content. Accelerator methods exist to simplify common cases, such as constructing a request for a single piece of text content. +To request a completion, call the method. The request is composed of one or more messages, each of which is composed of one or more pieces of content. Accelerator methods exist to simplify common cases, such as constructing a request for a single piece of text content. :::code language="csharp" source="snippets/ai/ConsoleAI/Program.cs"::: -The core `IChatClient.CompleteAsync` method accepts a list of messages. This list represents the history of all messages that are part of the conversation. +The core `IChatClient.GetResponseAsync` method accepts a list of messages. This list represents the history of all messages that are part of the conversation. -:::code language="csharp" source="snippets/ai/ConsoleAI.CompleteAsyncArgs/Program.cs"::: +:::code language="csharp" source="snippets/ai/ConsoleAI.GetResponseAsyncArgs/Program.cs"::: Each message in the history is represented by a object. The `ChatMessage` class provides a property that indicates the role of the message. By default, the is used. The following roles are available: @@ -84,19 +84,17 @@ Each message in the history is represented by a property a new . There are various [types of content](xref:Microsoft.Extensions.AI.AIContent) that can be represented, such as a simple string or a more complex object that represents a multi-modal message with text, images, and audio: -- - - - -- - - ### Request chat completion with streaming -The inputs to are identical to those of `CompleteAsync`. However, rather than returning the complete response as part of a object, the method returns an where `T` is , providing a stream of updates that collectively form the single response. +The inputs to are identical to those of `GetResponseAsync`. However, rather than returning the complete response as part of a object, the method returns an where `T` is , providing a stream of updates that collectively form the single response. -:::code language="csharp" source="snippets/ai/ConsoleAI.CompleteStreamingAsync/Program.cs"::: +:::code language="csharp" source="snippets/ai/ConsoleAI.GetStreamingResponseAsync/Program.cs"::: > [!TIP] > Streaming APIs are nearly synonymous with AI user experiences. C# enables compelling scenarios with its `IAsyncEnumerable` support, allowing for a natural and efficient way to stream data. @@ -120,7 +118,7 @@ The preceding code: - Defines a function named `GetCurrentWeather` that returns a random weather forecast. - This function is decorated with a , which is used to provide a description of the function to the AI service. - Instantiates a with an and configures it to use function invocation. -- Calls `CompleteStreamingAsync` on the client, passing a prompt and a list of tools that includes a function created with . +- Calls `GetStreamingResponseAsync` on the client, passing a prompt and a list of tools that includes a function created with . - Iterates over the response, printing each update to the console. ### Cache responses @@ -141,7 +139,7 @@ The preceding example depends on the [📦 OpenTelemetry.Exporter.Console](https ### Provide options -Every call to or can optionally supply a instance containing additional parameters for the operation. The most common parameters among AI models and services show up as strongly typed properties on the type, such as . Other parameters can be supplied by name in a weakly typed manner via the dictionary. +Every call to or can optionally supply a instance containing additional parameters for the operation. The most common parameters among AI models and services show up as strongly typed properties on the type, such as . Other parameters can be supplied by name in a weakly typed manner via the dictionary. You can also specify options when building an `IChatClient` with the fluent API and chaining a call to the `ConfigureOptions` extension method. This delegating client wraps another client and invokes the supplied delegate to populate a `ChatOptions` instance for every call. For example, to ensure that the property defaults to a particular model name, you can use code like the following: @@ -165,7 +163,7 @@ The preceding example depends on the following NuGet packages: To add additional functionality, you can implement `IChatClient` directly or use the class. This class serves as a base for creating chat clients that delegate operations to another `IChatClient` instance. It simplifies chaining multiple clients, allowing calls to pass through to an underlying client. -The `DelegatingChatClient` class provides default implementations for methods like `CompleteAsync`, `CompleteStreamingAsync`, and `Dispose`, which forward calls to the inner client. You can derive from this class and override only the methods you need to enhance behavior, while delegating other calls to the base implementation. This approach helps create flexible and modular chat clients that are easy to extend and compose. +The `DelegatingChatClient` class provides default implementations for methods like `GetResponseAsync`, `GetStreamingResponseAsync`, and `Dispose`, which forward calls to the inner client. You can derive from this class and override only the methods you need to enhance behavior, while delegating other calls to the base implementation. This approach helps create flexible and modular chat clients that are easy to extend and compose. The following is an example class derived from `DelegatingChatClient` to provide rate limiting functionality, utilizing the : @@ -189,12 +187,12 @@ The consumer can then easily use this in their pipeline, for example: This example demonstrates [hosted scenario](generic-host.md), where the consumer relies on [dependency injection](dependency-injection.md) to provide the `RateLimiter` instance. The preceding extension methods demonstrate using a `Use` method on . The `ChatClientBuilder` also provides overloads that make it easier to write such delegating handlers. -- +- - - -- +- -For example, in the earlier `RateLimitingChatClient` example, the overrides of `CompleteAsync` and `CompleteStreamingAsync` only need to do work before and after delegating to the next client in the pipeline. To achieve the same thing without writing a custom class, you can use an overload of `Use` that accepts a delegate that's used for both `CompleteAsync` and `CompleteStreamingAsync`, reducing the boilerplate required: +For example, in the earlier `RateLimitingChatClient` example, the overrides of `GetResponseAsync` and `GetStreamingResponseAsync` only need to do work before and after delegating to the next client in the pipeline. To achieve the same thing without writing a custom class, you can use an overload of `Use` that accepts a delegate that's used for both `GetResponseAsync` and `GetStreamingResponseAsync`, reducing the boilerplate required: :::code language="csharp" source="snippets/ai/ConsoleAI.UseExample/Program.cs"::: @@ -202,7 +200,7 @@ The preceding overload internally uses an `AnonymousDelegatingChatClient`, which :::code language="csharp" source="snippets/ai/ConsoleAI.UseExampleAlt/Program.cs"::: -For scenarios where the developer would like to specify delegating implementations of `CompleteAsync` and `CompleteStreamingAsync` inline, and where it's important to be able to write a different implementation for each in order to handle their unique return types specially, another overload of `Use` exists that accepts a delegate for each. +For scenarios where the developer would like to specify delegating implementations of `GetResponseAsync` and `GetStreamingResponseAsync` inline, and where it's important to be able to write a different implementation for each in order to handle their unique return types specially, another overload of `Use` exists that accepts a delegate for each. ### Dependency injection diff --git a/docs/core/extensions/snippets/ai/AI.Shared/AI.Shared.csproj b/docs/core/extensions/snippets/ai/AI.Shared/AI.Shared.csproj index 0322057468166..3b7a06b2c109f 100644 --- a/docs/core/extensions/snippets/ai/AI.Shared/AI.Shared.csproj +++ b/docs/core/extensions/snippets/ai/AI.Shared/AI.Shared.csproj @@ -7,7 +7,7 @@ - + diff --git a/docs/core/extensions/snippets/ai/AI.Shared/RateLimitingChatClient.cs b/docs/core/extensions/snippets/ai/AI.Shared/RateLimitingChatClient.cs index e5d3ada7f1f60..2755e8d4cd84f 100644 --- a/docs/core/extensions/snippets/ai/AI.Shared/RateLimitingChatClient.cs +++ b/docs/core/extensions/snippets/ai/AI.Shared/RateLimitingChatClient.cs @@ -6,7 +6,7 @@ public sealed class RateLimitingChatClient( IChatClient innerClient, RateLimiter rateLimiter) : DelegatingChatClient(innerClient) { - public override async Task CompleteAsync( + public override async Task GetResponseAsync( IList chatMessages, ChatOptions? options = null, CancellationToken cancellationToken = default) @@ -19,11 +19,11 @@ public override async Task CompleteAsync( throw new InvalidOperationException("Unable to acquire lease."); } - return await base.CompleteAsync(chatMessages, options, cancellationToken) + return await base.GetResponseAsync(chatMessages, options, cancellationToken) .ConfigureAwait(false); } - public override async IAsyncEnumerable CompleteStreamingAsync( + public override async IAsyncEnumerable GetStreamingResponseAsync( IList chatMessages, ChatOptions? options = null, [EnumeratorCancellation] CancellationToken cancellationToken = default) @@ -36,7 +36,7 @@ public override async IAsyncEnumerable CompleteSt throw new InvalidOperationException("Unable to acquire lease."); } - await foreach (var update in base.CompleteStreamingAsync(chatMessages, options, cancellationToken) + await foreach (var update in base.GetStreamingResponseAsync(chatMessages, options, cancellationToken) .ConfigureAwait(false)) { yield return update; diff --git a/docs/core/extensions/snippets/ai/AI.Shared/SampleChatClient.cs b/docs/core/extensions/snippets/ai/AI.Shared/SampleChatClient.cs index 99e0fb033df9a..6eb12af104363 100644 --- a/docs/core/extensions/snippets/ai/AI.Shared/SampleChatClient.cs +++ b/docs/core/extensions/snippets/ai/AI.Shared/SampleChatClient.cs @@ -5,7 +5,7 @@ public sealed class SampleChatClient(Uri endpoint, string modelId) : IChatClient { public ChatClientMetadata Metadata { get; } = new(nameof(SampleChatClient), endpoint, modelId); - public async Task CompleteAsync( + public async Task GetResponseAsync( IList chatMessages, ChatOptions? options = null, CancellationToken cancellationToken = default) @@ -28,7 +28,7 @@ public async Task CompleteAsync( }]); } - public async IAsyncEnumerable CompleteStreamingAsync( + public async IAsyncEnumerable GetStreamingResponseAsync( IList chatMessages, ChatOptions? options = null, [EnumeratorCancellation] CancellationToken cancellationToken = default) @@ -41,7 +41,7 @@ public async IAsyncEnumerable CompleteStreamingAs await Task.Delay(100, cancellationToken); // Yield the next message in the response. - yield return new StreamingChatCompletionUpdate + yield return new ChatResponseUpdate { Role = ChatRole.Assistant, Text = word, diff --git a/docs/core/extensions/snippets/ai/ConsoleAI.CacheResponses/Program.cs b/docs/core/extensions/snippets/ai/ConsoleAI.CacheResponses/Program.cs index 51096d1df9a95..eac78def1b9e0 100644 --- a/docs/core/extensions/snippets/ai/ConsoleAI.CacheResponses/Program.cs +++ b/docs/core/extensions/snippets/ai/ConsoleAI.CacheResponses/Program.cs @@ -15,7 +15,7 @@ foreach (var prompt in prompts) { - await foreach (var update in client.CompleteStreamingAsync(prompt)) + await foreach (var update in client.GetStreamingResponseAsync(prompt)) { Console.Write(update); } diff --git a/docs/core/extensions/snippets/ai/ConsoleAI.ConsumeClientMiddleware/Program.cs b/docs/core/extensions/snippets/ai/ConsoleAI.ConsumeClientMiddleware/Program.cs index f95efffe26568..082ee7821cdc2 100644 --- a/docs/core/extensions/snippets/ai/ConsoleAI.ConsumeClientMiddleware/Program.cs +++ b/docs/core/extensions/snippets/ai/ConsoleAI.ConsumeClientMiddleware/Program.cs @@ -20,7 +20,7 @@ // Elsewhere in the app var chatClient = app.Services.GetRequiredService(); -Console.WriteLine(await chatClient.CompleteAsync("What is AI?")); +Console.WriteLine(await chatClient.GetResponseAsync("What is AI?")); app.Run(); //
diff --git a/docs/core/extensions/snippets/ai/ConsoleAI.CustomClientMiddle/ConsoleAI.CustomClientMiddle.csproj b/docs/core/extensions/snippets/ai/ConsoleAI.CustomClientMiddle/ConsoleAI.CustomClientMiddle.csproj index f4296fe4b5cda..2f67400fed6fe 100644 --- a/docs/core/extensions/snippets/ai/ConsoleAI.CustomClientMiddle/ConsoleAI.CustomClientMiddle.csproj +++ b/docs/core/extensions/snippets/ai/ConsoleAI.CustomClientMiddle/ConsoleAI.CustomClientMiddle.csproj @@ -8,7 +8,7 @@ - + diff --git a/docs/core/extensions/snippets/ai/ConsoleAI.CustomClientMiddle/Program.cs b/docs/core/extensions/snippets/ai/ConsoleAI.CustomClientMiddle/Program.cs index dd69572c6c7a2..31b73e10c8f53 100644 --- a/docs/core/extensions/snippets/ai/ConsoleAI.CustomClientMiddle/Program.cs +++ b/docs/core/extensions/snippets/ai/ConsoleAI.CustomClientMiddle/Program.cs @@ -9,4 +9,4 @@ QueueLimit = int.MaxValue })); -await client.CompleteAsync("What color is the sky?"); +await client.GetResponseAsync("What color is the sky?"); diff --git a/docs/core/extensions/snippets/ai/ConsoleAI.DependencyInjection/Program.cs b/docs/core/extensions/snippets/ai/ConsoleAI.DependencyInjection/Program.cs index 930b0b036c74e..aa1ad1cfc4358 100644 --- a/docs/core/extensions/snippets/ai/ConsoleAI.DependencyInjection/Program.cs +++ b/docs/core/extensions/snippets/ai/ConsoleAI.DependencyInjection/Program.cs @@ -15,6 +15,6 @@ // Elsewhere in the app var chatClient = app.Services.GetRequiredService(); -Console.WriteLine(await chatClient.CompleteAsync("What is AI?")); +Console.WriteLine(await chatClient.GetResponseAsync("What is AI?")); app.Run(); diff --git a/docs/core/extensions/snippets/ai/ConsoleAI.FunctionalityPipelines/ConsoleAI.FunctionalityPipelines.csproj b/docs/core/extensions/snippets/ai/ConsoleAI.FunctionalityPipelines/ConsoleAI.FunctionalityPipelines.csproj index a48697c3b26e9..a2d29c0295a8d 100644 --- a/docs/core/extensions/snippets/ai/ConsoleAI.FunctionalityPipelines/ConsoleAI.FunctionalityPipelines.csproj +++ b/docs/core/extensions/snippets/ai/ConsoleAI.FunctionalityPipelines/ConsoleAI.FunctionalityPipelines.csproj @@ -9,7 +9,7 @@ - + diff --git a/docs/core/extensions/snippets/ai/ConsoleAI.FunctionalityPipelines/Program.cs b/docs/core/extensions/snippets/ai/ConsoleAI.FunctionalityPipelines/Program.cs index 16f563b3689a3..392c16c4d6e60 100644 --- a/docs/core/extensions/snippets/ai/ConsoleAI.FunctionalityPipelines/Program.cs +++ b/docs/core/extensions/snippets/ai/ConsoleAI.FunctionalityPipelines/Program.cs @@ -42,5 +42,5 @@ new ChatMessage(ChatRole.User, "Do I need an umbrella?") ]; - Console.WriteLine(await client.CompleteAsync(history, options)); + Console.WriteLine(await client.GetResponseAsync(history, options)); } diff --git a/docs/core/extensions/snippets/ai/ConsoleAI.CompleteAsyncArgs/ConsoleAI.CompleteAsyncArgs.csproj b/docs/core/extensions/snippets/ai/ConsoleAI.GetResponseAsyncArgs/ConsoleAI.GetResponseAsyncArgs.csproj similarity index 100% rename from docs/core/extensions/snippets/ai/ConsoleAI.CompleteAsyncArgs/ConsoleAI.CompleteAsyncArgs.csproj rename to docs/core/extensions/snippets/ai/ConsoleAI.GetResponseAsyncArgs/ConsoleAI.GetResponseAsyncArgs.csproj diff --git a/docs/core/extensions/snippets/ai/ConsoleAI.CompleteAsyncArgs/Program.cs b/docs/core/extensions/snippets/ai/ConsoleAI.GetResponseAsyncArgs/Program.cs similarity index 83% rename from docs/core/extensions/snippets/ai/ConsoleAI.CompleteAsyncArgs/Program.cs rename to docs/core/extensions/snippets/ai/ConsoleAI.GetResponseAsyncArgs/Program.cs index eda37fef75fbf..b33fe5f1a3d80 100644 --- a/docs/core/extensions/snippets/ai/ConsoleAI.CompleteAsyncArgs/Program.cs +++ b/docs/core/extensions/snippets/ai/ConsoleAI.GetResponseAsyncArgs/Program.cs @@ -3,7 +3,7 @@ IChatClient client = new SampleChatClient( new Uri("http://coolsite.ai"), "target-ai-model"); -Console.WriteLine(await client.CompleteAsync( +Console.WriteLine(await client.GetResponseAsync( [ new(ChatRole.System, "You are a helpful AI assistant"), new(ChatRole.User, "What is AI?"), diff --git a/docs/core/extensions/snippets/ai/ConsoleAI.CompleteStreamingAsync/ConsoleAI.CompleteStreamingAsync.csproj b/docs/core/extensions/snippets/ai/ConsoleAI.GetStreamingResponseAsync/ConsoleAI.GetStreamingResponseAsync.csproj similarity index 100% rename from docs/core/extensions/snippets/ai/ConsoleAI.CompleteStreamingAsync/ConsoleAI.CompleteStreamingAsync.csproj rename to docs/core/extensions/snippets/ai/ConsoleAI.GetStreamingResponseAsync/ConsoleAI.GetStreamingResponseAsync.csproj diff --git a/docs/core/extensions/snippets/ai/ConsoleAI.CompleteStreamingAsync/Program.cs b/docs/core/extensions/snippets/ai/ConsoleAI.GetStreamingResponseAsync/Program.cs similarity index 67% rename from docs/core/extensions/snippets/ai/ConsoleAI.CompleteStreamingAsync/Program.cs rename to docs/core/extensions/snippets/ai/ConsoleAI.GetStreamingResponseAsync/Program.cs index a5e32ce3438a0..56a5fb5678a4d 100644 --- a/docs/core/extensions/snippets/ai/ConsoleAI.CompleteStreamingAsync/Program.cs +++ b/docs/core/extensions/snippets/ai/ConsoleAI.GetStreamingResponseAsync/Program.cs @@ -3,7 +3,7 @@ IChatClient client = new SampleChatClient( new Uri("http://coolsite.ai"), "target-ai-model"); -await foreach (var update in client.CompleteStreamingAsync("What is AI?")) +await foreach (var update in client.GetStreamingResponseAsync("What is AI?")) { Console.Write(update); } diff --git a/docs/core/extensions/snippets/ai/ConsoleAI.ProvideOptions/ConsoleAI.ProvideOptions.csproj b/docs/core/extensions/snippets/ai/ConsoleAI.ProvideOptions/ConsoleAI.ProvideOptions.csproj index 52b8ab4531c7f..dd7878962bbb6 100644 --- a/docs/core/extensions/snippets/ai/ConsoleAI.ProvideOptions/ConsoleAI.ProvideOptions.csproj +++ b/docs/core/extensions/snippets/ai/ConsoleAI.ProvideOptions/ConsoleAI.ProvideOptions.csproj @@ -8,7 +8,7 @@ - + diff --git a/docs/core/extensions/snippets/ai/ConsoleAI.ProvideOptions/Program.cs b/docs/core/extensions/snippets/ai/ConsoleAI.ProvideOptions/Program.cs index c6ce0bfb7010e..77098afb4b8ba 100644 --- a/docs/core/extensions/snippets/ai/ConsoleAI.ProvideOptions/Program.cs +++ b/docs/core/extensions/snippets/ai/ConsoleAI.ProvideOptions/Program.cs @@ -6,8 +6,8 @@ .Build(); // will request "phi3" -Console.WriteLine(await client.CompleteAsync("What is AI?")); +Console.WriteLine(await client.GetResponseAsync("What is AI?")); // will request "llama3.1" -Console.WriteLine(await client.CompleteAsync( +Console.WriteLine(await client.GetResponseAsync( "What is AI?", new() { ModelId = "llama3.1" })); diff --git a/docs/core/extensions/snippets/ai/ConsoleAI.ToolCalling/ConsoleAI.ToolCalling.csproj b/docs/core/extensions/snippets/ai/ConsoleAI.ToolCalling/ConsoleAI.ToolCalling.csproj index 52b8ab4531c7f..dd7878962bbb6 100644 --- a/docs/core/extensions/snippets/ai/ConsoleAI.ToolCalling/ConsoleAI.ToolCalling.csproj +++ b/docs/core/extensions/snippets/ai/ConsoleAI.ToolCalling/ConsoleAI.ToolCalling.csproj @@ -8,7 +8,7 @@ - + diff --git a/docs/core/extensions/snippets/ai/ConsoleAI.ToolCalling/Program.cs b/docs/core/extensions/snippets/ai/ConsoleAI.ToolCalling/Program.cs index ff8ef0c2ba7c8..a3d9c6247da96 100644 --- a/docs/core/extensions/snippets/ai/ConsoleAI.ToolCalling/Program.cs +++ b/docs/core/extensions/snippets/ai/ConsoleAI.ToolCalling/Program.cs @@ -11,7 +11,7 @@ string GetCurrentWeather() => Random.Shared.NextDouble() > 0.5 .UseFunctionInvocation() .Build(); -var response = client.CompleteStreamingAsync( +var response = client.GetStreamingResponseAsync( "Should I wear a rain coat?", new() { Tools = [AIFunctionFactory.Create(GetCurrentWeather)] }); diff --git a/docs/core/extensions/snippets/ai/ConsoleAI.UseTelemetry/Program.cs b/docs/core/extensions/snippets/ai/ConsoleAI.UseTelemetry/Program.cs index d4c5e2c28e723..beee01a4777a1 100644 --- a/docs/core/extensions/snippets/ai/ConsoleAI.UseTelemetry/Program.cs +++ b/docs/core/extensions/snippets/ai/ConsoleAI.UseTelemetry/Program.cs @@ -17,4 +17,4 @@ configure: static c => c.EnableSensitiveData = true) .Build(); -Console.WriteLine((await client.CompleteAsync("What is AI?")).Message); +Console.WriteLine((await client.GetResponseAsync("What is AI?")).Message); diff --git a/docs/core/extensions/snippets/ai/ConsoleAI/ConsoleAI.csproj b/docs/core/extensions/snippets/ai/ConsoleAI/ConsoleAI.csproj index bcec98d0ad009..05947b9ec5925 100644 --- a/docs/core/extensions/snippets/ai/ConsoleAI/ConsoleAI.csproj +++ b/docs/core/extensions/snippets/ai/ConsoleAI/ConsoleAI.csproj @@ -8,7 +8,7 @@ - + diff --git a/docs/core/extensions/snippets/ai/ConsoleAI/Program.cs b/docs/core/extensions/snippets/ai/ConsoleAI/Program.cs index 258a6d41ac681..42a1ef7b164e5 100644 --- a/docs/core/extensions/snippets/ai/ConsoleAI/Program.cs +++ b/docs/core/extensions/snippets/ai/ConsoleAI/Program.cs @@ -3,6 +3,6 @@ IChatClient client = new SampleChatClient( new Uri("http://coolsite.ai"), "target-ai-model"); -var response = await client.CompleteAsync("What is AI?"); +var response = await client.GetResponseAsync("What is AI?"); Console.WriteLine(response.Message); diff --git a/docs/core/testing/mstest-analyzers/mstest0001.md b/docs/core/testing/mstest-analyzers/mstest0001.md index 54df7eb6b1f8d..13622dd37ce9f 100644 --- a/docs/core/testing/mstest-analyzers/mstest0001.md +++ b/docs/core/testing/mstest-analyzers/mstest0001.md @@ -47,12 +47,15 @@ Do not suppress a warning from this rule. Many libraries can benefit from a mass ## Suppress a warning -Violations to this rule cannot be suppressed inline. +Because this rule is reported at the compilation level and not in a *.cs* or *.vb* source file, you can't suppress violations to this rule inline or via an `.editorconfig` file. -To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../../../fundamentals/code-analysis/configuration-files.md). +To disable the rule for a project, add `$(NoWarn);MSTEST0001` to the project file or `Directory.Build.props` file. + +To control the severity of this rule, you can do it only via a `.globalconfig` file. For more information, see [Configuration files](../../../fundamentals/code-analysis/configuration-files.md#global-analyzerconfig). ```ini -[*.{cs,vb}] +is_global = true + dotnet_diagnostic.MSTEST0001.severity = none ``` diff --git a/docs/csharp/language-reference/compiler-messages/nullable-warnings.md b/docs/csharp/language-reference/compiler-messages/nullable-warnings.md index 7e8251e19edb9..ad7dbb028f669 100644 --- a/docs/csharp/language-reference/compiler-messages/nullable-warnings.md +++ b/docs/csharp/language-reference/compiler-messages/nullable-warnings.md @@ -3,6 +3,7 @@ title: Resolve nullable warnings description: Several compiler warnings indicate code that isn't null-safe. Learn how to address those warnings by making your code more resilient. f1_keywords: - "CS8597" # WRN_ThrowPossibleNull: Thrown value may be null. + - "CS8598" - "CS8600" # WRN_ConvertingNullableToNonNullable: Converting null literal or possible null value to non-nullable type. - "CS8601" # WRN_NullReferenceAssignment: Possible null reference assignment. - "CS8602" # WRN_NullReferenceReceiver: Dereference of a possibly null reference. @@ -25,12 +26,18 @@ f1_keywords: - "CS8620" # WRN_NullabilityMismatchInArgument: Argument of type '{0}' cannot be used for parameter '{2}' of type '{1}' in '{3}' due to differences in the nullability of reference types. - "CS8621" # WRN_NullabilityMismatchInReturnTypeOfTargetDelegate: Nullability of reference types in return type of '{0}' doesn't match the target delegate '{1}' (possibly because of nullability attributes). - "CS8622" # WRN_NullabilityMismatchInParameterTypeOfTargetDelegate: Nullability of reference types in type of parameter '{0}' of '{1}' doesn't match the target delegate '{2}' (possibly because of nullability attributes). + - "CS8623" - "CS8624" # WRN_NullabilityMismatchInArgumentForOutput: Argument of type '{0}' cannot be used as an output of type '{1}' for parameter '{2}' in '{3}' due to differences in the nullability of reference types. - "CS8625" # WRN_NullAsNonNullable: Cannot convert null literal to non-nullable reference type. + - "CS8628" - "CS8629" # WRN_NullableValueTypeMayBeNull: Nullable value type may be null. - "CS8631" # WRN_NullabilityMismatchInTypeParameterConstraint: The type '{3}' cannot be used as type parameter '{2}' in the generic type or method '{0}'. Nullability of type argument '{3}' doesn't match constraint type '{1}'. + - "CS8632" - "CS8633" # WRN_NullabilityMismatchInConstraintsOnImplicitImplementation: Nullability in constraints for type parameter '{0}' of method '{1}' doesn't match the constraints for type parameter '{2}' of interface method '{3}'. Consider using an explicit interface implementation instead. - "CS8634" # WRN_NullabilityMismatchInTypeParameterReferenceTypeConstraint: The type '{2}' cannot be used as type parameter '{1}' in the generic type or method '{0}'. Nullability of type argument '{2}' doesn't match 'class' constraint. + - "CS8636" + - "CS8637" + - "CS8639" - "CS8643" # WRN_NullabilityMismatchInExplicitlyImplementedInterface: Nullability of reference types in explicit interface specifier doesn't match interface implemented by the type. - "CS8644" # WRN_NullabilityMismatchInInterfaceImplementedByBase: '{0}' does not implement interface member '{1}'. Nullability of reference types in interface implemented by the base type doesn't match. - "CS8645" # WRN_DuplicateInterfaceWithNullabilityMismatchInBaseList: '{0}' is already listed in the interface list on type '{1}' with different nullability of reference types. @@ -57,6 +64,7 @@ f1_keywords: - "CS8847" # WRN_SwitchExpressionNotExhaustiveForNullWithWhen: The switch expression does not handle some null inputs (it is not exhaustive). For example, the pattern '{0}' is not covered. However, a pattern with a 'when' clause might successfully match this value. helpviewer_keywords: - "CS8597" + - "CS8598" - "CS8600" - "CS8601" - "CS8602" @@ -79,12 +87,18 @@ helpviewer_keywords: - "CS8620" - "CS8621" - "CS8622" + - "CS8623" - "CS8624" - "CS8625" + - "CS8628" - "CS8629" - "CS8631" + - "CS8632" - "CS8633" - "CS8634" + - "CS8636" + - "CS8637" + - "CS8639" - "CS8643" - "CS8644" - "CS8645" @@ -109,13 +123,14 @@ helpviewer_keywords: - "CS8824" - "CS8825" - "CS8847" -ms.date: 06/30/2022 +ms.date: 02/20/2025 --- # Resolve nullable warnings This article covers the following compiler warnings: - [**CS8597**](#possible-null-assigned-to-a-nonnullable-reference) - *Thrown value may be null.* +- [**CS8598**](#incorrect-annotation-syntax) - *The suppression operator is not allowed in this context* - [**CS8600**](#possible-null-assigned-to-a-nonnullable-reference) - *Converting null literal or possible null value to non-nullable type.* - [**CS8601**](#possible-null-assigned-to-a-nonnullable-reference) - *Possible null reference assignment.* - [**CS8602**](#possible-dereference-of-null) - *Dereference of a possibly null reference.* @@ -138,12 +153,18 @@ This article covers the following compiler warnings: - [**CS8620**](#mismatch-in-nullability-declaration) - *Argument cannot be used for parameter due to differences in the nullability of reference types.* - [**CS8621**](#mismatch-in-nullability-declaration) - *Nullability of reference types in return type doesn't match the target delegate (possibly because of nullability attributes).* - [**CS8622**](#mismatch-in-nullability-declaration) - *Nullability of reference types in type of parameter doesn't match the target delegate (possibly because of nullability attributes).* +- [**CS8623**](#incorrect-annotation-syntax) - *Explicit application of `System.Runtime.CompilerServices.NullableAttribute` is not allowed.* - [**CS8624**](#mismatch-in-nullability-declaration) - *Argument cannot be used as an output due to differences in the nullability of reference types.* - [**CS8625**](#possible-null-assigned-to-a-nonnullable-reference) - *Cannot convert null literal to non-nullable reference type.* +- [**CS8628**](#incorrect-annotation-syntax) - *Cannot use a nullable reference type in object creation.* - [**CS8629**](#possible-null-assigned-to-a-nonnullable-reference) - *Nullable value type may be null.* - [**CS8631**](#mismatch-in-nullability-declaration) - *The type cannot be used as type parameter in the generic type or method. Nullability of type argument doesn't match constraint type.* +- [**CS8632**](#configure-nullable-context) - *The annotation for nullable reference types should only be used in code within a `#nullable` annotations context.* - [**CS8633**](#mismatch-in-nullability-declaration) - *Nullability in constraints for type parameter of method doesn't match the constraints for type parameter of interface method. Consider using an explicit interface implementation instead.* - [**CS8634**](#mismatch-in-nullability-declaration) - *The type cannot be used as type parameter in the generic type or method. Nullability of type argument doesn't match 'class' constraint.* +- [**CS8636**](#configure-nullable-context) - *Invalid option for `/nullable`; must be `disable`, `enable`, `warnings` or `annotations`* +- [**CS8637**](#configure-nullable-context) - *Expected `enable`, `disable`, or `restore`* +- [**CS8639**](#incorrect-annotation-syntax) - *The typeof operator cannot be used on a nullable reference type* - [**CS8643**](#mismatch-in-nullability-declaration) - *Nullability of reference types in explicit interface specifier doesn't match interface implemented by the type.* - [**CS8644**](#mismatch-in-nullability-declaration) - *Type does not implement interface member. Nullability of reference types in interface implemented by the base type doesn't match.* - [**CS8645**](#mismatch-in-nullability-declaration) - *Member is already listed in the interface list on type with different nullability of reference types.* @@ -169,15 +190,53 @@ This article covers the following compiler warnings: - [**CS8825**](#code-doesnt-match-attribute-declaration) - *Return value must be non-null because parameter is non-null.* - [**CS8847**](#exhaustive-switch-expression) - *The switch expression does not handle some null inputs (it is not exhaustive). However, a pattern with a 'when' clause might successfully match this value.* -The purpose of nullable warnings is to minimize the chance that your application throws a when run. To achieve this goal, the compiler uses static analysis and issues warnings when your code has constructs that may lead to null reference exceptions. You provide the compiler with information for its static analysis by applying type annotations and attributes. These annotations and attributes describe the nullability of arguments, parameters, and members of your types. In this article, you'll learn different techniques to address the nullable warnings the compiler generates from its static analysis. The techniques described here are for general C# code. Learn to work with nullable reference types and Entity Framework core in [Working with nullable reference types](/ef/core/miscellaneous/nullable-reference-types). +The purpose of nullable warnings is to minimize the chance that your application throws a when run. To achieve this goal, the compiler uses static analysis and issues warnings when your code has constructs that might lead to null reference exceptions. You provide the compiler with information for its static analysis by applying type annotations and attributes. These annotations and attributes describe the nullability of arguments, parameters, and members of your types. In this article, you learn different techniques to address the nullable warnings the compiler generates from its static analysis. The techniques described here are for general C# code. Learn to work with nullable reference types and Entity Framework core in [Working with nullable reference types](/ef/core/miscellaneous/nullable-reference-types). -You'll address almost all warnings using one of four techniques: +You address almost all warnings using one of five techniques: +- Configuring the nullable context. - Adding necessary null checks. -- Adding `?` or `!` nullable annotations. +- Adding or removing `?` or `!` nullable annotations. - Adding attributes that describe null semantics. - Initializing variables correctly. +If you're new to using nullable reference types, the [overview of nullable reference types](../../nullable-references.md) provides a background on what nullable reference types solve and how they work to provide warnings to possible mistakes in your code. You can also check the guidance on [migrating to nullable reference types](../../nullable-migration-strategies.md) to learn more about enabling nullable reference types in an existing project. + +## Configure nullable context + +The following warnings indicate that you haven't set the nullable context correctly: + +- **CS8632** - *The annotation for nullable reference types should only be used in code within a `#nullable` annotations context.* +- **CS8636** - *Invalid option for `/nullable`; must be `disable`, `enable`, `warnings` or `annotations`* +- **CS8637** - *Expected `enable`, `disable`, or `restore`* + +Nullable reference types, including the operators `?` and `!` are allowed only when the nullable context is set to `enable` or `annotations`. You can set the nullable annotation using the `Nullable` [compiler option](../compiler-options/language.md#nullable) in your project file, or using the [`#nullable`](../preprocessor-directives.md#nullable-context) pragma in your source code. + +## Incorrect annotation syntax + +These errors and warnings indicate that usage of the `!` or `?` annotation is incorrect. + +- **CS8598** - *The suppression operator is not allowed in this context* +- **CS8623** - *Explicit application of `System.Runtime.CompilerServices.NullableAttribute` is not allowed.* +- **CS8628** - *Cannot use a nullable reference type in object creation.* +- **CS8639** - *The typeof operator cannot be used on a nullable reference type* + +The `?` annotation in a declaration indicates that the variable might be null. It doesn't indicate a different runtime type. Both the following declarations are the same runtime type: + +```csharp +string s1 = "a string"; +string? s2 = "another string"; +``` + +The `?` is a hint to the compiler on the expectation for null values. + +The `!` annotation on an expression indicates that you know the expression is safe and should be assumed to be not null. + +- You must use these annotations, not the in your code. +- Because the `?` is an annotation, not a type, you can't use it with [`typeof`](../operators/type-testing-and-cast.md#typeof-operator), or [`new`](../operators/new-operator.md) expressions. +- The `!` operator can't be applied to a variable expression or a method group. +- The `!` operator can't be applied to the left of a member access operator, such as `obj.Field!.Method()`. + ## Possible dereference of null This set of warnings alerts you that you're dereferencing a variable whose *null-state* is *maybe-null*. These warnings are: @@ -189,11 +248,11 @@ The following code demonstrates one example of each of the preceding warnings: :::code language="csharp" source="snippets/null-warnings/NullWarnings.cs" id="PossibleNullDereference"::: -In the example above, the warning is because the `Container`, `c`, may have a null value for the `States` property. Assigning new states to a collection that might be null causes the warning. +In the preceding example, the warning is because the `Container`, `c`, might have a null value for the `States` property. Assigning new states to a collection that might be null causes the warning. -To remove these warnings, you need to add code to change that variable's *null-state* to *not-null* before dereferencing it. The collection initializer warning may be harder to spot. The compiler detects that the collection *maybe-null* when the initializer adds elements to it. +To remove these warnings, you need to add code to change that variable's *null-state* to *not-null* before dereferencing it. The collection initializer warning can be harder to spot. The compiler detects that the collection *maybe-null* when the initializer adds elements to it. -In many instances, you can fix these warnings by checking that a variable isn't null before dereferencing it. Consider the following that adds a null check before dereferencing the `message` parameter: +In many instances, you can fix these warnings by checking that a variable isn't null before dereferencing it. Consider the following example that adds a null check before dereferencing the `message` parameter: :::code language="csharp" source="snippets/null-warnings/Program.cs" id="ProvideNullCheck"::: @@ -201,11 +260,11 @@ The following example initializes the backing storage for the `States` and remov :::code language="csharp" source="snippets/null-warnings/NullWarnings.cs" id="SnippetUpdatedDefinition"::: -Other instances when you get these warnings may be false positive. You may have a private utility method that tests for null. The compiler doesn't know that the method provides a null check. Consider the following example that uses a private utility method, `IsNotNull`: +Other instances when you get these warnings might be false positive. You might have a private utility method that tests for null. The compiler doesn't know that the method provides a null check. Consider the following example that uses a private utility method, `IsNotNull`: :::code language="csharp" source="./snippets/null-warnings/NullTests.cs" id="PrivateNullTest"::: -The compiler warns that you may be dereferencing null when you write the property `message.Length` because its static analysis determines that `message` may be `null`. You may know that `IsNotNull` provides a null check, and when it returns `true`, the *null-state* of `message` should be *not-null*. You must tell the compiler those facts. One way is to use the null forgiving operator, `!`. You can change the `WriteLine` statement to match the following code: +The compiler warns that you might be dereferencing null when you write the property `message.Length` because its static analysis determines that `message` might be `null`. You know that `IsNotNull` provides a null check, and when it returns `true`, the *null-state* of `message` should be *not-null*. You must tell the compiler those facts. One way is to use the null forgiving operator, `!`. You can change the `WriteLine` statement to match the following code: ```csharp Console.WriteLine(message!.Length); @@ -224,7 +283,7 @@ Fixing a warning for dereferencing a *maybe-null* variable involves one of three - Add a missing null check. - Add null analysis attributes on APIs to affect the compiler's *null-state* static analysis. These attributes inform the compiler when a return value or argument should be *maybe-null* or *not-null* after calling the method. -- Apply the null forgiving operator `!` to the expression to force the state to *not-null*. +- Apply the null forgiving operator `!` to the expression which forces the state to *not-null*. ## Possible null assigned to a nonnullable reference @@ -245,13 +304,13 @@ The compiler emits these warnings when you attempt to assign an expression that The different warnings indicate provide details about the code, such as assignment, unboxing assignment, return statements, arguments to methods, and throw expressions. -You can take one of three actions to address these warnings. One is to add the `?` annotation to make the variable a nullable reference type. That change may cause other warnings. Changing a variable from a non-nullable reference to a nullable reference changes its default *null-state* from *not-null* to *maybe-null*. The compiler's static analysis may find instances where you dereference a variable that is *maybe-null*. +You can take one of three actions to address these warnings. One is to add the `?` annotation to make the variable a nullable reference type. That change can cause other warnings. Changing a variable from a non-nullable reference to a nullable reference changes its default *null-state* from *not-null* to *maybe-null*. The compiler's static analysis finds instances where you dereference a variable that is *maybe-null*. The other actions instruct the compiler that the right-hand-side of the assignment is *not-null*. The expression on the right-hand-side could be null-checked before assignment, as shown in the following example: :::code language="csharp" source="./snippets/null-warnings/Program.cs" id="NullGuard"::: -The previous examples demonstrate assignment of the return value of a method. You may annotate the method (or property) to indicate when a method returns a not-null value. The often specifies that a return value is *not-null* when an input argument is *not-null*. Another alternative is to add the null forgiving operator, `!` to the right-hand side: +The previous examples demonstrate assignment of the return value of a method. You annotate the method (or property) to indicate when a method returns a not-null value. The often specifies that a return value is *not-null* when an input argument is *not-null*. Another alternative is to add the null forgiving operator, `!` to the right-hand side: ```csharp string msg = TryGetMessage(42)!; @@ -259,7 +318,7 @@ string msg = TryGetMessage(42)!; Fixing a warning for assigning a *maybe-null* expression to a *not-null* variable involves one of four techniques: -- Change the left side of the assignment to a nullable type. This action may introduce new warnings when you dereference that variable. +- Change the left side of the assignment to a nullable type. This action can introduce new warnings when you dereference that variable. - Provide a null-check before the assignment. - Annotate the API that produces the right-hand side of the assignment. - Add the null forgiving operator to the right-hand side of the assignment. @@ -275,7 +334,7 @@ Consider the following class as an example: :::code language="csharp" source="./snippets/null-warnings/PersonExamples.cs" id="PersonExample"::: -Neither `FirstName` nor `LastName` are guaranteed initialized. If this code is new, consider changing the public interface. The above example could be updated as follows: +Neither `FirstName` nor `LastName` are guaranteed initialized. If this code is new, consider changing the public interface. The preceding example could be updated as follows: :::code language="csharp" source="./snippets/null-warnings/PersonExamples.cs" id="WithConstructor"::: @@ -283,11 +342,11 @@ If you require creating a `Person` object before setting the name, you can initi :::code language="csharp" source="./snippets/null-warnings/PersonExamples.cs" id="Initializer"::: -Another alternative may be to change those members to nullable reference types. The `Person` class could be defined as follows if `null` should be allowed for the name: +Another alternative is to change those members to nullable reference types. The `Person` class could be defined as follows if `null` should be allowed for the name: :::code language="csharp" source="./snippets/null-warnings/PersonExamples.cs" id="NullableMember"::: -Existing code may require other changes to inform the compiler about the null semantics for those members. You may have created multiple constructors, and your class may have a private helper method that initializes one or more members. You can move the initialization code into a single constructor and ensure all constructors call the one with the common initialization code. Or, you can use the and attributes. These attributes inform the compiler that a member is *not-null* after the method has been called. The following code shows an example of each. The `Person` class uses a common constructor called by all other constructors. The `Student` class has a helper method annotated with the attribute: +Existing code sometimes require other changes to inform the compiler about the null semantics for those members. It might have multiple constructors, and your class has a private helper method that initializes one or more members. You can move the initialization code into a single constructor and ensure all constructors call the one with the common initialization code. Or, you can use the and attributes. These attributes inform the compiler that a member is *not-null* after the method returns. The following code shows an example of each. The `Person` class uses a common constructor called by all other constructors. The `Student` class has a helper method annotated with the attribute: :::code language="csharp" source="./snippets/null-warnings/PersonExamples.cs" id="ConstructorChainingAndMemberNotNull"::: @@ -345,13 +404,13 @@ The following code demonstrates *CS8764*: The preceding example shows a `virtual` method in a base class and an `override` with different nullability. The base class returns a non-nullable string, but the derived class returns a nullable string. If the `string` and `string?` are reversed, it would be allowed because the derived class is more restrictive. Similarly, parameter declarations should match. Parameters in the override method can allow null even when the base class doesn't. -Other situations can generate these warnings. You may have a mismatch in an interface method declaration and the implementation of that method. Or a delegate type and the expression for that delegate may differ. A type parameter and the type argument may differ in nullability. +Other situations can generate these warnings. You have a mismatch in an interface method declaration and the implementation of that method. Or a delegate type and the expression for that delegate differ. A type parameter and the type argument differ in nullability. To fix these warnings, update the appropriate declaration. ## Code doesn't match attribute declaration -The preceding sections have discussed how you can use [Attributes for nullable static analysis](../attributes/nullable-analysis.md) to inform the compiler about the null semantics of your code. The compiler warns you if the code doesn't adhere to the promises of that attribute: +The preceding sections discussed how you can use [Attributes for nullable static analysis](../attributes/nullable-analysis.md) to inform the compiler about the null semantics of your code. The compiler warns you if the code doesn't adhere to the promises of that attribute: - **CS8607** - *A possible null value may not be used for a type marked with `[NotNull]` or `[DisallowNull]`* - **CS8763** - *A method marked `[DoesNotReturn]` should not return.* @@ -369,7 +428,7 @@ Consider the following method: The compiler produces a warning because the `message` parameter is assigned `null` *and* the method returns `true`. The `NotNullWhen` attribute indicates that shouldn't happen. -To address these warnings, update your code so it matches the expectations of the attributes you've applied. You may change the attributes, or the algorithm. +To address these warnings, update your code so it matches the expectations of the attributes applied. You can change the attributes, or the algorithm. ## Exhaustive switch expression @@ -382,4 +441,4 @@ The following example code demonstrates this condition: :::code language="csharp" source="snippets/null-warnings/NullWarnings.cs" id="NullExhaustiveSwitch"::: -The input expression is a `string`, not a `string?`. The compiler still generates this warning. The `{ }` pattern handles all non-null values, but doesn't match `null`. To address these errors, you can either add an explicit `null` case, or replace the `{ }` with the `_` (discard) pattern. The discard pattern matches null as well as any other value. +The input expression is a `string`, not a `string?`. The compiler still generates this warning. The `{ }` pattern handles all non-null values, but doesn't match `null`. To address these errors, you can either add an explicit `null` case, or replace the `{ }` with the `_` (discard) pattern. The discard pattern matches null in addition to any other value. diff --git a/docs/csharp/language-reference/toc.yml b/docs/csharp/language-reference/toc.yml index fbbd94d62a0f1..4de8acc791d26 100644 --- a/docs/csharp/language-reference/toc.yml +++ b/docs/csharp/language-reference/toc.yml @@ -516,10 +516,10 @@ items: - name: Nullable warnings href: ./compiler-messages/nullable-warnings.md displayName: > - CS8597, CS8600, CS8601, CS8602, CS8604, CS8605, CS8607, CS8608, CS8609, CS8610, CS8611, CS8612, CS8613, CS8614, CS8615, - CS8616, CS8617, CS8618, CS8619, CS8620, CS8621, CS8622, CS8624, CS8625, CS8629, CS8631, CS8634, CS8655, CS8633, CS8643, - CS8644, CS8645, CS8762, CS8763, CS8764, CS8765, CS8766, CS8667, CS8768, CS8670, CS8714, CS8767, CS8769, CS8770, CS8774, - CS8776, CS8775, CS8777, CS8819, CS8824, CS8825, CS8847 + CS8597, CS8598, CS8600, CS8601, CS8602, CS8604, CS8605, CS8607, CS8608, CS8609, CS8610, CS8611, CS8612, CS8613, CS8614, + CS8615, CS8616, CS8617, CS8618, CS8619, CS8620, CS8621, CS8622, CS8623, CS8624, CS8625, CS8628, CS8629, CS8631, CS8632, + CS8634, CS8636, CS8637, CS8639, CS8655, CS8633, CS8643, CS8644, CS8645, CS8762, CS8763, CS8764, CS8765, CS8766, CS8667, + CS8768, CS8670, CS8714, CS8767, CS8769, CS8770, CS8774, CS8776, CS8775, CS8777, CS8819, CS8824, CS8825, CS8847 - name: Pattern matching warnings href: ./compiler-messages/pattern-matching-warnings.md displayName: CS8509, CS9134, CS9135 diff --git a/docs/csharp/language-reference/xmldoc/index.md b/docs/csharp/language-reference/xmldoc/index.md index 5d9fab635f364..bc83132f797ee 100644 --- a/docs/csharp/language-reference/xmldoc/index.md +++ b/docs/csharp/language-reference/xmldoc/index.md @@ -25,7 +25,7 @@ This process provides many advantages for you to add API documentation in your c Tools like Visual Studio provide IntelliSense for many common XML elements used in documentation comments. -This article covers these articles: +This article covers these topics: - Documentation comments and XML file generation - Tags validated by the C# compiler and Visual Studio @@ -102,7 +102,7 @@ The use of XML doc comments requires delimiters that indicate where a documentat To refer to XML elements (for example, your function processes specific XML elements that you want to describe in an XML documentation comment), you can use the standard quoting mechanism (`<` and `>`). To refer to generic identifiers in code reference (`cref`) elements, you can use either the escape characters (for example, `cref="List<T>"`) or braces (`cref="List{T}"`). As a special case, the compiler parses the braces as angle brackets to make the documentation comment less cumbersome to the author when referring to generic identifiers. > [!NOTE] -> If you write comments using the single line XML comment delimiter, `///`, but don't include any tags, the compiler adds the text of those comments to the XML output file. However, the output doesn't include XML elements such as ``. Most tools that consume XML comments (including Visual Studio intellisense) don't read these comments. +> If you write comments using the single line XML comment delimiter, `///`, but don't include any tags, the compiler adds the text of those comments to the XML output file. However, the output doesn't include XML elements such as ``. Most tools that consume XML comments (including Visual Studio IntelliSense) don't read these comments. ## Tools that accept XML documentation input diff --git a/docs/csharp/misc/sorry-we-don-t-have-specifics-on-this-csharp-error.md b/docs/csharp/misc/sorry-we-don-t-have-specifics-on-this-csharp-error.md index 675e0ef72c714..54771c4384058 100644 --- a/docs/csharp/misc/sorry-we-don-t-have-specifics-on-this-csharp-error.md +++ b/docs/csharp/misc/sorry-we-don-t-have-specifics-on-this-csharp-error.md @@ -1,7 +1,7 @@ --- title: "Sorry, we don't have specifics on this error" description: "List of possible resources for compiler errors and warnings that haven't been documented yet." -ms.date: 12/18/2023 +ms.date: 02/20/2025 f1_keywords: - "CS0190" - "CS0224" @@ -361,14 +361,7 @@ f1_keywords: - "CS8522" - "CS8523" - "CS8524" - - "CS8598" - - "CS8623" - - "CS8628" - - "CS8632" - "CS8635" - - "CS8636" - - "CS8637" - - "CS8639" - "CS8641" - "CS8646" - "CS8647" @@ -615,9 +608,29 @@ f1_keywords: - "CS9123" - "CS9125" - "CS9205" + - "CS9212" + - "CS9213" + - "CS9214" + - "CS9215" + - "CS9222" + - "CS9229" + - "CS9230" + - "CS9231" + - "CS9232" + - "CS9233" + - "CS9234" + - "CS9235" + - "CS9236" +# C# 13 errors begin here + - "CS9268" + - "CS9269" + - "CS9270" + - "CS9271" +# C# 14 errors begin here + - "CS9273" + - "CS9274" helpviewer_keywords: - "errors [C#], additional information" -ms.assetid: 48320e4a-6e17-45a6-9966-88c6ec89bd2f --- # Sorry, we don't have specifics on this C# error diff --git a/docs/standard/serialization/binaryformatter-migration-guide/winforms-applications.md b/docs/standard/serialization/binaryformatter-migration-guide/winforms-applications.md index 9fd09fc8d2b8a..45894b73fa07f 100644 --- a/docs/standard/serialization/binaryformatter-migration-guide/winforms-applications.md +++ b/docs/standard/serialization/binaryformatter-migration-guide/winforms-applications.md @@ -74,9 +74,9 @@ If these statements are true, the Designer determines if that property's type ha Types that had been previously serialized into resource files via [BinaryFormatter] will continue to deserialize as expected without the need for [BinaryFormatter] as the content of ResX files are considered trusted data. In the rare case that deserialization cannot occur without [BinaryFormatter], it can be added back with an unsupported compatibility package. See [BinaryFormatter migration guide: Compatibility Package](compatibility-package.md) for details. Note that an extra step of setting `System.Resources.Extensions.UseBinaryFormatter` app context switch to `true` is required to use [BinaryFormatter] for resources. -##### Generating resource files via msbuild +##### Generating resource files via MSBuild -When generating resource files via msbuild, you may encounter an `MSB3825` error which specifies that your binary formatted resources may be deserialized using [BinaryFormatter] during runtime. As stated above, these resources will not deserialize using [BinaryFormatter] and this warning can be turned off by setting the property `GenerateResourceWarnOnBinaryFormatterUse` to `false`. In rare cases that deserialization cannot occur without [BinaryFormatter], it can be added back with an unsupported compatibility package. See [BinaryFormatter migration guide: Compatibility Package](compatibility-package.md) for details. Note that an additional step of setting `System.Resources.Extensions.UseBinaryFormatter` app context switch to `true` is required to use [BinaryFormatter] for resources. +When you generate resource files via MSBuild, you might encounter an `MSB3825` error. This error specifies that your binary-formatted resources might be deserialized using [BinaryFormatter] during run time. The warning is being removed from builds targeting .NET 9 and later, however the removal is not yet complete in all releases of .NET 9. The warning should be only of concern when targeting .NET 8 and lower. As stated earlier, these resources will not deserialize using [BinaryFormatter] during run time in .NET 9 and later versions. You can turn the warning off by setting the property `GenerateResourceWarnOnBinaryFormatterUse` to `false`. In rare cases that deserialization cannot occur without [BinaryFormatter], it can be added back with an unsupported compatibility package. For more information, see [BinaryFormatter migration guide: Compatibility package](compatibility-package.md). Note that an additional step of setting the `System.Resources.Extensions.UseBinaryFormatter` app context switch to `true` is required to use [BinaryFormatter] for resources. ## Migrate away from BinaryFormatter