/
githubmirror
/
roslyn
Обзор
Документация
Войти
/
githubmirror
/
roslyn
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Compilers/Test/Core/Syntax/SourceUtilities.cs
45 строк
1 KB
Tomas Matousek
Move
23 окт 2020, 21:06
23 окт 2020, 21:06
d49cd2b
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis.Text; using System; using System.Collections.Generic; using System.Text; namespace Roslyn.Test.Utilities.Syntax { internal sealed class RandomizedSourceText : SourceText { private readonly char[] _buffer = new char[2048]; public RandomizedSourceText() { var random = new Random(12345); for (var i = 0; i < _buffer.Length; i++) { _buffer[i] = (char)random.Next(); } } public override char this[int position] => _buffer[position % _buffer.Length]; public override Encoding Encoding => Encoding.UTF8; public override int Length { get { return 40 * 1000 * 1000; } } public override void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count) { for (var i = 0; i < count; i++) { destination[destinationIndex + i] = this[sourceIndex + i]; } } } }