Repository: dotnet/runtime
File: src/libraries/System.Private.CoreLib/src/System/Diagnostics/StackTrace.cs (C#)

Code before:
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;

namespace System.Diagnostics
{
    /// <summary>
    /// Class which represents a description of a stack trace
    /// There is no good reason for the methods of this class to be virtual.
    /// </summary>
    public partial class StackTrace
    {
        [FeatureSwitchDefinition("System.Diagnostics.StackTrace.IsSupported")]
        internal static bool IsSupported { get; } = InitializeIsSupported();

        [FeatureSwitchDefinition("System.Diagnostics.StackTrace.IsLineNumberSupported")]
        internal static bool IsLineNumberSupported { get; } = InitializeIsLineNumberSupported();

        private static bool InitializeIsSupported() =>
            AppContext.TryGetSwitch("System.Diagnostics.StackTrace.IsSupported", out bool isSupported) ? isSupported : true;

        private static bool InitializeIsLineNumberSupported() =>
            AppContext.TryGetSwitch("System.Diagnostics.StackTrace.IsLineNumberSupported", out bool isSupported) ? isSupported : true;

        public const int METHODS_TO_SKIP = 0;

        private int _numOfFrames;
        private int _methodsToSkip;

        /// <summary>
        /// Stack frames comprising this stack trace.
        /// </summary>
        private StackFrame[]? _stackFrames;

        /// <summary>
        /// Constructs a stack trace from the current location.
        /// </summary>
        [MethodImpl(MethodImplOptions.NoInlining)]
        public StackTrace()
        {
            InitializeForCurrentThread(METHODS_TO_SKIP, false);
        }

        /// <summary>
        /// Constructs a stack trace from the current location.
        /// </summary>
        [MethodImpl(MethodImplOptions.NoInlining)]

Review comment (suggestion):
I am not sure what's the point of having this in a separate method.

Should the above be just:
```
        [FeatureSwitchDefinition("System.Diagnostics.StackTrace.IsLineNumberSupported")]
        internal static bool IsLineNumberSupported { get; } =
            AppContext.TryGetSwitch("System.Diagnostics.StackTrace.IsLineNumberSupported", out bool isSupported) ? isSupported : true;
```
and similar for the existing InitializeIsSupported.

Code after:
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;

namespace System.Diagnostics
{
    /// <summary>
    /// Class which represents a description of a stack trace
    /// There is no good reason for the methods of this class to be virtual.
    /// </summary>
    public partial class StackTrace
    {
        [FeatureSwitchDefinition("System.Diagnostics.StackTrace.IsSupported")]
        internal static bool IsSupported { get; } = AppContext.TryGetSwitch("System.Diagnostics.StackTrace.IsSupported", out bool isSupported) ? isSupported : true;

        [FeatureSwitchDefinition("System.Diagnostics.StackTrace.IsLineNumberSupported")]
        internal static bool IsLineNumberSupported { get; } = AppContext.TryGetSwitch("System.Diagnostics.StackTrace.IsLineNumberSupported", out bool isSupported) ? isSupported : true;

        public const int METHODS_TO_SKIP = 0;

        private int _numOfFrames;
        private int _methodsToSkip;

        /// <summary>
        /// Stack frames comprising this stack trace.
        /// </summary>
        private StackFrame[]? _stackFrames;

        /// <summary>
        /// Constructs a stack trace from the current location.
        /// </summary>
        [MethodImpl(MethodImplOptions.NoInlining)]
        public StackTrace()
        {
            InitializeForCurrentThread(METHODS_TO_SKIP, false);
        }

        /// <summary>
        /// Constructs a stack trace from the current location.
        /// </summary>
        [MethodImpl(MethodImplOptions.NoInlining)]
        public StackTrace(bool fNeedFileInfo)
        {
            InitializeForCurrentThread(METHODS_TO_SKIP, fNeedFileInfo);
        }

        /// <summary>