Skip to content

Removal of debugger attributes causes linker warnings in code which refers to those attributes #39707

@vitek-karas

Description

@vitek-karas

With the recent debugger feature switch linker is now tasked to remove some attributes which are related to the debugger. Linker will do that for all attribute instantiations, but if there's code which refers to the removed attribute's type directly, linker will generate a warning since it's likely the behavior of that code will change.

Currently this produces 4 warnings in CoreLib:

ILLink: warning IL2045: System.Diagnostics.StackTrace.ToString(StackTrace.TraceFormat,StringBuilder): Custom Attribute System.Runtime.CompilerServices.CompilerGeneratedAttribute is being referenced in code but the linker was instructed to remove all instances of this attribute. If the attribute instances are necessary make sure to either remove the linker attribute XML portion which removes the attribute instances, or to override this use the linker XML descriptor to keep the attribute type (which in turn keeps all of its instances).
ILLink: warning IL2045: System.Diagnostics.StackTrace.ShowInStackTrace(MethodBase): Custom Attribute System.Diagnostics.StackTraceHiddenAttribute is being referenced in code but the linker was instructed to remove all instances of this attribute. If the attribute instances are necessary make sure to either remove the linker attribute XML portion which removes the attribute instances, or to override this use the linker XML descriptor to keep the attribute type (which in turn keeps all of its instances).
ILLink: warning IL2045: System.Diagnostics.StackTrace.ShowInStackTrace(MethodBase): Custom Attribute System.Diagnostics.StackTraceHiddenAttribute is being referenced in code but the linker was instructed to remove all instances of this attribute. If the attribute instances are necessary make sure to either remove the linker attribute XML portion which removes the attribute instances, or to override this use the linker XML descriptor to keep the attribute type (which in turn keeps all of its instances).
ILLink: warning IL2045: System.Diagnostics.Tracing.Statics.CreateDefaultTypeInfo(Type,List<Type>): Custom Attribute System.Runtime.CompilerServices.CompilerGeneratedAttribute is being referenced in code but the linker was instructed to remove all instances of this attribute. If the attribute instances are necessary make sure to either remove the linker attribute XML portion which removes the attribute instances, or to override this use the linker XML descriptor to keep the attribute type (which in turn keeps all of its instances).

We should either suppress these warnings or wrap the code which does this with the respective feature switch so that it gets removed.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions