Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add and use TargetFramework.Net70 #64490

Merged
merged 8 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
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
1 change: 1 addition & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<BasicReferenceAssembliesNetStandard20Version>1.2.4</BasicReferenceAssembliesNetStandard20Version>
<BasicReferenceAssembliesNet50Version>1.2.4</BasicReferenceAssembliesNet50Version>
<BasicReferenceAssembliesNet60Version>1.2.4</BasicReferenceAssembliesNet60Version>
<BasicReferenceAssembliesNet70Version>1.3.0</BasicReferenceAssembliesNet70Version>
<BasicReferenceAssembliesNetStandard13Version>1.2.4</BasicReferenceAssembliesNetStandard13Version>
<BenchmarkDotNetVersion>0.13.0</BenchmarkDotNetVersion>
<BenchmarkDotNetDiagnosticsWindowsVersion>0.13.0</BenchmarkDotNetDiagnosticsWindowsVersion>
Expand Down
27 changes: 5 additions & 22 deletions src/Compilers/CSharp/Portable/Symbols/AssemblySymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -442,19 +442,16 @@ internal bool RuntimeSupportsStaticAbstractMembersInInterfaces

/// <summary>
/// Whether the target runtime supports numeric IntPtr types.
/// This test hook should be removed once TargetFramework.Net70 is added.
/// Tracked by https://github.com/dotnet/roslyn/issues/61235
/// </summary>
internal virtual bool RuntimeSupportsNumericIntPtr
internal bool RuntimeSupportsNumericIntPtr
{
get
{
// CorLibrary should never be null, but that invariant is broken in some cases for MissingAssemblySymbol.
// Tracked by https://github.com/dotnet/roslyn/issues/61262
return CorLibrary?.RuntimeSupportsNumericIntPtr == true;
return CorLibrary is not null &&
Copy link
Member

@cston cston Oct 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CorLibrary is not null &&

Is the CorLibrary check needed here? It's not included in similar properties below. #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is. One test reaches this with a null CorLibrary (CompilationReferences_More, crash in EmitDifference). This is tracked by above issue.
I'm not sure why numeric IntPtr is uniquely susceptible, but it might be because it's involved in metadata decoding for a type that already exists in the BCL ref assemblies.

RuntimeSupportsFeature(SpecialMember.System_Runtime_CompilerServices_RuntimeFeature__NumericIntPtr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider separating product changes and infrastructure changes into separate PRs

}

set => CorLibrary.RuntimeSupportsNumericIntPtr = value;
}

protected bool RuntimeSupportsFeature(SpecialMember feature)
Expand All @@ -467,22 +464,8 @@ protected bool RuntimeSupportsFeature(SpecialMember feature)
internal bool RuntimeSupportsUnmanagedSignatureCallingConvention
=> RuntimeSupportsFeature(SpecialMember.System_Runtime_CompilerServices_RuntimeFeature__UnmanagedSignatureCallingConvention);

internal virtual bool RuntimeSupportsByRefFields
{
get
{
// CorLibrary should never be null, but that invariant is broken in some cases for MissingAssemblySymbol.
// Tracked by https://github.com/dotnet/roslyn/issues/61262
return CorLibrary?.RuntimeSupportsByRefFields == true;
}

set
{
// The setter should be removed once TargetFramework.Net70 is added
// Tracked by https://github.com/dotnet/roslyn/issues/61463
CorLibrary.RuntimeSupportsByRefFields = value;
}
}
internal bool RuntimeSupportsByRefFields
=> RuntimeSupportsFeature(SpecialMember.System_Runtime_CompilerServices_RuntimeFeature__ByRefFields);

/// <summary>
/// True if the target runtime support covariant returns of methods declared in classes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,70 +32,6 @@ internal abstract class MetadataOrSourceAssemblySymbol
private int _cachedSpecialTypes;

private NativeIntegerTypeSymbol[] _lazyNativeIntegerTypes;
private ThreeState _lazyRuntimeSupportsNumericIntPtr = ThreeState.Unknown;
private ThreeState _lazyRuntimeSupportsByRefFields = ThreeState.Unknown;

internal override bool RuntimeSupportsNumericIntPtr
{
get
{
if ((object)CorLibrary == this)
{
if (!_lazyRuntimeSupportsNumericIntPtr.HasValue())
{
_lazyRuntimeSupportsNumericIntPtr = RuntimeSupportsFeature(SpecialMember.System_Runtime_CompilerServices_RuntimeFeature__NumericIntPtr).ToThreeState();
}

return _lazyRuntimeSupportsNumericIntPtr.Value();
}

return base.RuntimeSupportsNumericIntPtr;
}
set
{
Debug.Assert(value);
Debug.Assert(!RuntimeSupportsFeature(SpecialMember.System_Runtime_CompilerServices_RuntimeFeature__NumericIntPtr));
if ((object)CorLibrary == this)
{
Debug.Assert(!_lazyRuntimeSupportsNumericIntPtr.HasValue());
_lazyRuntimeSupportsNumericIntPtr = value.ToThreeState();
return;
}

base.RuntimeSupportsNumericIntPtr = value;
}
}

internal override bool RuntimeSupportsByRefFields
{
get
{
if ((object)CorLibrary == this)
{
if (!_lazyRuntimeSupportsByRefFields.HasValue())
{
_lazyRuntimeSupportsByRefFields = RuntimeSupportsFeature(SpecialMember.System_Runtime_CompilerServices_RuntimeFeature__ByRefFields).ToThreeState();
}

return _lazyRuntimeSupportsByRefFields.Value();
}

return base.RuntimeSupportsByRefFields;
}
set
{
Debug.Assert(value);
Debug.Assert(!RuntimeSupportsFeature(SpecialMember.System_Runtime_CompilerServices_RuntimeFeature__ByRefFields));
if ((object)CorLibrary == this)
{
Debug.Assert(!_lazyRuntimeSupportsByRefFields.HasValue());
_lazyRuntimeSupportsByRefFields = value.ToThreeState();
return;
}

base.RuntimeSupportsByRefFields = value;
}
}

/// <summary>
/// Lookup declaration for predefined CorLib type in this Assembly.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,35 +64,5 @@ internal override NamedTypeSymbol GetDeclaredSpecialType(SpecialType type)

return _lazySpecialTypes[(int)type];
}

internal override bool RuntimeSupportsNumericIntPtr
{
get
{
// For now we assume that it is not supported by default
Debug.Assert((object)CorLibrary == this);
return false;
}
set
{
Debug.Assert((object)CorLibrary == this);
throw ExceptionUtilities.Unreachable();
}
}

internal override bool RuntimeSupportsByRefFields
{
get
{
// For now we assume that it is not supported by default
Debug.Assert((object)CorLibrary == this);
return false;
}
set
{
Debug.Assert((object)CorLibrary == this);
throw ExceptionUtilities.Unreachable();
}
}
}
}
Loading