提交 8a790e4e 编写于 作者: C Charles Stoner

Misc.

上级 a004c2c5
......@@ -1596,6 +1596,14 @@ private static BoundExpression SkipReferenceConversions(BoundExpression possibly
return possiblyConversion;
}
// https://github.com/dotnet/roslyn/issues/30140: Track nullable state from ??=.
public override BoundNode VisitNullCoalescingAssignmentOperator(BoundNullCoalescingAssignmentOperator node)
{
var result = base.VisitNullCoalescingAssignmentOperator(node);
SetResult(node);
return result;
}
public override BoundNode VisitNullCoalescingOperator(BoundNullCoalescingOperator node)
{
Debug.Assert(!IsConditionalState);
......
......@@ -332,9 +332,9 @@ public static LanguageVersion MapSpecifiedToEffectiveVersion(this LanguageVersio
switch (version)
{
case LanguageVersion.Latest:
return LanguageVersion.CSharp8;
return LanguageVersion.CSharp7_3;
case LanguageVersion.Default:
return LanguageVersion.CSharp8;
return LanguageVersion.CSharp7;
default:
return version;
}
......
......@@ -273,6 +273,7 @@ private IOperation CreateInternal(BoundNode boundNode)
case BoundKind.RefValueOperator:
case BoundKind.Sequence:
case BoundKind.StackAllocArrayCreation:
case BoundKind.SuppressNullableWarningExpression:
case BoundKind.TypeExpression:
case BoundKind.TypeOrValueExpression:
......
......@@ -36,7 +36,7 @@ ImmutableArray<MethodSymbol> makeConstructor(CSharpCompilation compilation, Name
Binder.ReportUseSiteDiagnostics(boolType, diagnostics, Location.None);
var boolWithAnnotations = TypeSymbolWithAnnotations.Create(boolType);
// PROTOTYPE constructor should save the parameter into a field (for users of reflection)
// PROTOTYPE(NullableReferenceTypes): Constructor should save the parameter into a field (for users of reflection)
return ImmutableArray.Create<MethodSymbol>(
new NonNullTypesAttributeConstructorSymbol(
containingType,
......
......@@ -1000,8 +1000,8 @@ namespace NotMicrosoft.CodeAnalysis { }
((NamespaceSymbol)comp.SourceModule.GlobalNamespace.GetMember("Microsoft.CodeAnalysis")).GetMembers().Single().ToTestDisplayString());
}
// PROTOTYPE Test emitting netmodule (we'll won't inject NNT)
// PROTOTYPE test script
// PROTOTYPE(NullableReferenceTypes): Test emitting netmodule (we won't inject NNT)
// PROTOTYPE(NullableReferenceTypes): Test script
[Theory]
[InlineData(NonNullTypesTrue)]
......@@ -7359,7 +7359,7 @@ partial class C1
{ }
}";
var compilation = CreateCompilation(new[] { source, NonNullTypesTrue });
// PROTOTYPE(NullReferenceTypes): What nullability is getting emitted?
// PROTOTYPE(NullableReferenceTypes): What nullability is getting emitted?
compilation.VerifyDiagnostics(
// (16,18): warning CS8611: Nullability of reference types in type of parameter 'x' doesn't match partial method declaration.
// partial void M1<T>(T? x, T[]? y, System.Action<T?> z, System.Action<T?[]?>?[]? u) where T : class
......@@ -7492,7 +7492,7 @@ partial class C1
{ }
}";
var compilation = CreateCompilation(new[] { source });
// PROTOTYPE(NullReferenceTypes): Missing WRN_MissingNonNullTypesContextForAnnotation for '?' in
// PROTOTYPE(NullableReferenceTypes): Missing WRN_MissingNonNullTypesContextForAnnotation for '?' in
// (17,18):
// partial void M1<T>(T? x, T[]? y, System.Action<T?> z, System.Action<T?[]?>?[]? u) where T : class
compilation.VerifyDiagnostics(
......@@ -8187,7 +8187,7 @@ class CL1
{
}
", NonNullTypesTrue });
// PROTOTYPE(NullReferenceTypes): Should report WRN_NullReferenceAssignment for `ref x3`
// PROTOTYPE(NullableReferenceTypes): Should report WRN_NullReferenceAssignment for `ref x3`
// even though the local is unassigned. (The local should be treated as an l-value for assignment.)
c.VerifyDiagnostics(
// (12,12): warning CS8604: Possible null reference argument for parameter 'p' in 'void C.M1(CL1 p)'.
......@@ -25276,7 +25276,7 @@ class CL1
}
}
", NonNullTypesTrue });
// PROTOTYPE(NullReferenceTypes): Should report WRN_NullReferenceAssignment for `x7--`
// PROTOTYPE(NullableReferenceTypes): Should report WRN_NullReferenceAssignment for `x7--`
// even though the local is unassigned. (The local should be treated as an l-value for assignment.)
c.VerifyDiagnostics(
// (10,21): warning CS8604: Possible null reference argument for parameter 'x' in 'CL0 CL0.operator ++(CL0 x)'.
......@@ -288,7 +288,7 @@ public class B
var countedTree = new CountedSyntaxTree(foreignType);
var compilation = CreateCompilation(new SyntaxTree[] { underlyingTree, countedTree });
var compilation = CreateCompilation(new SyntaxTree[] { underlyingTree, countedTree }, skipUsesIsNullable: true);
var type = compilation.Assembly.GlobalNamespace.GetTypeMembers().First();
Assert.Equal(1, countedTree.AccessCount); // parse once to build the decl table
......
......@@ -192,7 +192,6 @@ public enum OperationKind
ConstructorBodyOperation = 0x59,
/// <summary>Indicates an <see cref="IDiscardOperation"/>.</summary>
Discard = 0x5A,
/// <summary>Indicates an <see cref="IFlowCaptureOperation"/>.</summary>
FlowCapture = 0x5B,
/// <summary>Indicates an <see cref="IFlowCaptureReferenceOperation"/>.</summary>
......@@ -205,11 +204,10 @@ public enum OperationKind
StaticLocalInitializationSemaphore = 0x5F,
/// <summary>Indicates an <see cref="IFlowAnonymousFunctionOperation"/>.</summary>
FlowAnonymousFunction = 0x60,
/// <summary>Indicates an <see cref="ISuppressNullableWarningOperation"/>.</summary>
SuppressNullableWarning = 0x61,
/// <summary>Indicates an <see cref="ICoalesceAssignmentOperation"/>.</summary>
CoalesceAssignment = 0x61,
/// <summary>Indicates an <see cref="ISuppressNullableWarningOperation"/>.</summary>
SuppressNullableWarning = 0x62,
// /// <summary>Indicates an <see cref="IFixedOperation"/>.</summary>
// https://github.com/dotnet/roslyn/issues/21281
......
......@@ -29,7 +29,7 @@ Microsoft.CodeAnalysis.FlowAnalysis.IStaticLocalInitializationSemaphoreOperation
Microsoft.CodeAnalysis.FlowAnalysis.IStaticLocalInitializationSemaphoreOperation.Local.get -> Microsoft.CodeAnalysis.ILocalSymbol
Microsoft.CodeAnalysis.IOperation.SemanticModel.get -> Microsoft.CodeAnalysis.SemanticModel
Microsoft.CodeAnalysis.OperationKind.CoalesceAssignment = 97 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.SuppressNullableWarning = 97 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.SuppressNullableWarning = 98 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.Operations.CommonConversion.IsImplicit.get -> bool
Microsoft.CodeAnalysis.Operations.ICoalesceAssignmentOperation
Microsoft.CodeAnalysis.Operations.ISuppressNullableWarningOperation
......
......@@ -1536,7 +1536,7 @@ internal class T
{
public T(out DateTime d)
{
d = default;
d = default(DateTime);
}
}",
index: 1);
......@@ -1684,7 +1684,7 @@ private class T
{
public T(out X d)
{
d = default;
d = default(X);
}
}
}",
......
......@@ -550,7 +550,8 @@ void A()
</Project>
</Workspace>",
new[] {
string.Format(CSharpFeaturesResources.Upgrade_this_project_to_csharp_language_version_0, "7.0")
string.Format(CSharpFeaturesResources.Upgrade_this_project_to_csharp_language_version_0, "7.0"),
string.Format(CSharpFeaturesResources.Upgrade_all_csharp_projects_to_language_version_0, "7.0")
});
}
......@@ -584,13 +585,16 @@ public async Task OnlyOfferFixAllProjectsToDefaultWhenApplicable()
string defaultEffectiveVersion = LanguageVersion.Default.MapSpecifiedToEffectiveVersion().ToDisplayString();
await TestExactActionSetOfferedAsync(
@"<Workspace>
$@"<Workspace>
<Project Language=""C#"" LanguageVersion=""6"">
<Document>
class C
{
object F = [|null!|];
}
{{
void A()
{{
#error version:[|{defaultEffectiveVersion}|]
}}
}}
</Document>
</Project>
<Project Language=""C#"" LanguageVersion=""Default"">
......
......@@ -326,7 +326,7 @@ public Program((int, string) i)
(int, string) i;
(string, int) s;
public Program((int, string) i, (string, int) s = default)
public Program((int, string) i, (string, int) s = default((string, int)))
{
this.i = i;
this.s = s;
......@@ -382,7 +382,7 @@ public Program((int a, string b) i)
(int a, string b) i;
(string c, int d) s;
public Program((int a, string b) i, (string c, int d) s = default)
public Program((int a, string b) i, (string c, int d) s = default((string c, int d)))
{
this.i = i;
this.s = s;
......
......@@ -3991,7 +3991,7 @@ void bar(sfoo x)
{
void goo()
{
sfoo xyz = default;
sfoo xyz = default(sfoo);
bar(xyz);
}
......
......@@ -459,7 +459,7 @@ abstract class d
class c : d
{
public override void goo(b x = default)
public override void goo(b x = default(b))
{
throw new System.NotImplementedException();
}
......@@ -1564,7 +1564,7 @@ abstract class B
}
sealed class D : B
{
public override void M1(int i = 0, string s = null, int? j = null, V v = default)
public override void M1(int i = 0, string s = null, int? j = null, V v = default(V))
{
throw new System.NotImplementedException();
}
......
......@@ -1949,7 +1949,7 @@ class D : C
state.SendTypeChars(" Goo")
state.SendTab()
Await state.AssertNoCompletionSession()
Assert.Contains("public override void Goo<S>(S x = default)", state.SubjectBuffer.CurrentSnapshot.GetText(), StringComparison.Ordinal)
Assert.Contains("public override void Goo<S>(S x = default(S))", state.SubjectBuffer.CurrentSnapshot.GetText(), StringComparison.Ordinal)
End Using
End Function
......
......@@ -2160,7 +2160,7 @@ class C
{
string Name
{
get => default;
get => default(string);
set
{
}
......@@ -2188,7 +2188,7 @@ class C
{
get
{
return default;
return default(string);
}
set
......@@ -2220,7 +2220,7 @@ class C$$
<Code>
class C
{
string Name => default;
string Name => default(string);
}
</Code>
......@@ -2244,7 +2244,7 @@ class C
{
get
{
return default;
return default(string);
}
}
}
......
......@@ -1765,7 +1765,7 @@ public async Task TestParseOptions_CSharp_Compatibility_None()
public async Task TestParseOptions_CSharp_LanguageVersion_Default()
{
CreateCSharpFiles();
await AssertCSParseOptionsAsync(CS.LanguageVersion.CSharp8, options => options.LanguageVersion);
await AssertCSParseOptionsAsync(CS.LanguageVersion.CSharp7, options => options.LanguageVersion);
}
[ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册