Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit b785ee1

Browse files
authored
Move debugger attributes to shared partition (#15100)
- Break down DebuggerAttributes.cs into more files, apply cleanup done in CoreRT - Move two outliers (DebuggerStepperBoundaryAttribute, DebuggerVisualizerAttribute) from CoreFX to CoreLib so that all debugger attributes are together
1 parent afa95ac commit b785ee1

12 files changed

+351
-261
lines changed

src/mscorlib/System.Private.CoreLib.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,6 @@
532532
</ItemGroup>
533533
<ItemGroup>
534534
<Compile Include="$(BclSourcesRoot)\System\Diagnostics\Debugger.cs" />
535-
<Compile Include="$(BclSourcesRoot)\System\Diagnostics\DebuggerAttributes.cs" />
536535
<Compile Include="$(BclSourcesRoot)\System\Diagnostics\ICustomDebuggerNotification.cs" />
537536
<Compile Include="$(BclSourcesRoot)\System\Diagnostics\Stacktrace.cs" />
538537
<Compile Include="$(BclSourcesRoot)\System\Diagnostics\Stackframe.cs" />

src/mscorlib/shared/System.Private.CoreLib.Shared.projitems

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@
100100
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\CodeAnalysis\SuppressMessageAttribute.cs" />
101101
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\ConditionalAttribute.cs" />
102102
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\Debug.cs" />
103+
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\DebuggableAttribute.cs" />
104+
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\DebuggerBrowsableAttribute.cs" />
105+
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\DebuggerDisplayAttribute.cs" />
106+
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\DebuggerHiddenAttribute.cs" />
107+
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\DebuggerNonUserCodeAttribute.cs" />
108+
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\DebuggerStepThroughAttribute.cs" />
109+
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\DebuggerStepperBoundaryAttribute.cs" />
110+
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\DebuggerTypeProxyAttribute.cs" />
111+
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\DebuggerVisualizerAttribute.cs" />
103112
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\StackTraceHiddenAttribute.cs" />
104113
<Compile Include="$(MSBuildThisFileDirectory)System\DivideByZeroException.cs" />
105114
<Compile Include="$(MSBuildThisFileDirectory)System\DllNotFoundException.cs" />
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
namespace System.Diagnostics
6+
{
7+
// Attribute class used by the compiler to mark modules.
8+
// If present, then debugging information for everything in the
9+
// assembly was generated by the compiler, and will be preserved
10+
// by the Runtime so that the debugger can provide full functionality
11+
// in the case of JIT attach. If not present, then the compiler may
12+
// or may not have included debugging information, and the Runtime
13+
// won't preserve the debugging info, which will make debugging after
14+
// a JIT attach difficult.
15+
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module, AllowMultiple = false)]
16+
public sealed class DebuggableAttribute : Attribute
17+
{
18+
[Flags]
19+
public enum DebuggingModes
20+
{
21+
None = 0x0,
22+
Default = 0x1,
23+
DisableOptimizations = 0x100,
24+
IgnoreSymbolStoreSequencePoints = 0x2,
25+
EnableEditAndContinue = 0x4
26+
}
27+
28+
public DebuggableAttribute(bool isJITTrackingEnabled, bool isJITOptimizerDisabled)
29+
{
30+
DebuggingFlags = 0;
31+
32+
if (isJITTrackingEnabled)
33+
{
34+
DebuggingFlags |= DebuggingModes.Default;
35+
}
36+
37+
if (isJITOptimizerDisabled)
38+
{
39+
DebuggingFlags |= DebuggingModes.DisableOptimizations;
40+
}
41+
}
42+
43+
public DebuggableAttribute(DebuggingModes modes)
44+
{
45+
DebuggingFlags = modes;
46+
}
47+
48+
public bool IsJITTrackingEnabled => (DebuggingFlags & DebuggingModes.Default) != 0;
49+
50+
public bool IsJITOptimizerDisabled => (DebuggingFlags & DebuggingModes.DisableOptimizations) != 0;
51+
52+
public DebuggingModes DebuggingFlags { get; }
53+
}
54+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
namespace System.Diagnostics
6+
{
7+
// DebuggerBrowsableState states are defined as follows:
8+
// Never never show this element
9+
// Expanded expansion of the class is done, so that all visible internal members are shown
10+
// Collapsed expansion of the class is not performed. Internal visible members are hidden
11+
// RootHidden The target element itself should not be shown, but should instead be
12+
// automatically expanded to have its members displayed.
13+
// Default value is collapsed
14+
15+
// Please also change the code which validates DebuggerBrowsableState variable (in this file)
16+
// if you change this enum.
17+
public enum DebuggerBrowsableState
18+
{
19+
Never = 0,
20+
//Expanded is not supported in this release
21+
//Expanded = 1,
22+
Collapsed = 2,
23+
RootHidden = 3
24+
}
25+
26+
27+
// the one currently supported with the csee.dat
28+
// (mcee.dat, autoexp.dat) file.
29+
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false)]
30+
public sealed class DebuggerBrowsableAttribute : Attribute
31+
{
32+
public DebuggerBrowsableAttribute(DebuggerBrowsableState state)
33+
{
34+
if (state < DebuggerBrowsableState.Never || state > DebuggerBrowsableState.RootHidden)
35+
throw new ArgumentOutOfRangeException(nameof(state));
36+
37+
State = state;
38+
}
39+
public DebuggerBrowsableState State { get; }
40+
}
41+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
namespace System.Diagnostics
6+
{
7+
// This attribute is used to control what is displayed for the given class or field
8+
// in the data windows in the debugger. The single argument to this attribute is
9+
// the string that will be displayed in the value column for instances of the type.
10+
// This string can include text between { and } which can be either a field,
11+
// property or method (as will be documented in mscorlib). In the C# case,
12+
// a general expression will be allowed which only has implicit access to the this pointer
13+
// for the current instance of the target type. The expression will be limited,
14+
// however: there is no access to aliases, locals, or pointers.
15+
// In addition, attributes on properties referenced in the expression are not processed.
16+
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Delegate | AttributeTargets.Enum | AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Assembly, AllowMultiple = true)]
17+
public sealed class DebuggerDisplayAttribute : Attribute
18+
{
19+
private Type _target;
20+
21+
public DebuggerDisplayAttribute(string value)
22+
{
23+
Value = value ?? "";
24+
Name = "";
25+
Type = "";
26+
}
27+
28+
public string Value { get; }
29+
30+
public string Name { get; set; }
31+
32+
public string Type { get; set; }
33+
34+
public Type Target
35+
{
36+
get => _target;
37+
set
38+
{
39+
if (value == null)
40+
{
41+
throw new ArgumentNullException(nameof(value));
42+
}
43+
44+
TargetTypeName = value.AssemblyQualifiedName;
45+
_target = value;
46+
}
47+
}
48+
49+
public string TargetTypeName { get; set; }
50+
}
51+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
namespace System.Diagnostics
6+
{
7+
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Constructor, Inherited = false)]
8+
public sealed class DebuggerHiddenAttribute : Attribute
9+
{
10+
public DebuggerHiddenAttribute() { }
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
namespace System.Diagnostics
6+
{
7+
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Constructor | AttributeTargets.Struct, Inherited = false)]
8+
public sealed class DebuggerNonUserCodeAttribute : Attribute
9+
{
10+
public DebuggerNonUserCodeAttribute() { }
11+
}
12+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
namespace System.Diagnostics
6+
{
7+
#if PROJECTN
8+
// Used by the IL2IL toolchain to mark generated code to control debugger stepping policy
9+
[System.Runtime.CompilerServices.DependencyReductionRoot]
10+
#endif
11+
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Constructor, Inherited = false)]
12+
public sealed class DebuggerStepThroughAttribute : Attribute
13+
{
14+
public DebuggerStepThroughAttribute() { }
15+
}
16+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
namespace System.Diagnostics
6+
{
7+
/// <summary>Indicates the code following the attribute is to be executed in run, not step, mode.</summary>
8+
[AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method, Inherited = false)]
9+
public sealed class DebuggerStepperBoundaryAttribute : Attribute
10+
{
11+
public DebuggerStepperBoundaryAttribute() { }
12+
}
13+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
namespace System.Diagnostics
6+
{
7+
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)]
8+
public sealed class DebuggerTypeProxyAttribute : Attribute
9+
{
10+
private Type _target;
11+
12+
public DebuggerTypeProxyAttribute(Type type)
13+
{
14+
if (type == null)
15+
{
16+
throw new ArgumentNullException(nameof(type));
17+
}
18+
19+
ProxyTypeName = type.AssemblyQualifiedName;
20+
}
21+
22+
public DebuggerTypeProxyAttribute(string typeName)
23+
{
24+
ProxyTypeName = typeName;
25+
}
26+
27+
public string ProxyTypeName { get; }
28+
29+
public Type Target
30+
{
31+
get => _target;
32+
set
33+
{
34+
if (value == null)
35+
{
36+
throw new ArgumentNullException(nameof(value));
37+
}
38+
39+
TargetTypeName = value.AssemblyQualifiedName;
40+
_target = value;
41+
}
42+
}
43+
44+
public string TargetTypeName { get; set; }
45+
}
46+
}

0 commit comments

Comments
 (0)