2 types derived from Rope
Microsoft.CodeAnalysis (2)
Collections\Rope.cs (2)
87private sealed class StringRope : Rope 116private sealed class ConcatRope : Rope
73 references to Rope
Microsoft.CodeAnalysis (19)
Collections\Rope.cs (12)
18public static readonly Rope Empty = ForString(""); 29public static Rope ForString(string s) 40public static Rope Concat(Rope r1, Rope r2) 60if (!(obj is Rope other) || Length != other.Length) 118private readonly Rope _left, _right; 121public ConcatRope(Rope left, Rope right) 131var stack = new Stack<Rope>(); 160var stack = new Stack<Rope>(); 186var stack = new Stack<Rope>();
ConstantValue.cs (2)
46internal virtual Rope? RopeValue { get { throw new InvalidOperationException(); } } 111internal static ConstantValue CreateFromRope(Rope value)
ConstantValueSpecialized.cs (5)
96internal override Rope? RopeValue 136private readonly Rope _value; 149_value = Rope.ForString(value); 152public ConstantValueString(Rope value) 192internal override Rope RopeValue
Microsoft.CodeAnalysis.CSharp (10)
Binder\Binder_Operators.cs (5)
3059Rope leftValue = valueLeft.RopeValue ?? Rope.Empty; 3060Rope rightValue = valueRight.RopeValue ?? Rope.Empty; 3063return (newLength > int.MaxValue) ? ConstantValue.Bad : ConstantValue.CreateFromRope(Rope.Concat(leftValue, rightValue));
Lowering\LocalRewriter\LocalRewriter_StringConcat.cs (5)
323var previous = getRope(constantValue); 324var current = getRope(argument.ConstantValueOpt!); 326finalArguments[^1] = _factory.StringLiteral(ConstantValue.CreateFromRope(Rope.Concat(current, previous))); 335static Rope getRope(ConstantValue constantValue) 344return Rope.ForString(constantValue.CharValue.ToString());
Microsoft.CodeAnalysis.UnitTests (44)
Collections\RopeTests.cs (44)
23private static readonly Rope[] longRopes = longStrings.Select(s => Rope.ForString(s)).ToArray(); 29private static readonly Rope[] shortRopes = shortStrings.Select(s => Rope.ForString(s)).ToArray(); 31private static readonly Rope[] someRopes = shortRopes.Concat(longRopes).ToArray(); 37Rope r = Rope.Empty; 40Assert.Equal(r, Rope.ForString(string.Empty)); 41Assert.Equal(Rope.ForString(string.Empty), r); 47foreach (var rope in someRopes) 49Assert.Same(rope, Rope.Concat(rope, Rope.Empty)); 50Assert.Same(rope, Rope.Concat(Rope.Empty, rope)); 59Assert.Equal(s, Rope.ForString(s).ToString()); 66foreach (var r1 in someRopes) 68foreach (var r2 in someRopes) 70foreach (var r3 in someRopes) 72Rope c1 = Rope.Concat(r1, Rope.Concat(r2, r3)); 73Rope c2 = Rope.Concat(Rope.Concat(r1, r2), r3); 79Rope c3 = Rope.ForString(s); 92Assert.Throws<ArgumentNullException>(() => { Rope.ForString(null); }); 98foreach (var r in someRopes) 100Assert.Throws<ArgumentNullException>(() => { Rope.Concat(r, null); }); 101Assert.Throws<ArgumentNullException>(() => { Rope.Concat(null, r); }); 108var r = shortRopes.Aggregate(Rope.Concat); 121var r = Rope.ForString("x"); 128Rope r = Rope.ForString("x"); 129Rope all = r; 133r = Rope.Concat(r, r); 134all = Rope.Concat(all, r); 140var waferThinMint = Rope.ForString("y"); 141Assert.Throws<OverflowException>(() => Rope.Concat(all, waferThinMint)); 142Assert.Throws<OverflowException>(() => Rope.Concat(waferThinMint, all)); 143Assert.Throws<OverflowException>(() => Rope.Concat(all, all));