Skip to content
Merged
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ internal enum RefSafetyRulesAttributeVersion

private RefSafetyRulesAttributeVersion _lazyRefSafetyRulesAttributeVersion;

private MemorySafetyRulesVersion? _lazyMemorySafetyRulesVersion;
private SingleInitNullable<MemorySafetyRulesVersion> _lazyMemorySafetyRulesVersion;

#nullable enable
private DiagnosticInfo? _lazyCachedCompilerFeatureRequiredDiagnosticInfo = CSDiagnosticInfo.EmptyErrorInfo;
Expand Down Expand Up @@ -753,16 +753,14 @@ internal override MemorySafetyRulesVersion MemorySafetyRulesVersion
{
get
{
return _lazyMemorySafetyRulesVersion ??= getAttributeVersion();

// Returns
// * recognized: 1 if the attribute is not present,
// * recognized: 2 if the attribute is present and has the value 2,
// * unrecognized: -1 if the attribute is present and has the value 1 or some non-integer value,
// * unrecognized: the attribute's value (which is other than 1 or 2).
MemorySafetyRulesVersion getAttributeVersion()
return _lazyMemorySafetyRulesVersion.Initialize(static @this =>
Comment thread
jjonescz marked this conversation as resolved.
{
if (_module.HasMemorySafetyRulesAttribute(Token, out int version, out bool foundAttributeType) &&
// Returns
// * recognized: 1 if the attribute is not present,
// * recognized: 2 if the attribute is present and has the value 2,
// * unrecognized: -1 if the attribute is present and has the value 1 or some non-integer value,
// * unrecognized: the attribute's value (which is other than 1 or 2).
if (@this._module.HasMemorySafetyRulesAttribute(Token, out int version, out bool foundAttributeType) &&
version != (int)MemorySafetyRulesVersion.Version1)
{
return (MemorySafetyRulesVersion)version;
Expand All @@ -771,7 +769,7 @@ MemorySafetyRulesVersion getAttributeVersion()
return foundAttributeType
? (MemorySafetyRulesVersion)(-1)
: MemorySafetyRulesVersion.Version1;
}
}, this);
}
}

Expand Down
Loading