Skip to content

Commit

Permalink
fix build warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
gewarren committed Apr 9, 2024
1 parent 9147ceb commit 3956750
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions docs/core/whats-new/dotnet-9/libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ KMAC is available on Linux with OpenSSL 3.0 or later, and on Windows 11 Build 26

## Reflection

In .NET Core versions and .NET 5-8, support for building an assembly and emitting reflection metadata for dynamically created types was limited to a runnable <xref:System.Reflection.Emit.AssemblyBuilder>. The lack of support for *saving* an assembly was often a blocker for customers migrating from .NET Framework to .NET. .NET 9 adds a new type, <xref:System.Reflection.Emit.AssemblyBuilder.PersistedAssemblyBuilder?displayProperty=nameWithType>, that you can use to save an emitted assembly.
In .NET Core versions and .NET 5-8, support for building an assembly and emitting reflection metadata for dynamically created types was limited to a runnable <xref:System.Reflection.Emit.AssemblyBuilder>. The lack of support for *saving* an assembly was often a blocker for customers migrating from .NET Framework to .NET. .NET 9 adds a new type, `PersistedAssemblyBuilder` <!--<xref:System.Reflection.Emit.AssemblyBuilder.PersistedAssemblyBuilder>-->, that you can use to save an emitted assembly.

To create a `PersistedAssemblyBuilder` instance, call its constructor and pass the assembly name, the core assembly, `System.Private.CoreLib`, to reference base runtime types, and optional custom attributes. After you emit all members to the assembly, call the `PersistedAssemblyBuilder.Save(string assemblyFileName)` method to create an assembly with default settings. If you want to set the entry point or other options, you can call `PersistedAssemblyBuilder.GenerateMetadata(out BlobBuilder ilStream, out BlobBuilder mappedFieldData)` and use the metadata it returns to save the assembly. The following code shows an example of creating a persisted assembly and setting the entry point.
To create a `PersistedAssemblyBuilder` instance, call its constructor and pass the assembly name, the core assembly, `System.Private.CoreLib`, to reference base runtime types, and optional custom attributes. After you emit all members to the assembly, call the `PersistedAssemblyBuilder.Save(string assemblyFileName)` <!--<xref:System.Reflection.Emit.AssemblyBuilder.PersistedAssemblyBuilder.Save(System.String)>--> method to create an assembly with default settings. If you want to set the entry point or other options, you can call `PersistedAssemblyBuilder.GenerateMetadata(System.Reflection.Metadata.BlobBuilder,System.Reflection.Metadata.BlobBuilder)` <!--<xref:System.Reflection.Emit.AssemblyBuilder.PersistedAssemblyBuilder.GenerateMetadata(System.Reflection.Metadata.BlobBuilder,System.Reflection.Metadata.BlobBuilder)>--> and use the metadata it returns to save the assembly. The following code shows an example of creating a persisted assembly and setting the entry point.

:::code language="csharp" source="../snippets/dotnet-9/csharp/Reflection.cs" id="SaveAssembly":::

Expand Down Expand Up @@ -121,4 +121,4 @@ The following code shows an example of calling the `double` and one of the new i

## `ActivatorUtilities.CreateInstance` constructor

The constructor resolution for `ActivatorUtilities.CreateInstance()` has changed in .NET 9. Previously, a constructor that was explicitly marked using the `[ActivatorUtilitiesConstructor]` attribute might not be called, depending on the ordering of constructors and the number of constructor parameters. The logic has changed in .NET 9 such that a constructor that has the attribute is always called.
The constructor resolution for <xref:Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance%2A?displayProperty=nameWithType> has changed in .NET 9. Previously, a constructor that was explicitly marked using the <xref:Microsoft.Extensions.DependencyInjection.ActivatorUtilitiesConstructorAttribute> attribute might not be called, depending on the ordering of constructors and the number of constructor parameters. The logic has changed in .NET 9 such that a constructor that has the attribute is always called.
4 changes: 2 additions & 2 deletions docs/core/whats-new/dotnet-9/sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ In .NET 9, `dotnet test` is more fully integrated with MSBuild. Because MSBuild

Test result reporting for [`dotnet test`](../../tools/dotnet-test.md) is now supported directly in the MSBuild terminal logger. You get more fully featured test reporting both *while* tests are running (displays the running test name) and *after* tests are completed (any test errors are rendered in a better way).

For more information about the terminal logger, see [dotnet build options](../tools/dotnet-build.md#options).
For more information about the terminal logger, see [dotnet build options](../../tools/dotnet-build.md#options).

## .NET tool roll-forward

Expand All @@ -31,7 +31,7 @@ A new option for [`dotnet tool install`](../../tools/dotnet-tool-install.md) let

## Terminal logger usability

The terminal logger now summarizes the total count of failures and warnings at the end of a build. It also shows errors that contain newlines. (For more information about the terminal logger, see ['dotnet build' options](../../../tools/dotnet-build.md#options), specifically the `--tl` option.)
The terminal logger now summarizes the total count of failures and warnings at the end of a build. It also shows errors that contain newlines. (For more information about the terminal logger, see ['dotnet build' options](../../tools/dotnet-build.md#options), specifically the `--tl` option.)

Consider the following project file that emits a warning when the project is built:

Expand Down

0 comments on commit 3956750

Please sign in to comment.