Repository: dotnet/roslyn
File: src/Compilers/Test/Utilities/CSharp/CSharpTestBase.cs (C#)

Code before:

        internal const string RuntimeAsyncAwaitHelpers = """
            namespace System.Runtime.CompilerServices
            {
                public static class AsyncHelpers
                {
                    public static void AwaitAwaiter<TAwaiter>(TAwaiter awaiter) where TAwaiter : INotifyCompletion
                    {}
                    public static void UnsafeAwaitAwaiter<TAwaiter>(TAwaiter awaiter) where TAwaiter : ICriticalNotifyCompletion
                    {}

                    public static void Await(System.Threading.Tasks.Task task) => task.GetAwaiter().GetResult();
                    public static void Await(System.Threading.Tasks.ValueTask task) => task.GetAwaiter().GetResult();
                    public static T Await<T>(System.Threading.Tasks.Task<T> task) => task.GetAwaiter().GetResult();
                    public static T Await<T>(System.Threading.Tasks.ValueTask<T> task) => task.GetAwaiter().GetResult();
                }
            }
            """;

        internal const string RuntimeAsyncMethodGenerationAttributeDefinition = """
            namespace System.Runtime.CompilerServices;

            #pragma warning disable CS9113 // Unread primary constructor parameter

            [AttributeUsage(AttributeTargets.Method)]
            public class RuntimeAsyncMethodGenerationAttribute(bool runtimeAsync) : Attribute();
            """;

        protected static T GetSyntax<T>(SyntaxTree tree, string text, bool descendIntoTrivia = false)
            where T : notnull
        {
            return GetSyntaxes<T>(tree, text, descendIntoTrivia).Single();
        }

        protected static IEnumerable<T> GetSyntaxes<T>(SyntaxTree tree, string text, bool descendIntoTrivia = false)
            where T : notnull
        {
            return tree.GetRoot().DescendantNodes(descendIntoTrivia: descendIntoTrivia).OfType<T>().Where(e => e.ToString() == text);
        }

        protected static CSharpCompilationOptions WithNullableEnable(CSharpCompilationOptions? options = null)
        {
            return WithNullable(options, NullableContextOptions.Enable);
        }

        protected static CSharpCompilationOptions WithNullableDisable(CSharpCompilationOptions? options = null)
        {
            return WithNullable(options, NullableContextOptions.Disable);
        }

        protected static CSharpCompilationOptions WithNullable(NullableContextOptions nullableContextOptions)

Review comment (suggestion):
>public class RuntimeAsyncMethodGenerationAttribute(bool runtimeAsync) : Attribute() [](http://example.com/codeflow?start=12&length=83)

Consider restoring the warning mode after this in case the string will be concatenated with other source. #Closed

Code after:

        internal const string RuntimeAsyncAwaitHelpers = """
            namespace System.Runtime.CompilerServices
            {
                public static class AsyncHelpers
                {
                    public static void AwaitAwaiter<TAwaiter>(TAwaiter awaiter) where TAwaiter : INotifyCompletion
                    {}
                    public static void UnsafeAwaitAwaiter<TAwaiter>(TAwaiter awaiter) where TAwaiter : ICriticalNotifyCompletion
                    {}

                    public static void Await(System.Threading.Tasks.Task task) => task.GetAwaiter().GetResult();
                    public static void Await(System.Threading.Tasks.ValueTask task) => task.GetAwaiter().GetResult();
                    public static T Await<T>(System.Threading.Tasks.Task<T> task) => task.GetAwaiter().GetResult();
                    public static T Await<T>(System.Threading.Tasks.ValueTask<T> task) => task.GetAwaiter().GetResult();
                }
            }
            """;

        internal const string RuntimeAsyncMethodGenerationAttributeDefinition = """
            namespace System.Runtime.CompilerServices;

            #pragma warning disable CS9113 // Unread primary constructor parameter

            [AttributeUsage(AttributeTargets.Method)]
            public class RuntimeAsyncMethodGenerationAttribute(bool runtimeAsync) : Attribute();
            #pragma warning restore CS9113 // Unread primary constructor parameter
            """;

        protected static T GetSyntax<T>(SyntaxTree tree, string text, bool descendIntoTrivia = false)
            where T : notnull
        {
            return GetSyntaxes<T>(tree, text, descendIntoTrivia).Single();
        }

        protected static IEnumerable<T> GetSyntaxes<T>(SyntaxTree tree, string text, bool descendIntoTrivia = false)
            where T : notnull
        {
            return tree.GetRoot().DescendantNodes(descendIntoTrivia: descendIntoTrivia).OfType<T>().Where(e => e.ToString() == text);
        }

        protected static CSharpCompilationOptions WithNullableEnable(CSharpCompilationOptions? options = null)
        {
            return WithNullable(options, NullableContextOptions.Enable);
        }

        protected static CSharpCompilationOptions WithNullableDisable(CSharpCompilationOptions? options = null)
        {
            return WithNullable(options, NullableContextOptions.Disable);
        }