Skip to content

Commit 8d36989

Browse files
authored
Merge branch 'main' into seal
2 parents f214014 + 6d412f4 commit 8d36989

File tree

169 files changed

+2463
-2391
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+2463
-2391
lines changed

docs/design/features/byreflike-generics.md

Lines changed: 38 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -28,37 +28,61 @@ The expansion of ByRefLike types as Generic parameters does not relax restrictio
2828

2929
## API Proposal
3030

31-
Support for the following will be indicated by a new property. For .NET 7, the feature will be marked with `RequiresPreviewFeaturesAttribute` to indicate it is in [preview](https://github.com/dotnet/designs/blob/main/accepted/2021/preview-features/preview-features.md).
31+
A new `GenericParameterAttributes` value will be defined which also represents metadata defined in the `CorGenericParamAttr` enumeration.
3232

3333
```diff
34-
namespace System.Runtime.CompilerServices
34+
namespace System.Reflection
3535
{
36-
public static partial class RuntimeFeature
36+
[Flags]
37+
public enum GenericParameterAttributes
3738
{
38-
+ /// <summary>
39-
+ /// Represents a runtime feature where byref-like types can be used in Generic parameters.
40-
+ /// </summary>
41-
+ public const string GenericsAcceptByRefLike = nameof(GenericsAcceptByRefLike);
39+
+ AcceptByRefLike = 0x0020
4240
}
4341
}
4442
```
4543

46-
The compiler will need an indication for existing troublesome APIs where ByRefLike types will be permissable, but where the failure will be handled at runtime. An attribute will be created and added to these APIs.
44+
```diff
45+
typedef enum CorGenericParamAttr
46+
{
47+
+ gpAcceptByRefLike = 0x0020 // type argument can be ByRefLike
48+
} CorGenericParamAttr;
49+
```
50+
51+
The expansion of metadata will impact at least the following:
52+
53+
- ILDasm/ILAsm/`System.Reflection.Metadata`/`System.Reflection.Emit` &ndash; https://github.com/dotnet/runtime
54+
- Cecil &ndash; https://github.com/jbevain/cecil
55+
- IL Trimmer &ndash; https://github.com/dotnet/runtime/tree/main/src/tools/illink
56+
- F# &ndash; https://github.com/fsharp/fsharp
57+
- C++/CLI &ndash; The MSVC team
58+
59+
### Troublesome API mitigation
60+
61+
If existing types are expected to add ByRefLike support, it is possible they contain previously valid APIs that will become invalid when ByRefLike types are permitted. A potential mitigation for this would be create an attribute to indicate to compilers that specific APIs are validated at run-time not compile-time. What follows is a potential solution.
62+
63+
The compiler will be imbued with knowledge of an API that tells it where ByRefLike types will be permissable and where the failure will be handled by the runtime. The compiler will only respect the attribute that is defined in the same assembly containing `System.Object`.
4764

4865
```csharp
4966
namespace System.Runtime.CompilerServices
5067
{
5168
/// <summary>
52-
/// Indicates to the compiler that constraint checks should be suppressed
53-
/// and will instead be enforced at run-time.
69+
/// Indicates to the compiler the ByRefLike constraint check should be suppressed.
5470
/// </summary>
55-
[AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property)]
56-
internal sealed class SuppressConstraintChecksAttribute : Attribute
57-
{ }
71+
/// <remarks>
72+
/// The checking will be suppressed for both the signature and method body. These
73+
/// checks are deferred and will be enforced at run-time.
74+
/// </remarks>
75+
/// <seealso href="https://github.com/dotnet/runtime/issues/99788">Design discussion</seealso>
76+
[AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = false)]
77+
internal sealed class SuppressByRefLikeConstraintChecksAttribute : Attribute
78+
{
79+
/// <summary>Initializes the attribute.</summary>
80+
public SuppressByRefLikeConstraintChecksAttribute() { }
81+
}
5882
}
5983
```
6084

61-
Troublesome APIs:
85+
Current examples of APIs that would need the attribute applied:
6286

6387
- [`Span<T>`](https://docs.microsoft.com/dotnet/api/system.span-1)
6488
- `public Span(T[]? array);`
@@ -73,34 +97,6 @@ Troublesome APIs:
7397
- `public static implicit operator ReadOnlySpan<T>(ArraySegment<T> segment);`
7498
- `public static implicit operator ReadOnlySpan<T>(T[]? array);`
7599

76-
A new `GenericParameterAttributes` value will be defined which also represents metadata defined in the `CorGenericParamAttr` enumeration.
77-
78-
```diff
79-
namespace System.Reflection
80-
{
81-
[Flags]
82-
public enum GenericParameterAttributes
83-
{
84-
+ AcceptByRefLike = 0x0020
85-
}
86-
}
87-
```
88-
89-
```diff
90-
typedef enum CorGenericParamAttr
91-
{
92-
+ gpAcceptByRefLike = 0x0020 // type argument can be ByRefLike
93-
} CorGenericParamAttr;
94-
```
95-
96-
The expansion of metadata will impact at least the following:
97-
98-
- ILDasm/ILAsm/`System.Reflection.Metadata`/`System.Reflection.Emit` &ndash; https://github.com/dotnet/runtime
99-
- Cecil &ndash; https://github.com/jbevain/cecil
100-
- IL Trimmer &ndash; https://github.com/dotnet/runtime/tree/main/src/tools/illink
101-
- F# &ndash; https://github.com/fsharp/fsharp
102-
- C++/CLI &ndash; The MSVC team
103-
104100
## Semantic Proposal
105101

106102
An API that is a JIT-time intrinsic will be needed to determine if a parameter is ByRefLike. This API would represent a check to occur at JIT time to avoid taking paths that would be invalid for some values of `T`. The existing `Type.IsByRefLike` property will be made an intrinsic (e.g., `typeof(T).IsByRefLike`).

eng/Publishing.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
$(ArtifactsPackagesDir)**\*.zip;
2525
$(ArtifactsPackagesDir)**\*.deb;
2626
$(ArtifactsPackagesDir)**\*.rpm;
27+
$(ArtifactsPackagesDir)**\*.pkg;
2728
$(ArtifactsPackagesDir)**\*.exe;
2829
$(ArtifactsPackagesDir)**\*.msi"
2930
Exclude="$(ArtifactsPackagesDir)**\Symbols.runtime.tar.gz" />

eng/Version.Details.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@
7979
<SourceBuild RepoName="emsdk" ManagedOnly="true" />
8080
</Dependency>
8181
<!-- Intermediate is necessary for source build. -->
82-
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="9.0.0-alpha.1.24155.1">
82+
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="9.0.0-alpha.1.24162.2">
8383
<Uri>https://github.com/dotnet/source-build-reference-packages</Uri>
84-
<Sha>768378e775fc5ddc99d41f2c4d1c78182f326ea7</Sha>
84+
<Sha>c0b5d69a1a1513528c77fffff708c7502d57c35c</Sha>
8585
<SourceBuild RepoName="source-build-reference-packages" ManagedOnly="true" />
8686
</Dependency>
8787
<!-- Intermediate is necessary for source build. -->

eng/Versions.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<PackageVersionNet7>7.0.$([MSBuild]::Add($([System.Version]::Parse('$(PackageVersionNet8)').Build),14))</PackageVersionNet7>
1212
<PackageVersionNet6>6.0.$([MSBuild]::Add($([System.Version]::Parse('$(PackageVersionNet7)').Build),11))</PackageVersionNet6>
1313
<PreReleaseVersionLabel>preview</PreReleaseVersionLabel>
14-
<PreReleaseVersionIteration>3</PreReleaseVersionIteration>
14+
<PreReleaseVersionIteration>4</PreReleaseVersionIteration>
1515
<!-- Enable to remove prerelease label. -->
1616
<StabilizePackageVersion Condition="'$(StabilizePackageVersion)' == ''">false</StabilizePackageVersion>
1717
<DotNetFinalVersionKind Condition="'$(StabilizePackageVersion)' == 'true'">release</DotNetFinalVersionKind>

eng/pipelines/common/global-build-job.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ parameters:
3232
preBuildSteps: []
3333
enableRichCodeNavigation: false
3434
richCodeNavigationLanguage: 'csharp'
35-
disableComponentGovernance: false
35+
disableComponentGovernance: ''
3636

3737
jobs:
3838
- template: /eng/common/templates/job/job.yml

eng/pipelines/common/templates/runtimes/xplat-job.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ parameters:
1919
timeoutInMinutes: ''
2020
enableMicrobuild: ''
2121
gatherAssetManifests: false
22-
disableComponentGovernance: false
22+
disableComponentGovernance: ''
2323

2424
variables: {} ## any extra variables to add to the defaults defined below
2525

@@ -64,9 +64,11 @@ jobs:
6464
${{ if eq(parameters.osGroup, 'windows') }}:
6565
agentOs: windows
6666

67-
# Disable component governance if requested or on musl machines where it does not work well
68-
${{ if or(eq(parameters.disableComponentGovernance, true), eq(parameters.osSubGroup, '_musl')) }}:
67+
# Component governance does not work on musl machines
68+
${{ if eq(parameters.osSubGroup, '_musl') }}:
6969
disableComponentGovernance: true
70+
${{ else }}:
71+
disableComponentGovernance: ${{ parameters.disableComponentGovernance }}
7072

7173
# Setting this results in the arcade job template including a step
7274
# that gathers asset manifests and publishes them to pipeline

eng/pipelines/coreclr/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ extends:
4444
#
4545
- template: /eng/pipelines/common/platform-matrix.yml
4646
parameters:
47-
jobTemplate: /eng/pipelines/common/templates/global-build-job.yml
47+
jobTemplate: /eng/pipelines/common/global-build-job.yml
4848
buildConfig: debug
4949
platforms:
5050
- linux_arm
@@ -69,7 +69,7 @@ extends:
6969
#
7070
- template: /eng/pipelines/common/platform-matrix.yml
7171
parameters:
72-
jobTemplate: /eng/pipelines/common/templates/global-build-job.yml
72+
jobTemplate: /eng/pipelines/common/global-build-job.yml
7373
buildConfig: release
7474
platforms:
7575
- linux_arm

eng/pipelines/coreclr/libraries-gcstress-extra.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ extends:
2222
- template: /eng/pipelines/common/platform-matrix.yml
2323
parameters:
2424
jobTemplate: /eng/pipelines/common/global-build-job.yml
25-
buildConfig: checked
25+
buildConfig: Release
2626
helixQueueGroup: libraries
2727
helixQueuesTemplate: /eng/pipelines/coreclr/templates/helix-queues-setup.yml
2828
platformGroup: gcstress
2929
jobParameters:
3030
# Default timeout is 150 minutes (2.5 hours), which is not enough for stress.
3131
timeoutInMinutes: 660
32-
buildArgs: -s clr+libs -c $(_BuildConfig) -lc Release
32+
buildArgs: -s clr+libs+libs.tests -rc Checked -c $(_BuildConfig) /p:ArchiveTests=true
3333
postBuildSteps:
3434
- template: /eng/pipelines/libraries/helix.yml
3535
parameters:

eng/pipelines/coreclr/libraries-gcstress0x3-gcstress0xc.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ extends:
2828
- template: /eng/pipelines/common/platform-matrix.yml
2929
parameters:
3030
jobTemplate: /eng/pipelines/common/global-build-job.yml
31-
buildConfig: checked
31+
buildConfig: release
3232
helixQueueGroup: libraries
3333
helixQueuesTemplate: /eng/pipelines/coreclr/templates/helix-queues-setup.yml
3434
platformGroup: gcstress
3535
jobParameters:
3636
# Default timeout is 150 minutes (2.5 hours), which is not enough for stress.
3737
timeoutInMinutes: 660
38-
buildArgs: -s clr+libs -c $(_BuildConfig) -lc Release
38+
buildArgs: -s clr+libs+libs.tests -rc Checked -c $(_BuildConfig) /p:ArchiveTests=true
3939
postBuildSteps:
4040
- template: /eng/pipelines/libraries/helix.yml
4141
parameters:

eng/pipelines/coreclr/libraries-jitstress-random.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ extends:
2121
- template: /eng/pipelines/common/platform-matrix.yml
2222
parameters:
2323
jobTemplate: /eng/pipelines/common/global-build-job.yml
24-
buildConfig: checked
24+
buildConfig: Release
2525
helixQueueGroup: libraries
2626
helixQueuesTemplate: /eng/pipelines/coreclr/templates/helix-queues-setup.yml
2727
platforms:
@@ -34,7 +34,7 @@ extends:
3434
jobParameters:
3535
# Default timeout is 150 minutes (2.5 hours), which is not enough for stress.
3636
timeoutInMinutes: 360
37-
buildArgs: -s clr+libs -c $(_BuildConfig) -lc Release
37+
buildArgs: -s clr+libs+libs.tests -rc Checked -c $(_BuildConfig) /p:ArchiveTests=true
3838
postBuildSteps:
3939
- template: /eng/pipelines/libraries/helix.yml
4040
parameters:

0 commit comments

Comments
 (0)