Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions xml/System.Reflection.Metadata/MetadataStringComparer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,21 @@ No allocation is performed unless both the handle argument and the value argumen

Obtain instances using <xref:System.Reflection.Metadata.MetadataReader.StringComparer>. A default-initialized instance is useless and behaves as a `null` reference.

The code is optimized so that there is no additional overhead in re-obtaining a comparer over assigning it to a local. That is to say that a construct like:
The code is optimized so that there is no additional overhead in reobtaining a comparer over assigning it to a local. That is to say that a construct like:

```cs
```csharp
if (reader.StringComparer.Equals(typeDef.Namespace, "System") && reader.StringComparer.Equals(typeDef.Name, "Object")
{
/* found System.Object */
}
```
is no less efficient than:

```cs
...is no less efficient than:

```csharp
var comparer = reader.StringComparer;
if (comparer.Equals(typeDef.Namespace, "System") && comparer.Equals(typeDef.Name, "Object")
{
if (comparer.Equals(typeDef.Namespace, "System") && comparer.Equals(typeDef.Name, "Object")
{
/* found System.Object */
}
```
Expand Down
29 changes: 11 additions & 18 deletions xml/System.Reflection/AssemblyName.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,10 @@
## Remarks
The <xref:System.Reflection.AssemblyName> object contains information about an assembly, which you can use to bind to that assembly. An assembly's identity consists of the following:

- Simple name.

- Version number.

- Cryptographic key pair.

- Supported culture.
- Simple name.
- Version number.
- Cryptographic key pair.
- Supported culture.

The simple name is typically the file name for the manifest file without its extension. The key pair includes a public and private key, used to create strong-name signatures for assemblies.

Expand Down Expand Up @@ -146,13 +143,11 @@

To ensure that the names are constructed correctly, use the following properties:

- <xref:System.Reflection.Assembly.FullName%2A?displayProperty=nameWithType>

- <xref:System.Reflection.AssemblyName.FullName%2A?displayProperty=nameWithType>

- <xref:System.Type.AssemblyQualifiedName%2A?displayProperty=nameWithType>
- <xref:System.Reflection.Assembly.FullName%2A?displayProperty=nameWithType>
- <xref:System.Reflection.AssemblyName.FullName%2A?displayProperty=nameWithType>
- <xref:System.Type.AssemblyQualifiedName%2A?displayProperty=nameWithType>

You can also get the name by using the `/l` option with the [Gacutil.exe (Global Assembly Cache Tool)](/dotnet/framework/tools/gacutil-exe-gac-tool)
You can also get the name by using the `/l` option with the [Gacutil.exe (Global Assembly Cache Tool)](/dotnet/framework/tools/gacutil-exe-gac-tool).

For a partially specified strong name, create an <xref:System.Reflection.AssemblyName> object using the parameterless constructor and set the name and public key. An assembly created using such an <xref:System.Reflection.AssemblyName> can be signed later using the Assembly Linker (Al.exe).

Expand All @@ -174,18 +169,16 @@

The following example shows an <xref:System.Reflection.AssemblyName> for a simply named assembly with default culture.

```
```txt
ExampleAssembly, Culture=""
```

The following example shows a fully specified reference for a strongly named assembly with culture "en".

```
```txt
ExampleAssembly, Version=1.0.0.0, Culture=en, PublicKeyToken=a5d015c7d5a0b012
```



## Examples
This example shows how to use various reflection classes to analyze the metadata contained in an assembly.

Expand Down Expand Up @@ -812,7 +805,7 @@ Note: In <see href="https://go.microsoft.com/fwlink/?LinkID=247912">.NET for Win
## Remarks
The display name typically consists of the simple name, version number, supported culture, and public key. For example:

```
```txt
mylib, Version=1.2.1900.0, Culture=neutral, PublicKeyToken=a14f3033def15840
```

Expand Down
110 changes: 55 additions & 55 deletions xml/System.Reflection/AssemblyVersionAttribute.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,37 +68,37 @@
<Docs>
<summary>Specifies the version of the assembly being attributed.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Reflection.AssemblyVersionAttribute> attribute is used to assign a version number to an assembly. That version number is then stored with the assembly's metadata.
The assembly version number is part of an assembly's identity and plays a key part in binding to the assembly and in version policy. The default version policy for the runtime is that applications run only with the versions they were built and tested with, unless overridden by explicit version policy in configuration files (the application configuration file, the publisher policy file, and the computer's administrator configuration file). See [Assemblies in .NET](/dotnet/standard/assembly/#assemblies-in-the-common-language-runtime) for more information.
<format type="text/markdown"><![CDATA[

## Remarks
The <xref:System.Reflection.AssemblyVersionAttribute> attribute is used to assign a version number to an assembly. That version number is then stored with the assembly's metadata.

The assembly version number is part of an assembly's identity and plays a key part in binding to the assembly and in version policy. The default version policy for the runtime is that applications run only with the versions they were built and tested with, unless overridden by explicit version policy in configuration files (the application configuration file, the publisher policy file, and the computer's administrator configuration file). See [Assemblies in .NET](/dotnet/standard/assembly/#assemblies-in-the-common-language-runtime) for more information.

> [!NOTE]
> Version checking only occurs with strong-named assemblies.
The version number has four parts, as follows:
\<major version>.\<minor version>.\<build number>.\<revision>
> Version checking only occurs with strong-named assemblies.

The version number has four parts, as follows:

\<major version>.\<minor version>.\<build number>.\<revision>

> [!IMPORTANT]
> All components of the version must be integers greater than or equal to 0. Metadata restricts the major, minor, build, and revision components for an assembly to a maximum value of <xref:System.UInt16.MaxValue?displayProperty=nameWithType> - 1. If a component exceeds this value, a compilation error occurs.
> All components of the version must be integers greater than or equal to 0. Metadata restricts the major, minor, build, and revision components for an assembly to a maximum value of <xref:System.UInt16.MaxValue?displayProperty=nameWithType> - 1. If a component exceeds this value, a compilation error occurs.

For example, `[assembly:AssemblyVersion("2.3.25.1")]` indicates 2 as the major version, 3 as the minor version, 25 as the build number, and 1 as the revision number.
For example, `[assembly:AssemblyVersion("2.3.25.1")]` indicates 2 as the major version, 3 as the minor version, 25 as the build number, and 1 as the revision number.

The <xref:System.Reflection.AssemblyVersionAttribute> attribute allows you to specify an asterisk (\*) in place of the build or revision number. A version number such as `[assembly:AssemblyVersion("1.2.*")]` specifies 1 as the major version and 2 as the minor version, and accepts the default build and revision numbers. A version number such as `[assembly:AssemblyVersion("1.2.15.*")]` specifies 1 as the major version, 2 as the minor version, and 15 as the build number, and accepts the default revision number. The default build number increments daily. The default revision number is the number of seconds since midnight local time (without taking into account time zone adjustments for daylight saving time), divided by 2. If you specify an asterisk for the build number, you can't specify a revision number.
The <xref:System.Reflection.AssemblyVersionAttribute> attribute allows you to specify an asterisk (\*) in place of the build or revision number. A version number such as `[assembly:AssemblyVersion("1.2.*")]` specifies 1 as the major version and 2 as the minor version, and accepts the default build and revision numbers. A version number such as `[assembly:AssemblyVersion("1.2.15.*")]` specifies 1 as the major version, 2 as the minor version, and 15 as the build number, and accepts the default revision number. The default build number increments daily. The default revision number is the number of seconds since midnight local time (without taking into account time zone adjustments for daylight saving time), divided by 2. If you specify an asterisk for the build number, you can't specify a revision number.

> [!IMPORTANT]
> [!IMPORTANT]
> Use of the <xref:System.Reflection.AssemblyVersionAttribute> attribute that specifies an asterisk:
>
> - Makes the build outputs non-reproducible (see [Reproducible builds](https://reproducible-builds.org/)). If the project sets `Deterministic` build property to `true` an error `CS8357` is reported by the compiler.
> - Might degrade build performance, as it prevents build from caching compiler outputs.
> - Is incompatible with the [Edit & Continue](/visualstudio/debugger/edit-and-continue-visual-csharp) and [Hot Reload](/visualstudio/debugger/hot-reload) features.

You can mitigate some of these issues by limiting the use of time-based versions to release builds using conditional compilation, like so:

```
```csharp
#if DEBUG
[assembly: AssemblyVersion("1.0.0.0")]
#else
Expand All @@ -108,20 +108,20 @@ You can mitigate some of these issues by limiting the use of time-based versions

A better approach to versioning is to derive the assembly or file version from the `HEAD` commit SHA (for git repositories). See, for example, [Nerdbank.GitVersioning](https://github.com/dotnet/Nerdbank.GitVersioning).

The assembly major and minor versions are used as the type library version number when the assembly is exported. Some COM hosts do not accept type libraries with the version number 0.0. Therefore, if you want to expose an assembly to COM clients, set the assembly version explicitly to 1.0 in the `AssemblyVersionAttribute` page for projects created outside Visual Studio 2005 and with no `AssemblyVersionAttribute` specified. Do this even when the assembly version is 0.0. All projects created in Visual Studio 2005 have a default assembly version of 1.0.*.
To get the name of an assembly you have loaded, call <xref:System.Reflection.Assembly.GetName%2A> on the assembly to get an <xref:System.Reflection.AssemblyName>, and then get the <xref:System.Reflection.AssemblyName.Version%2A> property. To get the name of an assembly you have not loaded, call <xref:System.Reflection.AssemblyName.GetAssemblyName%2A> from your client application to check the assembly version that your application uses.
The <xref:System.Reflection.AssemblyVersionAttribute> attribute can only be applied once. Some Visual Studio project templates already include the attribute. In those projects, adding the attribute in code causes a compiler error.
## Examples
The following example uses the <xref:System.Reflection.AssemblyVersionAttribute> attribute to assign a version number to an assembly. At compile time, this version information is stored with the assembly's metadata. At run time, the example retrieves the value of the <xref:System.Type.Assembly%2A?displayProperty=nameWithType> property on a type found in the assembly to get a reference to the executing assembly, and it retrieves the assembly's version information from the <xref:System.Reflection.AssemblyName.Version%2A> property of the <xref:System.Reflection.AssemblyName> object returned by the <xref:System.Reflection.Assembly.GetName%2A?displayProperty=nameWithType> method.
The assembly major and minor versions are used as the type library version number when the assembly is exported. Some COM hosts do not accept type libraries with the version number 0.0. Therefore, if you want to expose an assembly to COM clients, set the assembly version explicitly to 1.0 in the `AssemblyVersionAttribute` page for projects created outside Visual Studio 2005 and with no `AssemblyVersionAttribute` specified. Do this even when the assembly version is 0.0. All projects created in Visual Studio 2005 have a default assembly version of 1.0.*.

To get the name of an assembly you have loaded, call <xref:System.Reflection.Assembly.GetName%2A> on the assembly to get an <xref:System.Reflection.AssemblyName>, and then get the <xref:System.Reflection.AssemblyName.Version%2A> property. To get the name of an assembly you have not loaded, call <xref:System.Reflection.AssemblyName.GetAssemblyName%2A> from your client application to check the assembly version that your application uses.

The <xref:System.Reflection.AssemblyVersionAttribute> attribute can only be applied once. Some Visual Studio project templates already include the attribute. In those projects, adding the attribute in code causes a compiler error.



## Examples
The following example uses the <xref:System.Reflection.AssemblyVersionAttribute> attribute to assign a version number to an assembly. At compile time, this version information is stored with the assembly's metadata. At run time, the example retrieves the value of the <xref:System.Type.Assembly%2A?displayProperty=nameWithType> property on a type found in the assembly to get a reference to the executing assembly, and it retrieves the assembly's version information from the <xref:System.Reflection.AssemblyName.Version%2A> property of the <xref:System.Reflection.AssemblyName> object returned by the <xref:System.Reflection.Assembly.GetName%2A?displayProperty=nameWithType> method.

:::code language="csharp" source="~/snippets/csharp/System/Version/Overview/example1.cs" id="Snippet6":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Version.Class/vb/example1.vb" id="Snippet6":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Version.Class/vb/example1.vb" id="Snippet6":::

]]></format>
</remarks>
<altmember cref="P:System.Reflection.AssemblyName.Version" />
Expand Down Expand Up @@ -175,29 +175,29 @@ You can mitigate some of these issues by limiting the use of time-based versions
<param name="version">The version number of the attributed assembly.</param>
<summary>Initializes a new instance of the <see langword="AssemblyVersionAttribute" /> class with the version number of the assembly being attributed.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The format of the `version` string is: `major`. `minor`. `build`. `revision`.
When specifying a version, you have to at least specify `major`. If you specify `major` and `minor`, you can specify an asterisk (*) for `build`. This will cause `build` to be equal to the number of days since January 1, 2000 local time, and for `revision` to be equal to the number of seconds since midnight local time (without taking into account time zone adjustments for daylight saving time), divided by 2.
If you specify `major`, `minor`, and `build`, you can specify an asterisk for `revision`. This will cause `revision` to be equal to the number of seconds since midnight local time, divided by 2.
Examples of valid version strings include:
1
1.1
1.1.*
1.1.1
1.1.1.*
1.1.1.1
<format type="text/markdown"><![CDATA[

## Remarks
The format of the `version` string is: `major`. `minor`. `build`. `revision`.

When specifying a version, you have to at least specify `major`. If you specify `major` and `minor`, you can specify an asterisk (*) for `build`. This will cause `build` to be equal to the number of days since January 1, 2000 local time, and for `revision` to be equal to the number of seconds since midnight local time (without taking into account time zone adjustments for daylight saving time), divided by 2.

If you specify `major`, `minor`, and `build`, you can specify an asterisk for `revision`. This will cause `revision` to be equal to the number of seconds since midnight local time, divided by 2.

Examples of valid version strings include:

1

1.1

1.1.*

1.1.1

1.1.1.*

1.1.1.1

]]></format>
</remarks>
<related type="Article" href="/dotnet/standard/assembly/set-attributes">Set assembly attributes</related>
Expand Down
8 changes: 4 additions & 4 deletions xml/System.Reflection/EventInfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ Note: In <see href="https://learn.microsoft.com/previous-versions/br230232(v=vs.
## Examples
Typically, the method has the following signature:

```
```csharp
add_<EventName>(<EventHandlerType> handler)
```

Expand Down Expand Up @@ -646,7 +646,7 @@ add_<EventName>(<EventHandlerType> handler)
## Examples
Typically, the method has the following signature:

```
```csharp
add_<EventName>(<EventHandlerType> handler)
```

Expand Down Expand Up @@ -1042,7 +1042,7 @@ add_<EventName>(<EventHandlerType> handler)
## Examples
Typically, the method has the following signature:

```
```csharp
remove_<EventName>(<EventHandlerType> handler)
```

Expand Down Expand Up @@ -1108,7 +1108,7 @@ remove_<EventName>(<EventHandlerType> handler)
## Examples
Typically, the method has the following signature:

```
```csharp
remove_<EventName>(<EventHandlerType> handler)
```

Expand Down
Loading