Skip to content

Commit 264f04f

Browse files
authored
EnC: Block additions to MethodImpl table when targeting .NET Framework (#81304)
Block additions to MethodImpl table when targeting .NET Framework. The EnC impl in .NET Framework doesn't handle them correctly. Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2631743 and https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1452066/ Public API change: #81305
1 parent f445b97 commit 264f04f

File tree

60 files changed

+411
-22
lines changed

Some content is hidden

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

60 files changed

+411
-22
lines changed

src/Compilers/CSharp/Portable/CSharpResources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,6 +1799,9 @@ If such a class is used as a base class and if the deriving class defines a dest
17991799
<data name="ERR_DllImportOnInvalidMethod" xml:space="preserve">
18001800
<value>The DllImport attribute must be specified on a method marked 'extern' that is either 'static' or an extension member</value>
18011801
</data>
1802+
<data name="ERR_EncUpdateRequiresEmittingExplicitInterfaceImplementationNotSupportedByTheRuntime" xml:space="preserve">
1803+
<value>Update requires emitting explicit interface implementation, which is not supported by the runtime without restarting the application.</value>
1804+
</data>
18021805
<data name="ERR_EncUpdateFailedMissingSymbol" xml:space="preserve">
18031806
<value>Cannot emit update; {0} '{1}' is missing.</value>
18041807
</data>

src/Compilers/CSharp/Portable/Emitter/EditAndContinue/PEDeltaAssemblyBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public PEDeltaAssemblyBuilder(
7878
public override SymbolChanges? EncSymbolChanges => _changes;
7979
public override EmitBaseline PreviousGeneration => _changes.DefinitionMap.Baseline;
8080
public override bool FieldRvaSupported => _options.EmitFieldRva;
81+
public override bool MethodImplSupported => _options.MethodImplEntriesSupported;
8182

8283
internal override Cci.ITypeReference EncTranslateLocalVariableType(TypeSymbol type, DiagnosticBag diagnostics)
8384
{

src/Compilers/CSharp/Portable/Emitter/Model/PEAssemblyBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,7 @@ internal sealed class PEAssemblyBuilder(
693693
public override EmitBaseline? PreviousGeneration => null;
694694
public override SymbolChanges? EncSymbolChanges => null;
695695
public override bool FieldRvaSupported => true;
696+
public override bool MethodImplSupported => true;
696697

697698
public override INamedTypeSymbolInternal? TryGetOrCreateSynthesizedHotReloadExceptionType()
698699
=> null;

src/Compilers/CSharp/Portable/Emitter/Model/PENetModuleBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ protected override void AddEmbeddedResourcesFromAddedModules(ArrayBuilder<Cci.Ma
4040
public override EmitBaseline? PreviousGeneration => null;
4141
public override SymbolChanges? EncSymbolChanges => null;
4242
public override bool FieldRvaSupported => true;
43+
public override bool MethodImplSupported => true;
4344

4445
public override INamedTypeSymbolInternal? TryGetOrCreateSynthesizedHotReloadExceptionType()
4546
=> null;

src/Compilers/CSharp/Portable/Errors/ErrorCode.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2444,6 +2444,7 @@ internal enum ErrorCode
24442444
ERR_UnexpectedArgumentListInBaseTypeWithoutParameterList = 9343,
24452445
ERR_EqualityOperatorInPatternNotSupported = 9344,
24462446
ERR_InequalityOperatorInPatternNotSupported = 9345,
2447+
ERR_EncUpdateRequiresEmittingExplicitInterfaceImplementationNotSupportedByTheRuntime = 9346,
24472448

24482449
// Note: you will need to do the following after adding errors:
24492450
// 1) Update ErrorFacts.IsBuildOnlyDiagnostic (src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs)

src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,10 @@ or ErrorCode.ERR_DataSectionStringLiteralHashCollision
641641
or ErrorCode.ERR_UnsupportedFeatureInRuntimeAsync
642642
or ErrorCode.ERR_NonTaskMainCantBeAsync
643643
or ErrorCode.ERR_FunctionPointerTypesInAttributeNotSupported
644+
or ErrorCode.ERR_EncUpdateFailedMissingSymbol
645+
or ErrorCode.ERR_EncNoPIAReference
646+
or ErrorCode.ERR_EncReferenceToAddedMember
647+
or ErrorCode.ERR_EncUpdateRequiresEmittingExplicitInterfaceImplementationNotSupportedByTheRuntime
644648
// Update src\Features\CSharp\Portable\Diagnostics\LanguageServer\CSharpLspBuildOnlyDiagnostics.cs
645649
// and TestIsBuildOnlyDiagnostic in src\Compilers\CSharp\Test\Syntax\Diagnostics\DiagnosticTest.cs
646650
// whenever new values are added here.
@@ -1609,7 +1613,6 @@ or ErrorCode.WRN_InvalidVersionFormat
16091613
or ErrorCode.ERR_NoCorrespondingArgument
16101614
or ErrorCode.ERR_ResourceFileNameNotUnique
16111615
or ErrorCode.ERR_DllImportOnGenericMethod
1612-
or ErrorCode.ERR_EncUpdateFailedMissingSymbol
16131616
or ErrorCode.ERR_ParameterNotValidForType
16141617
or ErrorCode.ERR_AttributeParameterRequired1
16151618
or ErrorCode.ERR_AttributeParameterRequired2
@@ -1649,11 +1652,9 @@ or ErrorCode.ERR_FixedBufferTooManyDimensions
16491652
or ErrorCode.ERR_CantReadConfigFile
16501653
or ErrorCode.ERR_BadAwaitInCatchFilter
16511654
or ErrorCode.WRN_FilterIsConstantTrue
1652-
or ErrorCode.ERR_EncNoPIAReference
16531655
or ErrorCode.ERR_LinkedNetmoduleMetadataMustProvideFullPEImage
16541656
or ErrorCode.ERR_MetadataReferencesNotSupported
16551657
or ErrorCode.ERR_InvalidAssemblyCulture
1656-
or ErrorCode.ERR_EncReferenceToAddedMember
16571658
or ErrorCode.ERR_MutuallyExclusiveOptions
16581659
or ErrorCode.ERR_InvalidDebugInfo
16591660
or ErrorCode.WRN_UnimplementedCommandLineSwitch

src/Compilers/CSharp/Portable/Errors/MessageProvider.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ public override void ReportDuplicateMetadataReferenceWeak(DiagnosticBag diagnost
253253
public override int ERR_InvalidDebugInfo => (int)ErrorCode.ERR_InvalidDebugInfo;
254254
public override int ERR_FunctionPointerTypesInAttributeNotSupported => (int)ErrorCode.ERR_FunctionPointerTypesInAttributeNotSupported;
255255
public override int ERR_DataSectionStringLiteralHashCollision => (int)ErrorCode.ERR_DataSectionStringLiteralHashCollision;
256+
public override int ERR_EncUpdateRequiresEmittingExplicitInterfaceImplementationNotSupportedByTheRuntime => (int)ErrorCode.ERR_EncUpdateRequiresEmittingExplicitInterfaceImplementationNotSupportedByTheRuntime;
256257

257258
// Generators:
258259
public override int WRN_GeneratorFailedDuringInitialization => (int)ErrorCode.WRN_GeneratorFailedDuringInitialization;

src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)