提交 5940424d 编写于 作者: M Manish Vasani

Add unit tests for ITypeOfExpression and ISizeOfExpression and make APIs public again

Fixes #22003 and #21296.
上级 744d6e2f
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26405.2
VisualStudioVersion = 15.0.26730.8
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodeAnalysisTest", "src\Compilers\Core\CodeAnalysisTest\CodeAnalysisTest.csproj", "{A4C99B85-765C-4C65-9C2A-BB609AAB09E6}"
EndProject
......@@ -159,7 +158,6 @@ Global
src\Compilers\Core\CommandLine\CommandLine.projitems*{4b45ca0c-03a0-400f-b454-3d4bcb16af38}*SharedItemsImports = 4
src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{5f8d2414-064a-4b3a-9b42-8e2a04246be5}*SharedItemsImports = 4
src\Compilers\Core\CommandLine\CommandLine.projitems*{7ad4fe65-9a30-41a6-8004-aa8f89bcb7f3}*SharedItemsImports = 4
src\Compilers\Core\CommandLine\CommandLine.projitems*{8ce3a581-2969-4864-a803-013e9d977c3a}*SharedItemsImports = 4
src\Compilers\Core\CommandLine\CommandLine.projitems*{9508f118-f62e-4c16-a6f4-7c3b56e166ad}*SharedItemsImports = 4
src\Compilers\Server\ServerShared\ServerShared.projitems*{9508f118-f62e-4c16-a6f4-7c3b56e166ad}*SharedItemsImports = 4
src\Compilers\Core\CommandLine\CommandLine.projitems*{ad6f474e-e6d4-4217-91f3-b7af1be31ccc}*SharedItemsImports = 13
......@@ -169,7 +167,6 @@ Global
src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{c1930979-c824-496b-a630-70f5369a636f}*SharedItemsImports = 13
src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{d0bc9be7-24f6-40ca-8dc6-fcb93bd44b34}*SharedItemsImports = 13
src\Dependencies\CodeAnalysis.Debugging\Microsoft.CodeAnalysis.Debugging.projitems*{d73adf7d-2c1c-42ae-b2ab-edc9497e4b71}*SharedItemsImports = 13
src\Compilers\Core\CommandLine\CommandLine.projitems*{e3cd2895-76a8-4d11-a316-ea67cb5ea42c}*SharedItemsImports = 4
src\Compilers\Core\CommandLine\CommandLine.projitems*{e58ee9d7-1239-4961-a0c1-f9ec3952c4c1}*SharedItemsImports = 4
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
......@@ -473,4 +470,7 @@ Global
{0141285D-8F6C-42C7-BAF3-3C0CCD61C716} = {B20208C3-D3A6-4020-A274-6BE3786D29FB}
{E512C6C1-F085-4AD7-B0D9-E8F1A0A2A510} = {B20208C3-D3A6-4020-A274-6BE3786D29FB}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7EE533BB-45F7-44C7-BEA2-29E32F6A850C}
EndGlobalSection
EndGlobal
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Linq;
using Microsoft.CodeAnalysis.CSharp.Syntax;
......@@ -140,29 +140,5 @@ public void TestParentOperations()
VerifyParentOperations(model);
}
[CompilerTrait(CompilerFeature.IOperation)]
[Fact]
public void TestSizeOfExpression()
{
string source = @"
using System;
class C
{
void M(int i)
{
i = /*<bind>*/sizeof(int)/*</bind>*/;
}
}
";
string expectedOperationTree = @"
ISizeOfExpression (OperationKind.None, Constant: 4) (Syntax: 'sizeof(int)')
TypeOperand: System.Int32
";
var expectedDiagnostics = DiagnosticDescription.None;
VerifyOperationTreeAndDiagnosticsForTest<SizeOfExpressionSyntax>(source, expectedOperationTree, expectedDiagnostics);
}
}
}
......@@ -578,7 +578,7 @@ void M(object x)
Clauses:
IPatternCaseClause (Label Symbol: case typeof(X):) (CaseKind.Pattern) (OperationKind.CaseClause, IsInvalid) (Syntax: 'case typeof(X):')
Pattern: IConstantPattern (OperationKind.ConstantPattern, IsInvalid) (Syntax: 'case typeof(X):')
Value: ITypeOfExpression (OperationKind.None, IsInvalid) (Syntax: 'typeof(X)')
Value: ITypeOfExpression (OperationKind.TypeOfExpression, Type: System.Type, IsInvalid) (Syntax: 'typeof(X)')
TypeOperand: X
Guard Expression: null
Body:
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.CSharp.Test.Utilities;
using Microsoft.CodeAnalysis.Test.Utilities;
using Xunit;
namespace Microsoft.CodeAnalysis.CSharp.UnitTests
{
public partial class IOperationTests : SemanticModelTestBase
{
[CompilerTrait(CompilerFeature.IOperation)]
[Fact]
public void TestSizeOfExpression()
{
string source = @"
using System;
class C
{
void M(int i)
{
i = /*<bind>*/sizeof(int)/*</bind>*/;
}
}
";
string expectedOperationTree = @"
ISizeOfExpression (OperationKind.SizeOfExpression, Type: System.Int32, Constant: 4) (Syntax: 'sizeof(int)')
TypeOperand: System.Int32
";
var expectedDiagnostics = DiagnosticDescription.None;
VerifyOperationTreeAndDiagnosticsForTest<SizeOfExpressionSyntax>(source, expectedOperationTree, expectedDiagnostics);
}
[CompilerTrait(CompilerFeature.IOperation)]
[Fact]
public void TestSizeOfExpression_NonPrimitiveTypeArgument()
{
string source = @"
using System;
class C
{
void M(int i)
{
i = /*<bind>*/sizeof(C)/*</bind>*/;
}
}
";
string expectedOperationTree = @"
ISizeOfExpression (OperationKind.SizeOfExpression, Type: System.Int32, IsInvalid) (Syntax: 'sizeof(C)')
TypeOperand: C
";
var expectedDiagnostics = new DiagnosticDescription[] {
// CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('C')
// i = /*<bind>*/sizeof(C)/*</bind>*/;
Diagnostic(ErrorCode.ERR_ManagedAddr, "sizeof(C)").WithArguments("C").WithLocation(8, 23),
// CS0233: 'C' does not have a predefined size, therefore sizeof can only be used in an unsafe context (consider using System.Runtime.InteropServices.Marshal.SizeOf)
// i = /*<bind>*/sizeof(C)/*</bind>*/;
Diagnostic(ErrorCode.ERR_SizeofUnsafe, "sizeof(C)").WithArguments("C").WithLocation(8, 23)
};
VerifyOperationTreeAndDiagnosticsForTest<SizeOfExpressionSyntax>(source, expectedOperationTree, expectedDiagnostics);
}
[CompilerTrait(CompilerFeature.IOperation)]
[Fact]
public void TestSizeOfExpression_PointerTypeArgument()
{
string source = @"
using System;
class C
{
unsafe void M(int i)
{
i = /*<bind>*/sizeof(void**)/*</bind>*/;
}
}
";
string expectedOperationTree = @"
ISizeOfExpression (OperationKind.SizeOfExpression, Type: System.Int32) (Syntax: 'sizeof(void**)')
TypeOperand: System.Void**
";
var expectedDiagnostics = DiagnosticDescription.None;
VerifyOperationTreeAndDiagnosticsForTest<SizeOfExpressionSyntax>(source, expectedOperationTree, expectedDiagnostics, compilationOptions: TestOptions.UnsafeReleaseDll);
}
[CompilerTrait(CompilerFeature.IOperation)]
[Fact]
public void TestSizeOfExpression_ErrorTypeArgument()
{
string source = @"
using System;
class C
{
void M(int i)
{
i = /*<bind>*/sizeof(UndefinedType)/*</bind>*/;
}
}
";
string expectedOperationTree = @"
ISizeOfExpression (OperationKind.SizeOfExpression, Type: System.Int32, IsInvalid) (Syntax: 'sizeof(UndefinedType)')
TypeOperand: UndefinedType
";
var expectedDiagnostics = new DiagnosticDescription[] {
// CS0246: The type or namespace name 'UndefinedType' could not be found (are you missing a using directive or an assembly reference?)
// i = /*<bind>*/sizeof(UndefinedType)/*</bind>*/;
Diagnostic(ErrorCode.ERR_SingleTypeNameNotFound, "UndefinedType").WithArguments("UndefinedType").WithLocation(8, 30),
// CS0233: 'UndefinedType' does not have a predefined size, therefore sizeof can only be used in an unsafe context (consider using System.Runtime.InteropServices.Marshal.SizeOf)
// i = /*<bind>*/sizeof(UndefinedType)/*</bind>*/;
Diagnostic(ErrorCode.ERR_SizeofUnsafe, "sizeof(UndefinedType)").WithArguments("UndefinedType").WithLocation(8, 23)
};
VerifyOperationTreeAndDiagnosticsForTest<SizeOfExpressionSyntax>(source, expectedOperationTree, expectedDiagnostics);
}
[CompilerTrait(CompilerFeature.IOperation)]
[Fact]
public void TestSizeOfExpression_IdentifierArgument()
{
string source = @"
using System;
class C
{
void M(int i)
{
i = /*<bind>*/sizeof(i)/*</bind>*/;
}
}
";
string expectedOperationTree = @"
ISizeOfExpression (OperationKind.SizeOfExpression, Type: System.Int32, IsInvalid) (Syntax: 'sizeof(i)')
TypeOperand: i
";
var expectedDiagnostics = new DiagnosticDescription[] {
// CS0118: 'i' is a variable but is used like a type
// i = /*<bind>*/sizeof(i)/*</bind>*/;
Diagnostic(ErrorCode.ERR_BadSKknown, "i").WithArguments("i", "variable", "type").WithLocation(8, 30),
// CS0233: 'i' does not have a predefined size, therefore sizeof can only be used in an unsafe context (consider using System.Runtime.InteropServices.Marshal.SizeOf)
// i = /*<bind>*/sizeof(i)/*</bind>*/;
Diagnostic(ErrorCode.ERR_SizeofUnsafe, "sizeof(i)").WithArguments("i").WithLocation(8, 23)
};
VerifyOperationTreeAndDiagnosticsForTest<SizeOfExpressionSyntax>(source, expectedOperationTree, expectedDiagnostics);
}
[CompilerTrait(CompilerFeature.IOperation)]
[Fact]
public void TestSizeOfExpression_ExpressionArgument()
{
string source = @"
using System;
class C
{
void M(int i)
{
i = /*<bind>*/sizeof(M2()/*</bind>*/);
}
int M2() => 0;
}
";
string expectedOperationTree = @"
IInvocationExpression ( ? System.Int32.()) (OperationKind.InvocationExpression, Type: ?, IsInvalid) (Syntax: 'sizeof(M2()')
Instance Receiver: ISizeOfExpression (OperationKind.SizeOfExpression, Type: System.Int32, IsInvalid) (Syntax: 'sizeof(M2')
TypeOperand: M2
Arguments(0)
";
var expectedDiagnostics = new DiagnosticDescription[] {
// CS1026: ) expected
// i = /*<bind>*/sizeof(M2()/*</bind>*/);
Diagnostic(ErrorCode.ERR_CloseParenExpected, "(").WithLocation(8, 32),
// CS1002: ; expected
// i = /*<bind>*/sizeof(M2()/*</bind>*/);
Diagnostic(ErrorCode.ERR_SemicolonExpected, ")").WithLocation(8, 45),
// CS1513: } expected
// i = /*<bind>*/sizeof(M2()/*</bind>*/);
Diagnostic(ErrorCode.ERR_RbraceExpected, ")").WithLocation(8, 45),
// CS0246: The type or namespace name 'M2' could not be found (are you missing a using directive or an assembly reference?)
// i = /*<bind>*/sizeof(M2()/*</bind>*/);
Diagnostic(ErrorCode.ERR_SingleTypeNameNotFound, "M2").WithArguments("M2").WithLocation(8, 30),
// CS0233: 'M2' does not have a predefined size, therefore sizeof can only be used in an unsafe context (consider using System.Runtime.InteropServices.Marshal.SizeOf)
// i = /*<bind>*/sizeof(M2()/*</bind>*/);
Diagnostic(ErrorCode.ERR_SizeofUnsafe, "sizeof(M2").WithArguments("M2").WithLocation(8, 23)
};
VerifyOperationTreeAndDiagnosticsForTest<InvocationExpressionSyntax>(source, expectedOperationTree, expectedDiagnostics);
}
[CompilerTrait(CompilerFeature.IOperation)]
[Fact]
public void TestSizeOfExpression_MissingArgument()
{
string source = @"
using System;
class C
{
void M(int i)
{
i = /*<bind>*/sizeof()/*</bind>*/;
}
}
";
string expectedOperationTree = @"
ISizeOfExpression (OperationKind.SizeOfExpression, Type: System.Int32, IsInvalid) (Syntax: 'sizeof()')
TypeOperand: ?
";
var expectedDiagnostics = new DiagnosticDescription[] {
// CS1031: Type expected
// i = /*<bind>*/sizeof()/*</bind>*/;
Diagnostic(ErrorCode.ERR_TypeExpected, ")").WithLocation(8, 30),
// CS0233: '?' does not have a predefined size, therefore sizeof can only be used in an unsafe context (consider using System.Runtime.InteropServices.Marshal.SizeOf)
// i = /*<bind>*/sizeof()/*</bind>*/;
Diagnostic(ErrorCode.ERR_SizeofUnsafe, "sizeof()").WithArguments("?").WithLocation(8, 23)
};
VerifyOperationTreeAndDiagnosticsForTest<SizeOfExpressionSyntax>(source, expectedOperationTree, expectedDiagnostics);
}
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Test.Utilities;
using Xunit;
namespace Microsoft.CodeAnalysis.CSharp.UnitTests
{
public partial class IOperationTests : SemanticModelTestBase
{
[CompilerTrait(CompilerFeature.IOperation)]
[Fact]
public void TestTypeOfExpression()
{
string source = @"
using System;
class C
{
void M(Type t)
{
t = /*<bind>*/typeof(int)/*</bind>*/;
}
}
";
string expectedOperationTree = @"
ITypeOfExpression (OperationKind.TypeOfExpression, Type: System.Type) (Syntax: 'typeof(int)')
TypeOperand: System.Int32
";
var expectedDiagnostics = DiagnosticDescription.None;
VerifyOperationTreeAndDiagnosticsForTest<TypeOfExpressionSyntax>(source, expectedOperationTree, expectedDiagnostics);
}
[CompilerTrait(CompilerFeature.IOperation)]
[Fact]
public void TestTypeOfExpression_NonPrimitiveTypeArgument()
{
string source = @"
using System;
class C
{
void M(Type t)
{
t = /*<bind>*/typeof(C)/*</bind>*/;
}
}
";
string expectedOperationTree = @"
ITypeOfExpression (OperationKind.TypeOfExpression, Type: System.Type) (Syntax: 'typeof(C)')
TypeOperand: C
";
var expectedDiagnostics = DiagnosticDescription.None;
VerifyOperationTreeAndDiagnosticsForTest<TypeOfExpressionSyntax>(source, expectedOperationTree, expectedDiagnostics);
}
[CompilerTrait(CompilerFeature.IOperation)]
[Fact]
public void TestTypeOfExpression_ErrorTypeArgument()
{
string source = @"
using System;
class C
{
void M(Type t)
{
t = /*<bind>*/typeof(UndefinedType)/*</bind>*/;
}
}
";
string expectedOperationTree = @"
ITypeOfExpression (OperationKind.TypeOfExpression, Type: System.Type, IsInvalid) (Syntax: 'typeof(UndefinedType)')
TypeOperand: UndefinedType
";
var expectedDiagnostics = new DiagnosticDescription[] {
// CS0246: The type or namespace name 'UndefinedType' could not be found (are you missing a using directive or an assembly reference?)
// t = /*<bind>*/typeof(UndefinedType)/*</bind>*/;
Diagnostic(ErrorCode.ERR_SingleTypeNameNotFound, "UndefinedType").WithArguments("UndefinedType").WithLocation(8, 30)
};
VerifyOperationTreeAndDiagnosticsForTest<TypeOfExpressionSyntax>(source, expectedOperationTree, expectedDiagnostics);
}
[CompilerTrait(CompilerFeature.IOperation)]
[Fact]
public void TestTypeOfExpression_IdentifierArgument()
{
string source = @"
using System;
class C
{
void M(Type t)
{
t = /*<bind>*/typeof(t)/*</bind>*/;
}
}
";
string expectedOperationTree = @"
ITypeOfExpression (OperationKind.TypeOfExpression, Type: System.Type, IsInvalid) (Syntax: 'typeof(t)')
TypeOperand: t
";
var expectedDiagnostics = new DiagnosticDescription[] {
// CS0118: 't' is a variable but is used like a type
// t = /*<bind>*/typeof(t)/*</bind>*/;
Diagnostic(ErrorCode.ERR_BadSKknown, "t").WithArguments("t", "variable", "type").WithLocation(8, 30)
};
VerifyOperationTreeAndDiagnosticsForTest<TypeOfExpressionSyntax>(source, expectedOperationTree, expectedDiagnostics);
}
[CompilerTrait(CompilerFeature.IOperation)]
[Fact]
public void TestTypeOfExpression_ExpressionArgument()
{
string source = @"
using System;
class C
{
void M(Type t)
{
t = /*<bind>*/typeof(M2()/*</bind>*/);
}
Type M2() => null;
}
";
string expectedOperationTree = @"
IInvocationExpression ( ? System.Type.()) (OperationKind.InvocationExpression, Type: ?, IsInvalid) (Syntax: 'typeof(M2()')
Instance Receiver: ITypeOfExpression (OperationKind.TypeOfExpression, Type: System.Type, IsInvalid) (Syntax: 'typeof(M2')
TypeOperand: M2
Arguments(0)
";
var expectedDiagnostics = new DiagnosticDescription[] {
// CS1026: ) expected
// t = /*<bind>*/typeof(M2()/*</bind>*/);
Diagnostic(ErrorCode.ERR_CloseParenExpected, "(").WithLocation(8, 32),
// CS1002: ; expected
// t = /*<bind>*/typeof(M2()/*</bind>*/);
Diagnostic(ErrorCode.ERR_SemicolonExpected, ")").WithLocation(8, 45),
// CS1513: } expected
// t = /*<bind>*/typeof(M2()/*</bind>*/);
Diagnostic(ErrorCode.ERR_RbraceExpected, ")").WithLocation(8, 45),
// CS0246: The type or namespace name 'M2' could not be found (are you missing a using directive or an assembly reference?)
// t = /*<bind>*/typeof(M2()/*</bind>*/);
Diagnostic(ErrorCode.ERR_SingleTypeNameNotFound, "M2").WithArguments("M2").WithLocation(8, 30)
};
VerifyOperationTreeAndDiagnosticsForTest<InvocationExpressionSyntax>(source, expectedOperationTree, expectedDiagnostics);
}
[CompilerTrait(CompilerFeature.IOperation)]
[Fact]
public void TestTypeOfExpression_MissingArgument()
{
string source = @"
using System;
class C
{
void M(Type t)
{
t = /*<bind>*/typeof()/*</bind>*/;
}
}
";
string expectedOperationTree = @"
ITypeOfExpression (OperationKind.TypeOfExpression, Type: System.Type, IsInvalid) (Syntax: 'typeof()')
TypeOperand: ?
";
var expectedDiagnostics = new DiagnosticDescription[] {
// CS1031: Type expected
// t = /*<bind>*/typeof()/*</bind>*/;
Diagnostic(ErrorCode.ERR_TypeExpected, ")").WithLocation(8, 30)
};
VerifyOperationTreeAndDiagnosticsForTest<TypeOfExpressionSyntax>(source, expectedOperationTree, expectedDiagnostics);
}
}
}
......@@ -4111,9 +4111,7 @@ public override void Accept(OperationVisitor visitor)
internal sealed partial class SizeOfExpression : Operation, ISizeOfExpression
{
public SizeOfExpression(ITypeSymbol typeOperand, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
// https://github.com/dotnet/roslyn/issues/21296
// base(OperationKind.SizeOfExpression, semanticModel, syntax, type, constantValue, isImplicit)
base(OperationKind.None, semanticModel, syntax, type, constantValue, isImplicit)
base(OperationKind.SizeOfExpression, semanticModel, syntax, type, constantValue, isImplicit)
{
TypeOperand = typeOperand;
}
......@@ -4495,9 +4493,7 @@ internal sealed partial class LazyTupleExpression : BaseTupleExpression, ITupleE
internal sealed partial class TypeOfExpression : Operation, ITypeOfExpression
{
public TypeOfExpression(ITypeSymbol typeOperand, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
// https://github.com/dotnet/roslyn/issues/22003
// base(OperationKind.TypeOfExpression, semanticModel, syntax, type, constantValue, isImplicit)
base(OperationKind.None, semanticModel, syntax, type, constantValue, isImplicit)
base(OperationKind.TypeOfExpression, semanticModel, syntax, type, constantValue, isImplicit)
{
TypeOperand = typeOperand;
}
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Immutable;
namespace Microsoft.CodeAnalysis.Semantics
{
/// <summary>
......@@ -11,7 +9,7 @@ namespace Microsoft.CodeAnalysis.Semantics
/// This interface is reserved for implementation by its associated APIs. We reserve the right to
/// change it in the future.
/// </remarks>
internal interface ISizeOfExpression : IOperation // https://github.com/dotnet/roslyn/issues/21296
public interface ISizeOfExpression : IOperation
{
/// <summary>
/// Type operand.
......@@ -19,4 +17,3 @@ internal interface ISizeOfExpression : IOperation // https://github.com/dotnet/r
ITypeSymbol TypeOperand { get; }
}
}
......@@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Semantics
/// This interface is reserved for implementation by its associated APIs. We reserve the right to
/// change it in the future.
/// </remarks>
internal interface ITypeOfExpression : IOperation // https://github.com/dotnet/roslyn/issues/22003
public interface ITypeOfExpression : IOperation
{
/// <summary>
/// Type operand.
......
......@@ -280,12 +280,12 @@ public override IOperation VisitIsTypeExpression(IIsTypeExpression operation, ob
return new IsTypeExpression(Visit(operation.Operand), operation.IsType, operation.IsNotTypeExpression, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
}
internal override IOperation VisitSizeOfExpression(ISizeOfExpression operation, object argument)
public override IOperation VisitSizeOfExpression(ISizeOfExpression operation, object argument)
{
return new SizeOfExpression(operation.TypeOperand, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
}
internal override IOperation VisitTypeOfExpression(ITypeOfExpression operation, object argument)
public override IOperation VisitTypeOfExpression(ITypeOfExpression operation, object argument)
{
return new TypeOfExpression(operation.TypeOperand, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
}
......
......@@ -156,12 +156,10 @@ public enum OperationKind
/// <summary>Indicates an <see cref="IDefaultValueExpression"/>.</summary>
DefaultValueExpression = 0x200,
// https://github.com/dotnet/roslyn/issues/22003
// /// <summary>Indicates an <see cref="ITypeOfExpression"/>.</summary>
// TypeOfExpression = 0x201,
// https://github.com/dotnet/roslyn/issues/21296
// /// <summary>Indicates an <see cref="ISizeOfExpression"/>.</summary>
// SizeOfExpression = 0x202,
/// <summary>Indicates an <see cref="ITypeOfExpression"/>.</summary>
TypeOfExpression = 0x201,
/// <summary>Indicates an <see cref="ISizeOfExpression"/>.</summary>
SizeOfExpression = 0x202,
/// <summary>Indicates an <see cref="IAddressOfExpression"/>.</summary>
AddressOfExpression = 0x203,
// <summary>Indicates an <see cref="IPointerIndirectionReferenceExpression"/>.</summary>
......
......@@ -290,14 +290,12 @@ public virtual void VisitIsTypeExpression(IIsTypeExpression operation)
DefaultVisit(operation);
}
// https://github.com/dotnet/roslyn/issues/21296
internal virtual void VisitSizeOfExpression(ISizeOfExpression operation)
public virtual void VisitSizeOfExpression(ISizeOfExpression operation)
{
DefaultVisit(operation);
}
// https://github.com/dotnet/roslyn/issues/22003
internal virtual void VisitTypeOfExpression(ITypeOfExpression operation)
public virtual void VisitTypeOfExpression(ITypeOfExpression operation)
{
DefaultVisit(operation);
}
......@@ -783,14 +781,12 @@ public virtual TResult VisitIsTypeExpression(IIsTypeExpression operation, TArgum
return DefaultVisit(operation, argument);
}
// https://github.com/dotnet/roslyn/issues/21296
internal virtual TResult VisitSizeOfExpression(ISizeOfExpression operation, TArgument argument)
public virtual TResult VisitSizeOfExpression(ISizeOfExpression operation, TArgument argument)
{
return DefaultVisit(operation, argument);
}
// https://github.com/dotnet/roslyn/issues/22003
internal virtual TResult VisitTypeOfExpression(ITypeOfExpression operation, TArgument argument)
public virtual TResult VisitTypeOfExpression(ITypeOfExpression operation, TArgument argument)
{
return DefaultVisit(operation, argument);
}
......
......@@ -69,10 +69,10 @@ Microsoft.CodeAnalysis.OperationKind.ConversionExpression = 258 -> Microsoft.Cod
Microsoft.CodeAnalysis.OperationKind.DeclarationPattern = 1038 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.DecrementExpression = 520 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.DefaultValueExpression = 512 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.DynamicIndexerAccessExpression = 296 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.DynamicInvocationExpression = 295 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.DynamicMemberReferenceExpression = 294 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.DynamicObjectCreationExpression = 293 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.DynamicIndexerAccessExpression = 296 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.EmptyStatement = 9 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.EventAssignmentExpression = 283 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.EventReferenceExpression = 268 -> Microsoft.CodeAnalysis.OperationKind
......@@ -110,10 +110,12 @@ Microsoft.CodeAnalysis.OperationKind.PropertyInitializer = 1027 -> Microsoft.Cod
Microsoft.CodeAnalysis.OperationKind.PropertyReferenceExpression = 266 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.ReturnStatement = 11 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.SimpleAssignmentExpression = 280 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.SizeOfExpression = 514 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.SwitchCase = 1033 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.SwitchStatement = 4 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.ThrowExpression = 519 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.TupleExpression = 292 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.TypeOfExpression = 513 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.TypeParameterObjectCreationExpression = 275 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.UnaryOperatorExpression = 269 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.UsingStatement = 15 -> Microsoft.CodeAnalysis.OperationKind
......@@ -249,9 +251,9 @@ Microsoft.CodeAnalysis.Semantics.IDeclarationPattern.DeclaredSymbol.get -> Micro
Microsoft.CodeAnalysis.Semantics.IDefaultCaseClause
Microsoft.CodeAnalysis.Semantics.IDefaultValueExpression
Microsoft.CodeAnalysis.Semantics.IDoLoopStatement
Microsoft.CodeAnalysis.Semantics.IDoLoopStatement.IgnoredCondition.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.IDoLoopStatement.Condition.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.IDoLoopStatement.DoLoopKind.get -> Microsoft.CodeAnalysis.Semantics.DoLoopKind
Microsoft.CodeAnalysis.Semantics.IDoLoopStatement.IgnoredCondition.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.IDynamicIndexerAccessExpression
Microsoft.CodeAnalysis.Semantics.IDynamicIndexerAccessExpression.Arguments.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.IOperation>
Microsoft.CodeAnalysis.Semantics.IDynamicIndexerAccessExpression.Expression.get -> Microsoft.CodeAnalysis.IOperation
......@@ -281,18 +283,18 @@ Microsoft.CodeAnalysis.Semantics.IFieldReferenceExpression
Microsoft.CodeAnalysis.Semantics.IFieldReferenceExpression.Field.get -> Microsoft.CodeAnalysis.IFieldSymbol
Microsoft.CodeAnalysis.Semantics.IFieldReferenceExpression.IsDeclaration.get -> bool
Microsoft.CodeAnalysis.Semantics.IForEachLoopStatement
Microsoft.CodeAnalysis.Semantics.IForEachLoopStatement.NextVariables.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.IOperation>
Microsoft.CodeAnalysis.Semantics.IForEachLoopStatement.Collection.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.IForEachLoopStatement.LoopControlVariable.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.IForEachLoopStatement.NextVariables.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.IOperation>
Microsoft.CodeAnalysis.Semantics.IForLoopStatement
Microsoft.CodeAnalysis.Semantics.IForLoopStatement.AtLoopBottom.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.IOperation>
Microsoft.CodeAnalysis.Semantics.IForLoopStatement.Before.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.IOperation>
Microsoft.CodeAnalysis.Semantics.IForLoopStatement.Condition.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.IForToLoopStatement
Microsoft.CodeAnalysis.Semantics.IForToLoopStatement.NextVariables.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.IOperation>
Microsoft.CodeAnalysis.Semantics.IForToLoopStatement.InitialValue.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.IForToLoopStatement.LimitValue.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.IForToLoopStatement.LoopControlVariable.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.IForToLoopStatement.NextVariables.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.IOperation>
Microsoft.CodeAnalysis.Semantics.IForToLoopStatement.StepValue.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.IHasArgumentsExpression
Microsoft.CodeAnalysis.Semantics.IHasArgumentsExpression.ArgumentsInEvaluationOrder.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.Semantics.IArgument>
......@@ -328,8 +330,8 @@ Microsoft.CodeAnalysis.Semantics.IIsPatternExpression
Microsoft.CodeAnalysis.Semantics.IIsPatternExpression.Expression.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.IIsPatternExpression.Pattern.get -> Microsoft.CodeAnalysis.Semantics.IPattern
Microsoft.CodeAnalysis.Semantics.IIsTypeExpression
Microsoft.CodeAnalysis.Semantics.IIsTypeExpression.IsType.get -> Microsoft.CodeAnalysis.ITypeSymbol
Microsoft.CodeAnalysis.Semantics.IIsTypeExpression.IsNotTypeExpression.get -> bool
Microsoft.CodeAnalysis.Semantics.IIsTypeExpression.IsType.get -> Microsoft.CodeAnalysis.ITypeSymbol
Microsoft.CodeAnalysis.Semantics.IIsTypeExpression.Operand.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.ILabeledStatement
Microsoft.CodeAnalysis.Semantics.ILabeledStatement.Label.get -> Microsoft.CodeAnalysis.ILabelSymbol
......@@ -391,6 +393,8 @@ Microsoft.CodeAnalysis.Semantics.IReturnStatement.ReturnedValue.get -> Microsoft
Microsoft.CodeAnalysis.Semantics.ISimpleAssignmentExpression
Microsoft.CodeAnalysis.Semantics.ISingleValueCaseClause
Microsoft.CodeAnalysis.Semantics.ISingleValueCaseClause.Value.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.ISizeOfExpression
Microsoft.CodeAnalysis.Semantics.ISizeOfExpression.TypeOperand.get -> Microsoft.CodeAnalysis.ITypeSymbol
Microsoft.CodeAnalysis.Semantics.ISwitchCase
Microsoft.CodeAnalysis.Semantics.ISwitchCase.Body.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.IOperation>
Microsoft.CodeAnalysis.Semantics.ISwitchCase.Clauses.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.Semantics.ICaseClause>
......@@ -403,6 +407,8 @@ Microsoft.CodeAnalysis.Semantics.IThrowExpression
Microsoft.CodeAnalysis.Semantics.IThrowExpression.Expression.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.ITupleExpression
Microsoft.CodeAnalysis.Semantics.ITupleExpression.Elements.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.IOperation>
Microsoft.CodeAnalysis.Semantics.ITypeOfExpression
Microsoft.CodeAnalysis.Semantics.ITypeOfExpression.TypeOperand.get -> Microsoft.CodeAnalysis.ITypeSymbol
Microsoft.CodeAnalysis.Semantics.ITypeParameterObjectCreationExpression
Microsoft.CodeAnalysis.Semantics.ITypeParameterObjectCreationExpression.Initializer.get -> Microsoft.CodeAnalysis.Semantics.IObjectOrCollectionInitializerExpression
Microsoft.CodeAnalysis.Semantics.IUnaryOperatorExpression
......@@ -439,9 +445,9 @@ Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind
Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.BitwiseNegation = 1 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind
Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.False = 6 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind
Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.Invalid = 255 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind
Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.Not = 2 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind
Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.Minus = 4 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind
Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.None = 0 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind
Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.Not = 2 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind
Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.Plus = 3 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind
Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.True = 5 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind
Microsoft.CodeAnalysis.SyntaxList<TNode>.SyntaxList(System.Collections.Generic.IEnumerable<TNode> nodes) -> void
......@@ -546,10 +552,12 @@ virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitRelationalCaseCla
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitReturnStatement(Microsoft.CodeAnalysis.Semantics.IReturnStatement operation) -> void
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitSimpleAssignmentExpression(Microsoft.CodeAnalysis.Semantics.ISimpleAssignmentExpression operation) -> void
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitSingleValueCaseClause(Microsoft.CodeAnalysis.Semantics.ISingleValueCaseClause operation) -> void
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitSizeOfExpression(Microsoft.CodeAnalysis.Semantics.ISizeOfExpression operation) -> void
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitSwitchCase(Microsoft.CodeAnalysis.Semantics.ISwitchCase operation) -> void
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitSwitchStatement(Microsoft.CodeAnalysis.Semantics.ISwitchStatement operation) -> void
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitThrowExpression(Microsoft.CodeAnalysis.Semantics.IThrowExpression operation) -> void
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitTupleExpression(Microsoft.CodeAnalysis.Semantics.ITupleExpression operation) -> void
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitTypeOfExpression(Microsoft.CodeAnalysis.Semantics.ITypeOfExpression operation) -> void
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitTypeParameterObjectCreationExpression(Microsoft.CodeAnalysis.Semantics.ITypeParameterObjectCreationExpression operation) -> void
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitUnaryOperatorExpression(Microsoft.CodeAnalysis.Semantics.IUnaryOperatorExpression operation) -> void
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitUsingStatement(Microsoft.CodeAnalysis.Semantics.IUsingStatement operation) -> void
......@@ -626,10 +634,12 @@ virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.Vi
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitReturnStatement(Microsoft.CodeAnalysis.Semantics.IReturnStatement operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitSimpleAssignmentExpression(Microsoft.CodeAnalysis.Semantics.ISimpleAssignmentExpression operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitSingleValueCaseClause(Microsoft.CodeAnalysis.Semantics.ISingleValueCaseClause operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitSizeOfExpression(Microsoft.CodeAnalysis.Semantics.ISizeOfExpression operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitSwitchCase(Microsoft.CodeAnalysis.Semantics.ISwitchCase operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitSwitchStatement(Microsoft.CodeAnalysis.Semantics.ISwitchStatement operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitThrowExpression(Microsoft.CodeAnalysis.Semantics.IThrowExpression operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitTupleExpression(Microsoft.CodeAnalysis.Semantics.ITupleExpression operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitTypeOfExpression(Microsoft.CodeAnalysis.Semantics.ITypeOfExpression operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitTypeParameterObjectCreationExpression(Microsoft.CodeAnalysis.Semantics.ITypeParameterObjectCreationExpression operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitUnaryOperatorExpression(Microsoft.CodeAnalysis.Semantics.IUnaryOperatorExpression operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitUsingStatement(Microsoft.CodeAnalysis.Semantics.IUsingStatement operation, TArgument argument) -> TResult
......
......@@ -976,7 +976,7 @@ public override void VisitIsTypeExpression(IIsTypeExpression operation)
Unindent();
}
internal override void VisitSizeOfExpression(ISizeOfExpression operation)
public override void VisitSizeOfExpression(ISizeOfExpression operation)
{
LogString(nameof(ISizeOfExpression));
LogCommonPropertiesAndNewLine(operation);
......@@ -987,7 +987,7 @@ internal override void VisitSizeOfExpression(ISizeOfExpression operation)
Unindent();
}
internal override void VisitTypeOfExpression(ITypeOfExpression operation)
public override void VisitTypeOfExpression(ITypeOfExpression operation)
{
LogString(nameof(ITypeOfExpression));
LogCommonPropertiesAndNewLine(operation);
......
......@@ -393,14 +393,14 @@ public override void VisitIsTypeExpression(IIsTypeExpression operation)
base.VisitIsTypeExpression(operation);
}
internal override void VisitSizeOfExpression(ISizeOfExpression operation)
public override void VisitSizeOfExpression(ISizeOfExpression operation)
{
var typeOperand = operation.TypeOperand;
base.VisitSizeOfExpression(operation);
}
internal override void VisitTypeOfExpression(ITypeOfExpression operation)
public override void VisitTypeOfExpression(ITypeOfExpression operation)
{
var typeOperand = operation.TypeOperand;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册