diff --git a/src/Compilers/CSharp/Portable/CSharpResources.resx b/src/Compilers/CSharp/Portable/CSharpResources.resx
index ebb126ee94926..61cb849a9e4d7 100644
--- a/src/Compilers/CSharp/Portable/CSharpResources.resx
+++ b/src/Compilers/CSharp/Portable/CSharpResources.resx
@@ -5314,6 +5314,9 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
Combined length of user strings used by the program exceeds allowed limit. Try to decrease use of string literals or try the EXPERIMENTAL feature flag 'experimental-data-section-string-literals'.
+
+ Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.
+
It is not legal to use nullable type '{0}?' in a pattern; use the underlying type '{0}' instead.
diff --git a/src/Compilers/CSharp/Portable/CodeGen/CodeGenerator.cs b/src/Compilers/CSharp/Portable/CodeGen/CodeGenerator.cs
index ce7045499e411..f1bcf5757fc9e 100644
--- a/src/Compilers/CSharp/Portable/CodeGen/CodeGenerator.cs
+++ b/src/Compilers/CSharp/Portable/CodeGen/CodeGenerator.cs
@@ -338,7 +338,7 @@ private void HandleReturn()
private void EmitTypeReferenceToken(Cci.ITypeReference symbol, SyntaxNode syntaxNode)
{
- _builder.EmitToken(symbol, syntaxNode, _diagnostics.DiagnosticBag);
+ _builder.EmitToken(symbol, syntaxNode);
}
private void EmitSymbolToken(TypeSymbol symbol, SyntaxNode syntaxNode)
@@ -349,18 +349,18 @@ private void EmitSymbolToken(TypeSymbol symbol, SyntaxNode syntaxNode)
private void EmitSymbolToken(MethodSymbol method, SyntaxNode syntaxNode, BoundArgListOperator optArgList, bool encodeAsRawDefinitionToken = false)
{
var methodRef = _module.Translate(method, syntaxNode, _diagnostics.DiagnosticBag, optArgList, needDeclaration: encodeAsRawDefinitionToken);
- _builder.EmitToken(methodRef, syntaxNode, _diagnostics.DiagnosticBag, encodeAsRawDefinitionToken ? Cci.MetadataWriter.RawTokenEncoding.RowId : 0);
+ _builder.EmitToken(methodRef, syntaxNode, encodeAsRawDefinitionToken ? Cci.MetadataWriter.RawTokenEncoding.RowId : 0);
}
private void EmitSymbolToken(FieldSymbol symbol, SyntaxNode syntaxNode)
{
var fieldRef = _module.Translate(symbol, syntaxNode, _diagnostics.DiagnosticBag);
- _builder.EmitToken(fieldRef, syntaxNode, _diagnostics.DiagnosticBag);
+ _builder.EmitToken(fieldRef, syntaxNode);
}
private void EmitSignatureToken(FunctionPointerTypeSymbol symbol, SyntaxNode syntaxNode)
{
- _builder.EmitToken(_module.Translate(symbol).Signature, syntaxNode, _diagnostics.DiagnosticBag);
+ _builder.EmitToken(_module.Translate(symbol).Signature, syntaxNode);
}
private void EmitSequencePointStatement(BoundSequencePoint node)
@@ -444,15 +444,15 @@ private void EmitRestorePreviousSequencePoint(BoundRestorePreviousSequencePoint
if (_savedSequencePoints is null || !_savedSequencePoints.TryGetValue(node.Identifier, out var span))
return;
- EmitStepThroughSequencePoint(node.Syntax.SyntaxTree, span);
+ EmitStepThroughSequencePoint(node.Syntax, span);
}
private void EmitStepThroughSequencePoint(BoundStepThroughSequencePoint node)
{
- EmitStepThroughSequencePoint(node.Syntax.SyntaxTree, node.Span);
+ EmitStepThroughSequencePoint(node.Syntax, node.Span);
}
- private void EmitStepThroughSequencePoint(SyntaxTree syntaxTree, TextSpan span)
+ private void EmitStepThroughSequencePoint(SyntaxNode syntaxNode, TextSpan span)
{
if (!_emitPdbSequencePoints)
return;
@@ -460,9 +460,9 @@ private void EmitStepThroughSequencePoint(SyntaxTree syntaxTree, TextSpan span)
var label = new object();
// The IL builder is eager to discard unreachable code, so
// we fool it by branching on a condition that is always true at runtime.
- _builder.EmitConstantValue(ConstantValue.Create(true));
+ _builder.EmitConstantValue(ConstantValue.Create(true), syntaxNode);
_builder.EmitBranch(ILOpCode.Brtrue, label);
- EmitSequencePoint(syntaxTree, span);
+ EmitSequencePoint(syntaxNode.SyntaxTree, span);
_builder.EmitOpCode(ILOpCode.Nop);
_builder.MarkLabel(label);
EmitHiddenSequencePoint();
diff --git a/src/Compilers/CSharp/Portable/CodeGen/EmitAddress.cs b/src/Compilers/CSharp/Portable/CodeGen/EmitAddress.cs
index f6358956bf7d4..c5402c35d4c46 100644
--- a/src/Compilers/CSharp/Portable/CodeGen/EmitAddress.cs
+++ b/src/Compilers/CSharp/Portable/CodeGen/EmitAddress.cs
@@ -409,7 +409,7 @@ private void EmitArrayElementAddress(BoundArrayAccess arrayAccess, AddressKind a
else
{
_builder.EmitArrayElementAddress(_module.Translate((ArrayTypeSymbol)arrayAccess.Expression.Type),
- arrayAccess.Syntax, _diagnostics.DiagnosticBag);
+ arrayAccess.Syntax);
}
}
diff --git a/src/Compilers/CSharp/Portable/CodeGen/EmitArrayInitializer.cs b/src/Compilers/CSharp/Portable/CodeGen/EmitArrayInitializer.cs
index e35d326e09bb6..ef1af66cd6730 100644
--- a/src/Compilers/CSharp/Portable/CodeGen/EmitArrayInitializer.cs
+++ b/src/Compilers/CSharp/Portable/CodeGen/EmitArrayInitializer.cs
@@ -55,7 +55,7 @@ private void EmitArrayInitializers(ArrayTypeSymbol arrayType, BoundArrayInitiali
{
ImmutableArray data = this.GetRawData(initExprs);
- _builder.EmitArrayBlockInitializer(data, inits.Syntax, _diagnostics.DiagnosticBag);
+ _builder.EmitArrayBlockInitializer(data, inits.Syntax);
if (initializationStyle == ArrayInitializerStyle.Mixed)
{
@@ -245,10 +245,9 @@ private bool EnableEnumArrayBlockInitialization
private ArrayInitializerStyle ShouldEmitBlockInitializer(TypeSymbol elementType, ImmutableArray inits)
{
- if (_module.IsEncDelta)
+ if (!_module.FieldRvaSupported)
{
- // Avoid using FieldRva table. Can be allowed if tested on all supported runtimes.
- // Consider removing: https://github.com/dotnet/roslyn/issues/69480
+ // Avoid using FieldRva table when not supported by the runtime.
return ArrayInitializerStyle.Element;
}
@@ -449,10 +448,9 @@ private bool TryEmitOptimizedReadonlySpanCreation(NamedTypeSymbol spanType, Boun
return true;
}
- if (_module.IsEncDelta)
+ if (!_module.FieldRvaSupported)
{
- // Avoid using FieldRva table. Can be allowed if tested on all supported runtimes.
- // Consider removing: https://github.com/dotnet/roslyn/issues/69480
+ // Avoid using FieldRva table when not supported by the runtime.
return false;
}
@@ -556,7 +554,7 @@ private bool TryEmitOptimizedReadonlySpanCreation(NamedTypeSymbol spanType, Boun
// Map a field to the block (that makes it addressable).
var field = _builder.module.GetFieldForData(data, alignment: 1, wrappedExpression.Syntax, _diagnostics.DiagnosticBag);
_builder.EmitOpCode(ILOpCode.Ldsflda);
- _builder.EmitToken(field, wrappedExpression.Syntax, _diagnostics.DiagnosticBag);
+ _builder.EmitToken(field, wrappedExpression.Syntax);
_builder.EmitIntConstant(lengthForConstructor);
@@ -617,7 +615,7 @@ private bool TryEmitOptimizedReadonlySpanCreation(NamedTypeSymbol spanType, Boun
// call ReadOnlySpan RuntimeHelpers::CreateSpan(fldHandle)
var field = _builder.module.GetFieldForData(data, alignment: (ushort)specialElementType.SizeInBytes(), wrappedExpression.Syntax, _diagnostics.DiagnosticBag);
_builder.EmitOpCode(ILOpCode.Ldtoken);
- _builder.EmitToken(field, wrappedExpression.Syntax, _diagnostics.DiagnosticBag);
+ _builder.EmitToken(field, wrappedExpression.Syntax);
_builder.EmitOpCode(ILOpCode.Call, stackAdjustment: 0);
EmitSymbolToken(createSpan.Construct(elementType), wrappedExpression.Syntax, optArgList: null);
return true;
@@ -654,7 +652,7 @@ bool tryEmitAsCachedArrayFromBlob(NamedTypeSymbol spanType, BoundExpression wrap
// T[]? array = PrivateImplementationDetails.cachingField;
// if (array is not null) goto arrayNotNull;
_builder.EmitOpCode(ILOpCode.Ldsfld);
- _builder.EmitToken(cachingField, wrappedExpression.Syntax, _diagnostics.DiagnosticBag);
+ _builder.EmitToken(cachingField, wrappedExpression.Syntax);
_builder.EmitOpCode(ILOpCode.Dup);
_builder.EmitBranch(ILOpCode.Brtrue, arrayNotNullLabel);
@@ -665,10 +663,10 @@ bool tryEmitAsCachedArrayFromBlob(NamedTypeSymbol spanType, BoundExpression wrap
_builder.EmitIntConstant(elementCount);
_builder.EmitOpCode(ILOpCode.Newarr);
EmitSymbolToken(arrayType.ElementType, wrappedExpression.Syntax);
- _builder.EmitArrayBlockInitializer(data, wrappedExpression.Syntax, _diagnostics.DiagnosticBag);
+ _builder.EmitArrayBlockInitializer(data, wrappedExpression.Syntax);
_builder.EmitOpCode(ILOpCode.Dup);
_builder.EmitOpCode(ILOpCode.Stsfld);
- _builder.EmitToken(cachingField, wrappedExpression.Syntax, _diagnostics.DiagnosticBag);
+ _builder.EmitToken(cachingField, wrappedExpression.Syntax);
// arrayNotNullLabel:
// new ReadOnlySpan(array)
@@ -714,7 +712,7 @@ bool tryEmitAsCachedArrayOfConstants(BoundArrayCreation arrayCreation, ArrayType
// T[]? array = PrivateImplementationDetails.cachingField;
// if (array is not null) goto arrayNotNull;
_builder.EmitOpCode(ILOpCode.Ldsfld);
- _builder.EmitToken(cachingField, arrayCreation.Syntax, _diagnostics.DiagnosticBag);
+ _builder.EmitToken(cachingField, arrayCreation.Syntax);
_builder.EmitOpCode(ILOpCode.Dup);
_builder.EmitBranch(ILOpCode.Brtrue, arrayNotNullLabel);
@@ -724,7 +722,7 @@ bool tryEmitAsCachedArrayOfConstants(BoundArrayCreation arrayCreation, ArrayType
EmitExpression(arrayCreation, used: true);
_builder.EmitOpCode(ILOpCode.Dup);
_builder.EmitOpCode(ILOpCode.Stsfld);
- _builder.EmitToken(cachingField, arrayCreation.Syntax, _diagnostics.DiagnosticBag);
+ _builder.EmitToken(cachingField, arrayCreation.Syntax);
// arrayNotNullLabel:
// new ReadOnlySpan(array)
diff --git a/src/Compilers/CSharp/Portable/CodeGen/EmitExpression.cs b/src/Compilers/CSharp/Portable/CodeGen/EmitExpression.cs
index 0b8cfbc2f54b7..c1191eba65e01 100644
--- a/src/Compilers/CSharp/Portable/CodeGen/EmitExpression.cs
+++ b/src/Compilers/CSharp/Portable/CodeGen/EmitExpression.cs
@@ -11,11 +11,11 @@
using System.Runtime.CompilerServices;
using Microsoft.CodeAnalysis.CodeGen;
using Microsoft.CodeAnalysis.CSharp.Symbols;
+using Microsoft.CodeAnalysis.Emit;
using Microsoft.CodeAnalysis.PooledObjects;
using Roslyn.Utilities;
using static System.Linq.ImmutableArrayExtensions;
-using static Microsoft.CodeAnalysis.CSharp.Binder;
namespace Microsoft.CodeAnalysis.CSharp.CodeGen
{
@@ -1098,7 +1098,7 @@ private void EmitArrayElementLoad(BoundArrayAccess arrayAccess, bool used)
}
else
{
- _builder.EmitArrayElementLoad(_module.Translate((ArrayTypeSymbol)arrayAccess.Expression.Type), arrayAccess.Expression.Syntax, _diagnostics.DiagnosticBag);
+ _builder.EmitArrayElementLoad(_module.Translate((ArrayTypeSymbol)arrayAccess.Expression.Type), arrayAccess.Expression.Syntax);
}
EmitPopIfUnused(used);
@@ -2382,7 +2382,7 @@ private void EmitArrayCreationExpression(BoundArrayCreation expression, bool use
}
else
{
- _builder.EmitArrayCreation(_module.Translate(arrayType), expression.Syntax, _diagnostics.DiagnosticBag);
+ _builder.EmitArrayCreation(_module.Translate(arrayType), expression.Syntax);
}
if (expression.InitializerOpt != null)
@@ -3200,7 +3200,7 @@ private void EmitArrayElementStore(ArrayTypeSymbol arrayType, SyntaxNode syntaxN
}
else
{
- _builder.EmitArrayElementStore(_module.Translate(arrayType), syntaxNode, _diagnostics.DiagnosticBag);
+ _builder.EmitArrayElementStore(_module.Translate(arrayType), syntaxNode);
}
}
@@ -3438,7 +3438,7 @@ private void EmitDefaultValue(TypeSymbol type, bool used, SyntaxNode syntaxNode)
var constantValue = type.GetDefaultValue();
if (constantValue != null)
{
- _builder.EmitConstantValue(constantValue);
+ _builder.EmitConstantValue(constantValue, syntaxNode);
return;
}
}
@@ -3474,44 +3474,28 @@ private void EmitDefaultExpression(BoundDefaultExpression expression, bool used)
private void EmitConstantExpression(TypeSymbol type, ConstantValue constantValue, bool used, SyntaxNode syntaxNode)
{
- if (used) // unused constant has no side-effects
+ // unused constant has no side-effects
+ if (!used)
{
- // Null type parameter values must be emitted as 'initobj' rather than 'ldnull'.
- if (((object)type != null) && (type.TypeKind == TypeKind.TypeParameter) && constantValue.IsNull)
- {
- EmitInitObj(type, used, syntaxNode);
- }
- else if (!TryEmitStringLiteralAsUtf8Encoded(constantValue, syntaxNode))
- {
- _builder.EmitConstantValue(constantValue);
- }
+ return;
}
- }
- private bool TryEmitStringLiteralAsUtf8Encoded(ConstantValue constantValue, SyntaxNode syntaxNode)
- {
- // Emit long strings into data section so they don't overflow the UserString heap.
- if (constantValue.IsString &&
- constantValue.StringValue.Length > _module.Compilation.DataSectionStringLiteralThreshold)
+ // Null type parameter values must be emitted as 'initobj' rather than 'ldnull'.
+ if (type is { TypeKind: TypeKind.TypeParameter } && constantValue.IsNull)
{
- if (Binder.GetWellKnownTypeMember(_module.Compilation, WellKnownMember.System_Text_Encoding__get_UTF8, _diagnostics, syntax: syntaxNode) == null |
- Binder.GetWellKnownTypeMember(_module.Compilation, WellKnownMember.System_Text_Encoding__GetString, _diagnostics, syntax: syntaxNode) == null)
- {
- return false;
- }
-
- Cci.IFieldReference field = _module.TryGetOrCreateFieldForStringValue(constantValue.StringValue, syntaxNode, _diagnostics.DiagnosticBag);
- if (field == null)
+ EmitInitObj(type, used, syntaxNode);
+ }
+ else
+ {
+ // TODO: use-site dependencies are not reported to UsedAssemblyReferences https://github.com/dotnet/roslyn/issues/78172
+ if (constantValue.IsString && constantValue.StringValue.Length > _module.Compilation.DataSectionStringLiteralThreshold)
{
- return false;
+ _ = Binder.GetWellKnownTypeMember(_module.Compilation, WellKnownMember.System_Text_Encoding__get_UTF8, _diagnostics, syntax: syntaxNode);
+ _ = Binder.GetWellKnownTypeMember(_module.Compilation, WellKnownMember.System_Text_Encoding__GetString, _diagnostics, syntax: syntaxNode);
}
- _builder.EmitOpCode(ILOpCode.Ldsfld);
- _builder.EmitToken(field, syntaxNode, _diagnostics.DiagnosticBag);
- return true;
+ _builder.EmitConstantValue(constantValue, syntaxNode);
}
-
- return false;
}
private void EmitInitObj(TypeSymbol type, bool used, SyntaxNode syntaxNode)
@@ -3602,7 +3586,7 @@ private void EmitHoistedVariableId(FieldSymbol field, SyntaxNode syntax)
var fieldRef = _module.Translate(field, syntax, _diagnostics.DiagnosticBag, needDeclaration: true);
_builder.EmitOpCode(ILOpCode.Ldtoken);
- _builder.EmitToken(fieldRef, syntax, _diagnostics.DiagnosticBag, Cci.MetadataWriter.RawTokenEncoding.LiftedVariableId);
+ _builder.EmitToken(fieldRef, syntax, Cci.MetadataWriter.RawTokenEncoding.LiftedVariableId);
}
private void EmitMaximumMethodDefIndexExpression(BoundMaximumMethodDefIndex node)
@@ -3628,8 +3612,7 @@ private void EmitModuleVersionIdToken(BoundModuleVersionId node)
{
_builder.EmitToken(
_module.GetModuleVersionId(_module.Translate(node.Type, node.Syntax, _diagnostics.DiagnosticBag), node.Syntax, _diagnostics.DiagnosticBag),
- node.Syntax,
- _diagnostics.DiagnosticBag);
+ node.Syntax);
}
private void EmitThrowIfModuleCancellationRequested(SyntaxNode syntax)
@@ -3639,8 +3622,7 @@ private void EmitThrowIfModuleCancellationRequested(SyntaxNode syntax)
_builder.EmitOpCode(ILOpCode.Ldsflda);
_builder.EmitToken(
_module.GetModuleCancellationToken(_module.Translate(cancellationTokenType, syntax, _diagnostics.DiagnosticBag), syntax, _diagnostics.DiagnosticBag),
- syntax,
- _diagnostics.DiagnosticBag);
+ syntax);
var throwMethod = (MethodSymbol)_module.Compilation.GetWellKnownTypeMember(WellKnownMember.System_Threading_CancellationToken__ThrowIfCancellationRequested);
@@ -3650,8 +3632,7 @@ private void EmitThrowIfModuleCancellationRequested(SyntaxNode syntax)
_builder.EmitOpCode(ILOpCode.Call, -1);
_builder.EmitToken(
_module.Translate(throwMethod, syntax, _diagnostics.DiagnosticBag),
- syntax,
- _diagnostics.DiagnosticBag);
+ syntax);
}
private void EmitModuleCancellationTokenLoad(SyntaxNode syntax)
@@ -3661,8 +3642,7 @@ private void EmitModuleCancellationTokenLoad(SyntaxNode syntax)
_builder.EmitOpCode(ILOpCode.Ldsfld);
_builder.EmitToken(
_module.GetModuleCancellationToken(_module.Translate(cancellationTokenType, syntax, _diagnostics.DiagnosticBag), syntax, _diagnostics.DiagnosticBag),
- syntax,
- _diagnostics.DiagnosticBag);
+ syntax);
}
private void EmitModuleVersionIdStringLoad()
@@ -3685,7 +3665,7 @@ private void EmitInstrumentationPayloadRootStore(BoundInstrumentationPayloadRoot
private void EmitInstrumentationPayloadRootToken(BoundInstrumentationPayloadRoot node)
{
- _builder.EmitToken(_module.GetInstrumentationPayloadRoot(node.AnalysisKind, _module.Translate(node.Type, node.Syntax, _diagnostics.DiagnosticBag), node.Syntax, _diagnostics.DiagnosticBag), node.Syntax, _diagnostics.DiagnosticBag);
+ _builder.EmitToken(_module.GetInstrumentationPayloadRoot(node.AnalysisKind, _module.Translate(node.Type, node.Syntax, _diagnostics.DiagnosticBag), node.Syntax, _diagnostics.DiagnosticBag), node.Syntax);
}
private void EmitSourceDocumentIndex(BoundSourceDocumentIndex node)
diff --git a/src/Compilers/CSharp/Portable/CodeGen/EmitOperators.cs b/src/Compilers/CSharp/Portable/CodeGen/EmitOperators.cs
index 8e90de620d901..87420dd579565 100644
--- a/src/Compilers/CSharp/Portable/CodeGen/EmitOperators.cs
+++ b/src/Compilers/CSharp/Portable/CodeGen/EmitOperators.cs
@@ -461,7 +461,7 @@ private void EmitIsNotNullOrZero(BoundExpression comparand, ConstantValue nullOr
EmitBox(comparandType, comparand.Syntax);
}
- _builder.EmitConstantValue(nullOrZero);
+ _builder.EmitConstantValue(nullOrZero, comparand.Syntax);
_builder.EmitOpCode(ILOpCode.Cgt_un);
}
@@ -475,7 +475,7 @@ private void EmitIsNullOrZero(BoundExpression comparand, ConstantValue nullOrZer
EmitBox(comparandType, comparand.Syntax);
}
- _builder.EmitConstantValue(nullOrZero);
+ _builder.EmitConstantValue(nullOrZero, comparand.Syntax);
_builder.EmitOpCode(ILOpCode.Ceq);
}
diff --git a/src/Compilers/CSharp/Portable/CodeGen/EmitStackAllocInitializer.cs b/src/Compilers/CSharp/Portable/CodeGen/EmitStackAllocInitializer.cs
index d6eadf22b4e2c..b057dfa35f650 100644
--- a/src/Compilers/CSharp/Portable/CodeGen/EmitStackAllocInitializer.cs
+++ b/src/Compilers/CSharp/Portable/CodeGen/EmitStackAllocInitializer.cs
@@ -59,7 +59,7 @@ private void EmitStackAlloc(TypeSymbol type, BoundArrayInitialization? inits, Bo
var field = _builder.module.GetFieldForData(data, alignment: 1, inits.Syntax, _diagnostics.DiagnosticBag);
_builder.EmitOpCode(ILOpCode.Dup);
_builder.EmitOpCode(ILOpCode.Ldsflda);
- _builder.EmitToken(field, inits.Syntax, _diagnostics.DiagnosticBag);
+ _builder.EmitToken(field, inits.Syntax);
_builder.EmitIntConstant(data.Length);
_builder.EmitUnaligned(alignment: 1);
_builder.EmitOpCode(ILOpCode.Cpblk, -3);
@@ -81,10 +81,10 @@ private void EmitStackAlloc(TypeSymbol type, BoundArrayInitialization? inits, Bo
// call ReadOnlySpan RuntimeHelpers::CreateSpan(fldHandle)
var field = _builder.module.GetFieldForData(data, alignment: (ushort)sizeInBytes, syntaxNode, _diagnostics.DiagnosticBag);
_builder.EmitOpCode(ILOpCode.Ldtoken);
- _builder.EmitToken(field, syntaxNode, _diagnostics.DiagnosticBag);
+ _builder.EmitToken(field, syntaxNode);
_builder.EmitOpCode(ILOpCode.Call, 0);
var createSpanHelperReference = createSpanHelper.Construct(elementType).GetCciAdapter();
- _builder.EmitToken(createSpanHelperReference, syntaxNode, _diagnostics.DiagnosticBag);
+ _builder.EmitToken(createSpanHelperReference, syntaxNode);
var temp = AllocateTemp(readOnlySpan, syntaxNode);
_builder.EmitLocalStore(temp);
@@ -128,10 +128,9 @@ void emitLocalloc()
private ArrayInitializerStyle ShouldEmitBlockInitializerForStackAlloc(TypeSymbol elementType, ImmutableArray inits)
{
- if (_module.IsEncDelta)
+ if (!_module.FieldRvaSupported)
{
- // Avoid using FieldRva table. Can be allowed if tested on all supported runtimes.
- // Consider removing: https://github.com/dotnet/roslyn/issues/69480
+ // Avoid using FieldRva table when not supported by the runtime.
return ArrayInitializerStyle.Element;
}
diff --git a/src/Compilers/CSharp/Portable/CodeGen/EmitStatement.cs b/src/Compilers/CSharp/Portable/CodeGen/EmitStatement.cs
index 107a8f02f2481..d2e30eb4e64a2 100644
--- a/src/Compilers/CSharp/Portable/CodeGen/EmitStatement.cs
+++ b/src/Compilers/CSharp/Portable/CodeGen/EmitStatement.cs
@@ -1096,7 +1096,7 @@ private void EmitCatchBlock(BoundCatchBlock catchBlock)
var exceptionType = _module.Translate(catchBlock.ExceptionTypeOpt, catchBlock.Syntax, _diagnostics.DiagnosticBag);
_builder.EmitOpCode(ILOpCode.Isinst);
- _builder.EmitToken(exceptionType, catchBlock.Syntax, _diagnostics.DiagnosticBag);
+ _builder.EmitToken(exceptionType, catchBlock.Syntax);
_builder.EmitOpCode(ILOpCode.Dup);
_builder.EmitBranch(ILOpCode.Brtrue, typeCheckPassedLabel);
_builder.EmitOpCode(ILOpCode.Pop);
@@ -1321,7 +1321,7 @@ private void EmitSwitchHeader(
}
else
{
- _builder.EmitIntegerSwitchJumpTable(switchCaseLabels, fallThroughLabel, key, expression.Type.EnumUnderlyingTypeOrSelf().PrimitiveTypeCode);
+ _builder.EmitIntegerSwitchJumpTable(switchCaseLabels, fallThroughLabel, key, expression.Type.EnumUnderlyingTypeOrSelf().PrimitiveTypeCode, expression.Syntax);
}
if (temp != null)
@@ -1408,7 +1408,10 @@ void emitLengthDispatch(LengthBasedStringSwitchData lengthBasedSwitchInfo, Local
// lengthConstant -> corresponding label
_builder.EmitIntegerSwitchJumpTable(
lengthBasedSwitchInfo.LengthBasedJumpTable.LengthCaseLabels.Select(p => new KeyValuePair(ConstantValue.Create(p.value), p.label)).ToArray(),
- fallThroughLabel, stringLength, int32Type.PrimitiveTypeCode);
+ fallThroughLabel,
+ stringLength,
+ int32Type.PrimitiveTypeCode,
+ syntaxNode);
FreeTemp(stringLength);
}
@@ -1445,7 +1448,10 @@ void emitCharDispatches(LengthBasedStringSwitchData lengthBasedSwitchInfo, Local
// charConstant -> corresponding label
_builder.EmitIntegerSwitchJumpTable(
charJumpTable.CharCaseLabels.Select(p => new KeyValuePair(ConstantValue.Create(p.value), p.label)).ToArray(),
- fallThroughLabel, charTemp, charType.PrimitiveTypeCode);
+ fallThroughLabel,
+ charTemp,
+ charType.PrimitiveTypeCode,
+ syntaxNode);
}
FreeTemp(charTemp);
@@ -1469,7 +1475,7 @@ void emitFinalDispatches(LengthBasedStringSwitchData lengthBasedSwitchInfo, Loca
void emitMethodRef(Microsoft.Cci.IMethodReference lengthMethodRef)
{
var diag = DiagnosticBag.GetInstance();
- _builder.EmitToken(lengthMethodRef, syntaxNode: null, diag);
+ _builder.EmitToken(lengthMethodRef, syntaxNode: null);
Debug.Assert(diag.IsEmptyWithoutResolution);
diag.Free();
}
@@ -1513,7 +1519,7 @@ private void EmitStringSwitchJumpTable(
_builder.EmitLoad(key);
_builder.EmitOpCode(ILOpCode.Call, stackAdjustment: 0);
- _builder.EmitToken(stringHashMethodRef, syntaxNode, _diagnostics.DiagnosticBag);
+ _builder.EmitToken(stringHashMethodRef, syntaxNode);
var UInt32Type = Binder.GetSpecialType(_module.Compilation, SpecialType.System_UInt32, syntaxNode, _diagnostics);
keyHash = AllocateTemp(UInt32Type, syntaxNode);
@@ -1586,7 +1592,7 @@ private void EmitStringSwitchJumpTable(
// Stack: key --> length
_builder.EmitOpCode(ILOpCode.Call, 0);
var diag = DiagnosticBag.GetInstance();
- _builder.EmitToken(lengthMethodRef, null, diag);
+ _builder.EmitToken(lengthMethodRef, null);
Debug.Assert(diag.IsEmptyWithoutResolution);
diag.Free();
@@ -1607,6 +1613,7 @@ private void EmitStringSwitchJumpTable(
};
_builder.EmitStringSwitchJumpTable(
+ syntaxNode,
caseLabels: switchCaseLabels,
fallThroughLabel: fallThroughLabel,
key: key,
@@ -1702,9 +1709,9 @@ private void EmitStringCompareAndBranch(LocalOrParameter key, SyntaxNode syntaxN
// stackAdjustment = (pushCount - popCount) = -1
_builder.EmitLoad(key);
- _builder.EmitConstantValue(stringConstant);
+ _builder.EmitConstantValue(stringConstant, syntaxNode);
_builder.EmitOpCode(ILOpCode.Call, stackAdjustment: -1);
- _builder.EmitToken(stringEqualityMethodRef, syntaxNode, _diagnostics.DiagnosticBag);
+ _builder.EmitToken(stringEqualityMethodRef, syntaxNode);
// Branch to targetLabel if String.Equals returned true.
_builder.EmitBranch(ILOpCode.Brtrue, targetLabel, ILOpCode.Brfalse);
@@ -1729,11 +1736,11 @@ private void EmitCharCompareAndBranch(LocalOrParameter key, SyntaxNode syntaxNod
Debug.Assert(asSpanRef != null);
_builder.EmitLoad(key);
- _builder.EmitConstantValue(stringConstant);
+ _builder.EmitConstantValue(stringConstant, syntaxNode);
_builder.EmitOpCode(ILOpCode.Call, stackAdjustment: 0);
- _builder.EmitToken(asSpanRef, syntaxNode, _diagnostics.DiagnosticBag);
+ _builder.EmitToken(asSpanRef, syntaxNode);
_builder.EmitOpCode(ILOpCode.Call, stackAdjustment: -1);
- _builder.EmitToken(sequenceEqualsRef, syntaxNode, _diagnostics.DiagnosticBag);
+ _builder.EmitToken(sequenceEqualsRef, syntaxNode);
// Branch to targetLabel if SequenceEquals returned true.
_builder.EmitBranch(ILOpCode.Brtrue, targetLabel, ILOpCode.Brfalse);
diff --git a/src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs b/src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs
index e23c3b07ded64..8e04aaa7840d3 100644
--- a/src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs
+++ b/src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs
@@ -3683,7 +3683,7 @@ private void GenerateModuleInitializer(PEModuleBuilder moduleBeingBuilt, Diagnos
if (_moduleInitializerMethods is object)
{
- var ilBuilder = new ILBuilder(moduleBeingBuilt, new LocalSlotManager(slotAllocator: null), OptimizationLevel.Release, areLocalsZeroed: false);
+ var ilBuilder = new ILBuilder(moduleBeingBuilt, new LocalSlotManager(slotAllocator: null), methodBodyDiagnosticBag, OptimizationLevel.Release, areLocalsZeroed: false);
foreach (MethodSymbol method in _moduleInitializerMethods.OrderBy(LexicalOrderSymbolComparer.Instance))
{
@@ -3691,8 +3691,7 @@ private void GenerateModuleInitializer(PEModuleBuilder moduleBeingBuilt, Diagnos
ilBuilder.EmitToken(
moduleBeingBuilt.Translate(method, methodBodyDiagnosticBag, needDeclaration: true),
- CSharpSyntaxTree.Dummy.GetRoot(),
- methodBodyDiagnosticBag);
+ CSharpSyntaxTree.Dummy.GetRoot());
}
ilBuilder.EmitRet(isVoid: true);
@@ -3778,6 +3777,7 @@ internal override EmitDifferenceResult EmitDifference(
Stream metadataStream,
Stream ilStream,
Stream pdbStream,
+ EmitDifferenceOptions options,
CompilationTestData? testData,
CancellationToken cancellationToken)
{
@@ -3789,6 +3789,7 @@ internal override EmitDifferenceResult EmitDifference(
metadataStream,
ilStream,
pdbStream,
+ options,
testData,
cancellationToken);
}
diff --git a/src/Compilers/CSharp/Portable/Compiler/MethodCompiler.cs b/src/Compilers/CSharp/Portable/Compiler/MethodCompiler.cs
index 1c996f88d1366..c4ebcd04da684 100644
--- a/src/Compilers/CSharp/Portable/Compiler/MethodCompiler.cs
+++ b/src/Compilers/CSharp/Portable/Compiler/MethodCompiler.cs
@@ -27,17 +27,18 @@ namespace Microsoft.CodeAnalysis.CSharp
{
internal sealed class MethodCompiler : CSharpSymbolVisitor
{
+#nullable enable
private readonly CSharpCompilation _compilation;
private readonly bool _emittingPdb;
private readonly CancellationToken _cancellationToken;
private readonly BindingDiagnosticBag _diagnostics;
private readonly bool _hasDeclarationErrors;
private readonly bool _emitMethodBodies;
- private readonly PEModuleBuilder _moduleBeingBuiltOpt; // Null if compiling for diagnostics
- private readonly Predicate _filterOpt; // If not null, limit analysis to specific symbols
- private readonly SynthesizedEntryPointSymbol.AsyncForwardEntryPoint _entryPointOpt;
+ private readonly PEModuleBuilder? _moduleBeingBuiltOpt; // Null if compiling for diagnostics
+ private readonly Predicate? _filterOpt; // If not null, limit analysis to specific symbols
+ private readonly SynthesizedEntryPointSymbol.AsyncForwardEntryPoint? _entryPointOpt;
- private DebugDocumentProvider _lazyDebugDocumentProvider;
+ private DebugDocumentProvider? _lazyDebugDocumentProvider;
//
// MethodCompiler employs concurrency by following flattened fork/join pattern.
@@ -54,7 +55,7 @@ internal sealed class MethodCompiler : CSharpSymbolVisitor _compilerTasks;
+ private ConcurrentStack? _compilerTasks;
// This field tracks whether any bound method body had hasErrors set or whether any constant field had a bad value.
// We track it so that we can abort emission in the event that an error occurs without a corresponding diagnostic
@@ -83,8 +84,8 @@ private void SetGlobalErrorIfTrue(bool arg)
}
// Internal for testing only.
- internal MethodCompiler(CSharpCompilation compilation, PEModuleBuilder moduleBeingBuiltOpt, bool emittingPdb, bool hasDeclarationErrors, bool emitMethodBodies,
- BindingDiagnosticBag diagnostics, Predicate filterOpt, SynthesizedEntryPointSymbol.AsyncForwardEntryPoint entryPointOpt, CancellationToken cancellationToken)
+ internal MethodCompiler(CSharpCompilation compilation, PEModuleBuilder? moduleBeingBuiltOpt, bool emittingPdb, bool hasDeclarationErrors, bool emitMethodBodies,
+ BindingDiagnosticBag diagnostics, Predicate? filterOpt, SynthesizedEntryPointSymbol.AsyncForwardEntryPoint? entryPointOpt, CancellationToken cancellationToken)
{
Debug.Assert(compilation != null);
Debug.Assert(diagnostics != null);
@@ -107,12 +108,12 @@ internal MethodCompiler(CSharpCompilation compilation, PEModuleBuilder moduleBei
public static void CompileMethodBodies(
CSharpCompilation compilation,
- PEModuleBuilder moduleBeingBuiltOpt,
+ PEModuleBuilder? moduleBeingBuiltOpt,
bool emittingPdb,
bool hasDeclarationErrors,
bool emitMethodBodies,
BindingDiagnosticBag diagnostics,
- Predicate filterOpt,
+ Predicate? filterOpt,
CancellationToken cancellationToken)
{
Debug.Assert(compilation != null);
@@ -132,7 +133,7 @@ public static void CompileMethodBodies(
// TODO: revise to use a loop instead of a recursion
}
- MethodSymbol entryPoint = null;
+ MethodSymbol? entryPoint = null;
if (filterOpt is null)
{
entryPoint = GetEntryPoint(compilation, moduleBeingBuiltOpt, hasDeclarationErrors, emitMethodBodies, diagnostics, cancellationToken);
@@ -182,6 +183,11 @@ public static void CompileMethodBodies(
methodCompiler.WaitForWorkers();
+ // Deleted definitions must be emitted before PrivateImplementationDetails are frozen since
+ // it may add new members to it. All changes to PrivateImplementationDetails are additions,
+ // so we don't need to create deleted method defs for those.
+ moduleBeingBuiltOpt.CreateDeletedMethodDefinitions(diagnostics.DiagnosticBag);
+
// all threads that were adding methods must be finished now, we can freeze the class:
var privateImplClass = moduleBeingBuiltOpt.FreezePrivateImplementationDetails();
if (privateImplClass != null)
@@ -197,7 +203,7 @@ public static void CompileMethodBodies(
if (moduleBeingBuiltOpt != null && (methodCompiler._globalHasErrors || moduleBeingBuiltOpt.SourceModule.HasBadAttributes) && !diagnostics.HasAnyErrors() && !hasDeclarationErrors)
{
var messageResourceName = methodCompiler._globalHasErrors ? nameof(CodeAnalysisResources.UnableToDetermineSpecificCauseOfFailure) : nameof(CodeAnalysisResources.ModuleHasInvalidAttributes);
- diagnostics.Add(ErrorCode.ERR_ModuleEmitFailure, NoLocation.Singleton, ((Cci.INamedEntity)moduleBeingBuiltOpt).Name,
+ diagnostics.Add(ErrorCode.ERR_ModuleEmitFailure, NoLocation.Singleton, ((Cci.INamedEntity)moduleBeingBuiltOpt).Name!,
new LocalizableResourceString(messageResourceName, CodeAnalysisResources.ResourceManager, typeof(CodeAnalysisResources)));
}
@@ -214,7 +220,7 @@ public static void CompileMethodBodies(
}
}
}
-
+#nullable disable
// Returns the MethodSymbol for the assembly entrypoint. If the user has a Task returning main,
// this function returns the synthesized Main MethodSymbol.
internal static MethodSymbol GetEntryPoint(CSharpCompilation compilation, PEModuleBuilder moduleBeingBuilt, bool hasDeclarationErrors, bool emitMethodBodies, BindingDiagnosticBag diagnostics, CancellationToken cancellationToken)
@@ -1385,6 +1391,7 @@ forSemanticModel.Syntax is { } semanticModelSyntax &&
}
}
+#nullable enable
private void EmitSkeletonMethodInExtension(MethodSymbol methodSymbol)
{
if (!_emitMethodBodies)
@@ -1392,7 +1399,10 @@ private void EmitSkeletonMethodInExtension(MethodSymbol methodSymbol)
return;
}
- ILBuilder builder = new ILBuilder(_moduleBeingBuiltOpt, new LocalSlotManager(slotAllocator: null), OptimizationLevel.Release, areLocalsZeroed: false);
+ Debug.Assert(_diagnostics.DiagnosticBag != null);
+ Debug.Assert(_moduleBeingBuiltOpt != null);
+
+ ILBuilder builder = new ILBuilder(_moduleBeingBuiltOpt, new LocalSlotManager(slotAllocator: null), _diagnostics.DiagnosticBag, OptimizationLevel.Release, areLocalsZeroed: false);
// Emit methods in extensions as skeletons:
// => throw null;
@@ -1423,16 +1433,15 @@ private void EmitSkeletonMethodInExtension(MethodSymbol methodSymbol)
orderedLambdaRuntimeRudeEdits: ImmutableArray.Empty,
closureDebugInfo: ImmutableArray.Empty,
stateMachineTypeNameOpt: null,
- stateMachineHoistedLocalScopes: default(ImmutableArray),
- stateMachineHoistedLocalSlots: default(ImmutableArray),
- stateMachineAwaiterSlots: default(ImmutableArray),
+ stateMachineHoistedLocalScopes: default,
+ stateMachineHoistedLocalSlots: default,
+ stateMachineAwaiterSlots: default,
StateMachineStatesDebugInfo.Create(variableSlotAllocator: null, ImmutableArray.Empty),
stateMachineMoveNextDebugInfoOpt: null,
codeCoverageSpans: ImmutableArray.Empty,
- isPrimaryConstructor: false)
- );
+ isPrimaryConstructor: false));
}
-
+#nullable disable
private static MethodSymbol GetSymbolForEmittedBody(MethodSymbol methodSymbol)
{
return methodSymbol.PartialDefinitionPart ?? methodSymbol;
@@ -1604,9 +1613,11 @@ private static MethodBody GenerateMethodBody(
var localSlotManager = new LocalSlotManager(variableSlotAllocatorOpt);
var optimizations = compilation.Options.OptimizationLevel;
- ILBuilder builder = new ILBuilder(moduleBuilder, localSlotManager, optimizations, method.AreLocalsZeroed);
- bool hasStackalloc;
var diagnosticsForThisMethod = BindingDiagnosticBag.GetInstance(withDiagnostics: true, diagnostics.AccumulatesDependencies);
+ Debug.Assert(diagnosticsForThisMethod.DiagnosticBag != null);
+
+ ILBuilder builder = new ILBuilder(moduleBuilder, localSlotManager, diagnosticsForThisMethod.DiagnosticBag, optimizations, method.AreLocalsZeroed);
+ bool hasStackalloc;
try
{
StateMachineMoveNextBodyDebugInfo moveNextBodyDebugInfoOpt = null;
diff --git a/src/Compilers/CSharp/Portable/Emitter/EditAndContinue/CSharpSymbolMatcher.cs b/src/Compilers/CSharp/Portable/Emitter/EditAndContinue/CSharpSymbolMatcher.cs
index 7e7f5a4f29ad0..c09438b4b510a 100644
--- a/src/Compilers/CSharp/Portable/Emitter/EditAndContinue/CSharpSymbolMatcher.cs
+++ b/src/Compilers/CSharp/Portable/Emitter/EditAndContinue/CSharpSymbolMatcher.cs
@@ -57,9 +57,17 @@ public CSharpSymbolMatcher(
// For simplicity, PID helpers and no-PIA embedded definitions are not reused across generations, so we don't map them here.
// Instead, new ones are regenerated as needed.
- Debug.Assert(definition is PrivateImplementationDetails or Cci.IEmbeddedDefinition);
+
+ Debug.Assert(
+ definition is Cci.IEmbeddedDefinition ||
+ isPrivateImplementationDetail(definition),
+ $"Unexpected definition of type: {definition.GetType()}");
return null;
+
+ static bool isPrivateImplementationDetail(Cci.IDefinition definition)
+ => definition is PrivateImplementationDetails ||
+ definition is Cci.ITypeDefinitionMember { ContainingTypeDefinition: var container } && isPrivateImplementationDetail(container);
}
public override Cci.INamespace? MapNamespace(Cci.INamespace @namespace)
diff --git a/src/Compilers/CSharp/Portable/Emitter/EditAndContinue/EmitHelpers.cs b/src/Compilers/CSharp/Portable/Emitter/EditAndContinue/EmitHelpers.cs
index 020e601857447..03e2185b727f7 100644
--- a/src/Compilers/CSharp/Portable/Emitter/EditAndContinue/EmitHelpers.cs
+++ b/src/Compilers/CSharp/Portable/Emitter/EditAndContinue/EmitHelpers.cs
@@ -28,6 +28,7 @@ internal static EmitDifferenceResult EmitDifference(
Stream metadataStream,
Stream ilStream,
Stream pdbStream,
+ EmitDifferenceOptions options,
CompilationTestData? testData,
CancellationToken cancellationToken)
{
@@ -94,6 +95,7 @@ internal static EmitDifferenceResult EmitDifference(
compilation.SourceAssembly,
changes,
emitOptions: emitOptions,
+ options: options,
outputKind: compilation.Options.OutputKind,
serializationProperties: serializationProperties,
manifestResources: manifestResources,
@@ -130,7 +132,6 @@ internal static EmitDifferenceResult EmitDifference(
newBaseline = compilation.SerializeToDeltaStreams(
moduleBeingBuilt,
definitionMap,
- changes,
metadataStream,
ilStream,
pdbStream,
diff --git a/src/Compilers/CSharp/Portable/Emitter/EditAndContinue/PEDeltaAssemblyBuilder.cs b/src/Compilers/CSharp/Portable/Emitter/EditAndContinue/PEDeltaAssemblyBuilder.cs
index c565c056a507c..08e1d677504f8 100644
--- a/src/Compilers/CSharp/Portable/Emitter/EditAndContinue/PEDeltaAssemblyBuilder.cs
+++ b/src/Compilers/CSharp/Portable/Emitter/EditAndContinue/PEDeltaAssemblyBuilder.cs
@@ -25,6 +25,7 @@ internal sealed class PEDeltaAssemblyBuilder : PEAssemblyBuilderBase, IPEDeltaAs
private readonly SymbolChanges _changes;
private readonly CSharpSymbolMatcher.DeepTranslator _deepTranslator;
private readonly MethodSymbol? _predefinedHotReloadExceptionConstructor;
+ private readonly EmitDifferenceOptions _options;
///
/// HotReloadException type. May be created even if not used. We might find out
@@ -47,6 +48,7 @@ public PEDeltaAssemblyBuilder(
SourceAssemblySymbol sourceAssembly,
CSharpSymbolChanges changes,
EmitOptions emitOptions,
+ EmitDifferenceOptions options,
OutputKind outputKind,
Cci.ModulePropertiesForSerialization serializationProperties,
IEnumerable manifestResources,
@@ -54,6 +56,7 @@ public PEDeltaAssemblyBuilder(
: base(sourceAssembly, emitOptions, outputKind, serializationProperties, manifestResources, additionalTypes: [])
{
_changes = changes;
+ _options = options;
// Workaround for https://github.com/dotnet/roslyn/issues/3192.
// When compiling state machine we stash types of awaiters and state-machine hoisted variables,
@@ -74,6 +77,7 @@ public PEDeltaAssemblyBuilder(
public override SymbolChanges? EncSymbolChanges => _changes;
public override EmitBaseline PreviousGeneration => _changes.DefinitionMap.Baseline;
+ public override bool FieldRvaSupported => _options.EmitFieldRva;
internal override Cci.ITypeReference EncTranslateLocalVariableType(TypeSymbol type, DiagnosticBag diagnostics)
{
@@ -234,7 +238,7 @@ public SynthesizedTypeMaps GetSynthesizedTypes()
}
public override IEnumerable GetTopLevelTypeDefinitions(EmitContext context)
- => GetTopLevelTypeDefinitionsCore(context);
+ => GetTopLevelTypeDefinitionsExcludingNoPiaAndRootModule(context, includePrivateImplementationDetails: true);
public override IEnumerable GetTopLevelSourceTypeDefinitions(EmitContext context)
{
diff --git a/src/Compilers/CSharp/Portable/Emitter/Model/PEAssemblyBuilder.cs b/src/Compilers/CSharp/Portable/Emitter/Model/PEAssemblyBuilder.cs
index 5244d968826cc..8f884e92d2e00 100644
--- a/src/Compilers/CSharp/Portable/Emitter/Model/PEAssemblyBuilder.cs
+++ b/src/Compilers/CSharp/Portable/Emitter/Model/PEAssemblyBuilder.cs
@@ -65,7 +65,7 @@ internal abstract class PEAssemblyBuilderBase : PEModuleBuilder, Cci.IAssemblyRe
///
private readonly string _metadataName;
#nullable enable
- public PEAssemblyBuilderBase(
+ protected PEAssemblyBuilderBase(
SourceAssemblySymbol sourceAssembly,
EmitOptions emitOptions,
OutputKind outputKind,
@@ -654,6 +654,7 @@ internal sealed class PEAssemblyBuilder(
{
public override EmitBaseline? PreviousGeneration => null;
public override SymbolChanges? EncSymbolChanges => null;
+ public override bool FieldRvaSupported => true;
public override INamedTypeSymbolInternal? TryGetOrCreateSynthesizedHotReloadExceptionType()
=> null;
diff --git a/src/Compilers/CSharp/Portable/Emitter/Model/PEModuleBuilder.cs b/src/Compilers/CSharp/Portable/Emitter/Model/PEModuleBuilder.cs
index 19cb20430e9bf..38f5669225f37 100644
--- a/src/Compilers/CSharp/Portable/Emitter/Model/PEModuleBuilder.cs
+++ b/src/Compilers/CSharp/Portable/Emitter/Model/PEModuleBuilder.cs
@@ -73,7 +73,7 @@ private void SetNeedsGeneratedAttributes(EmbeddableAttributes attributes)
ThreadSafeFlagOperations.Set(ref _needsGeneratedAttributes, (int)attributes);
}
- internal PEModuleBuilder(
+ protected PEModuleBuilder(
SourceModuleSymbol sourceModule,
EmitOptions emitOptions,
OutputKind outputKind,
diff --git a/src/Compilers/CSharp/Portable/Emitter/Model/PENetModuleBuilder.cs b/src/Compilers/CSharp/Portable/Emitter/Model/PENetModuleBuilder.cs
index 44acf7e6ee24a..576881232a380 100644
--- a/src/Compilers/CSharp/Portable/Emitter/Model/PENetModuleBuilder.cs
+++ b/src/Compilers/CSharp/Portable/Emitter/Model/PENetModuleBuilder.cs
@@ -38,6 +38,7 @@ protected override void AddEmbeddedResourcesFromAddedModules(ArrayBuilder null;
public override SymbolChanges? EncSymbolChanges => null;
+ public override bool FieldRvaSupported => true;
public override INamedTypeSymbolInternal? TryGetOrCreateSynthesizedHotReloadExceptionType()
=> null;
diff --git a/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs b/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
index 25ba50f1a42e3..7211e43d60c83 100644
--- a/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
+++ b/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
@@ -2408,6 +2408,8 @@ internal enum ErrorCode
ERR_PPShebangInProjectBasedProgram = 9314,
+ ERR_TooManyUserStrings_RestartRequired = 9315,
+
// Note: you will need to do the following after adding errors:
// 1) Update ErrorFacts.IsBuildOnlyDiagnostic (src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs)
// 2) Add message to CSharpResources.resx
diff --git a/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs b/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs
index 8a8498acc0013..278cbd4318a8a 100644
--- a/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs
+++ b/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs
@@ -1726,6 +1726,7 @@ or ErrorCode.ERR_BadAwaitInStaticVariableInitializer
or ErrorCode.ERR_InvalidPathMap
or ErrorCode.ERR_PublicSignButNoKey
or ErrorCode.ERR_TooManyUserStrings
+ or ErrorCode.ERR_TooManyUserStrings_RestartRequired
or ErrorCode.ERR_PeWritingFailure
or ErrorCode.WRN_AttributeIgnoredWhenPublicSigning
or ErrorCode.ERR_OptionMustBeAbsolutePath
diff --git a/src/Compilers/CSharp/Portable/Errors/MessageProvider.cs b/src/Compilers/CSharp/Portable/Errors/MessageProvider.cs
index ba05a944c54bd..059ec8b9672e4 100644
--- a/src/Compilers/CSharp/Portable/Errors/MessageProvider.cs
+++ b/src/Compilers/CSharp/Portable/Errors/MessageProvider.cs
@@ -245,6 +245,7 @@ public override void ReportDuplicateMetadataReferenceWeak(DiagnosticBag diagnost
public override int ERR_MetadataNameTooLong => (int)ErrorCode.ERR_MetadataNameTooLong;
public override int ERR_EncReferenceToAddedMember => (int)ErrorCode.ERR_EncReferenceToAddedMember;
public override int ERR_TooManyUserStrings => (int)ErrorCode.ERR_TooManyUserStrings;
+ public override int ERR_TooManyUserStrings_RestartRequired => (int)ErrorCode.ERR_TooManyUserStrings_RestartRequired;
public override int ERR_PeWritingFailure => (int)ErrorCode.ERR_PeWritingFailure;
public override int ERR_ModuleEmitFailure => (int)ErrorCode.ERR_ModuleEmitFailure;
public override int ERR_EncUpdateFailedMissingSymbol => (int)ErrorCode.ERR_EncUpdateFailedMissingSymbol;
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf
index 7b6ef24f74a69..37ae8bfc426e4 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf
@@ -2397,6 +2397,11 @@
Literál nezpracovaného řetězce nezačíná dostatečným počtem uvozovek, aby bylo možné tento počet po sobě jdoucích znaků uvozovek povolit jako obsah.
+
+ Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.
+ Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.
+
+
Top-level statements must precede namespace and type declarations.
Příkazy nejvyšší úrovně se musí nacházet před obory názvů a deklaracemi typů.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf
index ce1baff1c7ab2..e481e2a789344 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf
@@ -2397,6 +2397,11 @@
Das Rohzeichenfolgenliteral beginnt nicht mit genügend Anführungszeichen, um so viele aufeinanderfolgende Anführungszeichen als Inhalt zuzulassen.
+
+ Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.
+ Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.
+
+
Top-level statements must precede namespace and type declarations.
Anweisungen der obersten Ebene müssen vor Namespace- und Typdeklarationen stehen.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf
index d14f5fbc2aa2d..3dcae73e93f47 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf
@@ -2397,6 +2397,11 @@
El literal de cadena sin formato no comienza con suficientes comillas para permitir tantas comillas consecutivas como contenido.
+
+ Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.
+ Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.
+
+
Top-level statements must precede namespace and type declarations.
Las instrucciones de nivel superior deben preceder a las declaraciones de espacio de nombres y de tipos.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf
index a0db1f39b8732..73299c0f6772f 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf
@@ -2397,6 +2397,11 @@
Le littéral brut de la chaîne de caractères ne commence pas par un nombre suffisant de caractères de guillemets pour autoriser un tel nombre de caractères de guillemets consécutifs comme contenu.
+
+ Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.
+ Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.
+
+
Top-level statements must precede namespace and type declarations.
Les instructions de niveau supérieur doivent précéder les déclarations d'espace de noms et de type.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf
index 4776064d30d8f..ca9c6d183269e 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf
@@ -2397,6 +2397,11 @@
Il valore letterale stringa non elaborato non inizia con un numero sufficiente di virgolette per consentire questo numero di virgolette consecutive come contenuto.
+
+ Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.
+ Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.
+
+
Top-level statements must precede namespace and type declarations.
Le istruzioni di primo livello devono precedere le dichiarazioni di tipo e di spazio dei nomi.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf
index 67daf55e4fd5a..64ffd6274eeff 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf
@@ -2397,6 +2397,11 @@
生文字列リテラルの先頭に十分な数の引用符文字がないため、連続した引用符文字をコンテンツとして使用できません。
+
+ Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.
+ Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.
+
+
Top-level statements must precede namespace and type declarations.
トップレベルのステートメントは、名前空間および型の宣言の前にある必要があります。
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf
index 445c283cdecb1..7c16a674e240b 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf
@@ -2397,6 +2397,11 @@
원시 문자열 리터럴을 시작하는 따옴표 문자가 부족해 이렇게 많은 따옴표 문자를 콘텐츠로 사용할 수 없습니다.
+
+ Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.
+ Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.
+
+
Top-level statements must precede namespace and type declarations.
최상위 문은 네임스페이스 및 형식 선언 앞에 와야 합니다.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf
index 92320e99565ad..40a51a9d7aba7 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf
@@ -2397,6 +2397,11 @@
Nieprzetworzony literał ciągu nie rozpoczyna się od wystarczającej liczby znaków cudzysłowu, aby umożliwić używanie tak wielu kolejnych znaków cudzysłowu jako zawartości.
+
+ Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.
+ Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.
+
+
Top-level statements must precede namespace and type declarations.
Instrukcje najwyższego poziomu muszą poprzedzać deklaracje przestrzeni nazw i typów.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf
index 963929d643cd1..133576185f638 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf
@@ -2397,6 +2397,11 @@
A literal da cadeia de caracteres bruta não começa com caracteres de aspa suficientes para permitir esse número de caracteres de aspa consecutivos como conteúdo.
+
+ Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.
+ Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.
+
+
Top-level statements must precede namespace and type declarations.
As instruções de nível superior precisam preceder as declarações de namespace e de tipo.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf
index afe4e0b90bd80..30b7d953160bf 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf
@@ -2397,6 +2397,11 @@
Литерал необработанной строки не начинается с достаточного количества символов кавычек, чтобы разрешить использовать такое же количество последовательных символов кавычек в качестве содержимого.
+
+ Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.
+ Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.
+
+
Top-level statements must precede namespace and type declarations.
Инструкции верхнего уровня должны предшествовать объявлениям пространств имен и типов.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf
index 9015530c02117..2c46ca1dae051 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf
@@ -2397,6 +2397,11 @@
Ham dize sabit değeri, içerik olarak bu kadar çok ardışık tırnak işareti karakterine izin vermek için yeterli sayıda tırnak işareti karakteriyle başlamıyor.
+
+ Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.
+ Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.
+
+
Top-level statements must precede namespace and type declarations.
Üst düzey deyimler ad alanı ve tür bildirimlerinden önce gelmelidir.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf
index d92f7af8a95a5..8ca0b9a047b72 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf
@@ -2397,6 +2397,11 @@
原始字符串字面量的开头没有足够的引号字符以允许将这么多连续的引号字符作为内容。
+
+ Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.
+ Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.
+
+
Top-level statements must precede namespace and type declarations.
顶级语句必须位于命名空间和类型声明之前。
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf
index 0688757833c5b..04b102802f385 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf
@@ -2397,6 +2397,11 @@
原始字串常值開頭沒有足夠的引號字元,因此無法允許這麼多連續的引號字元做為內容。
+
+ Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.
+ Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.
+
+
Top-level statements must precede namespace and type declarations.
最上層陳述式必須在命名空間和型別宣告之前。
diff --git a/src/Compilers/CSharp/Test/Emit/Emit/EmitErrorTests.cs b/src/Compilers/CSharp/Test/Emit/Emit/EmitErrorTests.cs
index d522c10deec21..0c63bf61d1e25 100644
--- a/src/Compilers/CSharp/Test/Emit/Emit/EmitErrorTests.cs
+++ b/src/Compilers/CSharp/Test/Emit/Emit/EmitErrorTests.cs
@@ -341,8 +341,12 @@ public static void Main ()
var expectedDiagnostics = new[]
{
- // error CS8103: Combined length of user strings used by the program exceeds allowed limit. Try to decrease use of string literals or try the EXPERIMENTAL feature flag 'experimental-data-section-string-literals'.
- Diagnostic(ErrorCode.ERR_TooManyUserStrings).WithLocation(1, 1)
+ // (15,26): error CS8103: Combined length of user strings used by the program exceeds allowed limit. Try to decrease use of string literals or try the EXPERIMENTAL feature flag 'experimental-data-section-string-literals'.
+ // System.Console.WriteLine("J...J");
+ Diagnostic(ErrorCode.ERR_TooManyUserStrings, '"' + new string('J', 1000000) + '"').WithLocation(15, 26),
+ // (16,26): error CS8103: Combined length of user strings used by the program exceeds allowed limit. Try to decrease use of string literals or try the EXPERIMENTAL feature flag 'experimental-data-section-string-literals'.
+ // System.Console.WriteLine("K...K");
+ Diagnostic(ErrorCode.ERR_TooManyUserStrings, '"' + new string('K', 1000000) + '"').WithLocation(16, 26)
};
CreateCompilation(source).VerifyEmitDiagnostics(expectedDiagnostics);
diff --git a/src/Compilers/CSharp/Test/Emit/Emit/EmitMetadataTests.cs b/src/Compilers/CSharp/Test/Emit/Emit/EmitMetadataTests.cs
index c8577b654b471..484d3f8c0f0bc 100644
--- a/src/Compilers/CSharp/Test/Emit/Emit/EmitMetadataTests.cs
+++ b/src/Compilers/CSharp/Test/Emit/Emit/EmitMetadataTests.cs
@@ -3144,6 +3144,65 @@ .maxstack 1
Assert.Equal(0, verifier.Compilation.DataSectionStringLiteralThreshold);
}
+ [Fact]
+ public void DataSectionStringLiterals_Switch()
+ {
+ var source = """
+ System.Console.Write(args[0] switch
+ {
+ "a" => 1,
+ "bb" => 2,
+ "ccc" => 3,
+ _ => 4
+ });
+ """;
+
+ var verifier = CompileAndVerify(
+ source,
+ parseOptions: TestOptions.Regular.WithFeature("experimental-data-section-string-literals", "0"),
+ verify: Verification.Skipped);
+
+ verifier.VerifyIL("", """
+ {
+ // Code size 66 (0x42)
+ .maxstack 2
+ .locals init (int V_0,
+ string V_1)
+ IL_0000: ldarg.0
+ IL_0001: ldc.i4.0
+ IL_0002: ldelem.ref
+ IL_0003: stloc.1
+ IL_0004: ldloc.1
+ IL_0005: ldsfld "string .A96FAF705AF16834E6C632B61E964E1F.s"
+ IL_000a: call "bool string.op_Equality(string, string)"
+ IL_000f: brtrue.s IL_002d
+ IL_0011: ldloc.1
+ IL_0012: ldsfld "string .DB1DE4B3DA6C7871B776D5CB968AA5A4.s"
+ IL_0017: call "bool string.op_Equality(string, string)"
+ IL_001c: brtrue.s IL_0031
+ IL_001e: ldloc.1
+ IL_001f: ldsfld "string .BE20CA004CC2993A396345E0D52DF013.s"
+ IL_0024: call "bool string.op_Equality(string, string)"
+ IL_0029: brtrue.s IL_0035
+ IL_002b: br.s IL_0039
+ IL_002d: ldc.i4.1
+ IL_002e: stloc.0
+ IL_002f: br.s IL_003b
+ IL_0031: ldc.i4.2
+ IL_0032: stloc.0
+ IL_0033: br.s IL_003b
+ IL_0035: ldc.i4.3
+ IL_0036: stloc.0
+ IL_0037: br.s IL_003b
+ IL_0039: ldc.i4.4
+ IL_003a: stloc.0
+ IL_003b: ldloc.0
+ IL_003c: call "void System.Console.Write(int)"
+ IL_0041: ret
+ }
+ """);
+ }
+
[Fact]
public void DataSectionStringLiterals_InvalidUtf8()
{
diff --git a/src/Compilers/CSharp/Test/Emit2/Emit/EditAndContinue/AssemblyReferencesTests.cs b/src/Compilers/CSharp/Test/Emit2/Emit/EditAndContinue/AssemblyReferencesTests.cs
index 7a67122fa4787..f1cd2f3208240 100644
--- a/src/Compilers/CSharp/Test/Emit2/Emit/EditAndContinue/AssemblyReferencesTests.cs
+++ b/src/Compilers/CSharp/Test/Emit2/Emit/EditAndContinue/AssemblyReferencesTests.cs
@@ -81,9 +81,13 @@ class C
compilation1.GlobalNamespace.GetMember("C").GetMember("Main"))
};
- compilation1.EmitDifference(baseline, edits, s => false, mdStream, ilStream, pdbStream);
+ compilation1.EmitDifference(baseline, edits, s => false, mdStream, ilStream, pdbStream, EmitDifferenceOptions.Default, CancellationToken.None);
- var actualIL = ImmutableArray.Create(ilStream.ToArray()).GetMethodIL();
+ var il = ImmutableArray.Create(ilStream.ToArray());
+ mdStream.Position = 0;
+ using var mdReaderProvider = MetadataReaderProvider.FromMetadataStream(mdStream);
+
+ var actualIL = ILValidation.DumpEncDeltaMethodBodies(il, [mdReaderProvider.GetMetadataReader()]);
var expectedIL = @"
{
// Code size 7 (0x7)
@@ -153,9 +157,13 @@ class C
compilation1.GlobalNamespace.GetMember("C").GetMember("Main"))
};
- compilation1.EmitDifference(baseline, edits, s => false, mdStream, ilStream, pdbStream);
+ compilation1.EmitDifference(baseline, edits, s => false, mdStream, ilStream, pdbStream, EmitDifferenceOptions.Default, CancellationToken.None);
+
+ var il = ImmutableArray.Create(ilStream.ToArray());
+ mdStream.Position = 0;
+ using var mdReaderProvider = MetadataReaderProvider.FromMetadataStream(mdStream);
- var actualIL = ImmutableArray.Create(ilStream.ToArray()).GetMethodIL();
+ var actualIL = ILValidation.DumpEncDeltaMethodBodies(il, [mdReaderProvider.GetMetadataReader()]);
// Symbol matcher should ignore overloads with missing type symbols and match
// F(object).
diff --git a/src/Compilers/CSharp/Test/Emit2/Emit/EditAndContinue/EditAndContinueClosureTests.cs b/src/Compilers/CSharp/Test/Emit2/Emit/EditAndContinue/EditAndContinueClosureTests.cs
index 4f4d3c84cdba9..4b5b85deef2b2 100644
--- a/src/Compilers/CSharp/Test/Emit2/Emit/EditAndContinue/EditAndContinueClosureTests.cs
+++ b/src/Compilers/CSharp/Test/Emit2/Emit/EditAndContinue/EditAndContinueClosureTests.cs
@@ -4846,6 +4846,7 @@ public void F()
g.VerifyIL(
"""
+ F
{
// Code size 44 (0x2c)
.maxstack 2
@@ -4864,6 +4865,7 @@ .maxstack 2
IL_0026: stsfld 0x04000003
IL_002b: ret
}
+ b__0_0
{
// Code size 13 (0xd)
.maxstack 8
@@ -4872,6 +4874,7 @@ .maxstack 8
IL_0007: newobj 0x06000007
IL_000c: throw
}
+ b__0_1
{
// Code size 8 (0x8)
.maxstack 8
@@ -4880,6 +4883,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -4892,6 +4896,7 @@ .maxstack 8
IL_000a: stfld 0x04000004
IL_000f: ret
}
+ .ctor
{
// Code size 8 (0x8)
.maxstack 8
@@ -4900,6 +4905,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ b__0#1
{
// Code size 13 (0xd)
.maxstack 8
@@ -4986,6 +4992,7 @@ public void F()
g.VerifyIL(
"""
+ F
{
// Code size 12 (0xc)
.maxstack 2
@@ -4997,6 +5004,7 @@ .maxstack 2
IL_000a: nop
IL_000b: ret
}
+ g__L1|0_0
{
// Code size 13 (0xd)
.maxstack 8
@@ -5005,6 +5013,7 @@ .maxstack 8
IL_0007: newobj 0x06000006
IL_000c: throw
}
+ g__L2|0_1
{
// Code size 8 (0x8)
.maxstack 8
@@ -5013,6 +5022,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ g__L1|0_0#1
{
// Code size 13 (0xd)
.maxstack 8
@@ -5022,6 +5032,7 @@ .maxstack 8
IL_000b: nop
IL_000c: ret
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -5089,6 +5100,7 @@ public void F(int x)
g.VerifyIL(
"""
+ F
{
// Code size 44 (0x2c)
.maxstack 2
@@ -5107,6 +5119,7 @@ .maxstack 2
IL_0026: stsfld 0x04000003
IL_002b: ret
}
+ b__0_0
{
// Code size 13 (0xd)
.maxstack 8
@@ -5115,6 +5128,7 @@ .maxstack 8
IL_0007: newobj 0x06000007
IL_000c: throw
}
+ b__0_1
{
// Code size 8 (0x8)
.maxstack 8
@@ -5123,6 +5137,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -5135,6 +5150,7 @@ .maxstack 8
IL_000a: stfld 0x04000004
IL_000f: ret
}
+ .ctor
{
// Code size 8 (0x8)
.maxstack 8
@@ -5143,6 +5159,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ b__0#1
{
// Code size 13 (0xd)
.maxstack 8
@@ -5226,6 +5243,7 @@ public void F(int x)
g.VerifyMethodDefNames("F", "g__L1|0_0", "g__L2|0_1", "g__L1|0_0#1", ".ctor");
g.VerifyIL("""
+ F
{
// Code size 12 (0xc)
.maxstack 2
@@ -5237,6 +5255,7 @@ .maxstack 2
IL_000a: nop
IL_000b: ret
}
+ g__L1|0_0
{
// Code size 13 (0xd)
.maxstack 8
@@ -5245,6 +5264,7 @@ .maxstack 8
IL_0007: newobj 0x06000006
IL_000c: throw
}
+ g__L2|0_1
{
// Code size 8 (0x8)
.maxstack 8
@@ -5253,6 +5273,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ g__L1|0_0#1
{
// Code size 13 (0xd)
.maxstack 8
@@ -5262,6 +5283,7 @@ .maxstack 8
IL_000b: nop
IL_000c: ret
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -5331,6 +5353,7 @@ static void F()
g.VerifyIL(
"""
+ F
{
// Code size 34 (0x22)
.maxstack 2
@@ -5347,6 +5370,7 @@ .maxstack 2
IL_0020: stloc.0
IL_0021: ret
}
+ b__1_0
{
// Code size 31 (0x1f)
.maxstack 2
@@ -5361,6 +5385,7 @@ .maxstack 2
IL_0019: call 0x06000001
IL_001e: ret
}
+ b__1_1
{
// Code size 12 (0xc)
.maxstack 8
@@ -5369,6 +5394,7 @@ .maxstack 8
IL_0006: newobj 0x06000008
IL_000b: throw
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -5381,6 +5407,7 @@ .maxstack 8
IL_000a: stfld 0x04000004
IL_000f: ret
}
+ .ctor
{
// Code size 8 (0x8)
.maxstack 8
@@ -5389,6 +5416,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ b__1#1
{
// Code size 7 (0x7)
.maxstack 8
@@ -5453,6 +5481,7 @@ class C : B
g.VerifyIL(
"""
+ .ctor
{
// Code size 42 (0x2a)
.maxstack 3
@@ -5474,6 +5503,7 @@ .maxstack 3
IL_0028: nop
IL_0029: ret
}
+ <.ctor>b__0_0
{
// Code size 13 (0xd)
.maxstack 8
@@ -5482,6 +5512,7 @@ .maxstack 8
IL_0007: newobj 0x06000007
IL_000c: throw
}
+ <.ctor>b__0_1
{
// Code size 12 (0xc)
.maxstack 8
@@ -5490,6 +5521,7 @@ .maxstack 8
IL_0006: newobj 0x06000007
IL_000b: throw
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -5502,6 +5534,7 @@ .maxstack 8
IL_000a: stfld 0x04000004
IL_000f: ret
}
+ .ctor
{
// Code size 8 (0x8)
.maxstack 8
@@ -5510,6 +5543,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ <.ctor>b__0#1
{
// Code size 7 (0x7)
.maxstack 8
@@ -5517,6 +5551,7 @@ .maxstack 8
IL_0001: ldfld 0x04000005
IL_0006: ret
}
+ <.ctor>b__1#1
{
// Code size 13 (0xd)
.maxstack 8
@@ -5569,6 +5604,7 @@ class B(Func f);
g.VerifyIL(
"""
+ .ctor
{
// Code size 33 (0x21)
.maxstack 3
@@ -5585,6 +5621,7 @@ .maxstack 3
IL_001f: nop
IL_0020: ret
}
+ <.ctor>b__0_0
{
// Code size 13 (0xd)
.maxstack 8
@@ -5593,6 +5630,7 @@ .maxstack 8
IL_0007: newobj 0x06000006
IL_000c: throw
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -5605,6 +5643,7 @@ .maxstack 8
IL_000a: stfld 0x04000003
IL_000f: ret
}
+ .ctor
{
// Code size 8 (0x8)
.maxstack 8
@@ -5613,6 +5652,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ <.ctor>b__0#1
{
// Code size 7 (0x7)
.maxstack 8
@@ -5663,6 +5703,7 @@ public void Capture_TopLevelArgs()
g.VerifyIL(
"""
+ $
{
// Code size 27 (0x1b)
.maxstack 2
@@ -5677,6 +5718,7 @@ .maxstack 2
IL_0019: stloc.2
IL_001a: ret
}
+ <$>b__0_0
{
// Code size 13 (0xd)
.maxstack 8
@@ -5685,6 +5727,7 @@ .maxstack 8
IL_0007: newobj 0x06000006
IL_000c: throw
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -5697,6 +5740,7 @@ .maxstack 8
IL_000a: stfld 0x04000003
IL_000f: ret
}
+ .ctor
{
// Code size 8 (0x8)
.maxstack 8
@@ -5705,6 +5749,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ <$>b__0#1
{
// Code size 7 (0x7)
.maxstack 8
@@ -5793,6 +5838,7 @@ public void F()
g.VerifyIL(
"""
+ F
{
// Code size 31 (0x1f)
.maxstack 8
@@ -5806,6 +5852,7 @@ .maxstack 8
IL_0019: stsfld 0x04000004
IL_001e: ret
}
+ b__1_0
{
// Code size 13 (0xd)
.maxstack 8
@@ -5814,6 +5861,7 @@ .maxstack 8
IL_0007: newobj 0x06000008
IL_000c: throw
}
+ b__1_1
{
// Code size 8 (0x8)
.maxstack 8
@@ -5822,6 +5870,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ b__1_0#1
{
// Code size 13 (0xd)
.maxstack 8
@@ -5831,6 +5880,7 @@ .maxstack 8
IL_000b: nop
IL_000c: ret
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -5922,6 +5972,7 @@ public void F()
g.VerifyIL(
"""
+ F
{
// Code size 4 (0x4)
.maxstack 8
@@ -5930,6 +5981,7 @@ .maxstack 8
IL_0002: nop
IL_0003: ret
}
+ g__L1|1_0
{
// Code size 13 (0xd)
.maxstack 8
@@ -5938,6 +5990,7 @@ .maxstack 8
IL_0007: newobj 0x06000006
IL_000c: throw
}
+ g__L2|1_1
{
// Code size 8 (0x8)
.maxstack 8
@@ -5946,6 +5999,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ g__L1|1_0#1
{
// Code size 13 (0xd)
.maxstack 8
@@ -5955,6 +6009,7 @@ .maxstack 8
IL_000b: nop
IL_000c: ret
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -6021,6 +6076,7 @@ public void F()
g.VerifyIL(
"""
+ F
{
// Code size 31 (0x1f)
.maxstack 8
@@ -6034,6 +6090,7 @@ .maxstack 8
IL_0019: stsfld 0x04000003
IL_001e: ret
}
+ b__1_0
{
// Code size 13 (0xd)
.maxstack 8
@@ -6042,6 +6099,7 @@ .maxstack 8
IL_0007: newobj 0x06000008
IL_000c: throw
}
+ b__1_1
{
// Code size 8 (0x8)
.maxstack 8
@@ -6050,6 +6108,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ b__1_0#1
{
// Code size 13 (0xd)
.maxstack 8
@@ -6059,6 +6118,7 @@ .maxstack 8
IL_000b: nop
IL_000c: ret
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -6122,6 +6182,7 @@ public void F()
g.VerifyIL(
"""
+ F
{
// Code size 4 (0x4)
.maxstack 8
@@ -6130,6 +6191,7 @@ .maxstack 8
IL_0002: nop
IL_0003: ret
}
+ g__L1|1_0
{
// Code size 13 (0xd)
.maxstack 8
@@ -6138,6 +6200,7 @@ .maxstack 8
IL_0007: newobj 0x06000006
IL_000c: throw
}
+ g__L2|1_1
{
// Code size 8 (0x8)
.maxstack 8
@@ -6146,6 +6209,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ g__L1|1_0#1
{
// Code size 13 (0xd)
.maxstack 8
@@ -6155,6 +6219,7 @@ .maxstack 8
IL_000b: nop
IL_000c: ret
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -6257,6 +6322,7 @@ public void F()
g.VerifyIL(
"""
+ F
{
// Code size 35 (0x23)
.maxstack 2
@@ -6275,6 +6341,7 @@ .maxstack 2
IL_0021: nop
IL_0022: ret
}
+ b__0
{
// Code size 7 (0x7)
.maxstack 8
@@ -6356,6 +6423,7 @@ public void F()
g.VerifyIL(
"""
+ F
{
// Code size 13 (0xd)
.maxstack 2
@@ -6368,6 +6436,7 @@ .maxstack 2
IL_000b: nop
IL_000c: ret
}
+ g__L|0_0
{
// Code size 7 (0x7)
.maxstack 8
@@ -6427,6 +6496,7 @@ public void F()
g.VerifyIL(
"""
+ F
{
// Code size 32 (0x20)
.maxstack 2
@@ -6441,6 +6511,7 @@ .maxstack 2
IL_001a: stsfld 0x04000004
IL_001f: ret
}
+ b__0
{
// Code size 13 (0xd)
.maxstack 8
@@ -6449,6 +6520,7 @@ .maxstack 8
IL_0007: newobj 0x06000005
IL_000c: throw
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -6461,6 +6533,7 @@ .maxstack 8
IL_000a: stfld 0x04000002
IL_000f: ret
}
+ .cctor
{
// Code size 11 (0xb)
.maxstack 8
@@ -6468,6 +6541,7 @@ .maxstack 8
IL_0005: stsfld 0x04000003
IL_000a: ret
}
+ .ctor
{
// Code size 8 (0x8)
.maxstack 8
@@ -6476,6 +6550,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ b__0_0#1
{
// Code size 8 (0x8)
.maxstack 8
@@ -6518,6 +6593,7 @@ public void F()
g.VerifyIL(
"""
+ F
{
// Code size 16 (0x10)
.maxstack 2
@@ -6530,6 +6606,7 @@ .maxstack 2
IL_000e: nop
IL_000f: ret
}
+ b__0_0#1
{
// Code size 12 (0xc)
.maxstack 8
@@ -6538,6 +6615,7 @@ .maxstack 8
IL_0006: newobj 0x06000005
IL_000b: throw
}
+ .ctor
{
// Code size 8 (0x8)
.maxstack 8
@@ -6546,6 +6624,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ b__0#2
{
// Code size 15 (0xf)
.maxstack 8
@@ -6643,6 +6722,7 @@ public void F()
g.VerifyIL(
"""
+ F
{
// Code size 14 (0xe)
.maxstack 1
@@ -6661,6 +6741,7 @@ .maxstack 1
IL_000c: nop
IL_000d: ret
}
+ g__L|0_0
{
// Code size 13 (0xd)
.maxstack 8
@@ -6669,6 +6750,7 @@ .maxstack 8
IL_0007: newobj 0x06000007
IL_000c: throw
}
+ g__L|0_1
{
// Code size 12 (0xc)
.maxstack 8
@@ -6677,6 +6759,7 @@ .maxstack 8
IL_0006: newobj 0x06000007
IL_000b: throw
}
+ g__L|0_0#1
{
// Code size 8 (0x8)
.maxstack 8
@@ -6685,6 +6768,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ g__L|0_1#1
{
// Code size 8 (0x8)
.maxstack 8
@@ -6693,6 +6777,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -6807,6 +6892,7 @@ public void F()
g.VerifyIL(
"""
+ F
{
// Code size 58 (0x3a)
.maxstack 8
@@ -6825,6 +6911,7 @@ .maxstack 8
IL_0034: stsfld 0x04000003
IL_0039: ret
}
+ b__1_0
{
// Code size 13 (0xd)
.maxstack 8
@@ -6833,6 +6920,7 @@ .maxstack 8
IL_0007: newobj 0x06000007
IL_000c: throw
}
+ b__1_1
{
// Code size 8 (0x8)
.maxstack 8
@@ -6841,6 +6929,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -6853,6 +6942,7 @@ .maxstack 8
IL_000a: stfld 0x04000004
IL_000f: ret
}
+ b__1_0#1
{
// Code size 8 (0x8)
.maxstack 8
@@ -6959,6 +7049,7 @@ public void F()
g.VerifyIL(
"""
+ F
{
// Code size 4 (0x4)
.maxstack 8
@@ -6967,6 +7058,7 @@ .maxstack 8
IL_0002: nop
IL_0003: ret
}
+ g__L1|1_0
{
// Code size 13 (0xd)
.maxstack 8
@@ -6975,6 +7067,7 @@ .maxstack 8
IL_0007: newobj 0x06000006
IL_000c: throw
}
+ g__L2|1_1
{
// Code size 8 (0x8)
.maxstack 8
@@ -6983,6 +7076,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ g__L1|1_0#1
{
// Code size 8 (0x8)
.maxstack 8
@@ -6991,6 +7085,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -7056,6 +7151,7 @@ public void F()
g.VerifyIL(
"""
+ F
{
// Code size 16 (0x10)
.maxstack 2
@@ -7068,6 +7164,7 @@ .maxstack 2
IL_000e: nop
IL_000f: ret
}
+ .ctor
{
// Code size 8 (0x8)
.maxstack 8
@@ -7076,6 +7173,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ b__0#1
{
// Code size 13 (0xd)
.maxstack 8
@@ -7116,6 +7214,7 @@ public void F()
g.VerifyMethodDefNames("F", "b__0#1", ".ctor");
g.VerifyIL("""
+ F
{
// Code size 4 (0x4)
.maxstack 1
@@ -7124,6 +7223,7 @@ .maxstack 1
IL_0002: stloc.2
IL_0003: ret
}
+ b__0#1
{
// Code size 12 (0xc)
.maxstack 8
@@ -7132,6 +7232,7 @@ .maxstack 8
IL_0006: newobj 0x06000005
IL_000b: throw
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -7195,6 +7296,7 @@ public void F()
g.VerifyIL(
"""
+ F
{
// Code size 11 (0xb)
.maxstack 2
@@ -7205,6 +7307,7 @@ .maxstack 2
IL_0009: nop
IL_000a: ret
}
+ g__L|0#1_0#1
{
// Code size 13 (0xd)
.maxstack 8
@@ -7242,6 +7345,7 @@ public void F()
g.VerifyMethodDefNames("F", "g__L|0#1_0#1", ".ctor");
g.VerifyIL("""
+ F
{
// Code size 4 (0x4)
.maxstack 1
@@ -7250,6 +7354,7 @@ .maxstack 1
IL_0002: stloc.2
IL_0003: ret
}
+ g__L|0#1_0#1
{
// Code size 12 (0xc)
.maxstack 8
@@ -7258,6 +7363,7 @@ .maxstack 8
IL_0006: newobj 0x06000004
IL_000b: throw
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -7360,6 +7466,7 @@ void F()
g.VerifyIL(
"""
+ F
{
// Code size 82 (0x52)
.maxstack 3
@@ -7396,6 +7503,7 @@ .maxstack 3
IL_0050: nop
IL_0051: ret
}
+ b__0
{
// Code size 7 (0x7)
.maxstack 8
@@ -7403,6 +7511,7 @@ .maxstack 8
IL_0001: ldfld 0x04000001
IL_0006: ret
}
+ b__1
{
// Code size 12 (0xc)
.maxstack 8
@@ -7411,6 +7520,7 @@ .maxstack 8
IL_0006: newobj 0x06000008
IL_000b: throw
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -7423,6 +7533,7 @@ .maxstack 8
IL_000a: stfld 0x04000003
IL_000f: ret
}
+ .ctor
{
// Code size 8 (0x8)
.maxstack 8
@@ -7431,6 +7542,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ b__1#1
{
// Code size 19 (0x13)
.maxstack 8
@@ -7552,6 +7664,7 @@ void F()
g.VerifyIL(
"""
+ F
{
// Code size 24 (0x18)
.maxstack 2
@@ -7570,6 +7683,7 @@ .maxstack 2
IL_0016: nop
IL_0017: ret
}
+ g__L1|0_0
{
// Code size 7 (0x7)
.maxstack 8
@@ -7577,6 +7691,7 @@ .maxstack 8
IL_0001: ldfld 0x04000001
IL_0006: ret
}
+ g__L2|0_1
{
// Code size 12 (0xc)
.maxstack 8
@@ -7585,6 +7700,7 @@ .maxstack 8
IL_0006: newobj 0x06000006
IL_000b: throw
}
+ g__L2|0_1#1
{
// Code size 14 (0xe)
.maxstack 8
@@ -7595,6 +7711,7 @@ .maxstack 8
IL_000c: add
IL_000d: ret
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -7698,6 +7815,7 @@ void F()
g.VerifyIL(
"""
+ F
{
// Code size 68 (0x44)
.maxstack 2
@@ -7728,6 +7846,7 @@ .maxstack 2
IL_0042: nop
IL_0043: ret
}
+ b__0
{
// Code size 7 (0x7)
.maxstack 8
@@ -7735,6 +7854,7 @@ .maxstack 8
IL_0001: ldfld 0x04000001
IL_0006: ret
}
+ b__1
{
// Code size 12 (0xc)
.maxstack 8
@@ -7743,6 +7863,7 @@ .maxstack 8
IL_0006: newobj 0x06000008
IL_000b: throw
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -7755,6 +7876,7 @@ .maxstack 8
IL_000a: stfld 0x04000004
IL_000f: ret
}
+ .ctor
{
// Code size 8 (0x8)
.maxstack 8
@@ -7763,6 +7885,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ b__1#1
{
// Code size 7 (0x7)
.maxstack 8
@@ -7883,6 +8006,7 @@ void F()
g.VerifyIL(
"""
+ F
{
// Code size 24 (0x18)
.maxstack 2
@@ -7901,6 +8025,7 @@ .maxstack 2
IL_0016: nop
IL_0017: ret
}
+ g__L1|0_0
{
// Code size 7 (0x7)
.maxstack 8
@@ -7908,6 +8033,7 @@ .maxstack 8
IL_0001: ldfld 0x04000001
IL_0006: ret
}
+ g__L2|0_1
{
// Code size 12 (0xc)
.maxstack 8
@@ -7916,6 +8042,7 @@ .maxstack 8
IL_0006: newobj 0x06000006
IL_000b: throw
}
+ g__L2|0_1#1
{
// Code size 7 (0x7)
.maxstack 8
@@ -7923,6 +8050,7 @@ .maxstack 8
IL_0001: ldfld 0x04000002
IL_0006: ret
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -8019,6 +8147,7 @@ void F()
"b__2#1");
g.VerifyIL("""
+ F
{
// Code size 131 (0x83)
.maxstack 2
@@ -8069,6 +8198,7 @@ .maxstack 2
IL_0081: nop
IL_0082: ret
}
+ b__0
{
// Code size 7 (0x7)
.maxstack 8
@@ -8076,6 +8206,7 @@ .maxstack 8
IL_0001: ldfld 0x04000001
IL_0006: ret
}
+ b__1
{
// Code size 12 (0xc)
.maxstack 8
@@ -8084,6 +8215,7 @@ .maxstack 8
IL_0006: newobj 0x06000008
IL_000b: throw
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -8096,6 +8228,7 @@ .maxstack 8
IL_000a: stfld 0x04000004
IL_000f: ret
}
+ .ctor, .ctor
{
// Code size 8 (0x8)
.maxstack 8
@@ -8104,6 +8237,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ b__1#1
{
// Code size 24 (0x18)
.maxstack 8
@@ -8116,6 +8250,7 @@ .maxstack 8
IL_0016: add
IL_0017: ret
}
+ b__2#1
{
// Code size 36 (0x24)
.maxstack 8
@@ -8249,6 +8384,7 @@ void F()
g.VerifyMethodDefNames("F", "g__L1|0_0", "g__L2|0_1", "g__L3|0_2#1");
g.VerifyIL("""
+ F
{
// Code size 35 (0x23)
.maxstack 2
@@ -8273,6 +8409,7 @@ .maxstack 2
IL_0021: nop
IL_0022: ret
}
+ g__L1|0_0
{
// Code size 7 (0x7)
.maxstack 8
@@ -8280,6 +8417,7 @@ .maxstack 8
IL_0001: ldfld 0x04000001
IL_0006: ret
}
+ g__L2|0_1
{
// Code size 14 (0xe)
.maxstack 8
@@ -8290,6 +8428,7 @@ .maxstack 8
IL_000c: add
IL_000d: ret
}
+ g__L3|0_2#1
{
// Code size 21 (0x15)
.maxstack 8
@@ -8427,6 +8566,7 @@ public void F()
g.VerifyIL(
"""
+ F
{
// Code size 84 (0x54)
.maxstack 2
@@ -8460,6 +8600,7 @@ .maxstack 2
IL_0052: nop
IL_0053: ret
}
+ b__0
{
// Code size 7 (0x7)
.maxstack 8
@@ -8467,6 +8608,7 @@ .maxstack 8
IL_0001: ldfld 0x04000001
IL_0006: ret
}
+ b__2
{
// Code size 12 (0xc)
.maxstack 8
@@ -8475,6 +8617,7 @@ .maxstack 8
IL_0006: newobj 0x06000009
IL_000b: throw
}
+ b__1
{
// Code size 7 (0x7)
.maxstack 8
@@ -8482,6 +8625,7 @@ .maxstack 8
IL_0001: ldfld 0x04000002
IL_0006: ret
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -8494,6 +8638,7 @@ .maxstack 8
IL_000a: stfld 0x04000003
IL_000f: ret
}
+ b__2#1
{
// Code size 9 (0x9)
.maxstack 8
@@ -8625,6 +8770,7 @@ public void F()
g.VerifyIL(
"""
+ F
{
// Code size 23 (0x17)
.maxstack 2
@@ -8642,6 +8788,7 @@ .maxstack 2
IL_0015: nop
IL_0016: ret
}
+ g__L1|0_0
{
// Code size 7 (0x7)
.maxstack 8
@@ -8649,6 +8796,7 @@ .maxstack 8
IL_0001: ldfld 0x04000001
IL_0006: ret
}
+ g__L2|0_1
{
// Code size 7 (0x7)
.maxstack 8
@@ -8656,6 +8804,7 @@ .maxstack 8
IL_0001: ldfld 0x04000002
IL_0006: ret
}
+ g__L3|0_2
{
// Code size 12 (0xc)
.maxstack 8
@@ -8664,6 +8813,7 @@ .maxstack 8
IL_0006: newobj 0x06000007
IL_000b: throw
}
+ g__L3|0_2#1
{
// Code size 9 (0x9)
.maxstack 8
@@ -8673,6 +8823,7 @@ .maxstack 8
IL_0007: add
IL_0008: ret
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -8789,6 +8940,7 @@ public void F()
g.VerifyIL(
"""
+ F
{
// Code size 62 (0x3e)
.maxstack 2
@@ -8816,6 +8968,7 @@ .maxstack 2
IL_003c: nop
IL_003d: ret
}
+ g__L1|0
{
// Code size 13 (0xd)
.maxstack 8
@@ -8824,6 +8977,7 @@ .maxstack 8
IL_0007: newobj 0x0600000A
IL_000c: throw
}
+ b__2
{
// Code size 12 (0xc)
.maxstack 8
@@ -8832,6 +8986,7 @@ .maxstack 8
IL_0006: newobj 0x0600000A
IL_000b: throw
}
+ b__1
{
// Code size 7 (0x7)
.maxstack 8
@@ -8839,6 +8994,7 @@ .maxstack 8
IL_0001: ldfld 0x04000002
IL_0006: ret
}
+ g__L1|1_0#1
{
// Code size 7 (0x7)
.maxstack 8
@@ -8846,6 +9002,7 @@ .maxstack 8
IL_0001: ldfld 0x04000004
IL_0006: ret
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -8858,6 +9015,7 @@ .maxstack 8
IL_000a: stfld 0x04000003
IL_000f: ret
}
+ b__2#1
{
// Code size 9 (0x9)
.maxstack 8
@@ -8990,6 +9148,7 @@ public void F()
g.VerifyMethodDefNames("F", "g__L1|1_0", "g__L3|1_2", "b__1", ".ctor", "g__L3|2#1");
g.VerifyIL("""
+ F
{
// Code size 45 (0x2d)
.maxstack 2
@@ -9013,6 +9172,7 @@ .maxstack 2
IL_002b: nop
IL_002c: ret
}
+ g__L1|1_0
{
// Code size 7 (0x7)
.maxstack 8
@@ -9020,6 +9180,7 @@ .maxstack 8
IL_0001: ldfld 0x04000001
IL_0006: ret
}
+ g__L3|1_2
{
// Code size 12 (0xc)
.maxstack 8
@@ -9028,6 +9189,7 @@ .maxstack 8
IL_0006: newobj 0x06000008
IL_000b: throw
}
+ b__1
{
// Code size 7 (0x7)
.maxstack 8
@@ -9035,6 +9197,7 @@ .maxstack 8
IL_0001: ldfld 0x04000002
IL_0006: ret
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -9047,6 +9210,7 @@ .maxstack 8
IL_000a: stfld 0x04000003
IL_000f: ret
}
+ g__L3|2#1
{
// Code size 9 (0x9)
.maxstack 8
@@ -9128,6 +9292,7 @@ public void F()
g.VerifyIL(
"""
+ F
{
// Code size 40 (0x28)
.maxstack 2
@@ -9147,6 +9312,7 @@ .maxstack 2
IL_0026: nop
IL_0027: ret
}
+ b__0
{
// Code size 14 (0xe)
.maxstack 8
@@ -9224,6 +9390,7 @@ public void F()
g.VerifyMethodDefNames("F", "g__L|0_0", "g__L|0_0#1", ".ctor");
g.VerifyIL("""
+ F
{
// Code size 19 (0x13)
.maxstack 2
@@ -9237,6 +9404,7 @@ .maxstack 2
IL_0011: nop
IL_0012: ret
}
+ g__L|0_0
{
// Code size 13 (0xd)
.maxstack 8
@@ -9245,6 +9413,7 @@ .maxstack 8
IL_0007: newobj 0x06000005
IL_000c: throw
}
+ g__L|0_0#1
{
// Code size 14 (0xe)
.maxstack 8
@@ -9255,6 +9424,7 @@ .maxstack 8
IL_000c: add
IL_000d: ret
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -9342,6 +9512,7 @@ public void F()
g.VerifyIL(
"""
+ F
{
// Code size 40 (0x28)
.maxstack 2
@@ -9361,6 +9532,7 @@ .maxstack 2
IL_0026: nop
IL_0027: ret
}
+ b__0
{
// Code size 14 (0xe)
.maxstack 8
@@ -9442,6 +9614,7 @@ public void F()
g.VerifyIL(
"""
+ F
{
// Code size 11 (0xb)
.maxstack 2
@@ -9452,6 +9625,7 @@ .maxstack 2
IL_0009: nop
IL_000a: ret
}
+ g__L|0
{
// Code size 13 (0xd)
.maxstack 8
@@ -9460,6 +9634,7 @@ .maxstack 8
IL_0007: newobj 0x06000008
IL_000c: throw
}
+ b__1
{
// Code size 12 (0xc)
.maxstack 8
@@ -9468,6 +9643,7 @@ .maxstack 8
IL_0006: newobj 0x06000008
IL_000b: throw
}
+ g__L|1_0#1
{
// Code size 7 (0x7)
.maxstack 8
@@ -9475,6 +9651,7 @@ .maxstack 8
IL_0001: ldfld 0x04000003
IL_0006: ret
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -9573,6 +9750,7 @@ public void F()
g.VerifyIL(
"""
+ F
{
// Code size 11 (0xb)
.maxstack 2
@@ -9583,6 +9761,7 @@ .maxstack 2
IL_0009: nop
IL_000a: ret
}
+ g__L|0
{
// Code size 13 (0xd)
.maxstack 8
@@ -9591,6 +9770,7 @@ .maxstack 8
IL_0007: newobj 0x06000007
IL_000c: throw
}
+ g__L|1_0#1
{
// Code size 7 (0x7)
.maxstack 8
@@ -9598,6 +9778,7 @@ .maxstack 8
IL_0001: ldfld 0x04000003
IL_0006: ret
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -9676,6 +9857,7 @@ public void F()
g.VerifyMethodDefNames("F", "g__L|1_0", ".ctor", ".ctor", "g__L|0#1", "b__1#1");
g.VerifyIL("""
+ F
{
// Code size 34 (0x22)
.maxstack 2
@@ -9693,6 +9875,7 @@ .maxstack 2
IL_0020: nop
IL_0021: ret
}
+ g__L|1_0
{
// Code size 13 (0xd)
.maxstack 8
@@ -9701,6 +9884,7 @@ .maxstack 8
IL_0007: newobj 0x06000005
IL_000c: throw
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -9713,6 +9897,7 @@ .maxstack 8
IL_000a: stfld 0x04000002
IL_000f: ret
}
+ .ctor
{
// Code size 8 (0x8)
.maxstack 8
@@ -9721,6 +9906,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ g__L|0#1, b__1#1
{
// Code size 7 (0x7)
.maxstack 8
@@ -9794,7 +9980,8 @@ public void F()
g.VerifyIL(
"""
- {
+ F
+ {
// Code size 34 (0x22)
.maxstack 2
IL_0000: newobj 0x06000006
@@ -9811,6 +9998,7 @@ .maxstack 2
IL_0020: nop
IL_0021: ret
}
+ g__L|1_0
{
// Code size 13 (0xd)
.maxstack 8
@@ -9819,6 +10007,7 @@ .maxstack 8
IL_0007: newobj 0x06000005
IL_000c: throw
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -9831,6 +10020,7 @@ .maxstack 8
IL_000a: stfld 0x04000002
IL_000f: ret
}
+ .ctor
{
// Code size 8 (0x8)
.maxstack 8
@@ -9839,6 +10029,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ g__L|0#1
{
// Code size 7 (0x7)
.maxstack 8
@@ -9906,6 +10097,7 @@ public void F()
g.VerifyIL(
"""
+ F
{
// Code size 30 (0x1e)
.maxstack 8
@@ -9918,6 +10110,7 @@ .maxstack 8
IL_0018: stsfld 0x04000004
IL_001d: ret
}
+ b__0_0
{
// Code size 16 (0x10)
.maxstack 8
@@ -9926,6 +10119,7 @@ .maxstack 8
IL_000a: newobj 0x06000006
IL_000f: throw
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -9938,6 +10132,7 @@ .maxstack 8
IL_000a: stfld 0x04000003
IL_000f: ret
}
+ b__0_0#1
{
// Code size 10 (0xa)
.maxstack 8
diff --git a/src/Compilers/CSharp/Test/Emit2/Emit/EditAndContinue/EditAndContinueTests.cs b/src/Compilers/CSharp/Test/Emit2/Emit/EditAndContinue/EditAndContinueTests.cs
index cadd2d351b7b7..52fb9f8a63973 100644
--- a/src/Compilers/CSharp/Test/Emit2/Emit/EditAndContinue/EditAndContinueTests.cs
+++ b/src/Compilers/CSharp/Test/Emit2/Emit/EditAndContinue/EditAndContinueTests.cs
@@ -11,6 +11,8 @@
using System.Linq;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
+using System.Text;
+using System.Threading;
using Microsoft.CodeAnalysis.CodeGen;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Test.Utilities;
@@ -100,7 +102,8 @@ public C()
Handle(4, TableIndex.CustomAttribute)
});
- var expectedIL = """
+ g.VerifyIL("""
+ .ctor
{
// Code size 13 (0xd)
.maxstack 8
@@ -109,6 +112,7 @@ .maxstack 8
IL_0007: newobj 0x06000003
IL_000c: throw
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -121,10 +125,7 @@ .maxstack 8
IL_000a: stfld 0x04000001
IL_000f: ret
}
- """;
-
- // Can't verify the IL of individual methods because that requires IMethodSymbolInternal implementations
- g.VerifyIL(expectedIL);
+ """);
})
.Verify();
}
@@ -186,6 +187,7 @@ class C
});
g.VerifyIL("""
+ .ctor
{
// Code size 13 (0xd)
.maxstack 8
@@ -194,6 +196,7 @@ .maxstack 8
IL_0007: newobj 0x06000003
IL_000c: throw
}
+ .ctor
{
// Code size 8 (0x8)
.maxstack 8
@@ -202,6 +205,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -2324,6 +2328,7 @@ void F()
});
g.VerifyIL("""
+ F
{
// Code size 30 (0x1e)
.maxstack 8
@@ -2336,6 +2341,7 @@ .maxstack 8
IL_0018: stsfld 0x04000003
IL_001d: ret
}
+ b__0_0
{
// Code size 12 (0xc)
.maxstack 8
@@ -2344,6 +2350,7 @@ .maxstack 8
IL_0006: newobj 0x06000007
IL_000b: throw
}
+ b__0_1
{
// Code size 8 (0x8)
.maxstack 8
@@ -2352,6 +2359,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -2664,6 +2672,7 @@ partial void M()
g.VerifyMethodDefNames("M", "b__0", ".ctor", ".ctor", "b__0#1");
g.VerifyIL("""
+ M
{
// Code size 28 (0x1c)
.maxstack 2
@@ -2679,6 +2688,7 @@ .maxstack 2
IL_001a: stloc.1
IL_001b: ret
}
+ b__0
{
// Code size 12 (0xc)
.maxstack 8
@@ -2687,6 +2697,7 @@ .maxstack 8
IL_0006: newobj 0x06000005
IL_000b: throw
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -2699,6 +2710,7 @@ .maxstack 8
IL_000a: stfld 0x04000002
IL_000f: ret
}
+ .ctor
{
// Code size 8 (0x8)
.maxstack 8
@@ -2707,6 +2719,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ b__0#1
{
// Code size 9 (0x9)
.maxstack 8
@@ -3991,6 +4004,7 @@ class C
})
.AddGeneration(
+ // 1
source: """
class C
{
@@ -4031,6 +4045,7 @@ class C
});
g.VerifyIL("""
+ get_P, set_P
{
// Code size 13 (0xd)
.maxstack 8
@@ -4039,6 +4054,7 @@ .maxstack 8
IL_0007: newobj 0x06000004
IL_000c: throw
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -4054,6 +4070,7 @@ .maxstack 8
""");
})
.AddGeneration(
+ // 2
source: """
class C
{
@@ -4090,7 +4107,8 @@ class C
Handle(4, TableIndex.MethodSemantics),
});
- var expectedIL = """
+ g.VerifyIL("""
+ get_P
{
// Code size 7 (0x7)
.maxstack 8
@@ -4098,6 +4116,7 @@ .maxstack 8
IL_0001: ldfld 0x04000001
IL_0006: ret
}
+ set_P
{
// Code size 8 (0x8)
.maxstack 8
@@ -4106,10 +4125,7 @@ .maxstack 8
IL_0002: stfld 0x04000001
IL_0007: ret
}
- """;
-
- // Can't verify the IL of individual methods because that requires IMethodSymbolInternal implementations
- g.VerifyIL(expectedIL);
+ """);
})
.Verify();
}
@@ -4133,6 +4149,7 @@ class C
})
.AddGeneration(
+ // 1
source: """
class C
{
@@ -4175,6 +4192,7 @@ class C
]);
g.VerifyIL("""
+ get_P, set_P
{
// Code size 13 (0xd)
.maxstack 8
@@ -4183,6 +4201,7 @@ .maxstack 8
IL_0007: newobj 0x06000004
IL_000c: throw
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -4198,6 +4217,7 @@ .maxstack 8
""");
})
.AddGeneration(
+ // 2
source: """
class C
{
@@ -4243,7 +4263,8 @@ class C
Handle(4, TableIndex.MethodSemantics)
]);
- var expectedIL = """
+ g.VerifyIL("""
+ get_P
{
// Code size 7 (0x7)
.maxstack 8
@@ -4251,6 +4272,7 @@ .maxstack 8
IL_0001: ldfld 0x04000002
IL_0006: ret
}
+ set_P
{
// Code size 8 (0x8)
.maxstack 8
@@ -4259,10 +4281,7 @@ .maxstack 8
IL_0002: stfld 0x04000002
IL_0007: ret
}
- """;
-
- // Can't verify the IL of individual methods because that requires IMethodSymbolInternal implementations
- g.VerifyIL(expectedIL);
+ """);
})
.Verify();
}
@@ -4324,6 +4343,7 @@ class C
});
g.VerifyIL("""
+ get_P, set_P
{
// Code size 13 (0xd)
.maxstack 8
@@ -4332,6 +4352,7 @@ .maxstack 8
IL_0007: newobj 0x06000004
IL_000c: throw
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -4386,6 +4407,7 @@ class C
});
g.VerifyIL("""
+ get_P
{
// Code size 11 (0xb)
.maxstack 1
@@ -4396,6 +4418,7 @@ .maxstack 1
IL_0009: ldloc.0
IL_000a: ret
}
+ set_P
{
// Code size 2 (0x2)
.maxstack 8
@@ -4460,6 +4483,7 @@ class C
});
g.VerifyIL("""
+ set_P
{
// Code size 13 (0xd)
.maxstack 8
@@ -4468,6 +4492,7 @@ .maxstack 8
IL_0007: newobj 0x06000004
IL_000c: throw
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -4521,6 +4546,7 @@ class C
});
g.VerifyIL("""
+ get_P
{
// Code size 11 (0xb)
.maxstack 1
@@ -4531,6 +4557,7 @@ .maxstack 1
IL_0009: ldloc.0
IL_000a: ret
}
+ set_P
{
// Code size 2 (0x2)
.maxstack 8
@@ -4607,6 +4634,7 @@ class C
]);
var expectedIL = """
+ get_P
{
// Code size 7 (0x7)
.maxstack 8
@@ -4614,6 +4642,7 @@ .maxstack 8
IL_0001: ldfld 0x04000001
IL_0006: ret
}
+ set_P
{
// Code size 8 (0x8)
.maxstack 8
@@ -4692,6 +4721,7 @@ class C
]);
var expectedIL = """
+ get_P
{
// Code size 7 (0x7)
.maxstack 8
@@ -4699,6 +4729,7 @@ .maxstack 8
IL_0001: ldfld 0x04000001
IL_0006: ret
}
+ set_P
{
// Code size 8 (0x8)
.maxstack 8
@@ -4772,6 +4803,7 @@ class C
]);
var expectedIL = """
+ get_P
{
// Code size 7 (0x7)
.maxstack 8
@@ -4779,6 +4811,7 @@ .maxstack 8
IL_0001: ldfld 0x04000001
IL_0006: ret
}
+ set_P
{
// Code size 8 (0x8)
.maxstack 8
@@ -4881,7 +4914,8 @@ class C
Handle(4, TableIndex.MethodSemantics)
});
- var expectedIL = """
+ g.VerifyIL("""
+ get_P, set_P
{
// Code size 13 (0xd)
.maxstack 8
@@ -4890,6 +4924,7 @@ .maxstack 8
IL_0007: newobj 0x06000006
IL_000c: throw
}
+ get_P
{
// Code size 7 (0x7)
.maxstack 8
@@ -4897,6 +4932,7 @@ .maxstack 8
IL_0001: ldfld 0x04000002
IL_0006: ret
}
+ set_P
{
// Code size 8 (0x8)
.maxstack 8
@@ -4905,6 +4941,7 @@ .maxstack 8
IL_0002: stfld 0x04000002
IL_0007: ret
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -4917,10 +4954,7 @@ .maxstack 8
IL_000a: stfld 0x04000003
IL_000f: ret
}
- """;
-
- // Can't verify the IL of individual methods because that requires IMethodSymbolInternal implementations
- g.VerifyIL(expectedIL);
+ """);
})
.AddGeneration(
// 2
@@ -4972,6 +5006,7 @@ class C
});
g.VerifyIL("""
+ get_P
{
// Code size 7 (0x7)
.maxstack 8
@@ -4979,6 +5014,7 @@ .maxstack 8
IL_0001: ldfld 0x04000001
IL_0006: ret
}
+ set_P
{
// Code size 8 (0x8)
.maxstack 8
@@ -4987,6 +5023,7 @@ .maxstack 8
IL_0002: stfld 0x04000001
IL_0007: ret
}
+ get_P, set_P
{
// Code size 13 (0xd)
.maxstack 8
@@ -5087,6 +5124,7 @@ class C
});
g.VerifyIL("""
+ get_P, set_P
{
// Code size 13 (0xd)
.maxstack 8
@@ -5095,6 +5133,7 @@ .maxstack 8
IL_0007: newobj 0x06000006
IL_000c: throw
}
+ get_Q
{
// Code size 7 (0x7)
.maxstack 8
@@ -5102,6 +5141,7 @@ .maxstack 8
IL_0001: ldfld 0x04000002
IL_0006: ret
}
+ set_Q
{
// Code size 8 (0x8)
.maxstack 8
@@ -5110,6 +5150,7 @@ .maxstack 8
IL_0002: stfld 0x04000002
IL_0007: ret
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -5174,6 +5215,7 @@ class C
});
g.VerifyIL("""
+ get_P
{
// Code size 7 (0x7)
.maxstack 8
@@ -5181,6 +5223,7 @@ .maxstack 8
IL_0001: ldfld 0x04000001
IL_0006: ret
}
+ set_P
{
// Code size 8 (0x8)
.maxstack 8
@@ -5189,6 +5232,7 @@ .maxstack 8
IL_0002: stfld 0x04000001
IL_0007: ret
}
+ get_Q, set_Q
{
// Code size 13 (0xd)
.maxstack 8
@@ -5260,6 +5304,7 @@ class C
});
g.VerifyIL("""
+ get_Item, set_Item
{
// Code size 13 (0xd)
.maxstack 8
@@ -5268,6 +5313,7 @@ .maxstack 8
IL_0007: newobj 0x06000004
IL_000c: throw
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -5354,7 +5400,8 @@ class C
});
g.VerifyIL("""
- {
+ get_Item
+ {
// Code size 13 (0xd)
.maxstack 8
IL_0000: ldstr 0x70000005
@@ -5362,6 +5409,7 @@ .maxstack 8
IL_0007: newobj 0x06000004
IL_000c: throw
}
+ get_Item
{
// Code size 7 (0x7)
.maxstack 1
@@ -5372,6 +5420,7 @@ .maxstack 1
IL_0005: ldloc.0
IL_0006: ret
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -5426,6 +5475,7 @@ class C
});
g.VerifyIL("""
+ get_Item
{
// Code size 7 (0x7)
.maxstack 1
@@ -5436,6 +5486,7 @@ .maxstack 1
IL_0005: ldloc.0
IL_0006: ret
}
+ get_Item
{
// Code size 13 (0xd)
.maxstack 8
@@ -5485,6 +5536,7 @@ class C
});
g.VerifyIL("""
+ get_Item
{
// Code size 7 (0x7)
.maxstack 1
@@ -5553,12 +5605,14 @@ class C
});
g.VerifyIL("""
+ get_Item
{
// Code size 2 (0x2)
.maxstack 8
IL_0000: ldc.i4.1
IL_0001: ret
}
+ set_Item
{
// Code size 2 (0x2)
.maxstack 8
@@ -5767,6 +5821,7 @@ class C
});
g.VerifyIL("""
+ add_E, remove_E
{
// Code size 13 (0xd)
.maxstack 8
@@ -5775,6 +5830,7 @@ .maxstack 8
IL_0007: newobj 0x06000004
IL_000c: throw
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -5883,6 +5939,7 @@ class C
});
g.VerifyIL("""
+ add_E, remove_E
{
// Code size 13 (0xd)
.maxstack 8
@@ -5891,6 +5948,7 @@ .maxstack 8
IL_0007: newobj 0x06000006
IL_000c: throw
}
+ add_F
{
// Code size 41 (0x29)
.maxstack 3
@@ -5915,6 +5973,7 @@ .maxstack 3
IL_0026: bne.un.s IL_0007
IL_0028: ret
}
+ remove_F
{
// Code size 41 (0x29)
.maxstack 3
@@ -5939,6 +5998,7 @@ .maxstack 3
IL_0026: bne.un.s IL_0007
IL_0028: ret
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -6006,6 +6066,7 @@ class C
});
g.VerifyIL("""
+ add_E
{
// Code size 41 (0x29)
.maxstack 3
@@ -6030,6 +6091,7 @@ .maxstack 3
IL_0026: bne.un.s IL_0007
IL_0028: ret
}
+ remove_E
{
// Code size 41 (0x29)
.maxstack 3
@@ -6054,6 +6116,7 @@ .maxstack 3
IL_0026: bne.un.s IL_0007
IL_0028: ret
}
+ add_F, remove_F
{
// Code size 13 (0xd)
.maxstack 8
@@ -12190,7 +12253,8 @@ class C
Handle(4, TableIndex.CustomAttribute)
]);
- var expectedIL = """
+ g.VerifyIL("""
+ op_LogicalNot
{
// Code size 13 (0xd)
.maxstack 8
@@ -12199,6 +12263,7 @@ .maxstack 8
IL_0007: newobj 0x06000003
IL_000c: throw
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -12211,10 +12276,7 @@ .maxstack 8
IL_000a: stfld 0x04000001
IL_000f: ret
}
- """;
-
- // Can't verify the IL of individual methods because that requires IMethodSymbolInternal implementations
- g.VerifyIL(expectedIL);
+ """);
})
.Verify();
}
@@ -12447,8 +12509,9 @@ static string F()
badStream,
ilStream,
pdbStream,
+ EmitDifferenceOptions.Default,
new CompilationTestData(),
- default);
+ CancellationToken.None);
Assert.False(result.Success);
result.Diagnostics.Verify(
// error CS8104: An error occurred while writing the output file: System.IO.IOException: I/O error occurred.
@@ -12462,8 +12525,9 @@ static string F()
mdStream,
badStream,
pdbStream,
+ EmitDifferenceOptions.Default,
new CompilationTestData(),
- default);
+ CancellationToken.None);
Assert.False(result.Success);
result.Diagnostics.Verify(
// error CS8104: An error occurred while writing the output file: System.IO.IOException: I/O error occurred.
@@ -12477,8 +12541,9 @@ static string F()
mdStream,
ilStream,
badStream,
+ EmitDifferenceOptions.Default,
new CompilationTestData(),
- default);
+ CancellationToken.None);
Assert.False(result.Success);
result.Diagnostics.Verify(
// error CS0041: Unexpected error writing debug information -- 'I/O error occurred.'
@@ -12532,8 +12597,9 @@ static string F()
mdStream,
ilStream,
badStream,
+ EmitDifferenceOptions.Default,
new CompilationTestData(),
- default);
+ CancellationToken.None);
Assert.False(result.Success);
result.Diagnostics.Verify(
// error CS0041: Unexpected error writing debug information -- 'I/O error occurred.'
@@ -15990,6 +16056,7 @@ public void Records_AddPrimaryConstructorParameter()
});
g.VerifyIL("""
+ .ctor
{
// Code size 29 (0x1d)
.maxstack 8
@@ -16007,6 +16074,7 @@ .maxstack 8
IL_001b: nop
IL_001c: ret
}
+ get_Q
{
// Code size 7 (0x7)
.maxstack 8
@@ -16014,6 +16082,7 @@ .maxstack 8
IL_0001: ldfld 0x04000005
IL_0006: ret
}
+ set_Q
{
// Code size 8 (0x8)
.maxstack 8
@@ -16022,6 +16091,7 @@ .maxstack 8
IL_0002: stfld 0x04000005
IL_0007: ret
}
+ Deconstruct
{
// Code size 25 (0x19)
.maxstack 8
@@ -16108,6 +16178,7 @@ public void Records_AddProperty_NonPrimary()
});
g.VerifyIL("""
+ get_Q
{
// Code size 7 (0x7)
.maxstack 8
@@ -16115,6 +16186,7 @@ .maxstack 8
IL_0001: ldfld 0x04000004
IL_0006: ret
}
+ set_Q
{
// Code size 8 (0x8)
.maxstack 8
@@ -16351,7 +16423,8 @@ class C
g.VerifyTypeRefNames("Object");
g.VerifyIL("""
- {
+ F
+ {
// Code size 13 (0xd)
.maxstack 8
IL_0000: ldstr 0x70000005
@@ -16359,6 +16432,7 @@ .maxstack 8
IL_0007: newobj 0x06000004
IL_000c: throw
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -16417,6 +16491,7 @@ void F2() {}
g.VerifyTypeRefNames("Object");
g.VerifyIL("""
+ F1
{
// Code size 13 (0xd)
.maxstack 8
@@ -16445,6 +16520,7 @@ class C
g.VerifyTypeRefNames("Object");
g.VerifyIL("""
+ F2
{
// Code size 13 (0xd)
.maxstack 8
@@ -16500,6 +16576,7 @@ void F2() {}
g.VerifyTypeRefNames("Exception", "Object");
g.VerifyIL("""
+ F1
{
// Code size 13 (0xd)
.maxstack 8
@@ -16508,6 +16585,7 @@ .maxstack 8
IL_0007: newobj 0x06000004
IL_000c: throw
}
+ .ctor
{
// Code size 10 (0xa)
.maxstack 8
@@ -16538,6 +16616,7 @@ class C
g.VerifyTypeRefNames("Object");
g.VerifyIL("""
+ F2
{
// Code size 13 (0xd)
.maxstack 8
@@ -16594,6 +16673,84 @@ void F2() {}
.Verify();
}
+ [Fact]
+ public void Method_Delete_PredefinedHotReloadException_DataSectionLiterals()
+ {
+ var parseOptions = TestOptions.Regular.WithFeature("experimental-data-section-string-literals", "0");
+
+ var exceptionSource = """
+ namespace System.Runtime.CompilerServices
+ {
+ public class HotReloadException : Exception
+ {
+ public HotReloadException(string message, int code) : base(message) {}
+ }
+ }
+ """;
+
+ using var _ = new EditAndContinueTest(targetFramework: TargetFramework.Net90, verification: Verification.FailsPEVerify, parseOptions: parseOptions)
+ .AddBaseline(
+ source: exceptionSource + """
+ class C
+ {
+ void F1() {}
+ void F2() {}
+ }
+ """)
+ .AddGeneration(
+ // 1
+ source: exceptionSource + """
+ class C
+ {
+ void F2() {}
+ }
+ """,
+ edits:
+ [
+ Edit(SemanticEditKind.Delete, symbolProvider: c => c.GetMember("C.F1"), newSymbolProvider: c => c.GetMember("C")),
+ ],
+ validator: g =>
+ {
+ g.VerifySynthesizedMembers();
+ g.VerifyTypeDefNames("#1", "__StaticArrayInitTypeSize=163", "A70F5C822D3106BF474269B4991AB592");
+ g.VerifyTypeRefNames("Object", "CompilerGeneratedAttribute", "ValueType", "Encoding");
+
+ g.VerifyIL("""
+ F1
+ {
+ // Code size 13 (0xd)
+ .maxstack 8
+ IL_0000: ldsfld 0x04000002
+ IL_0005: ldc.i4.s -2
+ IL_0007: newobj 0x06000004
+ IL_000c: throw
+ }
+ BytesToString
+ {
+ // Code size 13 (0xd)
+ .maxstack 8
+ IL_0000: call 0x0A000008
+ IL_0005: ldarg.0
+ IL_0006: ldarg.1
+ IL_0007: callvirt 0x0A000009
+ IL_000c: ret
+ }
+ .cctor
+ {
+ // Code size 21 (0x15)
+ .maxstack 8
+ IL_0000: ldsflda 0x04000001
+ IL_0005: ldc.i4 0xa3
+ IL_000a: call 0x06000005
+ IL_000f: stsfld 0x04000002
+ IL_0014: ret
+ }
+ """);
+ },
+ options: new EmitDifferenceOptions() { EmitFieldRva = true })
+ .Verify();
+ }
+
[Theory]
[InlineData("void M1() { }")]
[InlineData("void M1(string s) { }")]
@@ -16665,7 +16822,8 @@ class N
Handle(4, TableIndex.CustomAttribute)
]);
- var expectedIL = """
+ g.VerifyIL("""
+ M1
{
// Code size 13 (0xd)
.maxstack 8
@@ -16674,6 +16832,7 @@ .maxstack 8
IL_0007: newobj 0x06000004
IL_000c: throw
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -16686,10 +16845,7 @@ .maxstack 8
IL_000a: stfld 0x04000001
IL_000f: ret
}
- """;
-
- // Can't verify the IL of individual methods because that requires IMethodSymbolInternal implementations
- g.VerifyIL(expectedIL);
+ """);
})
.Verify();
}
@@ -16737,17 +16893,15 @@ void M2() { }
Handle(3, TableIndex.MethodDef),
});
- var expectedIL = """
+ g.VerifyIL("""
+ M2
{
// Code size 2 (0x2)
.maxstack 8
IL_0000: nop
IL_0001: ret
}
- """;
-
- // Can't verify the IL of individual methods because that requires IMethodSymbolInternal implementations
- g.VerifyIL(expectedIL);
+ """);
})
.AddGeneration(
@@ -16784,7 +16938,8 @@ void M1() { }
Handle(4, TableIndex.CustomAttribute)
});
- var expectedIL = """
+ g.VerifyIL("""
+ M2
{
// Code size 13 (0xd)
.maxstack 8
@@ -16793,6 +16948,7 @@ .maxstack 8
IL_0007: newobj 0x06000004
IL_000c: throw
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -16805,10 +16961,7 @@ .maxstack 8
IL_000a: stfld 0x04000001
IL_000f: ret
}
- """;
-
- // Can't verify the IL of individual methods because that requires IMethodSymbolInternal implementations
- g.VerifyIL(expectedIL);
+ """);
})
.Verify();
}
@@ -16863,7 +17016,8 @@ class C
Handle(4, TableIndex.CustomAttribute)
});
- var expectedIL = """
+ g.VerifyIL("""
+ M1
{
// Code size 13 (0xd)
.maxstack 8
@@ -16872,6 +17026,7 @@ .maxstack 8
IL_0007: newobj 0x06000003
IL_000c: throw
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -16884,10 +17039,7 @@ .maxstack 8
IL_000a: stfld 0x04000001
IL_000f: ret
}
- """;
-
- // Can't verify the IL of individual methods because that requires IMethodSymbolInternal implementations
- g.VerifyIL(expectedIL);
+ """);
})
.AddGeneration(
@@ -16914,6 +17066,7 @@ class C
});
g.VerifyIL("""
+ M1
{
// Code size 9 (0x9)
.maxstack 8
@@ -16992,8 +17145,9 @@ class C
new CustomAttributeRow(Handle(5, TableIndex.TypeDef), Handle(6, TableIndex.MemberRef))
]);
- var expectedIL = """
- {
+ g.VerifyIL("""
+ M1
+ {
// Code size 13 (0xd)
.maxstack 8
IL_0000: ldstr 0x70000005
@@ -17001,6 +17155,7 @@ .maxstack 8
IL_0007: newobj 0x06000005
IL_000c: throw
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -17013,10 +17168,7 @@ .maxstack 8
IL_000a: stfld 0x04000001
IL_000f: ret
}
- """;
-
- // Can't verify the IL of individual methods because that requires IMethodSymbolInternal implementations
- g.VerifyIL(expectedIL);
+ """);
})
.AddGeneration(
@@ -17064,17 +17216,15 @@ void M1([B]int x) { }
new CustomAttributeRow(Handle(3, TableIndex.MethodDef), Handle(2, TableIndex.MethodDef))
});
- var expectedIL = """
+ g.VerifyIL("""
+ M1
{
// Code size 2 (0x2)
.maxstack 8
IL_0000: nop
IL_0001: ret
}
- """;
-
- // Can't verify the IL of individual methods because that requires IMethodSymbolInternal implementations
- g.VerifyIL(expectedIL);
+ """);
})
.Verify();
}
@@ -17128,7 +17278,8 @@ void Goo() { }
Handle(1, TableIndex.StandAloneSig)
});
- var expectedIL = """
+ g.VerifyIL("""
+ M1
{
// Code size 7 (0x7)
.maxstack 1
@@ -17139,10 +17290,7 @@ .maxstack 1
IL_0005: ldloc.0
IL_0006: ret
}
- """;
-
- // Can't verify the IL of individual methods because that requires IMethodSymbolInternal implementations
- g.VerifyIL(expectedIL);
+ """);
})
.AddGeneration(
@@ -17181,7 +17329,8 @@ void Goo() { }
Handle(4, TableIndex.CustomAttribute)
});
- var expectedIL = """
+ g.VerifyIL("""
+ M1
{
// Code size 13 (0xd)
.maxstack 8
@@ -17190,6 +17339,7 @@ .maxstack 8
IL_0007: newobj 0x06000004
IL_000c: throw
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -17202,10 +17352,7 @@ .maxstack 8
IL_000a: stfld 0x04000001
IL_000f: ret
}
- """;
-
- // Can't verify the IL of individual methods because that requires IMethodSymbolInternal implementations
- g.VerifyIL(expectedIL);
+ """);
})
@@ -17238,7 +17385,8 @@ void Goo() { }
Handle(2, TableIndex.StandAloneSig)
});
- var expectedIL = """
+ g.VerifyIL("""
+ M1
{
// Code size 14 (0xe)
.maxstack 1
@@ -17252,10 +17400,7 @@ .maxstack 1
IL_000c: ldloc.0
IL_000d: ret
}
- """;
-
- // Can't verify the IL of individual methods because that requires IMethodSymbolInternal implementations
- g.VerifyIL(expectedIL);
+ """);
})
.Verify();
}
@@ -17324,6 +17469,7 @@ class C
});
g.VerifyIL("""
+ F
{
// Code size 13 (0xd)
.maxstack 8
@@ -17332,6 +17478,7 @@ .maxstack 8
IL_0007: newobj 0x06000006
IL_000c: throw
}
+ b__0_0
{
// Code size 12 (0xc)
.maxstack 8
@@ -17340,6 +17487,7 @@ .maxstack 8
IL_0006: newobj 0x06000006
IL_000b: throw
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -17398,6 +17546,7 @@ class C
});
g.VerifyIL("""
+ F
{
// Code size 30 (0x1e)
.maxstack 8
@@ -17410,6 +17559,7 @@ .maxstack 8
IL_0018: stsfld 0x04000004
IL_001d: ret
}
+ .ctor
{
// Code size 8 (0x8)
.maxstack 8
@@ -17418,6 +17568,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ b__0#2_0#2
{
// Code size 8 (0x8)
.maxstack 8
@@ -17467,6 +17618,7 @@ class C
});
g.VerifyIL("""
+ F
{
// Code size 13 (0xd)
.maxstack 8
@@ -17475,6 +17627,7 @@ .maxstack 8
IL_0007: newobj 0x06000006
IL_000c: throw
}
+ b__0#2_0#2
{
// Code size 12 (0xc)
.maxstack 8
@@ -17576,7 +17729,8 @@ class C
});
g.VerifyIL("""
- {
+ F
+ {
// Code size 13 (0xd)
.maxstack 8
IL_0000: ldstr 0x70000009
@@ -17584,6 +17738,7 @@ .maxstack 8
IL_0007: newobj 0x06000006
IL_000c: throw
}
+ b__0#1_0#1
{
// Code size 12 (0xc)
.maxstack 8
@@ -17592,6 +17747,7 @@ .maxstack 8
IL_0006: newobj 0x06000006
IL_000b: throw
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -17754,6 +17910,7 @@ class C
});
g.VerifyIL("""
+ F
{
// Code size 13 (0xd)
.maxstack 8
@@ -17762,6 +17919,7 @@ .maxstack 8
IL_0007: newobj 0x0600000C
IL_000c: throw
}
+ b__0_0, b__0_1#1, b__0_2#2
{
// Code size 12 (0xc)
.maxstack 8
@@ -17770,6 +17928,7 @@ .maxstack 8
IL_0006: newobj 0x0600000C
IL_000b: throw
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -17816,6 +17975,7 @@ void F<[A]S>([A]T a, S b) where S : struct
g.VerifyMemberRefNames(".ctor", "<>9__0#4_0#4", "<>9", "b__0#4_0#4", ".ctor", ".ctor", "<>9", ".ctor", "WriteLine");
g.VerifyIL("""
+ F
{
// Code size 30 (0x1e)
.maxstack 8
@@ -17828,6 +17988,7 @@ .maxstack 8
IL_0018: stsfld 0x0A000026
IL_001d: ret
}
+ .cctor
{
// Code size 11 (0xb)
.maxstack 8
@@ -17835,6 +17996,7 @@ .maxstack 8
IL_0005: stsfld 0x0A00002B
IL_000a: ret
}
+ .ctor
{
// Code size 8 (0x8)
.maxstack 8
@@ -17843,6 +18005,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ b__0#4_0#4
{
// Code size 8 (0x8)
.maxstack 8
@@ -17896,6 +18059,7 @@ class C
});
g.VerifyIL("""
+ F
{
// Code size 13 (0xd)
.maxstack 8
@@ -17904,6 +18068,7 @@ .maxstack 8
IL_0007: newobj 0x0600000C
IL_000c: throw
}
+ b__0#4_0#4
{
// Code size 12 (0xc)
.maxstack 8
@@ -18029,6 +18194,7 @@ class C
});
g.VerifyIL("""
+ F
{
// Code size 13 (0xd)
.maxstack 8
@@ -18037,6 +18203,7 @@ .maxstack 8
IL_0007: newobj 0x06000009
IL_000c: throw
}
+ g__L|0_0, g__M|0_1#1
{
// Code size 12 (0xc)
.maxstack 8
@@ -18045,6 +18212,7 @@ .maxstack 8
IL_0006: newobj 0x06000009
IL_000b: throw
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -18096,6 +18264,7 @@ ref readonly T O(ref readonly T b)
g.VerifyMemberRefNames(".ctor", ".ctor", "x", "g__O|0#3", ".ctor", "g__N|0#3_1#3");
g.VerifyIL("""
+ F
{
// Code size 29 (0x1d)
.maxstack 2
@@ -18113,12 +18282,14 @@ .maxstack 2
IL_001b: pop
IL_001c: ret
}
+ g__N|0#3_1#3
{
// Code size 2 (0x2)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ret
}
+ .ctor
{
// Code size 8 (0x8)
.maxstack 8
@@ -18127,6 +18298,7 @@ .maxstack 8
IL_0006: nop
IL_0007: ret
}
+ g__O|0#3
{
// Code size 9 (0x9)
.maxstack 1
@@ -18139,6 +18311,7 @@ .maxstack 1
IL_0007: ldloc.0
IL_0008: ret
}
+ b__2#3
{
// Code size 12 (0xc)
.maxstack 8
@@ -18187,6 +18360,7 @@ class C
]);
g.VerifyIL("""
+ F
{
// Code size 13 (0xd)
.maxstack 8
@@ -18195,6 +18369,7 @@ .maxstack 8
IL_0007: newobj 0x06000009
IL_000c: throw
}
+ g__N|0#3_1#3, g__O|0#3, b__2#3
{
// Code size 12 (0xc)
.maxstack 8
@@ -18334,6 +18509,7 @@ class C
});
g.VerifyIL("""
+ M
{
// Code size 13 (0xd)
.maxstack 8
@@ -18342,6 +18518,7 @@ .maxstack 8
IL_0007: newobj 0x06000004
IL_000c: throw
}
+ M
{
// Code size 10 (0xa)
.maxstack 8
@@ -18351,6 +18528,7 @@ .maxstack 8
IL_0008: pop
IL_0009: ret
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -18398,6 +18576,7 @@ class C
});
g.VerifyIL("""
+ M
{
// Code size 10 (0xa)
.maxstack 8
@@ -18407,6 +18586,7 @@ .maxstack 8
IL_0008: pop
IL_0009: ret
}
+ M
{
// Code size 13 (0xd)
.maxstack 8
@@ -18483,6 +18663,7 @@ class C
});
g.VerifyIL("""
+ M
{
// Code size 13 (0xd)
.maxstack 8
@@ -18491,6 +18672,7 @@ .maxstack 8
IL_0007: newobj 0x06000004
IL_000c: throw
}
+ M
{
// Code size 7 (0x7)
.maxstack 1
@@ -18501,6 +18683,7 @@ .maxstack 1
IL_0005: ldloc.0
IL_0006: ret
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -18549,6 +18732,7 @@ class C
});
g.VerifyIL("""
+ M
{
// Code size 13 (0xd)
.maxstack 1
@@ -18560,6 +18744,7 @@ .maxstack 1
IL_000b: ldloc.0
IL_000c: ret
}
+ M
{
// Code size 13 (0xd)
.maxstack 8
@@ -18637,6 +18822,7 @@ class C
});
g.VerifyIL("""
+ M
{
// Code size 13 (0xd)
.maxstack 8
@@ -18645,6 +18831,7 @@ .maxstack 8
IL_0007: newobj 0x06000004
IL_000c: throw
}
+ M
{
// Code size 10 (0xa)
.maxstack 8
@@ -18654,6 +18841,7 @@ .maxstack 8
IL_0008: pop
IL_0009: ret
}
+ .ctor
{
// Code size 16 (0x10)
.maxstack 8
@@ -18700,6 +18888,7 @@ class C
});
g.VerifyIL("""
+ M
{
// Code size 10 (0xa)
.maxstack 8
@@ -18709,6 +18898,7 @@ .maxstack 8
IL_0008: pop
IL_0009: ret
}
+ M
{
// Code size 13 (0xd)
.maxstack 8
@@ -19129,7 +19319,7 @@ .locals init (System.Span V_0, //x
[Fact]
[WorkItem("https://github.com/dotnet/roslyn/issues/69480")]
- public void PrivateImplDetails_DataFields_Arrays()
+ public void PrivateImplDetails_DataFields_Arrays_FieldRvaNotSupported()
{
using var _ = new EditAndContinueTest()
.AddBaseline(
@@ -19233,7 +19423,95 @@ .maxstack 5
[Fact]
[WorkItem("https://github.com/dotnet/roslyn/issues/69480")]
- public void PrivateImplDetails_DataFields_StackAlloc()
+ public void PrivateImplDetails_DataFields_Arrays_FieldRvaSupported()
+ {
+ using var _ = new EditAndContinueTest()
+ .AddBaseline(
+ source: $$"""
+ class C
+ {
+ byte[] b = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+ }
+ """,
+ validator: g =>
+ {
+ g.VerifyTypeDefNames("", "C", "", "__StaticArrayInitTypeSize=10");
+ g.VerifyFieldDefNames("b", "1F825AA2F0020EF7CF91DFA30DA4668D791C5D4824FC8E41354B89EC05795AB3");
+ g.VerifyMethodDefNames(".ctor");
+ })
+
+ .AddGeneration(
+ source: """
+ class C
+ {
+ byte[] b = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
+ }
+ """,
+ edits: new[]
+ {
+ Edit(SemanticEditKind.Update, symbolProvider: c => c.GetParameterlessConstructor("C")),
+ },
+ validator: g =>
+ {
+ g.VerifyTypeDefNames("#1", "__StaticArrayInitTypeSize=11");
+ g.VerifyFieldDefNames("78A6273103D17C39A0B6126E226CEC70E33337F4BC6A38067401B54A33E78EAD");
+ g.VerifyMethodDefNames(".ctor");
+
+ g.VerifyEncLogDefinitions(new[]
+ {
+ Row(5, TableIndex.TypeDef, EditAndContinueOperation.Default),
+ Row(6, TableIndex.TypeDef, EditAndContinueOperation.Default),
+ Row(5, TableIndex.TypeDef, EditAndContinueOperation.AddField),
+ Row(3, TableIndex.Field, EditAndContinueOperation.Default),
+ Row(1, TableIndex.MethodDef, EditAndContinueOperation.Default),
+ Row(5, TableIndex.CustomAttribute, EditAndContinueOperation.Default),
+ Row(2, TableIndex.ClassLayout, EditAndContinueOperation.Default),
+ Row(2, TableIndex.FieldRva, EditAndContinueOperation.Default),
+ Row(2, TableIndex.NestedClass, EditAndContinueOperation.Default)
+ });
+
+ g.VerifyEncMapDefinitions(new[]
+ {
+ Handle(5, TableIndex.TypeDef),
+ Handle(6, TableIndex.TypeDef),
+ Handle(3, TableIndex.Field),
+ Handle(1, TableIndex.MethodDef),
+ Handle(5, TableIndex.CustomAttribute),
+ Handle(2, TableIndex.ClassLayout),
+ Handle(2, TableIndex.FieldRva),
+ Handle(2, TableIndex.NestedClass)
+ });
+
+ g.VerifyIL("C..ctor", """
+ {
+ // Code size 32 (0x20)
+ .maxstack 4
+ IL_0000: ldarg.0
+ IL_0001: ldc.i4.s 11
+ IL_0003: newarr "byte"
+ IL_0008: dup
+ IL_0009: ldtoken "#1.__StaticArrayInitTypeSize=11 #1.78A6273103D17C39A0B6126E226CEC70E33337F4BC6A38067401B54A33E78EAD"
+ IL_000e: call "void System.Runtime.CompilerServices.RuntimeHelpers.InitializeArray(System.Array, System.RuntimeFieldHandle)"
+ IL_0013: stfld "byte[] C.b"
+ IL_0018: ldarg.0
+ IL_0019: call "object..ctor()"
+ IL_001e: nop
+ IL_001f: ret
+ }
+ """);
+
+ // trailing zeros for alignment:
+ g.VerifyEncFieldRvaData("""
+ 78A6273103D17C39A0B6126E226CEC70E33337F4BC6A38067401B54A33E78EAD: 00-01-02-03-04-05-06-07-08-09-0A-00-00
+ """);
+ },
+ options: new EmitDifferenceOptions() { EmitFieldRva = true })
+ .Verify();
+ }
+
+ [Fact]
+ [WorkItem("https://github.com/dotnet/roslyn/issues/69480")]
+ public void PrivateImplDetails_DataFields_StackAlloc_FieldRvaNotSupported()
{
using var _ = new EditAndContinueTest(targetFramework: TargetFramework.Net80, verification: Verification.Skipped)
.AddBaseline(
@@ -19342,20 +19620,20 @@ .locals init (System.ReadOnlySpan V_0, //b
[Fact]
[WorkItem("https://github.com/dotnet/roslyn/issues/69480")]
- public void PrivateImplDetails_DataFields_Utf8()
+ public void PrivateImplDetails_DataFields_StackAlloc_FieldRvaSupported()
{
using var _ = new EditAndContinueTest(targetFramework: TargetFramework.Net80, verification: Verification.Skipped)
.AddBaseline(
- source: """
+ source: $$"""
class C
{
- System.ReadOnlySpan F() => "0123456789"u8;
+ void F() { System.ReadOnlySpan b = stackalloc byte[] { 0, 1, 2, 3, 4, 5, 6 }; }
}
""",
validator: g =>
{
- g.VerifyTypeDefNames("", "C", "", "__StaticArrayInitTypeSize=11");
- g.VerifyFieldDefNames("BEB0DBD1C6FAC1140DD817514F2FBDF501E246BF16C8E877E71187E9EB008189");
+ g.VerifyTypeDefNames("", "C", "", "__StaticArrayInitTypeSize=7");
+ g.VerifyFieldDefNames("57355AC3303C148F11AEF7CB179456B9232CDE33A818DFDA2C2FCB9325749A6B");
g.VerifyMethodDefNames("F", ".ctor");
})
@@ -19363,7 +19641,7 @@ class C
source: """
class C
{
- System.ReadOnlySpan F() => "0123456789X"u8;
+ void F() { System.ReadOnlySpan b = stackalloc byte[] { 0, 1, 2, 3, 4, 5, 6, 7 }; }
}
""",
edits: new[]
@@ -19372,49 +19650,140 @@ class C
},
validator: g =>
{
- g.VerifyTypeDefNames();
- g.VerifyFieldDefNames();
+ g.VerifyTypeDefNames("#1");
+ g.VerifyFieldDefNames("8A851FF82EE7048AD09EC3847F1DDF44944104D2CBD17EF4E3DB22C6785A0D45");
g.VerifyMethodDefNames("F");
g.VerifyEncLogDefinitions(new[]
{
- Row(1, TableIndex.MethodDef, EditAndContinueOperation.Default)
+ Row(2, TableIndex.StandAloneSig, EditAndContinueOperation.Default),
+ Row(5, TableIndex.TypeDef, EditAndContinueOperation.Default),
+ Row(5, TableIndex.TypeDef, EditAndContinueOperation.AddField),
+ Row(2, TableIndex.Field, EditAndContinueOperation.Default),
+ Row(1, TableIndex.MethodDef, EditAndContinueOperation.Default),
+ Row(5, TableIndex.CustomAttribute, EditAndContinueOperation.Default),
+ Row(2, TableIndex.FieldRva, EditAndContinueOperation.Default)
});
g.VerifyEncMapDefinitions(new[]
{
- Handle(1, TableIndex.MethodDef)
+ Handle(5, TableIndex.TypeDef),
+ Handle(2, TableIndex.Field),
+ Handle(1, TableIndex.MethodDef),
+ Handle(5, TableIndex.CustomAttribute),
+ Handle(2, TableIndex.StandAloneSig),
+ Handle(2, TableIndex.FieldRva)
});
g.VerifyIL("C.F", """
{
- // Code size 73 (0x49)
+ // Code size 32 (0x20)
.maxstack 4
- IL_0000: ldc.i4.s 12
- IL_0002: newarr "byte"
- IL_0007: dup
- IL_0008: ldc.i4.0
- IL_0009: ldc.i4.s 48
- IL_000b: stelem.i1
- IL_000c: dup
- IL_000d: ldc.i4.1
- IL_000e: ldc.i4.s 49
- IL_0010: stelem.i1
- IL_0011: dup
- IL_0012: ldc.i4.2
- IL_0013: ldc.i4.s 50
- IL_0015: stelem.i1
- IL_0016: dup
- IL_0017: ldc.i4.3
- IL_0018: ldc.i4.s 51
- IL_001a: stelem.i1
- IL_001b: dup
- IL_001c: ldc.i4.4
- IL_001d: ldc.i4.s 52
- IL_001f: stelem.i1
- IL_0020: dup
- IL_0021: ldc.i4.5
- IL_0022: ldc.i4.s 53
+ .locals init (System.ReadOnlySpan V_0, //b
+ System.Span V_1)
+ IL_0000: nop
+ IL_0001: ldc.i4.8
+ IL_0002: conv.u
+ IL_0003: localloc
+ IL_0005: dup
+ IL_0006: ldsflda "long #1.8A851FF82EE7048AD09EC3847F1DDF44944104D2CBD17EF4E3DB22C6785A0D45"
+ IL_000b: ldc.i4.8
+ IL_000c: unaligned. 1
+ IL_000f: cpblk
+ IL_0011: ldc.i4.8
+ IL_0012: newobj "System.Span..ctor(void*, int)"
+ IL_0017: stloc.1
+ IL_0018: ldloc.1
+ IL_0019: call "System.ReadOnlySpan System.Span.op_Implicit(System.Span)"
+ IL_001e: stloc.0
+ IL_001f: ret
+ }
+ """);
+
+ // trailing zeros for alignment:
+ g.VerifyEncFieldRvaData("""
+ 8A851FF82EE7048AD09EC3847F1DDF44944104D2CBD17EF4E3DB22C6785A0D45: 00-01-02-03-04-05-06-07
+ """);
+ },
+ options: new EmitDifferenceOptions() { EmitFieldRva = true })
+ .Verify();
+ }
+
+ [Fact]
+ [WorkItem("https://github.com/dotnet/roslyn/issues/69480")]
+ public void PrivateImplDetails_DataFields_Utf8_FieldRvaNotSupported()
+ {
+ using var _ = new EditAndContinueTest(targetFramework: TargetFramework.Net80, verification: Verification.Skipped)
+ .AddBaseline(
+ source: """
+ class C
+ {
+ System.ReadOnlySpan F() => "0123456789"u8;
+ }
+ """,
+ validator: g =>
+ {
+ g.VerifyTypeDefNames("", "C", "", "__StaticArrayInitTypeSize=11");
+ g.VerifyFieldDefNames("BEB0DBD1C6FAC1140DD817514F2FBDF501E246BF16C8E877E71187E9EB008189");
+ g.VerifyMethodDefNames("F", ".ctor");
+ })
+
+ .AddGeneration(
+ source: """
+ class C
+ {
+ System.ReadOnlySpan F() => "0123456789X"u8;
+ }
+ """,
+ edits: new[]
+ {
+ Edit(SemanticEditKind.Update, symbolProvider: c => c.GetMember("C.F")),
+ },
+ validator: g =>
+ {
+ g.VerifyTypeDefNames();
+ g.VerifyFieldDefNames();
+ g.VerifyMethodDefNames("F");
+
+ g.VerifyEncLogDefinitions(new[]
+ {
+ Row(1, TableIndex.MethodDef, EditAndContinueOperation.Default)
+ });
+
+ g.VerifyEncMapDefinitions(new[]
+ {
+ Handle(1, TableIndex.MethodDef)
+ });
+
+ g.VerifyIL("C.F", """
+ {
+ // Code size 73 (0x49)
+ .maxstack 4
+ IL_0000: ldc.i4.s 12
+ IL_0002: newarr "byte"
+ IL_0007: dup
+ IL_0008: ldc.i4.0
+ IL_0009: ldc.i4.s 48
+ IL_000b: stelem.i1
+ IL_000c: dup
+ IL_000d: ldc.i4.1
+ IL_000e: ldc.i4.s 49
+ IL_0010: stelem.i1
+ IL_0011: dup
+ IL_0012: ldc.i4.2
+ IL_0013: ldc.i4.s 50
+ IL_0015: stelem.i1
+ IL_0016: dup
+ IL_0017: ldc.i4.3
+ IL_0018: ldc.i4.s 51
+ IL_001a: stelem.i1
+ IL_001b: dup
+ IL_001c: ldc.i4.4
+ IL_001d: ldc.i4.s 52
+ IL_001f: stelem.i1
+ IL_0020: dup
+ IL_0021: ldc.i4.5
+ IL_0022: ldc.i4.s 53
IL_0024: stelem.i1
IL_0025: dup
IL_0026: ldc.i4.6
@@ -19446,6 +19815,493 @@ .maxstack 4
.Verify();
}
+ [Fact]
+ [WorkItem("https://github.com/dotnet/roslyn/issues/69480")]
+ public void PrivateImplDetails_DataFields_Utf8_FieldRvaSupported()
+ {
+ using var _ = new EditAndContinueTest(targetFramework: TargetFramework.Net80, verification: Verification.Skipped)
+ .AddBaseline(
+ source: """
+ class C
+ {
+ System.ReadOnlySpan F() => "0123456789"u8;
+ }
+ """,
+ validator: g =>
+ {
+ g.VerifyTypeDefNames("", "C", "", "__StaticArrayInitTypeSize=11");
+ g.VerifyFieldDefNames("BEB0DBD1C6FAC1140DD817514F2FBDF501E246BF16C8E877E71187E9EB008189");
+ g.VerifyMethodDefNames("F", ".ctor");
+ })
+
+ .AddGeneration(
+ source: """
+ class C
+ {
+ System.ReadOnlySpan F() => "0123456789X"u8;
+ }
+ """,
+ edits: new[]
+ {
+ Edit(SemanticEditKind.Update, symbolProvider: c => c.GetMember("C.F")),
+ },
+ validator: g =>
+ {
+ g.VerifyTypeDefNames("#1", "__StaticArrayInitTypeSize=12");
+ g.VerifyFieldDefNames("AFB1C33C5229BFF7EF739BA44DA795A2B68A49E06001C07C5B026CAA6C6322BB");
+ g.VerifyMethodDefNames("F");
+
+ g.VerifyEncLogDefinitions(new[]
+ {
+ Row(5, TableIndex.TypeDef, EditAndContinueOperation.Default),
+ Row(6, TableIndex.TypeDef, EditAndContinueOperation.Default),
+ Row(5, TableIndex.TypeDef, EditAndContinueOperation.AddField),
+ Row(2, TableIndex.Field, EditAndContinueOperation.Default),
+ Row(1, TableIndex.MethodDef, EditAndContinueOperation.Default),
+ Row(5, TableIndex.CustomAttribute, EditAndContinueOperation.Default),
+ Row(2, TableIndex.ClassLayout, EditAndContinueOperation.Default),
+ Row(2, TableIndex.FieldRva, EditAndContinueOperation.Default),
+ Row(2, TableIndex.NestedClass, EditAndContinueOperation.Default)
+ });
+
+ g.VerifyEncMapDefinitions(new[]
+ {
+ Handle(5, TableIndex.TypeDef),
+ Handle(6, TableIndex.TypeDef),
+ Handle(2, TableIndex.Field),
+ Handle(1, TableIndex.MethodDef),
+ Handle(5, TableIndex.CustomAttribute),
+ Handle(2, TableIndex.ClassLayout),
+ Handle(2, TableIndex.FieldRva),
+ Handle(2, TableIndex.NestedClass)
+ });
+
+ g.VerifyIL("C.F", """
+ {
+ // Code size 13 (0xd)
+ .maxstack 2
+ IL_0000: ldsflda "#1.__StaticArrayInitTypeSize=12 #1.AFB1C33C5229BFF7EF739BA44DA795A2B68A49E06001C07C5B026CAA6C6322BB"
+ IL_0005: ldc.i4.s 11
+ IL_0007: newobj "System.ReadOnlySpan..ctor(void*, int)"
+ IL_000c: ret
+ }
+ """);
+
+ // trailing zeros for alignment:
+ g.VerifyEncFieldRvaData($"""
+ AFB1C33C5229BFF7EF739BA44DA795A2B68A49E06001C07C5B026CAA6C6322BB: {BitConverter.ToString(Encoding.UTF8.GetBytes("0123456789X"))}-00-00-00-00-00-00-00
+ """);
+ },
+ options: new EmitDifferenceOptions() { EmitFieldRva = true })
+ .Verify();
+ }
+
+ [Fact]
+ [WorkItem("https://github.com/dotnet/roslyn/issues/69480")]
+ public void PrivateImplDetails_DataSectionStringLiterals_FieldRvaSupported()
+ {
+ var parseOptions = TestOptions.Regular.WithFeature("experimental-data-section-string-literals", "0");
+
+ using var _ = new EditAndContinueTest(targetFramework: TargetFramework.Net90, verification: Verification.Skipped, parseOptions: parseOptions)
+ .AddBaseline(
+ source: """
+ class C
+ {
+ string F() => "0123456789";
+ }
+ """,
+ validator: g =>
+ {
+ g.VerifyTypeDefNames("", "C", "", "__StaticArrayInitTypeSize=10", "E353667619EC664B49655FC9692165FB");
+ g.VerifyFieldDefNames("84D89877F0D4041EFB6BF91A16F0248F2FD573E6AF05C19F96BEDB9F882F7882", "s");
+ g.VerifyMethodDefNames("F", ".ctor", "BytesToString", ".cctor");
+ })
+ .AddGeneration(
+ source: """
+ class C
+ {
+ string F() => "0123456789X";
+ }
+ """,
+ edits:
+ [
+ Edit(SemanticEditKind.Update, symbolProvider: c => c.GetMember("C.F")),
+ ],
+ validator: g =>
+ {
+ g.VerifyTypeDefNames("#1", "__StaticArrayInitTypeSize=11", "6D2201523542AEFFB91657B2AEBDC84B");
+ g.VerifyFieldDefNames("ACE59E7D984CCEB2D860A056A3386344236CE5C42C978E26ECE3F35956DAC3AD", "s");
+ g.VerifyMethodDefNames("F", "BytesToString", ".cctor");
+
+ g.VerifyEncLogDefinitions(
+ [
+ Row(6, TableIndex.TypeDef, EditAndContinueOperation.Default),
+ Row(7, TableIndex.TypeDef, EditAndContinueOperation.Default),
+ Row(8, TableIndex.TypeDef, EditAndContinueOperation.Default),
+ Row(6, TableIndex.TypeDef, EditAndContinueOperation.AddField),
+ Row(3, TableIndex.Field, EditAndContinueOperation.Default),
+ Row(8, TableIndex.TypeDef, EditAndContinueOperation.AddField),
+ Row(4, TableIndex.Field, EditAndContinueOperation.Default),
+ Row(1, TableIndex.MethodDef, EditAndContinueOperation.Default),
+ Row(6, TableIndex.TypeDef, EditAndContinueOperation.AddMethod),
+ Row(5, TableIndex.MethodDef, EditAndContinueOperation.Default),
+ Row(8, TableIndex.TypeDef, EditAndContinueOperation.AddMethod),
+ Row(6, TableIndex.MethodDef, EditAndContinueOperation.Default),
+ Row(5, TableIndex.MethodDef, EditAndContinueOperation.AddParameter),
+ Row(3, TableIndex.Param, EditAndContinueOperation.Default),
+ Row(5, TableIndex.MethodDef, EditAndContinueOperation.AddParameter),
+ Row(4, TableIndex.Param, EditAndContinueOperation.Default),
+ Row(6, TableIndex.CustomAttribute, EditAndContinueOperation.Default),
+ Row(2, TableIndex.ClassLayout, EditAndContinueOperation.Default),
+ Row(2, TableIndex.FieldRva, EditAndContinueOperation.Default),
+ Row(3, TableIndex.NestedClass, EditAndContinueOperation.Default),
+ Row(4, TableIndex.NestedClass, EditAndContinueOperation.Default)
+ ]);
+
+ g.VerifyEncMapDefinitions(
+ [
+ Handle(6, TableIndex.TypeDef),
+ Handle(7, TableIndex.TypeDef),
+ Handle(8, TableIndex.TypeDef),
+ Handle(3, TableIndex.Field),
+ Handle(4, TableIndex.Field),
+ Handle(1, TableIndex.MethodDef),
+ Handle(5, TableIndex.MethodDef),
+ Handle(6, TableIndex.MethodDef),
+ Handle(3, TableIndex.Param),
+ Handle(4, TableIndex.Param),
+ Handle(6, TableIndex.CustomAttribute),
+ Handle(2, TableIndex.ClassLayout),
+ Handle(2, TableIndex.FieldRva),
+ Handle(3, TableIndex.NestedClass),
+ Handle(4, TableIndex.NestedClass)
+ ]);
+
+ g.VerifyIL("C.F", """
+ {
+ // Code size 6 (0x6)
+ .maxstack 1
+ IL_0000: ldsfld "string #1.6D2201523542AEFFB91657B2AEBDC84B.s"
+ IL_0005: ret
+ }
+ """);
+
+ // trailing zeros for alignment:
+ g.VerifyEncFieldRvaData($"""
+ ACE59E7D984CCEB2D860A056A3386344236CE5C42C978E26ECE3F35956DAC3AD: {BitConverter.ToString(Encoding.UTF8.GetBytes("0123456789X"))}-00
+ """);
+ },
+ options: new EmitDifferenceOptions() { EmitFieldRva = true })
+ .Verify();
+ }
+
+ [Fact]
+ [WorkItem("https://github.com/dotnet/roslyn/issues/69480")]
+ public void PrivateImplDetails_DataSectionStringLiterals_FieldRvaNotSupported()
+ {
+ var parseOptions = TestOptions.Regular.WithFeature("experimental-data-section-string-literals", "0");
+
+ using var _ = new EditAndContinueTest(targetFramework: TargetFramework.Net90, verification: Verification.Skipped, parseOptions: parseOptions)
+ .AddBaseline(
+ source: """
+ class C
+ {
+ string F() => "0123456789";
+ }
+ """,
+ validator: g =>
+ {
+ g.VerifyTypeDefNames("", "C", "", "__StaticArrayInitTypeSize=10", "E353667619EC664B49655FC9692165FB");
+ g.VerifyFieldDefNames("84D89877F0D4041EFB6BF91A16F0248F2FD573E6AF05C19F96BEDB9F882F7882", "s");
+ g.VerifyMethodDefNames("F", ".ctor", "BytesToString", ".cctor");
+ })
+ .AddGeneration(
+ source: """
+ class C
+ {
+ string F() => "0123456789X";
+ }
+ """,
+ edits:
+ [
+ Edit(SemanticEditKind.Update, symbolProvider: c => c.GetMember("C.F")),
+ ],
+ validator: g =>
+ {
+ g.VerifyTypeDefNames();
+ g.VerifyFieldDefNames();
+ g.VerifyMethodDefNames("F");
+
+ g.VerifyEncLogDefinitions(
+ [
+ Row(1, TableIndex.MethodDef, EditAndContinueOperation.Default)
+ ]);
+
+ g.VerifyEncMapDefinitions(
+ [
+ Handle(1, TableIndex.MethodDef)
+ ]);
+
+ g.VerifyIL("C.F", """
+ {
+ // Code size 6 (0x6)
+ .maxstack 1
+ IL_0000: ldstr "0123456789X"
+ IL_0005: ret
+ }
+ """);
+ })
+ .Verify();
+ }
+
+ [Fact]
+ [WorkItem("https://github.com/dotnet/roslyn/issues/69480")]
+ public void PrivateImplDetails_DataSectionStringLiterals_HeapOverflow_FieldRvaSupported()
+ {
+ // The longest string that can fit in the #US heap. The next string would overflow the heap.
+ var baseString = new string('x', (1 << 23) - 3);
+
+ using var _ = new EditAndContinueTest(targetFramework: TargetFramework.Net90, verification: Verification.Skipped)
+ .AddBaseline(
+ source: $$"""
+ class C
+ {
+ string F() => "{{baseString}}";
+ }
+ """,
+ validator: g =>
+ {
+ g.VerifyTypeDefNames("", "C");
+ g.VerifyFieldDefNames();
+ g.VerifyMethodDefNames("F", ".ctor");
+ })
+ .AddGeneration(
+ source: """
+ class C
+ {
+ string F() => "0123456789";
+ }
+ """,
+ edits:
+ [
+ Edit(SemanticEditKind.Update, symbolProvider: c => c.GetMember("C.F")),
+ ],
+ validator: g =>
+ {
+ g.VerifyTypeDefNames("#1", "__StaticArrayInitTypeSize=10", "E353667619EC664B49655FC9692165FB");
+ g.VerifyFieldDefNames("84D89877F0D4041EFB6BF91A16F0248F2FD573E6AF05C19F96BEDB9F882F7882", "s");
+ g.VerifyMethodDefNames("F", "BytesToString", ".cctor");
+
+ g.VerifyEncLogDefinitions(
+ [
+ Row(3, TableIndex.TypeDef, EditAndContinueOperation.Default),
+ Row(4, TableIndex.TypeDef, EditAndContinueOperation.Default),
+ Row(5, TableIndex.TypeDef, EditAndContinueOperation.Default),
+ Row(3, TableIndex.TypeDef, EditAndContinueOperation.AddField),
+ Row(1, TableIndex.Field, EditAndContinueOperation.Default),
+ Row(5, TableIndex.TypeDef, EditAndContinueOperation.AddField),
+ Row(2, TableIndex.Field, EditAndContinueOperation.Default),
+ Row(1, TableIndex.MethodDef, EditAndContinueOperation.Default),
+ Row(3, TableIndex.TypeDef, EditAndContinueOperation.AddMethod),
+ Row(3, TableIndex.MethodDef, EditAndContinueOperation.Default),
+ Row(5, TableIndex.TypeDef, EditAndContinueOperation.AddMethod),
+ Row(4, TableIndex.MethodDef, EditAndContinueOperation.Default),
+ Row(3, TableIndex.MethodDef, EditAndContinueOperation.AddParameter),
+ Row(1, TableIndex.Param, EditAndContinueOperation.Default),
+ Row(3, TableIndex.MethodDef, EditAndContinueOperation.AddParameter),
+ Row(2, TableIndex.Param, EditAndContinueOperation.Default),
+ Row(4, TableIndex.CustomAttribute, EditAndContinueOperation.Default),
+ Row(1, TableIndex.ClassLayout, EditAndContinueOperation.Default),
+ Row(1, TableIndex.FieldRva, EditAndContinueOperation.Default),
+ Row(1, TableIndex.NestedClass, EditAndContinueOperation.Default),
+ Row(2, TableIndex.NestedClass, EditAndContinueOperation.Default)
+ ]);
+
+ g.VerifyEncMapDefinitions(
+ [
+ Handle(3, TableIndex.TypeDef),
+ Handle(4, TableIndex.TypeDef),
+ Handle(5, TableIndex.TypeDef),
+ Handle(1, TableIndex.Field),
+ Handle(2, TableIndex.Field),
+ Handle(1, TableIndex.MethodDef),
+ Handle(3, TableIndex.MethodDef),
+ Handle(4, TableIndex.MethodDef),
+ Handle(1, TableIndex.Param),
+ Handle(2, TableIndex.Param),
+ Handle(4, TableIndex.CustomAttribute),
+ Handle(1, TableIndex.ClassLayout),
+ Handle(1, TableIndex.FieldRva),
+ Handle(1, TableIndex.NestedClass),
+ Handle(2, TableIndex.NestedClass)
+ ]);
+
+ g.VerifyIL("C.F", """
+ {
+ // Code size 6 (0x6)
+ .maxstack 1
+ IL_0000: ldsfld "string #1.E353667619EC664B49655FC9692165FB.s"
+ IL_0005: ret
+ }
+ """);
+
+ // trailing zeros for alignment:
+ g.VerifyEncFieldRvaData($"""
+ 84D89877F0D4041EFB6BF91A16F0248F2FD573E6AF05C19F96BEDB9F882F7882: {BitConverter.ToString(Encoding.UTF8.GetBytes("0123456789"))}-00-00
+ """);
+ },
+ options: new EmitDifferenceOptions() { EmitFieldRva = true })
+ .Verify();
+ }
+
+ [Fact]
+ public void PrivateImplDetails_DataSectionStringLiterals_StringReuse_FieldRvaSupported()
+ {
+ // Literals are currently only reused within generation.
+
+ var baseString = new string('x', (1 << 23) - 100);
+ var newString1 = new string('1', 40);
+ var newString2 = new string('2', 80);
+
+ using var _ = new EditAndContinueTest(targetFramework: TargetFramework.Net90, verification: Verification.Skipped)
+ .AddBaseline(
+ source: $$"""
+ class C
+ {
+ void G(string a, string b, string c) {}
+
+ void F() => G("{{baseString}}", "{{newString1}}", "");
+ }
+ """,
+ validator: g =>
+ {
+ g.VerifyTypeDefNames("", "C");
+ g.VerifyFieldDefNames();
+ g.VerifyMethodDefNames("G", "F", ".ctor");
+ })
+ .AddGeneration(
+ source: $$"""
+ class C
+ {
+ void G(string a, string b, string c) {}
+
+ void F() => G("{{newString2}}", "{{newString2}}", "{{newString1}}");
+ }
+ """,
+ edits:
+ [
+ Edit(SemanticEditKind.Update, symbolProvider: c => c.GetMember("C.F")),
+ ],
+ validator: g =>
+ {
+ g.VerifyTypeDefNames("#1", "__StaticArrayInitTypeSize=40", "62CF64E173E5BF9EF5312BB6D57CC26C");
+ g.VerifyFieldDefNames("468D019EA81224AECA7EE270B11959D8A187F6F0B6A3FEBFF1C34DC1D66C8D85", "s");
+ g.VerifyMethodDefNames("F", "BytesToString", ".cctor");
+
+ g.VerifyEncLogDefinitions(
+ [
+ Row(3, TableIndex.TypeDef, EditAndContinueOperation.Default),
+ Row(4, TableIndex.TypeDef, EditAndContinueOperation.Default),
+ Row(5, TableIndex.TypeDef, EditAndContinueOperation.Default),
+ Row(3, TableIndex.TypeDef, EditAndContinueOperation.AddField),
+ Row(1, TableIndex.Field, EditAndContinueOperation.Default),
+ Row(5, TableIndex.TypeDef, EditAndContinueOperation.AddField),
+ Row(2, TableIndex.Field, EditAndContinueOperation.Default),
+ Row(2, TableIndex.MethodDef, EditAndContinueOperation.Default),
+ Row(3, TableIndex.TypeDef, EditAndContinueOperation.AddMethod),
+ Row(4, TableIndex.MethodDef, EditAndContinueOperation.Default),
+ Row(5, TableIndex.TypeDef, EditAndContinueOperation.AddMethod),
+ Row(5, TableIndex.MethodDef, EditAndContinueOperation.Default),
+ Row(4, TableIndex.MethodDef, EditAndContinueOperation.AddParameter),
+ Row(4, TableIndex.Param, EditAndContinueOperation.Default),
+ Row(4, TableIndex.MethodDef, EditAndContinueOperation.AddParameter),
+ Row(5, TableIndex.Param, EditAndContinueOperation.Default),
+ Row(4, TableIndex.CustomAttribute, EditAndContinueOperation.Default),
+ Row(1, TableIndex.ClassLayout, EditAndContinueOperation.Default),
+ Row(1, TableIndex.FieldRva, EditAndContinueOperation.Default),
+ Row(1, TableIndex.NestedClass, EditAndContinueOperation.Default),
+ Row(2, TableIndex.NestedClass, EditAndContinueOperation.Default)
+ ]);
+
+ g.VerifyEncMapDefinitions(
+ [
+ Handle(3, TableIndex.TypeDef),
+ Handle(4, TableIndex.TypeDef),
+ Handle(5, TableIndex.TypeDef),
+ Handle(1, TableIndex.Field),
+ Handle(2, TableIndex.Field),
+ Handle(2, TableIndex.MethodDef),
+ Handle(4, TableIndex.MethodDef),
+ Handle(5, TableIndex.MethodDef),
+ Handle(4, TableIndex.Param),
+ Handle(5, TableIndex.Param),
+ Handle(4, TableIndex.CustomAttribute),
+ Handle(1, TableIndex.ClassLayout),
+ Handle(1, TableIndex.FieldRva),
+ Handle(1, TableIndex.NestedClass),
+ Handle(2, TableIndex.NestedClass)
+ ]);
+
+ g.VerifyIL("C.F", """
+ {
+ // Code size 23 (0x17)
+ .maxstack 4
+ IL_0000: ldarg.0
+ IL_0001: ldstr "22222222222222222222222222222222222222222222222222222222222222222222222222222222"
+ IL_0006: ldstr "22222222222222222222222222222222222222222222222222222222222222222222222222222222"
+ IL_000b: ldsfld "string #1.62CF64E173E5BF9EF5312BB6D57CC26C.s"
+ IL_0010: call "void C.G(string, string, string)"
+ IL_0015: nop
+ IL_0016: ret
+ }
+ """);
+ },
+ options: new EmitDifferenceOptions() { EmitFieldRva = true })
+ .Verify();
+ }
+
+ [Fact]
+ public void PrivateImplDetails_DataSectionStringLiterals_HeapOverflow_FieldRvaNotSupported()
+ {
+ // The max number of bytes that can fit into #US the heap is 2^29 - 1,
+ // but each string also needs to have an offset < 0x1000000 (2^24) to be addressable by a token.
+ // If the string is larger than that the next string can't be emitted.
+ var baseString = new string('x', 1 << 23);
+
+ using var _ = new EditAndContinueTest(targetFramework: TargetFramework.Net90, verification: Verification.Skipped)
+ .AddBaseline(
+ source: $$"""
+ class C
+ {
+ string F() => "{{baseString}}";
+ }
+ """,
+ validator: g =>
+ {
+ g.VerifyTypeDefNames("", "C");
+ g.VerifyFieldDefNames();
+ g.VerifyMethodDefNames("F", ".ctor");
+ })
+ .AddGeneration(
+ source: """
+ class C
+ {
+ string F() => "new string that doesn't fit";
+ }
+ """,
+ edits:
+ [
+ Edit(SemanticEditKind.Update, symbolProvider: c => c.GetMember("C.F")),
+ ],
+ expectedErrors:
+ [
+ // (3,19): error CS9307: Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.
+ // string F() => "new string that doesn't fit";
+ Diagnostic(ErrorCode.ERR_TooManyUserStrings_RestartRequired, @"""new string that doesn't fit""").WithLocation(3, 19)
+ ])
+ .Verify();
+ }
+
[Theory]
[InlineData("ComputeStringHash", "string")]
[InlineData("ComputeSpanHash", "Span")]
diff --git a/src/Compilers/Core/CodeAnalysisTest/MetadataReferences/MetadataHelpersTests.cs b/src/Compilers/Core/CodeAnalysisTest/MetadataReferences/MetadataHelpersTests.cs
index 63341865aa107..b6494e4c279da 100644
--- a/src/Compilers/Core/CodeAnalysisTest/MetadataReferences/MetadataHelpersTests.cs
+++ b/src/Compilers/Core/CodeAnalysisTest/MetadataReferences/MetadataHelpersTests.cs
@@ -503,5 +503,16 @@ public void ObfuscatedNamespaceNames_02()
Assert.Equal("a", nestedNamespaces.ElementAt(0).Key);
Assert.Equal("b", nestedNamespaces.ElementAt(1).Key);
}
+
+ [Theory]
+ [InlineData("")]
+ [InlineData("abc")]
+ [InlineData("\u1234")]
+ public static void GetUserStringBlobSize(string str)
+ {
+ var builder = new BlobBuilder();
+ builder.WriteUserString(str);
+ Assert.Equal(builder.Count, MetadataHelpers.GetUserStringBlobSize(str));
+ }
}
}
diff --git a/src/Compilers/Core/Portable/CodeGen/ILBuilder.cs b/src/Compilers/Core/Portable/CodeGen/ILBuilder.cs
index 2a170dbc2ffa9..3d7af82151476 100644
--- a/src/Compilers/Core/Portable/CodeGen/ILBuilder.cs
+++ b/src/Compilers/Core/Portable/CodeGen/ILBuilder.cs
@@ -2,15 +2,15 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-#nullable disable
-
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Reflection.Metadata;
using Microsoft.CodeAnalysis.Debugging;
+using Microsoft.CodeAnalysis.Emit;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Text;
@@ -20,20 +20,21 @@ namespace Microsoft.CodeAnalysis.CodeGen
internal sealed partial class ILBuilder
{
private readonly OptimizationLevel _optimizations;
- internal readonly LocalSlotManager LocalSlotManager;
+ internal readonly LocalSlotManager? LocalSlotManager;
+ private readonly DiagnosticBag _diagnostics;
private readonly LocalScopeManager _scopeManager;
// internal for testing
- internal readonly ITokenDeferral module;
+ internal readonly CommonPEModuleBuilder module;
//leader block is the entry point of the method body
internal readonly BasicBlock leaderBlock;
private EmitState _emitState;
- private BasicBlock _lastCompleteBlock;
- private BasicBlock _currentBlock;
+ private BasicBlock? _lastCompleteBlock;
+ private BasicBlock? _currentBlock;
- private SyntaxTree _lastSeqPointTree;
+ private SyntaxTree? _lastSeqPointTree;
private readonly SmallDictionary