diff --git a/docs/features/ExpressionVariables.md b/docs/features/ExpressionVariables.md
index e901e544bf7f0..b8bdaba9d3e44 100644
--- a/docs/features/ExpressionVariables.md
+++ b/docs/features/ExpressionVariables.md
@@ -6,7 +6,7 @@ containing expression variables (out variable declarations and declaration patte
initializers, property initializers, ctor-initializers, and query clauses.
See https://github.com/dotnet/csharplang/issues/32 and
-https://github.com/dotnet/csharplang/blob/main/proposals/csharp-7.3/expression-variables-in-initializers.md
+https://github.com/dotnet/csharplang/blob/main/proposals/expression-variables-in-initializers.md
for more information.
Current state of the feature:
@@ -14,4 +14,4 @@ Current state of the feature:
[X] Permit in field initializers
[X] Permit in property initializers
[ ] Permit in ctor-initializers
-[X] Permit in query clauses
+[X] Permit in query clauses
\ No newline at end of file
diff --git a/dotnet-tools.json b/dotnet-tools.json
index 0d36407e3c7fa..6ab0998319770 100644
--- a/dotnet-tools.json
+++ b/dotnet-tools.json
@@ -2,7 +2,7 @@
"isRoot": true,
"tools": {
"dotnet-format": {
- "version": "6.0.240501",
+ "version": "6.0.231801",
"commands": [
"dotnet-format"
]
diff --git a/eng/Versions.props b/eng/Versions.props
index a89a4458ec461..08726f9e09f32 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -30,8 +30,7 @@
3.3.3-beta1.21105.3
6.0.0-rc1.21366.2
1.1.0-beta1.21322.2
-
- 4.0.0-3.final
+ 3.10.0
16.10.230
17.0.278-preview
5.0.0-alpha1.19409.1
diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_InterpolatedString.cs b/src/Compilers/CSharp/Portable/Binder/Binder_InterpolatedString.cs
index ebdb4fefe70d6..46a2cd45f3ced 100644
--- a/src/Compilers/CSharp/Portable/Binder/Binder_InterpolatedString.cs
+++ b/src/Compilers/CSharp/Portable/Binder/Binder_InterpolatedString.cs
@@ -187,7 +187,7 @@ bool tryBindAsHandlerType([NotNullWhen(true)] out BoundInterpolatedString? resul
{
result = null;
- if (InExpressionTree || !ValidateInterpolatedStringParts(unconvertedInterpolatedString))
+ if (InExpressionTree || unconvertedInterpolatedString.Parts.ContainsAwaitExpression())
{
return false;
}
@@ -204,12 +204,8 @@ bool tryBindAsHandlerType([NotNullWhen(true)] out BoundInterpolatedString? resul
}
}
- private static bool ValidateInterpolatedStringParts(BoundUnconvertedInterpolatedString unconvertedInterpolatedString)
- => !unconvertedInterpolatedString.Parts.ContainsAwaitExpression()
- && unconvertedInterpolatedString.Parts.All(p => p is not BoundStringInsert { Value.Type.TypeKind: TypeKind.Dynamic });
-
private static bool AllInterpolatedStringPartsAreStrings(ImmutableArray parts)
- => parts.All(p => p is BoundLiteral or BoundStringInsert { Value.Type.SpecialType: SpecialType.System_String, Alignment: null, Format: null });
+ => parts.All(p => p is BoundLiteral or BoundStringInsert { Value: { Type: { SpecialType: SpecialType.System_String } }, Alignment: null, Format: null });
private bool TryBindUnconvertedBinaryOperatorToDefaultInterpolatedStringHandler(BoundBinaryOperator binaryOperator, BindingDiagnosticBag diagnostics, [NotNullWhen(true)] out BoundBinaryOperator? convertedBinaryOperator)
{
@@ -244,7 +240,7 @@ private bool TryBindUnconvertedBinaryOperatorToDefaultInterpolatedStringHandler(
isConstant = isConstant && current.Right.ConstantValue is not null;
var rightInterpolatedString = (BoundUnconvertedInterpolatedString)current.Right;
- if (!ValidateInterpolatedStringParts(rightInterpolatedString))
+ if (rightInterpolatedString.Parts.ContainsAwaitExpression())
{
// Exception to case 3. Delegate to standard binding.
stack.Free();
@@ -263,7 +259,7 @@ private bool TryBindUnconvertedBinaryOperatorToDefaultInterpolatedStringHandler(
case BoundUnconvertedInterpolatedString interpolatedString:
isConstant = isConstant && interpolatedString.ConstantValue is not null;
- if (!ValidateInterpolatedStringParts(interpolatedString))
+ if (interpolatedString.Parts.ContainsAwaitExpression())
{
// Exception to case 3. Delegate to standard binding.
stack.Free();
diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs b/src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs
index 9d66957b6315d..34f2a42406241 100644
--- a/src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs
+++ b/src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs
@@ -1878,15 +1878,6 @@ internal void GenerateAnonymousFunctionConversionError(BindingDiagnosticBag diag
return;
}
- if (reason == LambdaConversionResult.CannotInferDelegateType)
- {
- Debug.Assert(targetType.SpecialType == SpecialType.System_Delegate || targetType.IsNonGenericExpressionType());
- Error(diagnostics, ErrorCode.ERR_CannotInferDelegateType, syntax);
- var lambda = anonymousFunction.BindForErrorRecovery();
- diagnostics.AddRange(lambda.Diagnostics);
- return;
- }
-
// At this point we know that we have either a delegate type or an expression type for the target.
// The target type is a valid delegate or expression tree type. Is there something wrong with the
diff --git a/src/Compilers/CSharp/Portable/Binder/Semantics/Conversions/ConversionsBase.cs b/src/Compilers/CSharp/Portable/Binder/Semantics/Conversions/ConversionsBase.cs
index d8f2705d5f980..41a8a249334f4 100644
--- a/src/Compilers/CSharp/Portable/Binder/Semantics/Conversions/ConversionsBase.cs
+++ b/src/Compilers/CSharp/Portable/Binder/Semantics/Conversions/ConversionsBase.cs
@@ -6,6 +6,7 @@
using System.Collections.Immutable;
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
using System.Threading;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
@@ -1393,8 +1394,7 @@ private static LambdaConversionResult IsAnonymousFunctionCompatibleWithExpressio
if (delegateType is null)
{
- Debug.Assert(IsFeatureInferredDelegateTypeEnabled(anonymousFunction));
- return GetInferredDelegateTypeResult(anonymousFunction);
+ return LambdaConversionResult.Success;
}
return IsAnonymousFunctionCompatibleWithDelegate(anonymousFunction, delegateType, isTargetExpressionTree: true);
@@ -1409,7 +1409,7 @@ public static LambdaConversionResult IsAnonymousFunctionCompatibleWithType(Unbou
{
if (IsFeatureInferredDelegateTypeEnabled(anonymousFunction))
{
- return GetInferredDelegateTypeResult(anonymousFunction);
+ return LambdaConversionResult.Success;
}
}
else if (type.IsDelegateType())
@@ -1432,14 +1432,6 @@ internal static bool IsFeatureInferredDelegateTypeEnabled(BoundExpression expr)
return expr.Syntax.IsFeatureEnabled(MessageID.IDS_FeatureInferredDelegateType);
}
- private static LambdaConversionResult GetInferredDelegateTypeResult(UnboundLambda anonymousFunction)
- {
- var discardedUseSiteInfo = CompoundUseSiteInfo.Discarded;
- return anonymousFunction.InferDelegateType(ref discardedUseSiteInfo) is null ?
- LambdaConversionResult.CannotInferDelegateType :
- LambdaConversionResult.Success;
- }
-
private static bool HasAnonymousFunctionConversion(BoundExpression source, TypeSymbol destination)
{
Debug.Assert(source != null);
diff --git a/src/Compilers/CSharp/Portable/Binder/Semantics/Conversions/LambdaConversionResult.cs b/src/Compilers/CSharp/Portable/Binder/Semantics/Conversions/LambdaConversionResult.cs
index 227ec23eb7b40..5a10903cb935a 100644
--- a/src/Compilers/CSharp/Portable/Binder/Semantics/Conversions/LambdaConversionResult.cs
+++ b/src/Compilers/CSharp/Portable/Binder/Semantics/Conversions/LambdaConversionResult.cs
@@ -16,7 +16,6 @@ internal enum LambdaConversionResult
StaticTypeInImplicitlyTypedLambda,
ExpressionTreeMustHaveDelegateTypeArgument,
ExpressionTreeFromAnonymousMethod,
- CannotInferDelegateType,
BindingFailed
}
}
diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol.cs
index 264e2968947b4..2b02d006d6e53 100644
--- a/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol.cs
+++ b/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol.cs
@@ -3650,7 +3650,7 @@ private void AddSynthesizedRecordMembersIfNecessary(MembersAndInitializersBuilde
memberNames.Free();
// Synthesizing non-readonly properties in struct would require changing readonly logic for PrintMembers method synthesis
- Debug.Assert(isRecordClass || !members.Any(m => m is PropertySymbol { GetMethod.IsEffectivelyReadOnly: false }));
+ Debug.Assert(isRecordClass || !members.Any(m => m is PropertySymbol { GetMethod.IsEffectivelyReadOnly : false }));
// We put synthesized record members first so that errors about conflicts show up on user-defined members rather than all
// going to the record declaration
diff --git a/src/Compilers/CSharp/Portable/Symbols/Synthesized/Records/SynthesizedRecordCopyCtor.cs b/src/Compilers/CSharp/Portable/Symbols/Synthesized/Records/SynthesizedRecordCopyCtor.cs
index 76f19629921d9..a580b862007f9 100644
--- a/src/Compilers/CSharp/Portable/Symbols/Synthesized/Records/SynthesizedRecordCopyCtor.cs
+++ b/src/Compilers/CSharp/Portable/Symbols/Synthesized/Records/SynthesizedRecordCopyCtor.cs
@@ -101,7 +101,7 @@ internal override void GenerateMethodBodyStatements(SyntheticBoundNodeFactory F,
internal static bool IsCopyConstructor(Symbol member)
{
- if (member is MethodSymbol { ContainingType.IsRecordStruct: false, MethodKind: MethodKind.Constructor } method)
+ if (member is MethodSymbol { ContainingType: { IsRecordStruct: false }, MethodKind: MethodKind.Constructor } method)
{
return HasCopyConstructorSignature(method);
}
diff --git a/src/Compilers/CSharp/Portable/Syntax/InternalSyntax/CSharpSyntaxNode.cs b/src/Compilers/CSharp/Portable/Syntax/InternalSyntax/CSharpSyntaxNode.cs
index 2c39131b36ccb..2073cd5fb160c 100644
--- a/src/Compilers/CSharp/Portable/Syntax/InternalSyntax/CSharpSyntaxNode.cs
+++ b/src/Compilers/CSharp/Portable/Syntax/InternalSyntax/CSharpSyntaxNode.cs
@@ -4,7 +4,6 @@
#nullable disable
-using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
@@ -280,8 +279,8 @@ public override bool IsTriviaWithEndOfLine()
}
// Use conditional weak table so we always return same identity for structured trivia
- private static readonly ConditionalWeakTable>> s_structuresTable
- = new ConditionalWeakTable>>();
+ private static readonly ConditionalWeakTable> s_structuresTable
+ = new ConditionalWeakTable>();
///
/// Gets the syntax node represented the structure of this trivia, if any. The HasStructure property can be used to
@@ -309,15 +308,10 @@ public override SyntaxNode GetStructure(Microsoft.CodeAnalysis.SyntaxTrivia triv
var structsInParent = s_structuresTable.GetOrCreateValue(parent);
lock (structsInParent)
{
- if (!structsInParent.TryGetValue(trivia, out var weakStructure))
+ if (!structsInParent.TryGetValue(trivia, out structure))
{
structure = CSharp.Syntax.StructuredTriviaSyntax.Create(trivia);
- structsInParent.Add(trivia, new WeakReference(structure));
- }
- else if (!weakStructure.TryGetTarget(out structure))
- {
- structure = CSharp.Syntax.StructuredTriviaSyntax.Create(trivia);
- weakStructure.SetTarget(structure);
+ structsInParent.Add(trivia, structure);
}
}
diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleEqualityTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleEqualityTests.cs
index 404b9a4487de1..ff2fa54d329e5 100644
--- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleEqualityTests.cs
+++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleEqualityTests.cs
@@ -1682,9 +1682,12 @@ static void Main()
comp = CreateCompilation(source, parseOptions: TestOptions.RegularPreview);
comp.VerifyDiagnostics(
- // (6,30): error CS0019: Operator '==' cannot be applied to operands of type '' and 'lambda expression'
+ // (6,65): error CS8917: The delegate type could not be inferred.
// System.Console.Write((null, null, null, null) == (null, x => x, Main, (int i) => { int j = 0; return i + j; }));
- Diagnostic(ErrorCode.ERR_BadBinaryOps, "(null, null, null, null) == (null, x => x, Main, (int i) => { int j = 0; return i + j; })").WithArguments("==", "", "lambda expression").WithLocation(6, 30));
+ Diagnostic(ErrorCode.ERR_CannotInferDelegateType, "x => x").WithLocation(6, 65),
+ // (6,65): error CS8917: The delegate type could not be inferred.
+ // System.Console.Write((null, null, null, null) == (null, x => x, Main, (int i) => { int j = 0; return i + j; }));
+ Diagnostic(ErrorCode.ERR_CannotInferDelegateType, "x => x").WithLocation(6, 65));
verify(comp, inferDelegate: true);
static void verify(CSharpCompilation comp, bool inferDelegate)
@@ -1711,7 +1714,7 @@ static void verify(CSharpCompilation comp, bool inferDelegate)
// ... its first lambda ...
var firstLambda = tuple2.Arguments[1].Expression;
Assert.Null(model.GetTypeInfo(firstLambda).Type);
- verifyType("System.Delegate", model.GetTypeInfo(firstLambda).ConvertedType, inferDelegate: false); // cannot infer delegate type for x => x
+ verifyType("System.Delegate", model.GetTypeInfo(firstLambda).ConvertedType, inferDelegate);
// ... its method group ...
var methodGroup = tuple2.Arguments[2].Expression;
diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/DelegateTypeTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/DelegateTypeTests.cs
index 27eb4db64382d..76d15d826bc57 100644
--- a/src/Compilers/CSharp/Test/Semantic/Semantics/DelegateTypeTests.cs
+++ b/src/Compilers/CSharp/Test/Semantic/Semantics/DelegateTypeTests.cs
@@ -389,9 +389,9 @@ static void Main(string[] args)
if (expectedType is null)
{
comp.VerifyDiagnostics(
- // (5,38): error CS8917: The delegate type could not be inferred.
+ // (5,20): error CS8917: The delegate type could not be inferred.
// object o = (System.Delegate)(x => x);
- Diagnostic(ErrorCode.ERR_CannotInferDelegateType, anonymousFunction).WithLocation(5, 38));
+ Diagnostic(ErrorCode.ERR_CannotInferDelegateType, $"(System.Delegate)({anonymousFunction})").WithLocation(5, 20));
}
else
{
@@ -474,9 +474,9 @@ static void Main(string[] args)
if (expectedType is null)
{
comp.VerifyDiagnostics(
- // (5,57): error CS8917: The delegate type could not be inferred.
+ // (5,20): error CS8917: The delegate type could not be inferred.
// object o = (System.Linq.Expressions.Expression)(x => x);
- Diagnostic(ErrorCode.ERR_CannotInferDelegateType, anonymousFunction).WithLocation(5, 57));
+ Diagnostic(ErrorCode.ERR_CannotInferDelegateType, $"(System.Linq.Expressions.Expression)({anonymousFunction})").WithLocation(5, 20));
}
else
{
@@ -1978,17 +1978,7 @@ static void Main()
F(delegate () { return string.Empty; });
}
}";
-
- var comp = CreateCompilation(source, parseOptions: TestOptions.Regular9);
- comp.VerifyDiagnostics(
- // (9,11): error CS1660: Cannot convert anonymous method to type 'Expression' because it is not a delegate type
- // F(delegate () { return 0; });
- Diagnostic(ErrorCode.ERR_AnonMethToNonDel, "delegate () { return 0; }").WithArguments("anonymous method", "System.Linq.Expressions.Expression").WithLocation(9, 11),
- // (10,11): error CS1660: Cannot convert anonymous method to type 'Expression' because it is not a delegate type
- // F(delegate () { return string.Empty; });
- Diagnostic(ErrorCode.ERR_AnonMethToNonDel, "delegate () { return string.Empty; }").WithArguments("anonymous method", "System.Linq.Expressions.Expression").WithLocation(10, 11));
-
- comp = CreateCompilation(source, parseOptions: TestOptions.Regular10);
+ var comp = CreateCompilation(source, parseOptions: TestOptions.RegularPreview);
comp.VerifyDiagnostics(
// (9,11): error CS1946: An anonymous method expression cannot be converted to an expression tree
// F(delegate () { return 0; });
@@ -1998,143 +1988,6 @@ static void Main()
Diagnostic(ErrorCode.ERR_AnonymousMethodToExpressionTree, "delegate () { return string.Empty; }").WithLocation(10, 11));
}
- [WorkItem(55319, "https://github.com/dotnet/roslyn/issues/55319")]
- [Fact]
- public void OverloadResolution_08()
- {
- var source =
-@"using System;
-using static System.Console;
-class C
-{
- static void Main()
- {
- var c = new C();
- c.F(x => x);
- c.F((int x) => x);
- }
- void F(Delegate d) => Write(""instance, "");
-}
-static class Extensions
-{
- public static void F(this C c, Func f) => Write(""extension, "");
-}";
-
- CompileAndVerify(source, parseOptions: TestOptions.Regular9, expectedOutput: "extension, extension, ");
- CompileAndVerify(source, parseOptions: TestOptions.Regular10, expectedOutput: "extension, instance, ");
- CompileAndVerify(source, expectedOutput: "extension, instance, ");
- }
-
- [WorkItem(55319, "https://github.com/dotnet/roslyn/issues/55319")]
- [Fact]
- public void OverloadResolution_09()
- {
- var source =
-@"using System;
-using System.Linq.Expressions;
-using static System.Console;
-class C
-{
- static void Main()
- {
- var c = new C();
- c.F(x => x);
- c.F((int x) => x);
- }
- void F(Expression e) => Write(""instance, "");
-}
-static class Extensions
-{
- public static void F(this C c, Expression> e) => Write(""extension, "");
-}";
-
- CompileAndVerify(source, parseOptions: TestOptions.Regular9, expectedOutput: "extension, extension, ");
- CompileAndVerify(source, parseOptions: TestOptions.Regular10, expectedOutput: "extension, instance, ");
- CompileAndVerify(source, expectedOutput: "extension, instance, ");
- }
-
- [WorkItem(55319, "https://github.com/dotnet/roslyn/issues/55319")]
- [Fact]
- public void OverloadResolution_10()
- {
- var source =
-@"using System;
-using static System.Console;
-class C
-{
- static object M1(object o) => o;
- static int M1(int i) => i;
- static int M2(int i) => i;
- static void Main()
- {
- var c = new C();
- c.F(M1);
- c.F(M2);
- }
- void F(Delegate d) => Write(""instance, "");
-}
-static class Extensions
-{
- public static void F(this C c, Func f) => Write(""extension, "");
-}";
-
- CompileAndVerify(source, parseOptions: TestOptions.Regular9, expectedOutput: "extension, extension, ");
- CompileAndVerify(source, parseOptions: TestOptions.Regular10, expectedOutput: "extension, instance, ");
- CompileAndVerify(source, expectedOutput: "extension, instance, ");
- }
-
- [Fact]
- public void OverloadResolution_11()
- {
- var source =
-@"using System;
-using System.Linq.Expressions;
-class C
-{
- static object M1(object o) => o;
- static int M1(int i) => i;
- static void Main()
- {
- F1(x => x);
- F1(M1);
- F2(x => x);
- }
- static void F1(Delegate d) { }
- static void F2(Expression e) { }
-}";
-
- var comp = CreateCompilation(source, parseOptions: TestOptions.Regular9);
- comp.VerifyDiagnostics(
- // (9,12): error CS1660: Cannot convert lambda expression to type 'Delegate' because it is not a delegate type
- // F1(x => x);
- Diagnostic(ErrorCode.ERR_AnonMethToNonDel, "x => x").WithArguments("lambda expression", "System.Delegate").WithLocation(9, 12),
- // (10,12): error CS1503: Argument 1: cannot convert from 'method group' to 'Delegate'
- // F1(M1);
- Diagnostic(ErrorCode.ERR_BadArgType, "M1").WithArguments("1", "method group", "System.Delegate").WithLocation(10, 12),
- // (11,12): error CS1660: Cannot convert lambda expression to type 'Expression' because it is not a delegate type
- // F2(x => x);
- Diagnostic(ErrorCode.ERR_AnonMethToNonDel, "x => x").WithArguments("lambda expression", "System.Linq.Expressions.Expression").WithLocation(11, 12));
-
- var expectedDiagnostics10AndLater = new[]
- {
- // (9,12): error CS8917: The delegate type could not be inferred.
- // F1(x => x);
- Diagnostic(ErrorCode.ERR_CannotInferDelegateType, "x => x").WithLocation(9, 12),
- // (10,12): error CS1503: Argument 1: cannot convert from 'method group' to 'Delegate'
- // F1(M1);
- Diagnostic(ErrorCode.ERR_BadArgType, "M1").WithArguments("1", "method group", "System.Delegate").WithLocation(10, 12),
- // (11,12): error CS8917: The delegate type could not be inferred.
- // F2(x => x);
- Diagnostic(ErrorCode.ERR_CannotInferDelegateType, "x => x").WithLocation(11, 12)
- };
-
- comp = CreateCompilation(source, parseOptions: TestOptions.Regular10);
- comp.VerifyDiagnostics(expectedDiagnostics10AndLater);
-
- comp = CreateCompilation(source);
- comp.VerifyDiagnostics(expectedDiagnostics10AndLater);
- }
-
[Fact]
public void ImplicitlyTypedVariables_01()
{
diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/InterpolationTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/InterpolationTests.cs
index 8600ab575b158..c5784fb39764e 100644
--- a/src/Compilers/CSharp/Test/Semantic/Semantics/InterpolationTests.cs
+++ b/src/Compilers/CSharp/Test/Semantic/Semantics/InterpolationTests.cs
@@ -2761,110 +2761,6 @@ .locals init (int V_0,
");
}
- [Theory, WorkItem(55609, "https://github.com/dotnet/roslyn/issues/55609")]
- [InlineData(@"$""base{hole}""")]
- [InlineData(@"$""base"" + $""{hole}""")]
- public void DynamicInHoles_UsesFormat(string expression)
- {
- var source = @"
-using System;
-using System.Threading.Tasks;
-
-dynamic hole = 1;
-Console.WriteLine(" + expression + @");
-";
-
- var interpolatedStringBuilder = GetInterpolatedStringHandlerDefinition(includeSpanOverloads: false, useDefaultParameters: false, useBoolReturns: false);
-
- var verifier = CompileAndVerifyWithCSharp(new[] { source, interpolatedStringBuilder }, expectedOutput: @"base1");
-
- verifier.VerifyIL("", expression.Contains('+')
-? @"
-{
- // Code size 34 (0x22)
- .maxstack 3
- .locals init (object V_0) //hole
- IL_0000: ldc.i4.1
- IL_0001: box ""int""
- IL_0006: stloc.0
- IL_0007: ldstr ""base""
- IL_000c: ldstr ""{0}""
- IL_0011: ldloc.0
- IL_0012: call ""string string.Format(string, object)""
- IL_0017: call ""string string.Concat(string, string)""
- IL_001c: call ""void System.Console.WriteLine(string)""
- IL_0021: ret
-}
-"
-: @"
-{
- // Code size 24 (0x18)
- .maxstack 2
- .locals init (object V_0) //hole
- IL_0000: ldc.i4.1
- IL_0001: box ""int""
- IL_0006: stloc.0
- IL_0007: ldstr ""base{0}""
- IL_000c: ldloc.0
- IL_000d: call ""string string.Format(string, object)""
- IL_0012: call ""void System.Console.WriteLine(string)""
- IL_0017: ret
-}
-");
- }
-
- [Theory, WorkItem(55609, "https://github.com/dotnet/roslyn/issues/55609")]
- [InlineData(@"$""{hole}base""")]
- [InlineData(@"$""{hole}"" + $""base""")]
- public void DynamicInHoles_UsesFormat2(string expression)
- {
- var source = @"
-using System;
-using System.Threading.Tasks;
-
-dynamic hole = 1;
-Console.WriteLine(" + expression + @");
-";
-
- var interpolatedStringBuilder = GetInterpolatedStringHandlerDefinition(includeSpanOverloads: false, useDefaultParameters: false, useBoolReturns: false);
-
- var verifier = CompileAndVerifyWithCSharp(new[] { source, interpolatedStringBuilder }, expectedOutput: @"1base");
-
- verifier.VerifyIL("", expression.Contains('+')
-? @"
-{
- // Code size 34 (0x22)
- .maxstack 2
- .locals init (object V_0) //hole
- IL_0000: ldc.i4.1
- IL_0001: box ""int""
- IL_0006: stloc.0
- IL_0007: ldstr ""{0}""
- IL_000c: ldloc.0
- IL_000d: call ""string string.Format(string, object)""
- IL_0012: ldstr ""base""
- IL_0017: call ""string string.Concat(string, string)""
- IL_001c: call ""void System.Console.WriteLine(string)""
- IL_0021: ret
-}
-"
-: @"
-{
- // Code size 24 (0x18)
- .maxstack 2
- .locals init (object V_0) //hole
- IL_0000: ldc.i4.1
- IL_0001: box ""int""
- IL_0006: stloc.0
- IL_0007: ldstr ""{0}base""
- IL_000c: ldloc.0
- IL_000d: call ""string string.Format(string, object)""
- IL_0012: call ""void System.Console.WriteLine(string)""
- IL_0017: ret
-}
-");
- }
-
[Fact]
public void MissingCreate_01()
{
@@ -12668,25 +12564,5 @@ .locals init (System.ValueTuple V_0, //t
}
");
}
-
-
- [Theory, WorkItem(55609, "https://github.com/dotnet/roslyn/issues/55609")]
- [InlineData(@"$""{h1}{h2}""")]
- [InlineData(@"$""{h1}"" + $""{h2}""")]
- public void RefStructHandler_DynamicInHole(string expression)
- {
- var code = @"
-dynamic h1 = 1;
-dynamic h2 = 2;
-CustomHandler c = " + expression + ";";
-
- var handler = GetInterpolatedStringCustomHandlerType("CustomHandler", "ref struct", useBoolReturns: false);
-
- var comp = CreateCompilationWithCSharp(new[] { code, handler });
-
- // Note: We don't give any errors when mixing dynamic and ref structs today. If that ever changes, we should get an
- // error here. This will crash at runtime because of this.
- comp.VerifyEmitDiagnostics();
- }
}
}
diff --git a/src/Compilers/VisualBasic/Portable/Syntax/InternalSyntax/SyntaxNode.vb b/src/Compilers/VisualBasic/Portable/Syntax/InternalSyntax/SyntaxNode.vb
index c42cc07a761d7..75e57c177b88c 100644
--- a/src/Compilers/VisualBasic/Portable/Syntax/InternalSyntax/SyntaxNode.vb
+++ b/src/Compilers/VisualBasic/Portable/Syntax/InternalSyntax/SyntaxNode.vb
@@ -223,7 +223,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax
End Function
' Use conditional weak table so we always return same identity for structured trivia
- Private Shared ReadOnly s_structuresTable As New ConditionalWeakTable(Of SyntaxNode, Dictionary(Of Microsoft.CodeAnalysis.SyntaxTrivia, WeakReference(Of SyntaxNode)))
+ Private Shared ReadOnly s_structuresTable As New ConditionalWeakTable(Of SyntaxNode, Dictionary(Of Microsoft.CodeAnalysis.SyntaxTrivia, SyntaxNode))
Public Overrides Function GetStructure(trivia As Microsoft.CodeAnalysis.SyntaxTrivia) As SyntaxNode
If Not trivia.HasStructure Then
@@ -239,13 +239,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax
Dim structsInParent = s_structuresTable.GetOrCreateValue(parent)
SyncLock structsInParent
- Dim weakStructure As WeakReference(Of SyntaxNode) = Nothing
- If Not structsInParent.TryGetValue(trivia, weakStructure) Then
+ If Not structsInParent.TryGetValue(trivia, [structure]) Then
[structure] = VisualBasic.Syntax.StructuredTriviaSyntax.Create(trivia)
- structsInParent.Add(trivia, New WeakReference(Of SyntaxNode)([structure]))
- ElseIf Not weakStructure.TryGetTarget([structure]) Then
- [structure] = VisualBasic.Syntax.StructuredTriviaSyntax.Create(trivia)
- weakStructure.SetTarget([structure])
+ structsInParent.Add(trivia, [structure])
End If
End SyncLock
diff --git a/src/EditorFeatures/CSharpTest/ConvertToInterpolatedString/ConvertPlaceholderToInterpolatedStringTests.cs b/src/EditorFeatures/CSharpTest/ConvertToInterpolatedString/ConvertPlaceholderToInterpolatedStringTests.cs
index 277e602674dd5..cfb74399cb6a2 100644
--- a/src/EditorFeatures/CSharpTest/ConvertToInterpolatedString/ConvertPlaceholderToInterpolatedStringTests.cs
+++ b/src/EditorFeatures/CSharpTest/ConvertToInterpolatedString/ConvertPlaceholderToInterpolatedStringTests.cs
@@ -4,8 +4,6 @@
#nullable disable
-using System.Collections.Generic;
-using System.Linq;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeRefactorings;
using Microsoft.CodeAnalysis.CSharp.ConvertToInterpolatedString;
@@ -21,129 +19,27 @@ public class ConvertPlaceholderToInterpolatedStringTests : AbstractCSharpCodeAct
protected override CodeRefactoringProvider CreateCodeRefactoringProvider(Workspace workspace, TestParameters parameters)
=> new CSharpConvertPlaceholderToInterpolatedStringRefactoringProvider();
- private static readonly string[] CompositeFormattedMethods = new[]
- {
- "Console.Write",
- "Console.WriteLine",
- "Debug.WriteLine",
- "Debug.Print",
- "Trace.TraceError",
- "Trace.TraceWarning",
- "Trace.TraceInformation",
- };
-
- public static IEnumerable