Skip to content

Commit f9b6b3b

Browse files
Merge pull request #43315 from dotnet/main
Merge main into live
2 parents 1e7fc8d + 30839a4 commit f9b6b3b

File tree

8 files changed

+579
-20
lines changed

8 files changed

+579
-20
lines changed

docs/core/diagnostics/eventsource-collect-and-view-traces.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,3 +272,34 @@ this isn't required. Following is an example `EventListener` implementation that
272272
3/24/2022 9:23:35 AM RequestStart
273273
3/24/2022 9:23:35 AM RequestStop
274274
```
275+
276+
> [!WARNING]
277+
> Potential Pitfalls when implementing EventSource Callbacks via EventListener include deadlocks, infinite recursions, and uninitialized types.
278+
>
279+
> EventSource instances are initialized early in the runtime, before some core features are fully initialized. As a result, acquiring locks inside an EventSource callback like <xref:System.Diagnostics.Tracing.EventListener.OnEventWritten%2A> when the thread normally would not have done so may cause deadlocks.
280+
>
281+
> To mitigate this risk, consider the following precautions:
282+
>
283+
> - **Use Queues to Defer Work**: There are a variety of APIs you might want to call in OnEventWritten() that do non-trivial work, for example File IO, Console, or Http. For most events, these APIs work fine, but if you tried to call Console.WriteLine() in an event handler during the initialization of the Console class then it would probably fail. If you don't know whether a given event handler occurs at a time when APIs are safe to call, consider adding some information about the event to an in-memory queue instead. Then, on a separate thread, process items in the queue.
284+
> - **Minimize Lock Duration**: Ensure that any locks acquired within the callback are not held for extended periods.
285+
> - **Use Non-blocking APIs**: Prefer using non-blocking APIs within the callback to avoid potential deadlocks.
286+
> - **Implement a Re-entrancy Guard**: Use a re-entrancy guard to prevent infinite recursion. For example:
287+
>
288+
> ```csharp
289+
> [ThreadStatic] private static bool t_insideCallback;
290+
>
291+
> public void OnEventWritten(...)
292+
> {
293+
> if (t_insideCallback) return; // if our callback triggered the event to occur recursively
294+
> // exit now to avoid infinite recursion
295+
> try
296+
> {
297+
> t_insideCallback = true;
298+
> // do callback work
299+
> }
300+
> finally
301+
> {
302+
> t_insideCallback = false;
303+
> }
304+
> }
305+
> ```

docs/core/extensions/options.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ms.date: 08/13/2024
88

99
# Options pattern in .NET
1010

11-
The options pattern uses classes to provide strongly-typed access to groups of related settings. When [configuration settings](configuration.md) are isolated by scenario into separate classes, the app adheres to two important software engineering principles:
11+
The options pattern uses classes to provide strongly typed access to groups of related settings. When [configuration settings](configuration.md) are isolated by scenario into separate classes, the app adheres to two important software engineering principles:
1212

1313
- The [Interface Segregation Principle (ISP) or Encapsulation](../../architecture/modern-web-apps-azure/architectural-principles.md#encapsulation): Scenarios (classes) that depend on configuration settings depend only on the configuration settings that they use.
1414
- [Separation of Concerns](../../architecture/modern-web-apps-azure/architectural-principles.md#separation-of-concerns): Settings for different parts of the app aren't dependent or coupled with one another.

docs/core/runtime-config/index.md

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,21 @@ description: Learn how to configure the .NET runtime using configuration setting
44
ms.topic: conceptual
55
ms.date: 07/23/2021
66
---
7-
# .NET Runtime configuration settings
8-
9-
.NET 5+ (including .NET Core versions) supports the use of configuration files and environment variables to configure the behavior of .NET applications.
10-
11-
> [!NOTE]
12-
> The articles in this section concern configuration of the .NET Runtime itself. If you're migrating an app from .NET Framework to .NET and are looking for a replacement for the *app.config* file, or if you simply want a way to use custom configuration values in your .NET app, see the <xref:Microsoft.Extensions.Configuration.ConfigurationBuilder?displayProperty=fullName> class and [Configuration in .NET](../extensions/configuration.md).
13-
14-
Using these settings is an attractive option if:
15-
16-
- You don't own or control the source code for an application and therefore are unable to configure it programmatically.
17-
- Multiple instances of your application run at the same time on a single system, and you want to configure each for optimum performance.
7+
# .NET runtime configuration settings
188

199
.NET provides the following mechanisms for configuring behavior of the .NET runtime:
2010

21-
- The [runtimeconfig.json file](#runtimeconfigjson)
22-
- [MSBuild properties](#msbuild-properties)
23-
- [Environment variables](#environment-variables)
24-
25-
> [!TIP]
26-
> Configuring an option by using an environment variable applies the setting to all .NET apps. Configuring an option in the *runtimeconfig.json* or project file applies the setting to that application only.
11+
| Mechanism | Notes |
12+
|---------------------------------------------------|----------------------------------------|
13+
| The [runtimeconfig.json file](#runtimeconfigjson) | Applies the setting to a specific app. Use this file if multiple instances of your app run at the same time on a single system, and you want to configure each for optimum performance. |
14+
| [MSBuild properties](#msbuild-properties) | Applies the setting to a specific app. MSBuild properties take precedence over settings in *runtimeconfig.json*. |
15+
| [Environment variables](#environment-variables) | Applies the setting to all .NET apps. |
2716

2817
Some configuration values can also be set programmatically by calling the <xref:System.AppContext.SetSwitch%2A?displayProperty=nameWithType> method.
2918

19+
> [!NOTE]
20+
> The articles in this section concern configuration of the .NET runtime itself. If you're migrating an app from .NET Framework to .NET and are looking for a replacement for the *app.config* file, see [Modernize after upgrading to .NET](../porting/modernize.md#appconfig). For information about supplying custom configuration values to .NET apps, see [Configuration in .NET](../extensions/configuration.md).
21+
3022
The articles in this section of the documentation are organized by category, for example, [debugging](debugging-profiling.md) and [garbage collection](garbage-collector.md). Where applicable, configuration options are shown for *runtimeconfig.json* files, MSBuild properties, environment variables, and, for cross-reference, *app.config* files for .NET Framework projects.
3123

3224
## runtimeconfig.json
@@ -49,7 +41,7 @@ Specify runtime configuration options in the **configProperties** section of the
4941

5042
### Example [appname].runtimeconfig.json file
5143

52-
If you're placing the options in the output JSON file, nest them under the `runtimeOptions` property.
44+
If you're placing the options in the *output* JSON file, nest them under the `runtimeOptions` property.
5345

5446
```json
5547
{
@@ -72,7 +64,7 @@ If you're placing the options in the output JSON file, nest them under the `runt
7264

7365
### Example runtimeconfig.template.json file
7466

75-
If you're placing the options in the template JSON file, omit the `runtimeOptions` property.
67+
If you're placing the options in the *template* JSON file, **omit** the `runtimeOptions` property.
7668

7769
```json
7870
{

docs/core/whats-new/dotnet-9/overview.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,26 @@ C# 13 ships with the .NET 9 SDK and includes the following new features:
9090

9191
For more information, see [What's new in C# 13](../../../csharp/whats-new/csharp-13.md).
9292

93+
## F# 9
94+
95+
F# 9 ships with the .NET 9 SDK and includes the following new features:
96+
97+
- Nullable reference types
98+
- Discriminated union .Is* properties
99+
- Partial active patterns can return bool instead of unit option
100+
- Prefer extension methods to intrinsic properties when arguments are provided
101+
- Empty-bodied computation expressions
102+
- Hash directives are allowed to take non-string arguments
103+
- Extended #help directive in fsi to show documentation in the read-eval-print loop (REPL)
104+
- Allow #nowarn to support the FS prefix on error codes to disable warnings
105+
- Warning about TailCall attribute on non-recursive functions or let-bound values
106+
- Enforce attribute targets
107+
- Random functions for collections
108+
- C# collection expression support for F# lists and sets
109+
- Various developer productivity, performance and tooling improvements
110+
111+
For more information, see [What's new in F# 9](../../../fsharp/whats-new/fsharp-9.md).
112+
93113
## Windows Presentation Foundation
94114

95115
Windows Presentation Foundation (WPF) includes support for Windows 11 theming and hyphen-based ligatures. For more information, see [WPF in .NET 9 Preview 4 - Release Notes](https://github.com/dotnet/core/blob/main/release-notes/9.0/preview/preview4/wpf.md).
32.7 KB
Loading
213 KB
Loading

docs/fsharp/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ items:
292292
href: tutorials/using-functions.md
293293
- name: What's new
294294
items:
295+
- name: F# 9
296+
href: whats-new/fsharp-9.md
295297
- name: F# 8
296298
href: whats-new/fsharp-8.md
297299
- name: F# 7

0 commit comments

Comments
 (0)