├── .gitattributes
├── .gitignore
├── .travis.yml
├── COPYING
├── ICSharpCode.NRefactory.CSharp
├── Analysis
│ ├── ControlFlow.cs
│ ├── DefiniteAssignmentAnalysis.cs
│ └── ReachabilityAnalysis.cs
├── Ast
│ ├── AstNode.cs
│ ├── AstNodeCollection.cs
│ ├── AstType.cs
│ ├── CSharpModifierToken.cs
│ ├── CSharpTokenNode.cs
│ ├── ComposedType.cs
│ ├── DepthFirstAstVisitor.cs
│ ├── DocumentationReference.cs
│ ├── ErrorNode.cs
│ ├── Expressions
│ │ ├── AnonymousMethodExpression.cs
│ │ ├── AnonymousTypeCreateExpression.cs
│ │ ├── ArrayCreateExpression.cs
│ │ ├── ArrayInitializerExpression.cs
│ │ ├── AsExpression.cs
│ │ ├── AssignmentExpression.cs
│ │ ├── BaseReferenceExpression.cs
│ │ ├── BinaryOperatorExpression.cs
│ │ ├── CastExpression.cs
│ │ ├── CheckedExpression.cs
│ │ ├── ConditionalExpression.cs
│ │ ├── DefaultValueExpression.cs
│ │ ├── DirectionExpression.cs
│ │ ├── ErrorExpression.cs
│ │ ├── Expression.cs
│ │ ├── IdentifierExpression.cs
│ │ ├── IndexerExpression.cs
│ │ ├── InvocationExpression.cs
│ │ ├── IsExpression.cs
│ │ ├── LambdaExpression.cs
│ │ ├── MemberReferenceExpression.cs
│ │ ├── NamedArgumentExpression.cs
│ │ ├── NamedExpression.cs
│ │ ├── NullReferenceExpression.cs
│ │ ├── ObjectCreateExpression.cs
│ │ ├── ParenthesizedExpression.cs
│ │ ├── PointerReferenceExpression.cs
│ │ ├── PrimitiveExpression.cs
│ │ ├── QueryExpression.cs
│ │ ├── SizeOfExpression.cs
│ │ ├── StackAllocExpression.cs
│ │ ├── ThisReferenceExpression.cs
│ │ ├── TypeOfExpression.cs
│ │ ├── TypeReferenceExpression.cs
│ │ ├── UnaryOperatorExpression.cs
│ │ ├── UncheckedExpression.cs
│ │ └── UndocumentedExpression.cs
│ ├── GeneralScope
│ │ ├── Attribute.cs
│ │ ├── AttributeSection.cs
│ │ ├── Comment.cs
│ │ ├── Constraint.cs
│ │ ├── DelegateDeclaration.cs
│ │ ├── ExternAliasDeclaration.cs
│ │ ├── NamespaceDeclaration.cs
│ │ ├── NewLineNode.cs
│ │ ├── PreProcessorDirective.cs
│ │ ├── TextNode.cs
│ │ ├── TypeDeclaration.cs
│ │ ├── TypeParameterDeclaration.cs
│ │ ├── UsingAliasDeclaration.cs
│ │ ├── UsingDeclaration.cs
│ │ └── WhitespaceNode.cs
│ ├── IAstVisitor.cs
│ ├── Identifier.cs
│ ├── IdentifierExpressionBackreference.cs
│ ├── MemberType.cs
│ ├── Modifiers.cs
│ ├── NodeType.cs
│ ├── PrimitiveType.cs
│ ├── Roles.cs
│ ├── SimpleType.cs
│ ├── Statements
│ │ ├── BlockStatement.cs
│ │ ├── BreakStatement.cs
│ │ ├── CheckedStatement.cs
│ │ ├── ContinueStatement.cs
│ │ ├── DoWhileStatement.cs
│ │ ├── EmptyStatement.cs
│ │ ├── ExpressionStatement.cs
│ │ ├── FixedStatement.cs
│ │ ├── ForStatement.cs
│ │ ├── ForeachStatement.cs
│ │ ├── GotoStatement.cs
│ │ ├── IfElseStatement.cs
│ │ ├── LabelStatement.cs
│ │ ├── LockStatement.cs
│ │ ├── ReturnStatement.cs
│ │ ├── Statement.cs
│ │ ├── SwitchStatement.cs
│ │ ├── ThrowStatement.cs
│ │ ├── TryCatchStatement.cs
│ │ ├── UncheckedStatement.cs
│ │ ├── UnsafeStatement.cs
│ │ ├── UsingStatement.cs
│ │ ├── VariableDeclarationStatement.cs
│ │ ├── WhileStatement.cs
│ │ ├── YieldBreakStatement.cs
│ │ └── YieldReturnStatement.cs
│ ├── SyntaxExtensions.cs
│ ├── SyntaxTree.cs
│ ├── TokenRole.cs
│ └── TypeMembers
│ │ ├── Accessor.cs
│ │ ├── ConstructorDeclaration.cs
│ │ ├── DestructorDeclaration.cs
│ │ ├── EntityDeclaration.cs
│ │ ├── EnumMemberDeclaration.cs
│ │ ├── EventDeclaration.cs
│ │ ├── FieldDeclaration.cs
│ │ ├── FixedFieldDeclaration.cs
│ │ ├── FixedVariableInitializer.cs
│ │ ├── IndexerDeclaration.cs
│ │ ├── MethodDeclaration.cs
│ │ ├── OperatorDeclaration.cs
│ │ ├── ParameterDeclaration.cs
│ │ ├── PropertyDeclaration.cs
│ │ └── VariableInitializer.cs
├── CommentReference.cs
├── Extensions.cs
├── Formatter
│ ├── CSharpFormattingOptions.cs
│ └── FormattingOptionsFactory.cs
├── ICSharpCode.NRefactory.CSharp.csproj
├── NameLookupMode.cs
├── OutputVisitor
│ ├── CSharpOutputVisitor.cs
│ ├── ITokenWriter.cs
│ ├── InsertMissingTokensDecorator.cs
│ ├── InsertParenthesesVisitor.cs
│ ├── InsertRequiredSpacesDecorator.cs
│ ├── InsertSpecialsDecorator.cs
│ └── TextWriterOutputFormatter.cs
├── Parser
│ └── mcs
│ │ └── method.cs
├── PatternMatching
│ └── AnyType.cs
├── Properties
│ └── AssemblyInfo.cs
├── Resolver
│ ├── AliasNamespaceResolveResult.cs
│ ├── AliasTypeResolveResult.cs
│ ├── AwaitResolveResult.cs
│ ├── CSharpAstResolver.cs
│ ├── CSharpConversions.cs
│ ├── CSharpInvocationResolveResult.cs
│ ├── CSharpOperators.cs
│ ├── CSharpResolver.cs
│ ├── CastResolveResult.cs
│ ├── CompositeResolveVisitorNavigator.cs
│ ├── DetectSkippableNodesNavigator.cs
│ ├── DynamicInvocationResolveResult.cs
│ ├── DynamicMemberResolveResult.cs
│ ├── FindReferenceSearchScope.cs
│ ├── FindReferencedEntities.cs
│ ├── FindReferences.cs
│ ├── IResolveVisitorNavigator.cs
│ ├── LambdaResolveResult.cs
│ ├── Log.cs
│ ├── MemberLookup.cs
│ ├── MethodGroupResolveResult.cs
│ ├── NodeListResolveVisitorNavigator.cs
│ ├── OverloadResolution.cs
│ ├── OverloadResolutionErrors.cs
│ ├── ReducedExtensionMethod.cs
│ ├── RenameCallbackArguments.cs
│ ├── ResolveAtLocation.cs
│ ├── ResolveVisitor.cs
│ └── TypeInference.cs
└── TypeSystem
│ ├── AliasNamespaceReference.cs
│ ├── AttributeTypeReference.cs
│ ├── CSharpAttribute.cs
│ ├── CSharpDocumentationComment.cs
│ ├── CSharpTypeResolveContext.cs
│ ├── CSharpUnresolvedFile.cs
│ ├── CSharpUnresolvedTypeDefinition.cs
│ ├── ConstantValues.cs
│ ├── MemberTypeOrNamespaceReference.cs
│ ├── MethodTypeParameterWithInheritedConstraints.cs
│ ├── ResolvedUsingScope.cs
│ ├── SimpleTypeOrNamespaceReference.cs
│ ├── TypeOrNamespaceReference.cs
│ ├── TypeSystemConvertVisitor.cs
│ └── UsingScope.cs
├── ICSharpCode.NRefactory.Tests
├── Analysis
│ ├── AbiComparerTests.cs
│ └── SymbolCollectorTests.cs
├── CSharp
│ ├── Analysis
│ │ ├── DeclarationSpace
│ │ │ ├── LocalDeclarationSpaceTests.cs
│ │ │ └── LocalDeclarationSpaceVisitorTests.cs
│ │ ├── DefiniteAssignmentTests.cs
│ │ ├── NullValueAnalysisTests.cs
│ │ └── SemanticHighlightingTests.cs
│ ├── AstStructureTests.cs
│ ├── AstTests.cs
│ ├── CSharpAmbienceTests.cs
│ ├── CSharpOutputVisitorTests.cs
│ ├── CodeActions
│ │ ├── AbstractAndVirtualConversionActionTests.cs
│ │ ├── AddAnotherAccessorTests.cs
│ │ ├── AddArgumentNameTests.cs
│ │ ├── AddBracesActionTests.cs
│ │ ├── AddCatchTypeTests.cs
│ │ ├── AddExceptionDescriptionActionTests.cs
│ │ ├── AddOptionalParameterToInvocationTests.cs
│ │ ├── AddUsing
│ │ │ ├── AddUsingActionAlphabeticalTests.cs
│ │ │ ├── AddUsingActionInsideNamespaceTests.cs
│ │ │ ├── AddUsingActionTests.cs
│ │ │ └── AddUsingRunActionTests.cs
│ │ ├── AutoLinqSumTests.cs
│ │ ├── CS1105ExtensionMethodMustBeDeclaredStaticActionTests.cs
│ │ ├── CS1520MethodMustHaveAReturnTypeTests.cs
│ │ ├── ChangeAccessModifierTests.cs
│ │ ├── CheckIfParameterIsNullTests.cs
│ │ ├── ComputeConstantValueTests.cs
│ │ ├── ContextActionTestBase.cs
│ │ ├── ConvertAnonymousDelegateToLambdaTests.cs
│ │ ├── ConvertAsToCastTests.cs
│ │ ├── ConvertAssignmentToIfActionTests.cs
│ │ ├── ConvertBitwiseFlagComparisonToHasFlagsActionTests.cs
│ │ ├── ConvertCastToAsTests.cs
│ │ ├── ConvertDecToHexTests.cs
│ │ ├── ConvertDoWhileToWhileLoopTests.cs
│ │ ├── ConvertEqualityOperatorToEqualsActionTests.cs
│ │ ├── ConvertEqualsToEqualityOperatorActionTests.cs
│ │ ├── ConvertExplicitToImplicitImplementationTests.cs
│ │ ├── ConvertForToWhileActionTests.cs
│ │ ├── ConvertForeachToForTests.cs
│ │ ├── ConvertHasFlagsToBitwiseFlagComparisonActionTests.cs
│ │ ├── ConvertHexToDecTests.cs
│ │ ├── ConvertIfStatementToConditionalTernaryExpressionActionTests.cs
│ │ ├── ConvertIfStatementToNullCoalescingExpressionActionTests.cs
│ │ ├── ConvertIfStatementToReturnStatementActionTests.cs
│ │ ├── ConvertIfStatementToSwitchStatementActionTests.cs
│ │ ├── ConvertImplicitToExplicittImplementationTests.cs
│ │ ├── ConvertLambdaBodyExpressionToStatementTests.cs
│ │ ├── ConvertLambdaBodyStatementToExpressionTests.cs
│ │ ├── ConvertLamdaToAnonymousDelegateTests.cs
│ │ ├── ConvertMethodGroupToAnonymousMethodActionTests.cs
│ │ ├── ConvertMethodGroupToLambdaActionTests.cs
│ │ ├── ConvertMultiplyToShiftActionTests.cs
│ │ ├── ConvertNullCoalescingToConditionalExpressionActionTests.cs
│ │ ├── ConvertReturnStatementToIfActionTests.cs
│ │ ├── ConvertShiftToMultiplyActionTests.cs
│ │ ├── ConvertSwitchToIfTests.cs
│ │ ├── ConvertToInitializer
│ │ │ ├── ConvertInitializerToExplicitIntializationsTests.cs
│ │ │ └── ConvertToInitializerTests.cs
│ │ ├── ConvertWhileToDoWhileLoopTests.cs
│ │ ├── CopyCommentsFromBaseTests.cs
│ │ ├── CopyCommentsFromIntefaceTests.cs
│ │ ├── CreateBackingStoreTests.cs
│ │ ├── CreateChangedEventTests.cs
│ │ ├── CreateClassDeclarationTests.cs
│ │ ├── CreateConstructorDeclarationTests.cs
│ │ ├── CreateCustomEventImplementationTests.cs
│ │ ├── CreateDelegateTests.cs
│ │ ├── CreateEnumValueTests.cs
│ │ ├── CreateEventInvocatorTests.cs
│ │ ├── CreateFieldTests.cs
│ │ ├── CreateIndexerTests.cs
│ │ ├── CreateLocalVariableTests.cs
│ │ ├── CreateMethodDeclarationTests.cs
│ │ ├── CreateOverloadWithoutParameterTests.cs
│ │ ├── CreatePropertyTests.cs
│ │ ├── DeclareLocalVariableTests.cs
│ │ ├── ExtensionMethodInvocationToStaticMethodInvocationTests.cs
│ │ ├── ExtractAnonymousMethodTests.cs
│ │ ├── ExtractFieldTests.cs
│ │ ├── ExtractMethodTests.cs
│ │ ├── ExtractWhileConditionToInternalIfStatementActionTests.cs
│ │ ├── FlipEqualsTargetAndArgumentActionTests.cs
│ │ ├── FlipOperatorArgumentsTests.cs
│ │ ├── GenerateGetterTests.cs
│ │ ├── GeneratePropertyTests.cs
│ │ ├── GenerateSwitchLabelsTests.cs
│ │ ├── ImplementAbstractMembersTest.cs
│ │ ├── ImplementInterfaceExplicitTests.cs
│ │ ├── ImplementInterfaceTests.cs
│ │ ├── ImplementNotImplementedPropertyTests.cs
│ │ ├── InlineLocalVariableTests.cs
│ │ ├── InsertAnonymousMethodSignatureTests.cs
│ │ ├── IntroduceConstantTests.cs
│ │ ├── IntroduceFormatItemTests.cs
│ │ ├── InvertConditionalOperatorActionTests.cs
│ │ ├── InvertIfAndSimplifyTests.cs
│ │ ├── InvertIfTests.cs
│ │ ├── InvertLogicalExpressionTests.cs
│ │ ├── IterateViaForeachTests.cs
│ │ ├── JoinDeclarationAndAssignmentTests.cs
│ │ ├── JoinStringTests.cs
│ │ ├── LinqFluentToQueryTests.cs
│ │ ├── LinqQueryToFluentTests.cs
│ │ ├── MergeNestedIfTests.cs
│ │ ├── MetaTests.cs
│ │ ├── MoveToOuterScopeTests.cs
│ │ ├── NegateIsExpressionActionTests.cs
│ │ ├── NegateRelationalExpressionTests.cs
│ │ ├── PutInsideUsingTests.cs
│ │ ├── RemoveBackingStoreTests.cs
│ │ ├── RemoveBracesTests.cs
│ │ ├── RemoveFieldRefactoryActionTests.cs
│ │ ├── RemoveRedundantCatchTypeTests.cs
│ │ ├── RemoveRegionTests.cs
│ │ ├── ReplaceAssignmentWithPostfixExpressionActionTests.cs
│ │ ├── ReplaceEmptyStringTests.cs
│ │ ├── ReplaceOperatorAssignmentWithAssignmentActionTests.cs
│ │ ├── ReplacePostfixExpressionWithAssignmentActionTests.cs
│ │ ├── ReplaceWithOperatorAssignmentActionTests.cs
│ │ ├── ReverseDirectionForForLoopTests.cs
│ │ ├── SimplifyIfFlowInLoopsTests.cs
│ │ ├── SimplifyIfFlowTests.cs
│ │ ├── SortUsingsTests.cs
│ │ ├── SplitDeclarationAndAssignmentTests.cs
│ │ ├── SplitDeclarationListTests.cs
│ │ ├── SplitIfActionTests.cs
│ │ ├── SplitStringTests.cs
│ │ ├── TestRefactoringContext.cs
│ │ ├── UseAsAndNullCheckActionTests.cs
│ │ ├── UseExplicitTypeTests.cs
│ │ ├── UseStringFormatTests.cs
│ │ └── UseVarKeywordTests.cs
│ ├── CodeCompletion
│ │ ├── BrowsableAttributeTests.cs
│ │ ├── CodeCompletionAccessibleTests.cs
│ │ ├── CodeCompletionBugTests.cs
│ │ ├── CodeCompletionCSharp3Tests.cs
│ │ ├── CodeCompletionCSharpTests.cs
│ │ ├── CodeCompletionOperatorTests.cs
│ │ ├── CompletionDataList.cs
│ │ ├── DelegateContextTests.cs
│ │ ├── DocumentationContextTests.cs
│ │ ├── EnumContextTests.cs
│ │ ├── FormatItemTests.cs
│ │ ├── GetCurrentParameterIndexTests.cs
│ │ ├── ImportCompletionTests.cs
│ │ ├── KeywordTests.cs
│ │ ├── NameContextTests.cs
│ │ ├── ObjectInitializerTests.cs
│ │ ├── ParameterCompletionTests.cs
│ │ ├── PreProcessorTests.cs
│ │ ├── TestBase.cs
│ │ └── VariableDeclarationStatementTests.cs
│ ├── CodeDomConvertVisitorTests.cs
│ ├── CodeIssues
│ │ ├── AccessToDisposedClosureTests.cs
│ │ ├── AccessToModifiedClosureTests.cs
│ │ ├── AccessToStaticMemberViaDerivedTypeIssueTests.cs
│ │ ├── AdditionalOfTypeIssuesTests.cs
│ │ ├── ArrayCreationCanBeReplacedWithArrayInitializerIssueTests.cs
│ │ ├── AutoAsyncTests.cs
│ │ ├── BaseMemberHasParamsIssueTests.cs
│ │ ├── BaseMethodCallWithDefaultParameterIssueTests.cs
│ │ ├── BaseMethodParameterNameMismatchIssueTests.cs
│ │ ├── BitwiseOperatorOnEnumWithoutFlagsIssueTests.cs
│ │ ├── CS0029InvalidConversionIssueTests.cs
│ │ ├── CS0126ReturnMustBeFollowedByAnyExpressionTestes.cs
│ │ ├── CS0127ReturnMustNotBeFollowedByAnyExpressionTests.cs
│ │ ├── CS0152DuplicateCaseLabelValueIssueTests.cs
│ │ ├── CS0169FieldIsNeverUsedIssueTests.cs
│ │ ├── CS0183ExpressionIsAlwaysOfProvidedTypeIssueTests.cs
│ │ ├── CS0618UsageOfObsoleteMemberIssueTests.cs
│ │ ├── CS0659OverrideEqualsWithoutGetHashCodeTests.cs
│ │ ├── CS0759RedundantPartialMethodIssueTests.cs
│ │ ├── CS1573ParameterHasNoMatchingParamTagIssueTests.cs
│ │ ├── CS1717AssignmentMadeToSameVariableIssueTests.cs
│ │ ├── CS1729TypeHasNoConstructorWithNArgumentsIssueTests.cs
│ │ ├── CallToObjectEqualsViaBaseTests.cs
│ │ ├── CanBeReplacedWithTryCastAndCheckForNullIssueTests.cs
│ │ ├── CastExpressionOfIncompatibleTypeIssueTests.cs
│ │ ├── CheckNamespaceIssueTests.cs
│ │ ├── CompareNonConstrainedGenericWithNullIssueTests.cs
│ │ ├── CompareOfFloatsByEqualityOperatorIssueTests.cs
│ │ ├── ConditionIsAlwaysTrueOrFalseIssueTests.cs
│ │ ├── ConditionalTernaryEqualBranchTests.cs
│ │ ├── ConstantConditionIssueTests.cs
│ │ ├── ConstantNullCoalescingConditionIssueTests.cs
│ │ ├── ConvertClosureToMethodGroupIssueTests.cs
│ │ ├── ConvertConditionalTernaryToNullCoalescingIssueTests.cs
│ │ ├── ConvertIfDoToWhileIssueTests.cs
│ │ ├── ConvertIfStatementToConditionalTernaryExpressionIssueTests.cs
│ │ ├── ConvertIfStatementToNullCoalescingExpressionIssueTests.cs
│ │ ├── ConvertIfStatementToSwitchStatementIssueTests.cs
│ │ ├── ConvertIfToAndExpressionIssueTests.cs
│ │ ├── ConvertIfToOrExpressionIssueTests.cs
│ │ ├── ConvertNullableToShortFormIssueTests.cs
│ │ ├── ConvertTailRecursiveCallToLoopIssueTests.cs
│ │ ├── ConvertToAutoPropertyIssueTests.cs
│ │ ├── ConvertToConstantIssueTests.cs
│ │ ├── ConvertToLambdaExpressionIssueTests.cs
│ │ ├── ConvertToStaticTypeTests.cs
│ │ ├── DelegateSubtractionIssueTests.cs
│ │ ├── DisposeMethodInNonIDisposableTypeTests.cs
│ │ ├── DoNotCallOverridableMethodsInConstructorIssueTests.cs
│ │ ├── DontUseLinqWhenItsVerboseAndInefficientTests.cs
│ │ ├── DoubleNegationOperatorIssueTests.cs
│ │ ├── DuplicateBodyMethodIssueTests.cs
│ │ ├── DuplicateExpressionsInConditionsIssueTests.cs
│ │ ├── DuplicateIfInIfChainIssueTests.cs
│ │ ├── DuplicatedLinqToListOrArrayTests.cs
│ │ ├── EmptyConstructorIssueTests.cs
│ │ ├── EmptyDestructorTests.cs
│ │ ├── EmptyEmbeddedStatementIssueTests.cs
│ │ ├── EmptyGeneralCatchClauseTests.cs
│ │ ├── EmptyNamespaceTests.cs
│ │ ├── EmptyStatementIssueTests.cs
│ │ ├── EnumUnderlyingTypeIsIntTests.cs
│ │ ├── EqualExpressionComparisonIssueTests.cs
│ │ ├── EventUnsubscriptionViaAnonymousDelegateIssueTests.cs
│ │ ├── ExceptionRethrowTests.cs
│ │ ├── ExplicitConversionInForEachIssueTests.cs
│ │ ├── ExpressionIsNeverOfProvidedTypeIssueTests.cs
│ │ ├── FieldCanBeMadeReadOnlyIssueTests.cs
│ │ ├── ForCanBeConvertedToForeachIssueTests.cs
│ │ ├── ForControlVariableIsNeverModifiedIssueTests.cs
│ │ ├── ForStatementConditionIsTrueTests.cs
│ │ ├── FormatStringProblemIssueTests.cs
│ │ ├── FunctionNeverReturnsIssueTests.cs
│ │ ├── InconsistentNamingTests.cs
│ │ ├── IncorrectCallToGetHashCodeTests.cs
│ │ ├── InspectionActionTestBase.cs
│ │ ├── InvokeAsExtensionMethodIssueTests.cs
│ │ ├── LocalVariableHidesMemberIssueTests.cs
│ │ ├── LocalVariableNotUsedIssueTests.cs
│ │ ├── LockThisTests.cs
│ │ ├── LongLiteralEndingLowerLIssueTests.cs
│ │ ├── LoopCanBeConvertedToQueryIssueTests.cs
│ │ ├── MemberCanBeMadeStaticIssueTests.cs
│ │ ├── MemberHidesStaticFromOuterClassIssueTests.cs
│ │ ├── MethodOverloadWithOptionalParameterIssueTests.cs
│ │ ├── MissingInterfaceMemberImplementationIssueTests.cs
│ │ ├── NegativeRelationalExpressionIssueTests.cs
│ │ ├── NonPublicMethodWithTestAttributeIssueTests.cs
│ │ ├── NonReadonlyReferencedInGetHashCodeTests.cs
│ │ ├── NonReadonlyReferencedInGetHashCodeTetsts.cs
│ │ ├── NotImplementedExceptionInspectorTests.cs
│ │ ├── NotResolvedInTextIssueTests.cs
│ │ ├── ObjectCreationAsStatementIssueTests.cs
│ │ ├── OperatorIsCanBeUsedIssueTests.cs
│ │ ├── OptionalParameterHierarchyMismatchIssueTests.cs
│ │ ├── OptionalParameterRefOutIssueTests.cs
│ │ ├── ParameterCanBeDemotedIssue
│ │ │ ├── IsTypeCriterionTests.cs
│ │ │ ├── ParameterCanBeDeclaredWithBaseTypeIssueTests.cs
│ │ │ ├── ParameterCanBeIEnumerableTests.cs
│ │ │ └── SupportsIndexingCriterionTests.cs
│ │ ├── ParameterHidesMemberIssueTests.cs
│ │ ├── ParameterOnlyAssignedIssueTests.cs
│ │ ├── PartOfBodyCanBeConvertedToQueryIssueTests.cs
│ │ ├── PartialMethodParameterNameMismatchIssueTests.cs
│ │ ├── PartialTypeWithSinglePartIssueTests.cs
│ │ ├── PolymorphicFieldLikeEventInvocationIssueTests.cs
│ │ ├── PossibleAssignmentToReadonlyFieldIssueTests.cs
│ │ ├── PossibleMistakenCallToGetTypeIssueTests.cs
│ │ ├── PossibleMultipleEnumerationIssueTests.cs
│ │ ├── ProhibitedModifiersIssueTests.cs
│ │ ├── PublicConstructorInAbstractClassIssueTest.cs
│ │ ├── RedundantAnonymousTypePropertyNameIssueTests.cs
│ │ ├── RedundantArgumentDefaultValueIssueTests.cs
│ │ ├── RedundantArgumentNameTests.cs
│ │ ├── RedundantAssignmentIssueTests.cs
│ │ ├── RedundantAttributeParenthesesIssueTests.cs
│ │ ├── RedundantBaseConstructorIssueTests.cs
│ │ ├── RedundantBaseQualifierTests.cs
│ │ ├── RedundantBlockInDifferentBranchesTests.cs
│ │ ├── RedundantBoolCompareIssueTests.cs
│ │ ├── RedundantCaseLabelIssueTests.cs
│ │ ├── RedundantCastIssueTests.cs
│ │ ├── RedundantCatchClauseIssueTests.cs
│ │ ├── RedundantCheckBeforeAssignmentTests.cs
│ │ ├── RedundantCommaInArrayInitializerIssueTests.cs
│ │ ├── RedundantComparisonWithNullIssueTests.cs
│ │ ├── RedundantDefaultFieldInitializerIssueTests.cs
│ │ ├── RedundantDelegateCreationIssueTests.cs
│ │ ├── RedundantEmptyDefaultSwitchBranchIssueTests.cs
│ │ ├── RedundantEmptyFinallyBlockIssueTests.cs
│ │ ├── RedundantEnumerableCastCallIssueTests.cs
│ │ ├── RedundantExplicitArrayCreationIssueTests.cs
│ │ ├── RedundantExplicitArraySizeIssueTests.cs
│ │ ├── RedundantExplicitNullableCreationIssueTests.cs
│ │ ├── RedundantExtendsListEntryIssueTests.cs
│ │ ├── RedundantIfElseBlockIssueTests.cs
│ │ ├── RedundantInternalInspectorTests.cs
│ │ ├── RedundantLambdaParameterTypeTests.cs
│ │ ├── RedundantLambdaSignatureParenthesesIssueTests.cs
│ │ ├── RedundantLogicalConditionalExpressionOperandIssueTests.cs
│ │ ├── RedundantNameQualifierIssueTests.cs
│ │ ├── RedundantNotNullAttributeInNonNullableTypeTests.cs
│ │ ├── RedundantObjectCreationArgumentListIssueTests.cs
│ │ ├── RedundantObjectOrCollectionInitializerIssueTests.cs
│ │ ├── RedundantOverridenMemberTests.cs
│ │ ├── RedundantParamsIssueTests.cs
│ │ ├── RedundantPrivateInspectorTests.cs
│ │ ├── RedundantStringToCharArrayCallIssueTests.cs
│ │ ├── RedundantTernaryExpressionIssueTests.cs
│ │ ├── RedundantThisQualifierIssueTests.cs
│ │ ├── RedundantToStringCallForValueTypesIssue.cs
│ │ ├── RedundantToStringCallIssueTests.cs
│ │ ├── RedundantTypeArgumentsOfMethodIssueTests.cs
│ │ ├── RedundantUnsafeContextIssueTests.cs
│ │ ├── RedundantUsingDirectiveIssueTests.cs
│ │ ├── RedundantWhereWithPredicateIssueTests.cs
│ │ ├── ReferenceEqualsWithValueTypeIssueTests.cs
│ │ ├── RemoveRedundantOrStatementIssueTests.cs
│ │ ├── ReplaceWithFirstOrDefaultIssueTests.cs
│ │ ├── ReplaceWithLastOrDefaultIssueTests.cs
│ │ ├── ReplaceWithOfTypeAnyIssueTests.cs
│ │ ├── ReplaceWithOfTypeCountIssueTests.cs
│ │ ├── ReplaceWithOfTypeFirstIssueTests.cs
│ │ ├── ReplaceWithOfTypeFirstOrDefaultIssueTests.cs
│ │ ├── ReplaceWithOfTypeIssueTests.cs
│ │ ├── ReplaceWithOfTypeLastIssueTests.cs
│ │ ├── ReplaceWithOfTypeLastOrDefaultIssueTests.cs
│ │ ├── ReplaceWithOfTypeLongCountIssueTests.cs
│ │ ├── ReplaceWithOfTypeSingleIssueTests.cs
│ │ ├── ReplaceWithOfTypeSingleOrDefaultIssueTests.cs
│ │ ├── ReplaceWithOfTypeWhereIssueTests.cs
│ │ ├── ReplaceWithSimpleAssignmentIssueTests.cs
│ │ ├── ReplaceWithSingleCallToAverageIssueTests.cs
│ │ ├── ReplaceWithSingleCallToCountIssueTests.cs
│ │ ├── ReplaceWithSingleCallToFirstIssueTests.cs
│ │ ├── ReplaceWithSingleCallToFirstOrDefaultIssueTests.cs
│ │ ├── ReplaceWithSingleCallToLastIssueTests.cs
│ │ ├── ReplaceWithSingleCallToLastOrDefaultIssueTests.cs
│ │ ├── ReplaceWithSingleCallToLongCountIssueTests.cs
│ │ ├── ReplaceWithSingleCallToMaxIssueTests.cs
│ │ ├── ReplaceWithSingleCallToMinIssueTests.cs
│ │ ├── ReplaceWithSingleCallToSingleIssueTests.cs
│ │ ├── ReplaceWithSingleCallToSingleOrDefaultIssueTests.cs
│ │ ├── ReplaceWithSingleCallToSumIssueTests.cs
│ │ ├── ReplaceWithStringIsNullOrEmptyIssueTests.cs
│ │ ├── RewriteIfReturnToReturnIssueTests.cs
│ │ ├── SameGuardConditionExpressionInIfElseBranchesTests.cs
│ │ ├── SealedMemberInSealedClassIssueTests.cs
│ │ ├── SimplifyConditionalTernaryExpressionIssueTests.cs
│ │ ├── SimplifyLinqExpressionIssueTests.cs
│ │ ├── StaticConstructorParameterIssueTests.cs
│ │ ├── StaticEventSubscriptionIssueTests.cs
│ │ ├── StaticFieldInGenericTypeTests.cs
│ │ ├── StringCompareIsCultureSpecificIssueTests.cs
│ │ ├── StringCompareToIsCultureSpecificIssueTests.cs
│ │ ├── StringEndsWithIsCultureSpecificIssueTest.cs
│ │ ├── StringIndexOfIsCultureSpecificIssueTest.cs
│ │ ├── StringLastIndexOfIsCultureSpecificIssueTest.cs
│ │ ├── StringStartsWithIsCultureSpecificIssueTest.cs
│ │ ├── SuggestUseVarKeywordEvidentTests.cs
│ │ ├── ThreadStaticAtInstanceFieldTests.cs
│ │ ├── UnassignedReadonlyFieldIssueTests.cs
│ │ ├── UnmatchedSizeSpeicificationInArrayCreationTests.cs
│ │ ├── UnreachableCodeIssueTests.cs
│ │ ├── UnusedAnonymousMethodSignatureIssueTests.cs
│ │ ├── UnusedLabelIssueTests.cs
│ │ ├── UnusedParameterIssueTests.cs
│ │ ├── UnusedTypeParameterIssueTests.cs
│ │ ├── UseArrayCreationExpressionIssueTests.cs
│ │ ├── UseIsOperatorIssueTests.cs
│ │ ├── UseMethodAnyIssueTests.cs
│ │ ├── UseMethodIsInstanceOfTypeIssueTests.cs
│ │ ├── UseOfMemberOfNullReferenceTests.cs
│ │ ├── ValueParameterNotUsedIssueTests.cs
│ │ ├── VariableDeclaredInWideScopeTests.cs
│ │ └── XmlDocIssueIssueTests.cs
│ ├── DepthFirstVisitorTests.cs
│ ├── InsertMissingTokensDecoratorTests.cs
│ ├── InsertParenthesesVisitorTests.cs
│ ├── Inspector
│ │ └── InconsistentNamingIssueTests.cs
│ ├── Parser
│ │ ├── Bugs
│ │ │ └── ParserBugTests.cs
│ │ ├── ConsistencyChecker.cs
│ │ ├── Expression
│ │ │ ├── AnonymousMethodExpressionTests.cs
│ │ │ ├── AnonymousTypeCreateExpressionTests.cs
│ │ │ ├── ArrayCreateExpressionTests.cs
│ │ │ ├── AssignmentExpressionTests.cs
│ │ │ ├── BaseReferenceExpressionTests.cs
│ │ │ ├── BinaryOperatorExpressionTests.cs
│ │ │ ├── CastExpressionTests.cs
│ │ │ ├── CheckedExpressionTests.cs
│ │ │ ├── ConditionalExpressionTests.cs
│ │ │ ├── DefaultValueExpressionTests.cs
│ │ │ ├── IdentifierExpressionTests.cs
│ │ │ ├── IndexerExpressionTests.cs
│ │ │ ├── InvocationExpressionTests.cs
│ │ │ ├── IsExpressionTests.cs
│ │ │ ├── LambdaExpressionTests.cs
│ │ │ ├── MemberReferenceExpressionTests.cs
│ │ │ ├── ObjectCreateExpressionTests.cs
│ │ │ ├── ParenthesizedExpressionTests.cs
│ │ │ ├── PointerReferenceExpressionTests.cs
│ │ │ ├── PrimitiveExpressionTests.cs
│ │ │ ├── QueryExpressionTests.cs
│ │ │ ├── SizeOfExpressionTests.cs
│ │ │ ├── StackAllocExpressionTests.cs
│ │ │ ├── ThisReferenceExpressionTests.cs
│ │ │ ├── TypeOfExpressionTests.cs
│ │ │ ├── TypeReferenceExpressionTests.cs
│ │ │ ├── UnaryOperatorExpressionTests.cs
│ │ │ └── UndocumentedExpressionTests.cs
│ │ ├── GeneralScope
│ │ │ ├── AttributeSectionTests.cs
│ │ │ ├── CommentTests.cs
│ │ │ ├── DelegateDeclarationTests.cs
│ │ │ ├── NamespaceDeclarationTests.cs
│ │ │ ├── PreprocessorDirectiveTests.cs
│ │ │ ├── TypeDeclarationTests.cs
│ │ │ └── UsingDeclarationTests.cs
│ │ ├── ParseSelfTests.cs
│ │ ├── ParseUtil.cs
│ │ ├── Statements
│ │ │ ├── BlockStatementTests.cs
│ │ │ ├── CheckedStatementTests.cs
│ │ │ ├── EmptyStatementTests.cs
│ │ │ ├── ExpressionStatementTests.cs
│ │ │ ├── FixedStatementTests.cs
│ │ │ ├── ForStatementTests.cs
│ │ │ ├── GotoStatementTests.cs
│ │ │ ├── IfElseStatementTests.cs
│ │ │ ├── InvalidStatementsTests.cs
│ │ │ ├── LabelStatementTests.cs
│ │ │ ├── LockStatementTests.cs
│ │ │ ├── ReturnStatementTests.cs
│ │ │ ├── SwitchStatementTests.cs
│ │ │ ├── ThrowStatementTests.cs
│ │ │ ├── TryCatchStatementTests.cs
│ │ │ ├── UnsafeStatementTests.cs
│ │ │ ├── UsingStatementTests.cs
│ │ │ ├── VariableDeclarationStatementTests.cs
│ │ │ ├── WhileStatementTests.cs
│ │ │ └── YieldStatementTests.cs
│ │ ├── TypeMembers
│ │ │ ├── ConstructorDeclarationTests.cs
│ │ │ ├── DestructorDeclarationTests.cs
│ │ │ ├── EventDeclarationTests.cs
│ │ │ ├── FieldDeclarationTests.cs
│ │ │ ├── IndexerDeclarationTests.cs
│ │ │ ├── MethodDeclarationTests.cs
│ │ │ ├── OperatorDeclarationTests.cs
│ │ │ └── PropertyDeclarationTests.cs
│ │ └── TypeSystemConvertVisitorTests.cs
│ ├── QueryExpressionExpanderTests.cs
│ ├── Refactoring
│ │ ├── LambdaHelperTests.cs
│ │ ├── NamingHelperTests.cs
│ │ ├── RefactoringStructureTests.cs
│ │ ├── ScriptTests.cs
│ │ └── TypeSystemAstBuilderTests.cs
│ └── Resolver
│ │ ├── AnonymousTypeTests.cs
│ │ ├── ArrayCreateTests.cs
│ │ ├── AttributeTests.cs
│ │ ├── BinaryOperatorTests.cs
│ │ ├── CastTests.cs
│ │ ├── ComTests.cs
│ │ ├── ConditionalOperatorTests.cs
│ │ ├── ConversionsTest.cs
│ │ ├── DynamicTests.cs
│ │ ├── ExplicitConversionsTest.cs
│ │ ├── ExtensionMethodTests.cs
│ │ ├── FindReferencesTest.cs
│ │ ├── InvocationTests.cs
│ │ ├── LambdaTests.cs
│ │ ├── LinqTests.cs
│ │ ├── LocalTypeInferenceTests.cs
│ │ ├── MemberLookupTests.cs
│ │ ├── MethodTests.cs
│ │ ├── NameLookupTests.cs
│ │ ├── ObjectCreationTests.cs
│ │ ├── OverloadResolutionTests.cs
│ │ ├── ResolveAtLocationTests.cs
│ │ ├── ResolverTestBase.cs
│ │ ├── SizeOfTests.cs
│ │ ├── TypeInferenceTests.cs
│ │ ├── UnaryOperatorTests.cs
│ │ └── UnsafeCodeTests.cs
├── Documentation
│ ├── CSharpCrefLookupTests.cs
│ ├── CSharpCrefParserTests.cs
│ ├── CSharpDocumentationTests.cs
│ └── IDStringTests.cs
├── Editor
│ └── ReadOnlyDocumentTests.cs
├── FormattingTests
│ ├── ConstructFixerTests.cs
│ ├── TestBlankLineFormatting.cs
│ ├── TestBraceStlye.cs
│ ├── TestExpressionFormatting.cs
│ ├── TestFormattingBugs.cs
│ ├── TestGlobalLevelFormatting.cs
│ ├── TestKeepReformattingRules.cs
│ ├── TestLinq.cs
│ ├── TestSpacingVisitor.cs
│ ├── TestStatementIndentation.cs
│ ├── TestTypeLevelIndentation.cs
│ ├── TestWrapping.cs
│ └── TextEditorTestAdapter.cs
├── ICSharpCode.NRefactory.Tests.csproj
├── IndentationTests
│ ├── AlignmentTests.cs
│ ├── AllInOneTests.cs
│ ├── BlockTest.cs
│ ├── CommentTests.cs
│ ├── GeneralTests.cs
│ ├── Helper.cs
│ ├── PreProcessorTests.cs
│ ├── StringTests.cs
│ ├── TestFiles
│ │ ├── CSharpParser.cs
│ │ ├── Comments.cs
│ │ ├── IndentEngine.cs
│ │ ├── IndentState.cs
│ │ ├── InheritStatements.cs
│ │ ├── PreProcessorDirectives.cs
│ │ ├── Simple.cs
│ │ ├── Strings.cs
│ │ ├── SwitchCase.cs
│ │ └── TextArea.cs
│ └── TextPasteIndentEngineTests.cs
├── Properties
│ └── AssemblyInfo.cs
├── TypeSystem
│ ├── BinaryLoaderTests.cs
│ ├── BlobLoaderTests.cs
│ ├── CecilLoaderTests.cs
│ ├── CyclicProjectDependency.cs
│ ├── GetAllBaseTypesTest.cs
│ ├── GetMembersTests.cs
│ ├── IkvmLoaderTests.cs
│ ├── InheritanceHelperTests.cs
│ ├── LazyLoadedCecilLoaderTests.cs
│ ├── ReflectionHelperTests.cs
│ ├── SerializedCecilLoaderTests.cs
│ ├── SerializedIkvmLoaderTests.cs
│ ├── StructureTests.cs
│ ├── TestInterningProvider.cs
│ ├── TypeParameterTests.cs
│ ├── TypeSystemHelper.cs
│ ├── TypeSystemTests.TestCase.cs
│ └── TypeSystemTests.cs
├── Utils
│ ├── CSharpPrimitiveCastTests.cs
│ ├── CompositeFormatStringParser
│ │ └── CompositeFormatStringParserTests.cs
│ └── TreeTraversalTests.cs
└── packages.config
├── ICSharpCode.NRefactory.snk
├── ICSharpCode.NRefactory
├── Documentation
│ ├── DocumentationComment.cs
│ ├── GetPotentiallyNestedClassTypeReference.cs
│ ├── IDocumentationProvider.cs
│ ├── IdStringMemberReference.cs
│ ├── IdStringProvider.cs
│ └── XmlDocumentationProvider.cs
├── Editor
│ └── UnicodeNewline.cs
├── IAnnotatable.cs
├── ICSharpCode.NRefactory.csproj
├── NumberFormatter.cs
├── PatternMatching
│ ├── AnyNode.cs
│ ├── AnyNodeOrNull.cs
│ ├── Backreference.cs
│ ├── BacktrackingInfo.cs
│ ├── Choice.cs
│ ├── INode.cs
│ ├── Match.cs
│ ├── NamedNode.cs
│ ├── OptionalNode.cs
│ ├── Pattern.cs
│ └── Repeat.cs
├── Properties
│ ├── AssemblyInfo.cs
│ └── GlobalAssemblyInfo.cs
├── Role.cs
├── Semantics
│ ├── AmbiguousResolveResult.cs
│ ├── ArrayAccessResolveResult.cs
│ ├── ArrayCreateResolveResult.cs
│ ├── ByReferenceResolveResult.cs
│ ├── ConstantResolveResult.cs
│ ├── Conversion.cs
│ ├── ConversionResolveResult.cs
│ ├── ErrorResolveResult.cs
│ ├── ForEachResolveResult.cs
│ ├── InitializedObjectResolveResult.cs
│ ├── InvocationResolveResult.cs
│ ├── LocalResolveResult.cs
│ ├── MemberResolveResult.cs
│ ├── NamedArgumentResolveResult.cs
│ ├── NamespaceResolveResult.cs
│ ├── OperatorResolveResult.cs
│ ├── ResolveResult.cs
│ ├── SizeOfResolveResult.cs
│ ├── ThisResolveResult.cs
│ ├── TypeIsResolveResult.cs
│ ├── TypeOfResolveResult.cs
│ ├── TypeResolveResult.cs
│ └── UnknownMemberResolveResult.cs
├── TextLocation.cs
├── TypeSystem
│ ├── Accessibility.cs
│ ├── AnonymousType.cs
│ ├── ArrayType.cs
│ ├── AssemblyLoader.cs
│ ├── AssemblyQualifiedTypeName.cs
│ ├── ByReferenceType.cs
│ ├── ComHelper.cs
│ ├── DefaultSolutionSnapshot.cs
│ ├── DomRegion.cs
│ ├── EntityType.cs
│ ├── Error.cs
│ ├── FullTypeName.cs
│ ├── IAmbience.cs
│ ├── IAssembly.cs
│ ├── IAttribute.cs
│ ├── ICodeContext.cs
│ ├── ICompilation.cs
│ ├── IConstantValue.cs
│ ├── IEntity.cs
│ ├── IEvent.cs
│ ├── IField.cs
│ ├── IFreezable.cs
│ ├── IInterningProvider.cs
│ ├── IMember.cs
│ ├── IMethod.cs
│ ├── INamedElement.cs
│ ├── INamespace.cs
│ ├── IParameter.cs
│ ├── IParameterizedMember.cs
│ ├── IProjectContent.cs
│ ├── IProperty.cs
│ ├── ISolutionSnapshot.cs
│ ├── ISupportsInterning.cs
│ ├── ISymbol.cs
│ ├── IType.cs
│ ├── ITypeDefinition.cs
│ ├── ITypeParameter.cs
│ ├── ITypeReference.cs
│ ├── IUnresolvedFile.cs
│ ├── IVariable.cs
│ ├── Implementation
│ │ ├── AbstractFreezable.cs
│ │ ├── AbstractResolvedEntity.cs
│ │ ├── AbstractResolvedMember.cs
│ │ ├── AbstractResolvedTypeParameter.cs
│ │ ├── AbstractType.cs
│ │ ├── AbstractUnresolvedEntity.cs
│ │ ├── AbstractUnresolvedMember.cs
│ │ ├── AccessorOwnerMemberReference.cs
│ │ ├── BaseTypeCollector.cs
│ │ ├── BlobReader.cs
│ │ ├── DefaultAssemblyReference.cs
│ │ ├── DefaultAttribute.cs
│ │ ├── DefaultMemberReference.cs
│ │ ├── DefaultParameter.cs
│ │ ├── DefaultResolvedEvent.cs
│ │ ├── DefaultResolvedField.cs
│ │ ├── DefaultResolvedMethod.cs
│ │ ├── DefaultResolvedProperty.cs
│ │ ├── DefaultResolvedTypeDefinition.cs
│ │ ├── DefaultResolvedTypeParameter.cs
│ │ ├── DefaultUnresolvedAssembly.cs
│ │ ├── DefaultUnresolvedAttribute.cs
│ │ ├── DefaultUnresolvedEvent.cs
│ │ ├── DefaultUnresolvedField.cs
│ │ ├── DefaultUnresolvedMethod.cs
│ │ ├── DefaultUnresolvedParameter.cs
│ │ ├── DefaultUnresolvedProperty.cs
│ │ ├── DefaultUnresolvedTypeDefinition.cs
│ │ ├── DefaultUnresolvedTypeParameter.cs
│ │ ├── DefaultVariable.cs
│ │ ├── DummyTypeParameter.cs
│ │ ├── ExplicitInterfaceImplementationMemberReference.cs
│ │ ├── FullNameAndTypeParameterCount.cs
│ │ ├── GetClassTypeReference.cs
│ │ ├── GetMembersHelper.cs
│ │ ├── KnownTypeCache.cs
│ │ ├── MergedNamespace.cs
│ │ ├── MinimalCorlib.cs
│ │ ├── NestedTypeReference.cs
│ │ ├── ResolvedAttributeBlob.cs
│ │ ├── SimpleCompilation.cs
│ │ ├── SimpleConstantValue.cs
│ │ ├── SimpleInterningProvider.cs
│ │ ├── SpecializedEvent.cs
│ │ ├── SpecializedField.cs
│ │ ├── SpecializedMember.cs
│ │ ├── SpecializedMethod.cs
│ │ ├── SpecializedProperty.cs
│ │ ├── SpecializingMemberReference.cs
│ │ ├── TypeParameterReference.cs
│ │ ├── TypeWithElementType.cs
│ │ ├── UnknownType.cs
│ │ ├── UnresolvedAttributeBlob.cs
│ │ └── VoidTypeDefinition.cs
│ ├── InheritanceHelper.cs
│ ├── IntersectionType.cs
│ ├── KnownTypeReference.cs
│ ├── NullableType.cs
│ ├── ParameterListComparer.cs
│ ├── ParameterizedType.cs
│ ├── PointerType.cs
│ ├── ProjectReference.cs
│ ├── ReflectionHelper.cs
│ ├── ReflectionNameParseException.cs
│ ├── SimpleTypeResolveContext.cs
│ ├── SpecialType.cs
│ ├── TaskType.cs
│ ├── TopLevelTypeName.cs
│ ├── TypeKind.cs
│ ├── TypeParameterSubstitution.cs
│ ├── TypeSystemExtensions.cs
│ └── TypeVisitor.cs
└── Utils
│ ├── BitVector16.cs
│ ├── BusyManager.cs
│ ├── CSharpPrimitiveCast.cs
│ ├── CacheManager.cs
│ ├── CompositeFormatStringParser
│ ├── CompositeFormatStringParser.cs
│ ├── FormatItem.cs
│ ├── FormatStringSegmentBase.cs
│ ├── IFormatStringError.cs
│ ├── IFormatStringSegment.cs
│ └── TextSegment.cs
│ ├── EmptyList.cs
│ ├── ExtensionMethods.cs
│ ├── GraphVizGraph.cs
│ ├── ImmutableStack.cs
│ ├── LazyInit.cs
│ ├── MultiDictionary.cs
│ ├── Platform.cs
│ ├── ProjectedList.cs
│ ├── ReferenceComparer.cs
│ └── TreeTraversal.cs
├── NRefactory.sln
├── Packages
└── ICSharpCode.NRefactory.nuspec
├── README
└── doc
├── Pattern Matching.html
├── TODO
├── XML Documentation.html
├── copyright.txt
└── license.txt
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.cs text diff=csharp
2 | *.sln text eol=crlf
3 | *.csproj text eol=crlf
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | bin
2 | obj
3 | *.suo
4 | /lib/*.dll
5 | /ICSharpCode.NRefactory.Tests/PartCover/*
6 | _ReSharper*/*
7 | *.tmp_proj
8 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: csharp
2 | solution: NRefactory.sln
3 | install:
4 | - git clone git://github.com/jbevain/cecil.git ../cecil
5 | - git clone git://github.com/mono/ikvm-fork.git ../ikvm
6 | - pushd ../ikvm && git checkout c9edfe788667d5777e97e3f2fd195080d06dd32c && popd
7 | - nuget install NUnit.Runners -Version 2.6.4 -OutputDirectory testrunner
8 | script:
9 | - xbuild /p:Configuration=Debug NRefactory.sln
10 | - mono ./testrunner/NUnit.Runners.2.6.4/tools/nunit-console.exe bin/Debug/ICSharpCode.NRefactory.Tests.dll
11 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/NewLineNode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | namespace ICSharpCode.NRefactory.CSharp
3 | {
4 |
5 | ///
6 | /// A New line node represents a line break in the text.
7 | ///
8 | public sealed class NewLineNode : AstNode
9 | {
10 | public override NodeType NodeType {
11 | get {
12 | return NodeType.Whitespace;
13 | }
14 | }
15 |
16 | const uint newLineMask = 0xfu << AstNodeFlagsUsedBits;
17 | static readonly UnicodeNewline[] newLineTypes = {
18 | UnicodeNewline.Unknown,
19 | UnicodeNewline.LF,
20 | UnicodeNewline.CRLF,
21 | UnicodeNewline.CR,
22 | UnicodeNewline.NEL,
23 | UnicodeNewline.VT,
24 | UnicodeNewline.FF,
25 | UnicodeNewline.LS,
26 | UnicodeNewline.PS
27 | };
28 |
29 | public UnicodeNewline NewLineType {
30 | get {
31 | return newLineTypes[(flags & newLineMask) >> AstNodeFlagsUsedBits];
32 | }
33 | set {
34 | ThrowIfFrozen();
35 | int pos = Array.IndexOf(newLineTypes, value);
36 | if (pos < 0)
37 | pos = 0;
38 | flags &= ~newLineMask; // clear old newline type
39 | flags |= (uint)pos << AstNodeFlagsUsedBits;
40 | }
41 | }
42 |
43 | TextLocation startLocation;
44 | public override TextLocation StartLocation {
45 | get {
46 | return startLocation;
47 | }
48 | }
49 |
50 | public override TextLocation EndLocation {
51 | get {
52 | return new TextLocation (startLocation.Line + 1, 1);
53 | }
54 | }
55 |
56 | public NewLineNode() : this (TextLocation.Empty)
57 | {
58 | }
59 |
60 | public NewLineNode(TextLocation startLocation)
61 | {
62 | this.startLocation = startLocation;
63 | }
64 |
65 | public sealed override string ToString(CSharpFormattingOptions formattingOptions)
66 | {
67 | return NewLine.GetString (NewLineType);
68 | }
69 |
70 | public override void AcceptVisitor(IAstVisitor visitor)
71 | {
72 | visitor.VisitNewLine (this);
73 | }
74 |
75 | public override T AcceptVisitor(IAstVisitor visitor)
76 | {
77 | return visitor.VisitNewLine (this);
78 | }
79 |
80 | public override S AcceptVisitor(IAstVisitor visitor, T data)
81 | {
82 | return visitor.VisitNewLine (this, data);
83 | }
84 |
85 | protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match)
86 | {
87 | return other is NewLineNode;
88 | }
89 | }
90 | }
91 |
92 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.CSharp/Ast/Modifiers.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Modifiers.cs
3 | //
4 | // Author:
5 | // Mike Krüger
6 | //
7 | // Copyright (C) 2008 Novell, Inc (http://www.novell.com)
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining
10 | // a copy of this software and associated documentation files (the
11 | // "Software"), to deal in the Software without restriction, including
12 | // without limitation the rights to use, copy, modify, merge, publish,
13 | // distribute, sublicense, and/or sell copies of the Software, and to
14 | // permit persons to whom the Software is furnished to do so, subject to
15 | // the following conditions:
16 | //
17 | // The above copyright notice and this permission notice shall be
18 | // included in all copies or substantial portions of the Software.
19 | //
20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 | //
28 |
29 | using System;
30 |
31 | namespace ICSharpCode.NRefactory.CSharp
32 | {
33 | [Flags]
34 | public enum Modifiers
35 | {
36 | None = 0,
37 |
38 | Private = 0x0001,
39 | Internal = 0x0002,
40 | Protected = 0x0004,
41 | Public = 0x0008,
42 |
43 | Abstract = 0x0010,
44 | Virtual = 0x0020,
45 | Sealed = 0x0040,
46 | Static = 0x0080,
47 | Override = 0x0100,
48 | Readonly = 0x0200,
49 | Const = 0x0400,
50 | New = 0x0800,
51 | Partial = 0x1000,
52 |
53 | Extern = 0x2000,
54 | Volatile = 0x4000,
55 | Unsafe = 0x8000,
56 | Async = 0x10000,
57 | Ref = 0x20000,
58 | ReadonlyMember = 0x40000,
59 |
60 | VisibilityMask = Private | Internal | Protected | Public,
61 |
62 | ///
63 | /// Special value used to match any modifiers during pattern matching.
64 | ///
65 | Any = unchecked((int)0x80000000)
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.CSharp/Ast/NodeType.cs:
--------------------------------------------------------------------------------
1 | //
2 | // NodeType.cs
3 | //
4 | // Author:
5 | // Mike Krüger
6 | //
7 | // Copyright (c) 2009 Novell, Inc (http://www.novell.com)
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 |
27 |
28 | namespace ICSharpCode.NRefactory.CSharp {
29 | public enum NodeType
30 | {
31 | Unknown,
32 | ///
33 | /// AstType
34 | ///
35 | TypeReference,
36 | ///
37 | /// Type or delegate declaration
38 | ///
39 | TypeDeclaration,
40 | Member,
41 | Statement,
42 | Expression,
43 | Token,
44 | QueryClause,
45 | ///
46 | /// Comment or whitespace or pre-processor directive
47 | ///
48 | Whitespace,
49 | ///
50 | /// Placeholder for a pattern
51 | ///
52 | Pattern
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.CSharp/Ast/SyntaxExtensions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2013 Daniel Grunwald
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 | //
10 | // The above copyright notice and this permission notice shall be included in
11 | // all copies or substantial portions of the Software.
12 | //
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | // THE SOFTWARE.
20 |
21 |
22 | namespace ICSharpCode.NRefactory.CSharp {
23 | ///
24 | /// Extension methods for the syntax tree.
25 | ///
26 | public static class SyntaxExtensions
27 | {
28 | public static bool IsComparisonOperator(this OperatorType operatorType)
29 | {
30 | switch (operatorType) {
31 | case OperatorType.Equality:
32 | case OperatorType.Inequality:
33 | case OperatorType.GreaterThan:
34 | case OperatorType.LessThan:
35 | case OperatorType.GreaterThanOrEqual:
36 | case OperatorType.LessThanOrEqual:
37 | return true;
38 | default:
39 | return false;
40 | }
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.CSharp/Ast/TokenRole.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace ICSharpCode.NRefactory.CSharp {
4 | ///
5 | /// A specific role only used for C# tokens
6 | ///
7 | public sealed class TokenRole : Role
8 | {
9 | internal readonly static List Tokens = new List ();
10 | internal readonly static List TokenLengths = new List ();
11 | internal readonly uint TokenIndex;
12 |
13 | static TokenRole ()
14 | {
15 | // null token
16 | Tokens.Add ("");
17 | TokenLengths.Add (0);
18 | }
19 |
20 | ///
21 | /// Gets the token as string. Note that the token Name and Token value may differ.
22 | ///
23 | public string Token {
24 | get;
25 | private set;
26 | }
27 |
28 | ///
29 | /// Gets the char length of the token.
30 | ///
31 | public int Length {
32 | get;
33 | private set;
34 | }
35 |
36 |
37 | public TokenRole(string token) : base (token, CSharpTokenNode.Null)
38 | {
39 | this.Token = token;
40 | this.Length = token.Length;
41 |
42 | bool found = false;
43 | for (int i = 0; i < Tokens.Count; i++) {
44 | var existingToken = Tokens [i];
45 | if (existingToken == token) {
46 | TokenIndex = (uint)i;
47 | found = true;
48 | break;
49 | }
50 | }
51 | if (!found) {
52 | TokenIndex = (uint)Tokens.Count;
53 | Tokens.Add (token);
54 | TokenLengths.Add (this.Length);
55 | }
56 | }
57 | }
58 | }
59 |
60 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.CSharp/CommentReference.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2014-2019 de4dot@gmail.com
3 |
4 | This file is part of dnSpy
5 |
6 | dnSpy is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | dnSpy is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with dnSpy. If not, see .
18 | */
19 |
20 | using System.Collections.Generic;
21 | using System.Text;
22 |
23 | namespace ICSharpCode.NRefactory.CSharp {
24 | public struct CommentReference {
25 | public readonly int Length;
26 | public readonly object Reference;
27 | public readonly bool IsLocal;
28 |
29 | public CommentReference(int len, object @ref, bool isLocal = false) {
30 | this.Length = len;
31 | this.Reference = @ref;
32 | this.IsLocal = isLocal;
33 | }
34 | }
35 |
36 | public sealed class CommentReferencesCreator {
37 | readonly List refs;
38 | readonly StringBuilder sb;
39 |
40 | public CommentReference[] CommentReferences {
41 | get { return refs.ToArray(); }
42 | }
43 |
44 | public string Text {
45 | get { return sb.ToString(); }
46 | }
47 |
48 | public CommentReferencesCreator(StringBuilder sb) {
49 | this.refs = new List();
50 | this.sb = sb;
51 | this.sb.Clear();
52 | }
53 |
54 | public void AddText(string text) {
55 | Add(text, null, false);
56 | }
57 |
58 | public void AddReference(string text, object @ref, bool isLocal = false) {
59 | Add(text, @ref, isLocal);
60 | }
61 |
62 | void Add(string s, object @ref, bool isLocal) {
63 | refs.Add(new CommentReference(s.Length, @ref, isLocal));
64 | sb.Append(s);
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.CSharp/Extensions.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace ICSharpCode.NRefactory.CSharp
3 | {
4 | static class Extensions
5 | {
6 | public static T WithAnnotation(this T node, object annotation) where T : AstNode
7 | {
8 | if (annotation != null)
9 | node.AddAnnotation(annotation);
10 | return node;
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.CSharp/ICSharpCode.NRefactory.CSharp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | true
7 | ..\ICSharpCode.NRefactory.snk
8 | 1591,1587,1570,1685
9 | false
10 | false
11 | false
12 | false
13 | false
14 | false
15 | false
16 | false
17 | false
18 | false
19 | True
20 |
21 |
22 |
23 | $(DefineConstants);FULL_AST;NET_4_0;NET_4_5;NET_4_6
24 |
25 |
26 | $(DefineConstants);FULL_AST;NET_4_0;NET_4_5;NET_4_6
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.CSharp/NameLookupMode.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 |
20 | namespace ICSharpCode.NRefactory.CSharp {
21 | public enum NameLookupMode
22 | {
23 | ///
24 | /// Normal name lookup in expressions
25 | ///
26 | Expression,
27 | ///
28 | /// Name lookup in expression, where the expression is the target of an invocation.
29 | /// Such a lookup will only return methods and delegate-typed fields.
30 | ///
31 | InvocationTarget,
32 | ///
33 | /// Normal name lookup in type references.
34 | ///
35 | Type,
36 | ///
37 | /// Name lookup in the type reference inside a using declaration.
38 | ///
39 | TypeInUsingDeclaration,
40 | ///
41 | /// Name lookup for base type references.
42 | ///
43 | BaseTypeReference
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.CSharp/PatternMatching/AnyType.cs:
--------------------------------------------------------------------------------
1 | //
2 | // AnyType.cs
3 | //
4 | // Author:
5 | // Mike Krüger
6 | //
7 | // Copyright (c) 2013 Xamarin Inc. (http://xamarin.com)
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 |
27 | namespace ICSharpCode.NRefactory.PatternMatching {
28 |
29 |
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.CSharp/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 | using System.Runtime.CompilerServices;
19 |
20 | #region Using directives
21 |
22 | using System.Reflection;
23 |
24 | #endregion
25 |
26 | // General Information about an assembly is controlled through the following
27 | // set of attributes. Change these attribute values to modify the information
28 | // associated with an assembly.
29 | [assembly: AssemblyTitle("ICSharpCode.NRefactory.CSharp")]
30 | [assembly: AssemblyDescription("C# parser and semantic analysis")]
31 | [assembly: InternalsVisibleTo("ICSharpCode.NRefactory.CSharp.Refactoring, PublicKey=00240000048000009400000006020000002400005253413100040000010001004dcf3979c4e902efa4dd2163a039701ed5822e6f1134d77737296abbb97bf0803083cfb2117b4f5446a217782f5c7c634f9fe1fc60b4c11d62c5b3d33545036706296d31903ddcf750875db38a8ac379512f51620bb948c94d0831125fbc5fe63707cbb93f48c1459c4d1749eb7ac5e681a2f0d6d7c60fa527a3c0b8f92b02bf")]
32 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.CSharp/Resolver/AliasNamespaceResolveResult.cs:
--------------------------------------------------------------------------------
1 | //
2 | // AliasResolveResult.cs
3 | //
4 | // Author:
5 | // Mike Krüger
6 | //
7 | // Copyright (c) 2013 Xamarin Inc. (http://xamarin.com)
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 | using ICSharpCode.NRefactory.Semantics;
27 |
28 | namespace ICSharpCode.NRefactory.CSharp.Resolver {
29 | ///
30 | /// Represents a namespace resolve result that's resolved using an alias.
31 | ///
32 | public class AliasNamespaceResolveResult : NamespaceResolveResult
33 | {
34 | ///
35 | /// The alias used.
36 | ///
37 | public string Alias {
38 | get;
39 | private set;
40 | }
41 |
42 | public AliasNamespaceResolveResult(string alias, NamespaceResolveResult underlyingResult) : base (underlyingResult.Namespace)
43 | {
44 | this.Alias = alias;
45 | }
46 | }
47 | }
48 |
49 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.CSharp/Resolver/AliasTypeResolveResult.cs:
--------------------------------------------------------------------------------
1 | //
2 | // AliasTypeResolveResult.cs
3 | //
4 | // Author:
5 | // Mike Krüger
6 | //
7 | // Copyright (c) 2013 Xamarin Inc. (http://xamarin.com)
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 |
27 | using ICSharpCode.NRefactory.Semantics;
28 |
29 | namespace ICSharpCode.NRefactory.CSharp.Resolver {
30 | ///
31 | /// Represents a type resolve result that's resolved using an alias.
32 | ///
33 | public class AliasTypeResolveResult : TypeResolveResult
34 | {
35 | ///
36 | /// The alias used.
37 | ///
38 | public string Alias {
39 | get;
40 | private set;
41 | }
42 |
43 | public AliasTypeResolveResult(string alias, TypeResolveResult underlyingResult) : base (underlyingResult.Type)
44 | {
45 | this.Alias = alias;
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.CSharp/Resolver/DynamicMemberResolveResult.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System.Collections.Generic;
20 | using System.Globalization;
21 | using ICSharpCode.NRefactory.Semantics;
22 | using ICSharpCode.NRefactory.TypeSystem;
23 |
24 | namespace ICSharpCode.NRefactory.CSharp.Resolver {
25 | ///
26 | /// Represents the result of an access to a member of a dynamic object.
27 | ///
28 | public class DynamicMemberResolveResult : ResolveResult
29 | {
30 | ///
31 | /// Target of the member access (a dynamic object).
32 | ///
33 | public readonly ResolveResult Target;
34 |
35 | ///
36 | /// Name of the accessed member.
37 | ///
38 | public readonly string Member;
39 |
40 | public DynamicMemberResolveResult(ResolveResult target, string member) : base(SpecialType.Dynamic) {
41 | this.Target = target;
42 | this.Member = member;
43 | }
44 |
45 | public override string ToString()
46 | {
47 | return string.Format(CultureInfo.InvariantCulture, "[Dynamic member '{0}']", Member);
48 | }
49 |
50 | public override IEnumerable GetChildResults() {
51 | return new[] { Target };
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.CSharp/Resolver/RenameCallbackArguments.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2014 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 |
21 | namespace ICSharpCode.NRefactory.CSharp.Resolver
22 | {
23 | ///
24 | /// Arguments for the callback of .
25 | ///
26 | public class RenameCallbackArguments
27 | {
28 | public AstNode NodeToReplace { get; private set; }
29 | public AstNode NewNode { get; private set; }
30 |
31 | public RenameCallbackArguments(AstNode nodeToReplace, AstNode newNode)
32 | {
33 | if (nodeToReplace == null)
34 | throw new ArgumentNullException("nodeToReplace");
35 | if (newNode == null)
36 | throw new ArgumentNullException("newNode");
37 | this.NodeToReplace = nodeToReplace;
38 | this.NewNode = newNode;
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/CodeActions/ConvertDoWhileToWhileLoopTests.cs:
--------------------------------------------------------------------------------
1 | //
2 | // ConvertDoWhileToWhileLoopTests.cs
3 | //
4 | // Author:
5 | // Luís Reis
6 | //
7 | // Copyright (c) 2013 Luís Reis
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 | using NUnit.Framework;
27 | using ICSharpCode.NRefactory.CSharp.Refactoring;
28 |
29 | namespace ICSharpCode.NRefactory.CSharp.CodeActions
30 | {/* TOOD: Enable - it's not possible to compile this file on mono 3.0.7 due to an internal compiler error.
31 | [TestFixture]
32 | public class ConvertDoWhileToWhileLoopTests : ContextActionTestBase
33 | {
34 | [Test]
35 | public void TestSimple()
36 | {
37 | Test(@"
38 | class Foo {
39 | void TestMethod() {
40 | int x = 1;
41 | $do
42 | x++;
43 | while (x != 1);
44 | }
45 | }", @"
46 | class Foo {
47 | void TestMethod() {
48 | int x = 1;
49 | while (x != 1)
50 | x++;
51 | }
52 | }");
53 | }
54 |
55 | [Test]
56 | public void TestDisabledInContent()
57 | {
58 | TestWrongContext(@"
59 | class Foo {
60 | void TestMethod() {
61 | int x = 1;
62 | do
63 | $x++;
64 | while (x != 1);
65 | }
66 | }");
67 | }
68 | }*/
69 | }
70 |
71 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/CodeActions/ConvertNullCoalescingToConditionalExpressionActionTests.cs:
--------------------------------------------------------------------------------
1 | //
2 | // ConvertNullCoalescingToConditionalExpressionActionTests.cs
3 | //
4 | // Author:
5 | // Mike Krüger
6 | //
7 | // Copyright (c) 2013 Xamarin Inc. (http://xamarin.com)
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 | using ICSharpCode.NRefactory.CSharp.Refactoring;
27 | using NUnit.Framework;
28 |
29 | namespace ICSharpCode.NRefactory.CSharp.CodeActions
30 | {
31 | [TestFixture]
32 | public class ConvertNullCoalescingToConditionalExpressionActionTests: ContextActionTestBase
33 | {
34 | [Test]
35 | public void TestSimpleCase ()
36 | {
37 | Test(@"
38 | class Test
39 | {
40 | object Foo (object o, object p)
41 | {
42 | return o $?? p;
43 | }
44 | }
45 | ", @"
46 | class Test
47 | {
48 | object Foo (object o, object p)
49 | {
50 | return o != null ? o : p;
51 | }
52 | }
53 | ");
54 | }
55 | }
56 | }
57 |
58 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/CodeActions/ConvertShiftToMultiplyActionTests.cs:
--------------------------------------------------------------------------------
1 | //
2 | // ConvertShiftToMultiplyActionTests.cs
3 | //
4 | // Author:
5 | // Mike Krüger
6 | //
7 | // Copyright (c) 2013 Xamarin Inc. (http://xamarin.com)
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 | using ICSharpCode.NRefactory.CSharp.Refactoring;
27 | using NUnit.Framework;
28 |
29 | namespace ICSharpCode.NRefactory.CSharp.CodeActions
30 | {
31 | [TestFixture]
32 | public class ConvertShiftToMultiplyActionTests : ContextActionTestBase
33 | {
34 | [Test]
35 | public void TestShiftLeft ()
36 | {
37 | Test (@"
38 | class TestClass
39 | {
40 | int TestMethod (int i)
41 | {
42 | return i $<< 8;
43 | }
44 | }", @"
45 | class TestClass
46 | {
47 | int TestMethod (int i)
48 | {
49 | return i * 256;
50 | }
51 | }");
52 | }
53 |
54 | [Test]
55 | public void TestShiftRight ()
56 | {
57 | Test (@"
58 | class TestClass
59 | {
60 | int TestMethod (int i)
61 | {
62 | return i $>> 4;
63 | }
64 | }", @"
65 | class TestClass
66 | {
67 | int TestMethod (int i)
68 | {
69 | return i / 16;
70 | }
71 | }");
72 | }
73 | }
74 | }
75 |
76 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/CodeActions/CreateDelegateTests.cs:
--------------------------------------------------------------------------------
1 | //
2 | // CreateDelegateTests.cs
3 | //
4 | // Author:
5 | // Mike Krüger
6 | //
7 | // Copyright (c) 2012 Xamarin
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 |
27 | using System;
28 | using NUnit.Framework;
29 | using ICSharpCode.NRefactory.CSharp.Refactoring;
30 |
31 | namespace ICSharpCode.NRefactory.CSharp.CodeActions
32 | {
33 | [TestFixture]
34 | public class CreateDelegateTests : ContextActionTestBase
35 | {
36 | [Test()]
37 | public void TestCreateDelegate ()
38 | {
39 | Test (
40 | @"
41 | class TestClass
42 | {
43 | event $MyEventHandler evt;
44 | }
45 | ", @"
46 | delegate void MyEventHandler (object sender, System.EventArgs e);
47 | class TestClass
48 | {
49 | event MyEventHandler evt;
50 | }
51 | ");
52 | }
53 |
54 | [Test()]
55 | public void TestCreatePublicDelegate ()
56 | {
57 | Test (
58 | @"
59 | class TestClass
60 | {
61 | public event $MyEventHandler evt;
62 | }
63 | ", @"
64 | public delegate void MyEventHandler (object sender, System.EventArgs e);
65 | class TestClass
66 | {
67 | public event MyEventHandler evt;
68 | }
69 | ");
70 | }
71 |
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/CodeActions/GenerateGetterTests.cs:
--------------------------------------------------------------------------------
1 | //
2 | // GenerateGetterTests.cs
3 | //
4 | // Author:
5 | // Mike Krüger
6 | //
7 | // Copyright (c) 2012 Xamarin Inc.
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 |
27 | using System;
28 | using NUnit.Framework;
29 | using ICSharpCode.NRefactory.CSharp.Refactoring;
30 |
31 | namespace ICSharpCode.NRefactory.CSharp.CodeActions
32 | {
33 | [TestFixture]
34 | public class GenerateGetterTests : ContextActionTestBase
35 | {
36 | [Test()]
37 | public void Test ()
38 | {
39 | string result = RunContextAction (
40 | new GenerateGetterAction (),
41 | "using System;" + Environment.NewLine +
42 | "class TestClass" + Environment.NewLine +
43 | "{" + Environment.NewLine +
44 | " int $myField;" + Environment.NewLine +
45 | "}"
46 | );
47 | Assert.AreEqual (
48 | "using System;" + Environment.NewLine +
49 | "class TestClass" + Environment.NewLine +
50 | "{" + Environment.NewLine +
51 | " public int MyField {" + Environment.NewLine +
52 | " get {" + Environment.NewLine +
53 | " return myField;" + Environment.NewLine +
54 | " }" + Environment.NewLine +
55 | " }" + Environment.NewLine +
56 | " int myField;" + Environment.NewLine +
57 | "}", result);
58 | }
59 | }
60 | }
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/CodeActions/InvertIfAndSimplifyTests.cs:
--------------------------------------------------------------------------------
1 | using ICSharpCode.NRefactory.CSharp.Refactoring;
2 | using NUnit.Framework;
3 |
4 | namespace ICSharpCode.NRefactory.CSharp.CodeActions
5 | {
6 | [TestFixture]
7 | class InvertIfAndSimplifyTests : ContextActionTestBase
8 | {
9 | [Test]
10 | public void Test()
11 | {
12 | Test(
13 | @"class TestClass
14 | {
15 | void Test ()
16 | {
17 | $if (true) {
18 | Case1 ();
19 | Case2 ();
20 | }
21 | else
22 | {
23 | return;
24 | }
25 | }
26 | }",
27 | @"class TestClass
28 | {
29 | void Test ()
30 | {
31 | if (false)
32 | return;
33 | Case1 ();
34 | Case2 ();
35 | }
36 | }"
37 | );
38 | }
39 |
40 | [Test]
41 | public void TestNonVoidMoreComplexMethod()
42 | {
43 | Test(
44 | @"class TestClass
45 | {
46 | int Test ()
47 | {
48 | $if (true) {
49 | Case1 ();
50 | }
51 | else
52 | {
53 | return 0;
54 | testDummyCode ();
55 | }
56 | }
57 | }",
58 | @"class TestClass
59 | {
60 | int Test ()
61 | {
62 | if (false) {
63 | return 0;
64 | testDummyCode ();
65 | }
66 | Case1 ();
67 | }
68 | }"
69 | );
70 |
71 | }
72 |
73 | [Test]
74 | public void TestComplexMethod()
75 | {
76 | Test(
77 | @"class TestClass
78 | {
79 | int Test ()
80 | {
81 | $if (true) {
82 | Case1 ();
83 | }
84 | else
85 | continue;
86 | return 0;
87 | }
88 | }",
89 | @"class TestClass
90 | {
91 | int Test ()
92 | {
93 | if (false)
94 | continue;
95 | Case1 ();
96 | return 0;
97 | }
98 | }"
99 | );
100 | }
101 |
102 | [Test]
103 | public void TestComment()
104 | {
105 | Test(
106 | @"class TestClass
107 | {
108 | int Test ()
109 | {
110 | $if (true) {
111 | Case1 ();
112 | }
113 | else
114 | {
115 | //TestComment
116 | return 0;
117 | }
118 | }
119 | }",
120 | @"class TestClass
121 | {
122 | int Test ()
123 | {
124 | if (false) {
125 | //TestComment
126 | return 0;
127 | }
128 | Case1 ();
129 | }
130 | }"
131 | );
132 |
133 | }
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/CodeActions/JoinDeclarationAndAssignmentTests.cs:
--------------------------------------------------------------------------------
1 | //
2 | // JoinDeclarationAndAssignmentTests.cs
3 | //
4 | // Author:
5 | // Mansheng Yang
6 | //
7 | // Copyright (c) 2012 Mansheng Yang
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 |
27 | using ICSharpCode.NRefactory.CSharp.Refactoring;
28 | using NUnit.Framework;
29 |
30 | namespace ICSharpCode.NRefactory.CSharp.CodeActions
31 | {
32 | [TestFixture]
33 | public class JoinDeclarationAndAssignmentTests : ContextActionTestBase
34 | {
35 | [Test]
36 | public void Test ()
37 | {
38 | Test (@"
39 | class TestClass
40 | {
41 | void TestMethod ()
42 | {
43 | int $a;
44 | a = 1;
45 | }
46 | }", @"
47 | class TestClass
48 | {
49 | void TestMethod ()
50 | {
51 | int a = 1;
52 | }
53 | }");
54 | }
55 |
56 | [Test]
57 | public void TestDeclarationList ()
58 | {
59 | Test (@"
60 | class TestClass
61 | {
62 | void TestMethod ()
63 | {
64 | int a, $b;
65 | b = 1;
66 | }
67 | }", @"
68 | class TestClass
69 | {
70 | void TestMethod ()
71 | {
72 | int a;
73 | int b = 1;
74 | }
75 | }");
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/CodeActions/NegateIsExpressionActionTests.cs:
--------------------------------------------------------------------------------
1 | //
2 | // NegateIsExpressionActionTests.cs
3 | //
4 | // Author:
5 | // Mike Krüger
6 | //
7 | // Copyright (c) 2013 Xamarin Inc. (http://xamarin.com)
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 | using ICSharpCode.NRefactory.CSharp.Refactoring;
27 | using NUnit.Framework;
28 |
29 | namespace ICSharpCode.NRefactory.CSharp.CodeActions
30 | {
31 | [TestFixture]
32 | public class NegateIsExpressionActionTests : ContextActionTestBase
33 | {
34 | [Test]
35 | public void TestSimpleCase ()
36 | {
37 | Test (@"
38 | class TestClass
39 | {
40 | void Test (object x)
41 | {
42 | var b = x $is TestClass;
43 | }
44 | }", @"
45 | class TestClass
46 | {
47 | void Test (object x)
48 | {
49 | var b = !(x is TestClass);
50 | }
51 | }");
52 | }
53 |
54 | [Test]
55 | public void TestReverse ()
56 | {
57 | Test (@"
58 | class TestClass
59 | {
60 | void Test (object x)
61 | {
62 | var b = !(x $is TestClass);
63 | }
64 | }", @"
65 | class TestClass
66 | {
67 | void Test (object x)
68 | {
69 | var b = x is TestClass;
70 | }
71 | }");
72 | }
73 |
74 | }
75 | }
76 |
77 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/CodeActions/ReplaceEmptyStringTests.cs:
--------------------------------------------------------------------------------
1 | //
2 | // ReplaceEmptyStringTests.cs
3 | //
4 | // Author:
5 | // Mike Krüger
6 | //
7 | // Copyright (c) 2012 Xamarin Inc.
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 | using System;
27 | using NUnit.Framework;
28 | using ICSharpCode.NRefactory.CSharp.Refactoring;
29 |
30 | namespace ICSharpCode.NRefactory.CSharp.CodeActions
31 | {
32 | [TestFixture]
33 | public class ReplaceEmptyStringTests : ContextActionTestBase
34 | {
35 | [Test()]
36 | public void TestSimpleString()
37 | {
38 | string result = RunContextAction (
39 | new ReplaceEmptyStringAction (),
40 | "class TestClass" + Environment.NewLine +
41 | "{" + Environment.NewLine +
42 | " void Test ()" + Environment.NewLine +
43 | " {" + Environment.NewLine +
44 | " string str = $\"\";" + Environment.NewLine +
45 | " }" + Environment.NewLine +
46 | "}"
47 | );
48 |
49 | Assert.AreEqual (
50 | "class TestClass" + Environment.NewLine +
51 | "{" + Environment.NewLine +
52 | " void Test ()" + Environment.NewLine +
53 | " {" + Environment.NewLine +
54 | " string str = string.Empty;" + Environment.NewLine +
55 | " }" + Environment.NewLine +
56 | "}", result);
57 | }
58 | }
59 | }
60 |
61 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/CodeActions/ReplaceOperatorAssignmentWithAssignmentActionTests.cs:
--------------------------------------------------------------------------------
1 | //
2 | // ReplaceOperatorAssignmentWithAssignmentActionTests.cs
3 | //
4 | // Author:
5 | // Mike Krüger
6 | //
7 | // Copyright (c) 2013 Xamarin Inc. (http://xamarin.com)
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 | using System;
27 | using NUnit.Framework;
28 | using ICSharpCode.NRefactory.CSharp.Refactoring;
29 |
30 | namespace ICSharpCode.NRefactory.CSharp.CodeActions
31 | {
32 | [TestFixture]
33 | public class ReplaceOperatorAssignmentWithAssignmentActionTests : ContextActionTestBase
34 | {
35 | [Test]
36 | public void TestAdd ()
37 | {
38 | Test (@"
39 | class Test
40 | {
41 | void Foo (int i)
42 | {
43 | i $+= 1 + 2;
44 | }
45 | }", @"
46 | class Test
47 | {
48 | void Foo (int i)
49 | {
50 | i = i + 1 + 2;
51 | }
52 | }");
53 | }
54 |
55 |
56 | }
57 | }
58 |
59 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/CodeActions/ReplacePostfixExpressionWithAssignmentActionTests.cs:
--------------------------------------------------------------------------------
1 | //
2 | // ReplacePostfixExpressionWithAssignmentActionTests.cs
3 | //
4 | // Author:
5 | // Mike Krüger
6 | //
7 | // Copyright (c) 2013 Xamarin Inc. (http://xamarin.com)
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 |
27 | using System;
28 | using NUnit.Framework;
29 | using ICSharpCode.NRefactory.CSharp.Refactoring;
30 |
31 | namespace ICSharpCode.NRefactory.CSharp.CodeActions
32 | {
33 | [TestFixture]
34 | public class ReplacePostfixExpressionWithAssignmentActionTests : ContextActionTestBase
35 | {
36 | [Test]
37 | public void TestAdd ()
38 | {
39 | Test (@"
40 | class Test
41 | {
42 | void Foo (int i)
43 | {
44 | $i++;
45 | }
46 | }", @"
47 | class Test
48 | {
49 | void Foo (int i)
50 | {
51 | i += 1;
52 | }
53 | }");
54 | }
55 |
56 | [Test]
57 | public void TestSub ()
58 | {
59 | Test (@"
60 | class Test
61 | {
62 | void Foo (int i)
63 | {
64 | $i--;
65 | }
66 | }", @"
67 | class Test
68 | {
69 | void Foo (int i)
70 | {
71 | i -= 1;
72 | }
73 | }");
74 | }
75 | }
76 | }
77 |
78 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/CodeActions/ReplaceWithOperatorAssignmentActionTests.cs:
--------------------------------------------------------------------------------
1 | //
2 | // ReplaceWithOperatorAssignmentActionTests.cs
3 | //
4 | // Author:
5 | // Mike Krüger
6 | //
7 | // Copyright (c) 2013 Xamarin Inc. (http://xamarin.com)
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 | using System;
27 | using NUnit.Framework;
28 | using ICSharpCode.NRefactory.CSharp.Refactoring;
29 |
30 | namespace ICSharpCode.NRefactory.CSharp.CodeActions
31 | {
32 | [TestFixture]
33 | public class ReplaceWithOperatorAssignmentActionTests : ContextActionTestBase
34 | {
35 | [Test]
36 | public void TestAdd ()
37 | {
38 | Test (@"
39 | class Test
40 | {
41 | void Foo (int i)
42 | {
43 | i $= i + 1 + 2;
44 | }
45 | }", @"
46 | class Test
47 | {
48 | void Foo (int i)
49 | {
50 | i += 1 + 2;
51 | }
52 | }");
53 | }
54 |
55 |
56 | }
57 | }
58 |
59 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/CodeActions/SimplifyIfFlowInLoopsTests.cs:
--------------------------------------------------------------------------------
1 | //
2 | // SimplifyIfFlowInLoopsTests.cs
3 | //
4 | // Author:
5 | // Ciprian Khlud
6 | //
7 | // Copyright (c) 2013 Ciprian Khlud
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 | using ICSharpCode.NRefactory.CSharp.Refactoring;
27 | using NUnit.Framework;
28 |
29 | namespace ICSharpCode.NRefactory.CSharp.CodeActions
30 | {
31 | [TestFixture]
32 | public class SimplifyIfFlowInLoopsTests : ContextActionTestBase
33 | {
34 | [Test]
35 | public void Test()
36 | {
37 | Test(
38 | @"class TestClass
39 | {
40 | void Test ()
41 | {
42 | while(true)
43 | {
44 | $if (true) {
45 | Case1 ();
46 | }
47 | }
48 | }
49 | }",
50 | @"class TestClass
51 | {
52 | void Test ()
53 | {
54 | while(true) {
55 | if (false)
56 | continue;
57 | Case1 ();
58 | }
59 | }
60 | }");
61 | }
62 | }
63 | }
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/CodeActions/SimplifyIfFlowTests.cs:
--------------------------------------------------------------------------------
1 | //
2 | // SimplifyIfFlowTests.cs
3 | //
4 | // Author:
5 | // Ciprian Khlud
6 | //
7 | // Copyright (c) 2013 Ciprian Khlud
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 | using ICSharpCode.NRefactory.CSharp.Refactoring;
27 | using NUnit.Framework;
28 |
29 | namespace ICSharpCode.NRefactory.CSharp.CodeActions
30 | {
31 | [TestFixture]
32 | public class SimplifyIfFlowTests : ContextActionTestBase
33 | {
34 | [Test]
35 | public void Test()
36 | {
37 | Test(
38 | @"class TestClass
39 | {
40 | void Test ()
41 | {
42 | $if (true) {
43 | Case1 ();
44 | }
45 | }
46 | }",
47 | @"class TestClass
48 | {
49 | void Test ()
50 | {
51 | if (false)
52 | return;
53 | Case1 ();
54 | }
55 | }"
56 | );
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/CodeActions/UseVarKeywordTests.cs:
--------------------------------------------------------------------------------
1 | //
2 | // UseVarKeywordTests.cs
3 | //
4 | // Author:
5 | // Mike Krüger
6 | //
7 | // Copyright (c) 2011 Xamarin Inc.
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 |
27 | using System;
28 | using NUnit.Framework;
29 | using ICSharpCode.NRefactory.CSharp.Refactoring;
30 |
31 | namespace ICSharpCode.NRefactory.CSharp.CodeActions
32 | {
33 | [TestFixture]
34 | public class UseVarKeywordTests : ContextActionTestBase
35 | {
36 | [Test()]
37 | public void SimpleVarDeclaration ()
38 | {
39 | string result = RunContextAction (new UseVarKeywordAction (),
40 | @"class TestClass
41 | {
42 | void Test ()
43 | {
44 | $TestClass aVar = this;
45 | }
46 | }");
47 | Assert.AreEqual (@"class TestClass
48 | {
49 | void Test ()
50 | {
51 | var aVar = this;
52 | }
53 | }", result);
54 | }
55 |
56 | [Test()]
57 | public void ForeachDeclaration ()
58 | {
59 | string result = RunContextAction (new UseVarKeywordAction (),
60 | @"class TestClass
61 | {
62 | void Test ()
63 | {
64 | foreach ($TestClass aVar in this) {
65 | }
66 | }
67 | }");
68 | Assert.AreEqual (@"class TestClass
69 | {
70 | void Test ()
71 | {
72 | foreach (var aVar in this) {
73 | }
74 | }
75 | }", result);
76 | }
77 | }
78 | }
79 |
80 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CompletionDataList.cs:
--------------------------------------------------------------------------------
1 | //
2 | // CompletionDataList.cs
3 | //
4 | // Author:
5 | // Mike Krüger
6 | //
7 | // Copyright (c) 2011 Xamarin Inc. (http://xamarin.com)
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 | using System;
27 | using System.Collections.Generic;
28 | using ICSharpCode.NRefactory.Completion;
29 | using System.Linq;
30 |
31 |
32 | namespace ICSharpCode.NRefactory.CSharp.CodeCompletion
33 | {
34 | public class CompletionDataList
35 | {
36 | public IEnumerable Data {
37 | get;
38 | set;
39 | }
40 |
41 | public int Count {
42 | get {
43 | return Data.Count ();
44 | }
45 | }
46 |
47 | public ICompletionData this[int i] {
48 | get {
49 | return Data.ElementAt (i);
50 | }
51 | }
52 |
53 | public bool AutoCompleteEmptyMatch { get; set; }
54 |
55 | public bool AutoSelect { get; set; }
56 |
57 | public string DefaultCompletionString { get; set; }
58 |
59 | public ICompletionData Find (string name, bool includeImportData = false)
60 | {
61 | return Data.FirstOrDefault (d => (!(d is CodeCompletionBugTests.TestFactory.ImportCompletionData) || includeImportData) && d.DisplayText == name);
62 | }
63 | }
64 | }
65 |
66 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/CodeIssues/AdditionalOfTypeIssuesTests.cs:
--------------------------------------------------------------------------------
1 | //
2 | // AdditionalOfTypeIssuesTests.cs
3 | //
4 | // Author:
5 | // Mike Krüger
6 | //
7 | // Copyright (c) 2013 Xamarin Inc. (http://xamarin.com)
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 | using System;
27 | using NUnit.Framework;
28 | using ICSharpCode.NRefactory.CSharp.Refactoring;
29 | using ICSharpCode.NRefactory.CSharp.CodeActions;
30 | using System.Linq;
31 |
32 | namespace ICSharpCode.NRefactory.CSharp.CodeIssues
33 | {
34 | [TestFixture]
35 | public class AdditionalOfTypeIssuesTests : InspectionActionTestBase
36 | {
37 | [Test]
38 | public void TestAdditionalCase ()
39 | {
40 | Test(@"using System.Linq;
41 | class Test
42 | {
43 | public void Foo(object[] obj)
44 | {
45 | obj.Where(o => (o is Test));
46 | }
47 | }", @"using System.Linq;
48 | class Test
49 | {
50 | public void Foo(object[] obj)
51 | {
52 | obj.OfType ();
53 | }
54 | }");
55 | }
56 |
57 | [Test]
58 | public void TestInvalid ()
59 | {
60 | TestWrongContext(@"using System.Linq;
61 | class Test
62 | {
63 | public void Foo(object[] obj)
64 | {
65 | obj.OfType ().Where(o => this is IDisposable);
66 | }
67 | }");
68 | }
69 |
70 |
71 |
72 |
73 |
74 |
75 | }
76 | }
77 |
78 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/CodeIssues/CheckNamespaceIssueTests.cs:
--------------------------------------------------------------------------------
1 | //
2 | // CheckNamespaceIssueTests.cs
3 | //
4 | // Author:
5 | // Mike Krüger
6 | //
7 | // Copyright (c) 2013 Xamarin Inc. (http://xamarin.com)
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 | using ICSharpCode.NRefactory.CSharp.Refactoring;
27 | using NUnit.Framework;
28 |
29 | namespace ICSharpCode.NRefactory.CSharp.CodeIssues
30 | {
31 | [TestFixture]
32 | public class CheckNamespaceIssueTests : InspectionActionTestBase
33 | {
34 | [Test]
35 | public void TestWrongNamespace ()
36 | {
37 | TestIssue(@"namespace Foo {}");
38 | }
39 |
40 | [Test]
41 | public void TestSubstring ()
42 | {
43 | TestIssue(@"namespace TestFoo {}");
44 | }
45 |
46 |
47 | [Test]
48 | public void TestGlobalClass ()
49 | {
50 | TestIssue(@"class Foo {}");
51 | }
52 |
53 |
54 | [Test]
55 | public void CheckValidNamespace ()
56 | {
57 | TestWrongContext(@"namespace Test {}");
58 | }
59 |
60 | [Test]
61 | public void TestDisable ()
62 | {
63 | TestWrongContext(@"
64 | // ReSharper disable once CheckNamespace
65 | namespace Foo {}");
66 | }
67 |
68 | }
69 | }
70 |
71 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/CodeIssues/DoubleNegationOperatorIssueTests.cs:
--------------------------------------------------------------------------------
1 | //
2 | // DoubleNegationOperatorIssueTests.cs
3 | //
4 | // Author:
5 | // Mansheng Yang
6 | //
7 | // Copyright (c) 2012 Mansheng Yang
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 |
27 | using ICSharpCode.NRefactory.CSharp.Refactoring;
28 | using NUnit.Framework;
29 |
30 | namespace ICSharpCode.NRefactory.CSharp.CodeIssues
31 | {
32 | [TestFixture]
33 | public class DoubleNegationOperatorIssueTests : InspectionActionTestBase
34 | {
35 | [Test]
36 | public void Test ()
37 | {
38 | var input = @"
39 | class TestClass
40 | {
41 | bool GetBool () { }
42 |
43 | void TestMethod ()
44 | {
45 | var x = !!GetBool ();
46 | x = !(!(GetBool ()));
47 | }
48 | }";
49 | var output = @"
50 | class TestClass
51 | {
52 | bool GetBool () { }
53 |
54 | void TestMethod ()
55 | {
56 | var x = GetBool ();
57 | x = GetBool ();
58 | }
59 | }";
60 | Test (input, 2, output);
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/CodeIssues/MemberHidesStaticFromOuterClassIssueTests.cs:
--------------------------------------------------------------------------------
1 | //
2 | // MemberHidesStaticFromOuterClassIssueTests.cs
3 | //
4 | // Author:
5 | // Mike Krüger
6 | //
7 | // Copyright (c) 2013 Xamarin Inc. (http://xamarin.com)
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 | using NUnit.Framework;
27 | using ICSharpCode.NRefactory.CSharp.Refactoring;
28 |
29 | namespace ICSharpCode.NRefactory.CSharp.CodeIssues
30 | {
31 | [TestFixture]
32 | public class MemberHidesStaticFromOuterClassIssueTests : InspectionActionTestBase
33 | {
34 | [Test]
35 | public void TestSimpleCase()
36 | {
37 | TestIssue(@"
38 | public class Foo
39 | {
40 | public class Bar
41 | {
42 | public string Test { get; set; }
43 | }
44 |
45 | public static string Test { get; set; }
46 | }
47 | ");
48 | }
49 |
50 |
51 | [Test]
52 | public void TestDisable()
53 | {
54 | TestWrongContext(@"
55 | public class Foo
56 | {
57 | public class Bar
58 | {
59 | // ReSharper disable once MemberHidesStaticFromOuterClass
60 | public string Test { get; set; }
61 | }
62 |
63 | public static string Test { get; set; }
64 | }
65 | ");
66 | }
67 |
68 |
69 | }
70 | }
71 |
72 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/CodeIssues/NotImplementedExceptionInspectorTests.cs:
--------------------------------------------------------------------------------
1 | //
2 | // NotImplementedExceptionInspectorTests.cs
3 | //
4 | // Author:
5 | // Mike Krüger
6 | //
7 | // Copyright (c) 2012 Xamarin Inc. (http://xamarin.com)
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 |
27 | using System;
28 | using NUnit.Framework;
29 | using ICSharpCode.NRefactory.CSharp.Refactoring;
30 | using ICSharpCode.NRefactory.CSharp.CodeActions;
31 |
32 | namespace ICSharpCode.NRefactory.CSharp.CodeIssues
33 | {
34 | [TestFixture]
35 | public class NotImplementedExceptionInspectorTests : InspectionActionTestBase
36 | {
37 | [Test]
38 | public void TestInspectorCase1 ()
39 | {
40 | var input = @"class Foo
41 | {
42 | void Bar (string str)
43 | {
44 | throw new System.NotImplementedException ();
45 | }
46 | }";
47 |
48 | TestRefactoringContext context;
49 | var issues = GetIssues (new NotImplementedExceptionIssue (), input, out context);
50 | Assert.AreEqual (1, issues.Count);
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/CodeIssues/RedundantAttributeParenthesesIssueTests.cs:
--------------------------------------------------------------------------------
1 | //
2 | // RedundantAttributeParenthesesIssueTests.cs
3 | //
4 | // Author:
5 | // Mansheng Yang
6 | //
7 | // Copyright (c) 2012 Mansheng Yang
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 |
27 | using ICSharpCode.NRefactory.CSharp.Refactoring;
28 | using NUnit.Framework;
29 |
30 | namespace ICSharpCode.NRefactory.CSharp.CodeIssues
31 | {
32 | [TestFixture]
33 | public class RedundantAttributeParenthesesIssueTests : InspectionActionTestBase
34 | {
35 | [Test]
36 | public void Test ()
37 | {
38 | var input = @"
39 | [Test ()]
40 | class TestClass { }";
41 | var output = @"
42 | [Test]
43 | class TestClass { }";
44 | Test (input, 1, output);
45 | }
46 |
47 |
48 | [Test]
49 | public void TestDisable ()
50 | {
51 | var input = @"
52 | // Resharper disable once RedundantAttributeParentheses
53 | [Test ()]
54 | class TestClass { }";
55 | Test (input, 0);
56 | }
57 |
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/CodeIssues/RedundantTernaryExpressionIssueTests.cs:
--------------------------------------------------------------------------------
1 | //
2 | // RedundantTernaryExpressionIssueTests.cs
3 | //
4 | // Author:
5 | // Mike Krüger
6 | //
7 | // Copyright (c) 2013 Xamarin Inc. (http://xamarin.com)
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 | using System;
27 | using ICSharpCode.NRefactory.CSharp.Refactoring;
28 | using NUnit.Framework;
29 |
30 | namespace ICSharpCode.NRefactory.CSharp.CodeIssues
31 | {
32 | [TestFixture]
33 | public class RedundantTernaryExpressionIssueTests : InspectionActionTestBase
34 | {
35 | [Test]
36 | public void TestTrueFalseCase ()
37 | {
38 | Test(@"
39 | class Foo
40 | {
41 | void Bar ()
42 | {
43 | var a = 1 < 2 ? true : false;
44 | }
45 | }
46 | ", @"
47 | class Foo
48 | {
49 | void Bar ()
50 | {
51 | var a = 1 < 2;
52 | }
53 | }
54 | ");
55 | }
56 |
57 | [Test]
58 | public void TestDisable ()
59 | {
60 | TestWrongContext(@"
61 | class Foo
62 | {
63 | void Bar ()
64 | {
65 | // ReSharper disable once RedundantTernaryExpression
66 | var a = 1 < 2 ? true : false;
67 | }
68 | }
69 | ");
70 | }
71 | }
72 | }
73 |
74 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/CodeIssues/RedundantWhereWithPredicateIssueTests.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dnSpy/NRefactory/79d99d6fc3ff5b2c95ffa4861f0294a6c6b894c6/ICSharpCode.NRefactory.Tests/CSharp/CodeIssues/RedundantWhereWithPredicateIssueTests.cs
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/CodeIssues/StaticConstructorParameterIssueTests.cs:
--------------------------------------------------------------------------------
1 | //
2 | // StaticConstructorParameterIssueTests.cs
3 | //
4 | // Author:
5 | // Mike Krüger
6 | //
7 | // Copyright (c) 2013 Xamarin Inc. (http://xamarin.com)
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 |
27 | using System;
28 | using ICSharpCode.NRefactory.CSharp.CodeActions;
29 | using ICSharpCode.NRefactory.CSharp.Refactoring;
30 | using NUnit.Framework;
31 |
32 | namespace ICSharpCode.NRefactory.CSharp.CodeIssues
33 | {
34 | [TestFixture]
35 | public class StaticConstructorParameterIssueTests : InspectionActionTestBase
36 | {
37 | [Test]
38 | public void TestSimpleCase()
39 | {
40 | Test(@"
41 | class Foo
42 | {
43 | static Foo (int bar)
44 | {
45 | }
46 | }
47 | ", @"
48 | class Foo
49 | {
50 | static Foo ()
51 | {
52 | }
53 | }
54 | ", expectErrors: true);
55 | }
56 |
57 | [Test]
58 | public void TestNoIssue()
59 | {
60 | TestWrongContext(@"
61 | class Foo
62 | {
63 | static Foo ()
64 | {
65 | }
66 | }
67 | ");
68 | }
69 |
70 | }
71 | }
72 |
73 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/CodeIssues/UnusedTypeParameterIssueTests.cs:
--------------------------------------------------------------------------------
1 | //
2 | // UnusedTypeParameterIssueTests.cs
3 | //
4 | // Author:
5 | // Mansheng Yang
6 | //
7 | // Copyright (c) 2012 Mansheng Yang
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 |
27 | using ICSharpCode.NRefactory.CSharp.Refactoring;
28 | using NUnit.Framework;
29 |
30 | namespace ICSharpCode.NRefactory.CSharp.CodeIssues
31 | {
32 | [TestFixture]
33 | public class UnusedTypeParameterIssueTests : InspectionActionTestBase
34 | {
35 |
36 | [Test]
37 | public void TestUnusedTypeParameter ()
38 | {
39 | var input = @"
40 | class TestClass {
41 | void TestMethod ()
42 | {
43 | }
44 | }";
45 | Test (input, 1);
46 | }
47 |
48 | [Test]
49 | public void TestUsedTypeParameter ()
50 | {
51 | var input = @"
52 | class TestClass {
53 | void TestMethod (T i)
54 | {
55 | }
56 | }";
57 | var input2 = @"
58 | class TestClass {
59 | T TestMethod ()
60 | {
61 | }
62 | }";
63 | Test (input, 0);
64 | Test (input2, 0);
65 | }
66 |
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/DepthFirstVisitorTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using System.Collections.Generic;
21 | using System.Linq;
22 | using NUnit.Framework;
23 |
24 | namespace ICSharpCode.NRefactory.CSharp
25 | {
26 | [TestFixture]
27 | public class DepthFirstVisitorTests
28 | {
29 | sealed class CollectNodesVisitor : DepthFirstAstVisitor
30 | {
31 | internal List nodes = new List();
32 |
33 | protected override void VisitChildren(AstNode node)
34 | {
35 | nodes.Add(node);
36 | base.VisitChildren(node);
37 | }
38 | }
39 |
40 | [Test]
41 | public void TestCollectNodes()
42 | {
43 | var cu = new CSharpParser().Parse("using System;\nclass Test {\n int field; // comment\n}");
44 | CollectNodesVisitor v = new CollectNodesVisitor();
45 | cu.AcceptVisitor(v);
46 | Assert.AreEqual(cu.DescendantsAndSelf.ToList(), v.nodes);
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/Inspector/InconsistentNamingIssueTests.cs:
--------------------------------------------------------------------------------
1 | //
2 | // InconsistentNamingIssueTests.cs
3 | //
4 | // Author:
5 | // Mike Krüger
6 | //
7 | // Copyright (c) 2012 Xamarin
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 | using System;
27 |
28 | namespace ICSharpCode.NRefactory
29 | {
30 | public class InconsistentNamingIssueTests
31 | {
32 | public InconsistentNamingIssueTests ()
33 | {
34 | }
35 | }
36 | }
37 |
38 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/AnonymousTypeCreateExpressionTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using NUnit.Framework;
21 |
22 | namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
23 | {
24 | [TestFixture]
25 | public class AnonymousTypeCreateExpressionTests
26 | {
27 | [Test]
28 | public void Simple()
29 | {
30 | ParseUtilCSharp.AssertExpression(
31 | "new { Name = \"Test\", Price, Something.Property }",
32 | new AnonymousTypeCreateExpression {
33 | Initializers = {
34 | new NamedExpression("Name", new PrimitiveExpression("Test")),
35 | new IdentifierExpression("Price"),
36 | new IdentifierExpression("Something").Member("Property")
37 | }});
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/BaseReferenceExpressionTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using NUnit.Framework;
21 |
22 | namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
23 | {
24 | [TestFixture]
25 | public class BaseReferenceExpressionTests
26 | {
27 | [Test]
28 | public void BaseReferenceExpressionTest1()
29 | {
30 | MemberReferenceExpression fre = ParseUtilCSharp.ParseExpression("base.myField");
31 | Assert.IsTrue(fre.Target is BaseReferenceExpression);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/CheckedExpressionTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using NUnit.Framework;
21 |
22 | namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
23 | {
24 | [TestFixture]
25 | public class CheckedExpressionTests
26 | {
27 | [Test]
28 | public void CheckedExpressionTest()
29 | {
30 | CheckedExpression ce = ParseUtilCSharp.ParseExpression("checked(a)");
31 | Assert.IsTrue(ce.Expression is IdentifierExpression);
32 | }
33 |
34 | [Test]
35 | public void UncheckedExpressionTest()
36 | {
37 | UncheckedExpression ce = ParseUtilCSharp.ParseExpression("unchecked(a)");
38 | Assert.IsTrue(ce.Expression is IdentifierExpression);
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/IndexerExpressionTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using System.Linq;
21 | using NUnit.Framework;
22 |
23 | namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
24 | {
25 | [TestFixture]
26 | public class IndexerExpressionTests
27 | {
28 | [Test]
29 | public void IndexerExpressionTest()
30 | {
31 | IndexerExpression ie = ParseUtilCSharp.ParseExpression("field[1, \"Hello\", 'a']");
32 | Assert.IsTrue(ie.Target is IdentifierExpression);
33 |
34 | Assert.AreEqual(3, ie.Arguments.Count());
35 |
36 | Assert.IsTrue(ie.Arguments.ElementAt(0) is PrimitiveExpression);
37 | Assert.AreEqual(1, (int)((PrimitiveExpression)ie.Arguments.ElementAt(0)).Value);
38 | Assert.IsTrue(ie.Arguments.ElementAt(1) is PrimitiveExpression);
39 | Assert.AreEqual("Hello", (string)((PrimitiveExpression)ie.Arguments.ElementAt(1)).Value);
40 | Assert.IsTrue(ie.Arguments.ElementAt(2) is PrimitiveExpression);
41 | Assert.AreEqual('a', (char)((PrimitiveExpression)ie.Arguments.ElementAt(2)).Value);
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/ParenthesizedExpressionTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using NUnit.Framework;
21 |
22 | namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
23 | {
24 | [TestFixture]
25 | public class ParenthesizedExpressionTests
26 | {
27 | [Test]
28 | public void PrimitiveParenthesizedExpression()
29 | {
30 | ParenthesizedExpression p = ParseUtilCSharp.ParseExpression("((1))");
31 | Assert.IsTrue(p.Expression is ParenthesizedExpression);
32 | p = (ParenthesizedExpression)p.Expression;
33 | Assert.IsTrue(p.Expression is PrimitiveExpression);
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/PointerReferenceExpressionTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using NUnit.Framework;
21 |
22 | namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
23 | {
24 | [TestFixture]
25 | public class PointerReferenceExpressionTests
26 | {
27 | [Test]
28 | public void PointerReferenceExpressionTest()
29 | {
30 | PointerReferenceExpression pre = ParseUtilCSharp.ParseExpression("myObj.field->b");
31 | Assert.IsTrue(pre.Target is MemberReferenceExpression);
32 | Assert.AreEqual("b", pre.MemberName);
33 | }
34 |
35 | [Test]
36 | public void PointerReferenceGenericMethodTest()
37 | {
38 | ParseUtilCSharp.AssertExpression(
39 | "ptr->M();",
40 | new InvocationExpression {
41 | Target = new PointerReferenceExpression {
42 | Target = new IdentifierExpression("ptr"),
43 | MemberName = "M",
44 | TypeArguments = { new PrimitiveType("string") }
45 | }});
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/SizeOfExpressionTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using NUnit.Framework;
21 |
22 | namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
23 | {
24 | [TestFixture]
25 | public class SizeOfExpressionTests
26 | {
27 | [Test]
28 | public void SizeOfExpressionTest()
29 | {
30 | SizeOfExpression soe = ParseUtilCSharp.ParseExpression("sizeof(MyType)");
31 | Assert.AreEqual("MyType", ((SimpleType)soe.Type).Identifier);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/StackAllocExpressionTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using System.Linq;
21 | using NUnit.Framework;
22 |
23 | namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
24 | {
25 | [TestFixture]
26 | public class StackAllocExpressionTests
27 | {
28 | [Test]
29 | public void StackAllocExpressionTest()
30 | {
31 | var vd = ParseUtilCSharp.ParseStatement("int* a = stackalloc int[100];");
32 | StackAllocExpression sae = (StackAllocExpression)vd.Variables.Single().Initializer;
33 | Assert.AreEqual("int", ((PrimitiveType)sae.Type).Keyword);
34 | Assert.AreEqual(100, ((PrimitiveExpression)sae.CountExpression).Value);
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/ThisReferenceExpressionTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using NUnit.Framework;
21 |
22 | namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
23 | {
24 | [TestFixture]
25 | public class ThisReferenceExpressionTests
26 | {
27 | [Test]
28 | public void TestMethod()
29 | {
30 | ParseUtilCSharp.ParseExpression("this");
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/EmptyStatementTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using NUnit.Framework;
21 |
22 | namespace ICSharpCode.NRefactory.CSharp.Parser.Statements
23 | {
24 | [TestFixture]
25 | public class EmptyStatementTests
26 | {
27 | [Test]
28 | public void EmptyStatementTest()
29 | {
30 | ParseUtilCSharp.ParseStatement(";");
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/ExpressionStatementTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using NUnit.Framework;
21 |
22 | namespace ICSharpCode.NRefactory.CSharp.Parser.Statements
23 | {
24 | [TestFixture]
25 | public class ExpressionStatementTests
26 | {
27 | [Test]
28 | public void StatementExpressionTest()
29 | {
30 | ExpressionStatement stmtExprStmt = ParseUtilCSharp.ParseStatement("a = my.Obj.PropCall;");
31 | Assert.IsTrue(stmtExprStmt.Expression is AssignmentExpression);
32 | }
33 |
34 | [Test]
35 | public void StatementExpressionTest1()
36 | {
37 | ExpressionStatement stmtExprStmt = ParseUtilCSharp.ParseStatement("yield.yield();");
38 | Assert.IsTrue(stmtExprStmt.Expression is InvocationExpression);
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/GotoStatementTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using NUnit.Framework;
21 |
22 | namespace ICSharpCode.NRefactory.CSharp.Parser.Statements
23 | {
24 | [TestFixture]
25 | public class GotoStatementTests
26 | {
27 | [Test]
28 | public void GotoStatementTest()
29 | {
30 | var gotoStmt = ParseUtilCSharp.ParseStatement("goto myLabel;");
31 | Assert.AreEqual("myLabel", gotoStmt.Label);
32 | }
33 |
34 | [Test]
35 | public void GotoDefaultStatementTest()
36 | {
37 | ParseUtilCSharp.ParseStatement("goto default;");
38 | }
39 |
40 | [Test]
41 | public void GotoCaseStatementTest()
42 | {
43 | var gotoCaseStmt = ParseUtilCSharp.ParseStatement("goto case 6;");
44 | Assert.IsTrue(gotoCaseStmt.LabelExpression is PrimitiveExpression);
45 | }
46 |
47 | [Test]
48 | public void BreakStatementTest()
49 | {
50 | ParseUtilCSharp.ParseStatement("break;");
51 | }
52 |
53 | [Test]
54 | public void ContinueStatementTest()
55 | {
56 | ParseUtilCSharp.ParseStatement("continue;");
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/InvalidStatementsTests.cs:
--------------------------------------------------------------------------------
1 | //
2 | // InvalidStatementTests.cs
3 | //
4 | // Author:
5 | // Simon Lindgren
6 | //
7 | // Copyright (c) 2012 Simon Lindgren
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 | using NUnit.Framework;
27 | using ICSharpCode.NRefactory.CSharp;
28 | using ICSharpCode.NRefactory.CSharp.Parser;
29 |
30 | namespace ICSharpCode.NRefactory.CSharp.Parser.Statements
31 | {
32 | [TestFixture]
33 | public class InvalidStatementsTests
34 | {
35 |
36 | [Test]
37 | public void AsExpressionStatementPositions()
38 | {
39 | ExpressionStatement expr = ParseUtilCSharp.ParseStatement("\t\t\"\" as IEnumerable;", false);
40 | Assert.AreEqual(new TextLocation(1, 3), expr.StartLocation);
41 | Assert.AreEqual(new TextLocation(1, 27), expr.EndLocation);
42 | }
43 | }
44 | }
45 |
46 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/LabelStatementTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using System.Linq;
21 | using NUnit.Framework;
22 |
23 | namespace ICSharpCode.NRefactory.CSharp.Parser.Statements
24 | {
25 | [TestFixture]
26 | public class LabelStatementTests
27 | {
28 | [Test]
29 | public void LabelStatementTest()
30 | {
31 | BlockStatement block = ParseUtilCSharp.ParseStatement("{ myLabel: ; }");
32 | LabelStatement labelStmt = (LabelStatement)block.Statements.First();
33 | Assert.AreEqual("myLabel", labelStmt.Label);
34 | }
35 |
36 | [Test]
37 | public void Label2StatementTest()
38 | {
39 | BlockStatement block = ParseUtilCSharp.ParseStatement("{ yield: ; }");
40 | LabelStatement labelStmt = (LabelStatement)block.Statements.First();
41 | Assert.AreEqual("yield", labelStmt.Label);
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/LockStatementTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using NUnit.Framework;
21 |
22 | namespace ICSharpCode.NRefactory.CSharp.Parser.Statements
23 | {
24 | [TestFixture]
25 | public class LockStatementTests
26 | {
27 | [Test]
28 | public void LockStatementTest()
29 | {
30 | ParseUtilCSharp.ParseStatement("lock (myObj) {}");
31 | // TODO : Extend test.
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/ReturnStatementTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using NUnit.Framework;
21 |
22 | namespace ICSharpCode.NRefactory.CSharp.Parser.Statements
23 | {
24 | [TestFixture]
25 | public class ReturnStatementTests
26 | {
27 | [Test]
28 | public void EmptyReturnStatementTest()
29 | {
30 | ReturnStatement returnStatement = ParseUtilCSharp.ParseStatement("return;");
31 | Assert.IsTrue(returnStatement.Expression.IsNull);
32 | }
33 |
34 | [Test]
35 | public void ReturnStatementTest()
36 | {
37 | ReturnStatement returnStatement = ParseUtilCSharp.ParseStatement("return 5;");
38 | Assert.IsTrue(returnStatement.Expression is PrimitiveExpression);
39 | }
40 |
41 | [Test]
42 | public void ReturnStatementTest1()
43 | {
44 | ReturnStatement returnStatement = ParseUtilCSharp.ParseStatement("return yield;");
45 | Assert.IsTrue(returnStatement.Expression is IdentifierExpression);
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/SwitchStatementTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using NUnit.Framework;
21 |
22 | namespace ICSharpCode.NRefactory.CSharp.Parser.Statements
23 | {
24 | [TestFixture]
25 | public class SwitchStatementTests
26 | {
27 | [Test]
28 | public void SwitchStatementTest()
29 | {
30 | SwitchStatement switchStmt = ParseUtilCSharp.ParseStatement("switch (a) { case 4: case 5: break; case 6: break; default: break; }");
31 | Assert.AreEqual("a", ((IdentifierExpression)switchStmt.Expression).Identifier);
32 | // TODO: Extend test
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/ThrowStatementTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using NUnit.Framework;
21 |
22 | namespace ICSharpCode.NRefactory.CSharp.Parser.Statements
23 | {
24 | [TestFixture]
25 | public class ThrowStatementTests
26 | {
27 | [Test]
28 | public void EmptyThrowStatementTest()
29 | {
30 | ThrowStatement throwStmt = ParseUtilCSharp.ParseStatement("throw;");
31 | Assert.IsTrue(throwStmt.Expression.IsNull);
32 | }
33 |
34 | [Test]
35 | public void ThrowStatementTest()
36 | {
37 | ThrowStatement throwStmt = ParseUtilCSharp.ParseStatement("throw new Exception();");
38 | Assert.IsTrue(throwStmt.Expression is ObjectCreateExpression);
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/UnsafeStatementTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using NUnit.Framework;
21 |
22 | namespace ICSharpCode.NRefactory.CSharp.Parser.Statements
23 | {
24 | [TestFixture]
25 | public class UnsafeStatementTests
26 | {
27 | [Test]
28 | public void UnsafeStatementTest()
29 | {
30 | UnsafeStatement unsafeStatement = ParseUtilCSharp.ParseStatement("unsafe { }");
31 | Assert.IsFalse(unsafeStatement.Body.IsNull);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/WhileStatementTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using NUnit.Framework;
21 |
22 | namespace ICSharpCode.NRefactory.CSharp.Parser.Statements
23 | {
24 | [TestFixture]
25 | public class WhileStatementTests
26 | {
27 | [Test]
28 | public void WhileStatementTest()
29 | {
30 | WhileStatement loopStmt = ParseUtilCSharp.ParseStatement("while (true) { }");
31 | Assert.IsTrue(loopStmt.Condition is PrimitiveExpression);
32 | Assert.IsTrue(loopStmt.EmbeddedStatement is BlockStatement);
33 | }
34 |
35 | [Test]
36 | public void DoWhileStatementTest()
37 | {
38 | DoWhileStatement loopStmt = ParseUtilCSharp.ParseStatement("do { } while (true);");
39 | Assert.IsTrue(loopStmt.Condition is PrimitiveExpression);
40 | Assert.IsTrue(loopStmt.EmbeddedStatement is BlockStatement);
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/Parser/TypeMembers/DestructorDeclarationTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using NUnit.Framework;
21 |
22 | namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers
23 | {
24 | [TestFixture]
25 | public class DestructorDeclarationTests
26 | {
27 | [Test]
28 | public void DestructorDeclarationTest()
29 | {
30 | ParseUtilCSharp.ParseTypeMember("~MyClass() {}");
31 | }
32 |
33 | [Test]
34 | public void ExternDestructorDeclarationTest()
35 | {
36 | DestructorDeclaration dd = ParseUtilCSharp.ParseTypeMember("extern ~MyClass();");
37 | Assert.AreEqual(Modifiers.Extern, dd.Modifiers);
38 | }
39 |
40 | [Test]
41 | public void UnsafeDestructorDeclarationTest()
42 | {
43 | DestructorDeclaration dd = ParseUtilCSharp.ParseTypeMember("unsafe ~MyClass() {}");
44 | Assert.AreEqual(Modifiers.Unsafe, dd.Modifiers);
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/CSharp/Refactoring/LambdaHelperTests.cs:
--------------------------------------------------------------------------------
1 | //
2 | // LambdaHelperTests.cs
3 | //
4 | // Author:
5 | // Luís Reis
6 | //
7 | // Copyright (c) 2013 Luís Reis
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 | using NUnit.Framework;
27 | using System;
28 | using System.Linq;
29 | using ICSharpCode.NRefactory.CSharp.Refactoring;
30 | using ICSharpCode.NRefactory.CSharp.CodeActions;
31 | using ICSharpCode.NRefactory.CSharp;
32 |
33 | namespace ICSharpCode.NRefactory.CSharp.Refactoring
34 | {
35 | [TestFixture]
36 | public class LambdaHelperTests
37 | {
38 | RefactoringContext MakeContext(string input, bool expectErrors = false)
39 | {
40 | var context = TestRefactoringContext.Create(input, expectErrors);
41 | return context;
42 | }
43 |
44 | [Test]
45 | public void TestExtensionMethod()
46 | {
47 | string input = @"
48 | using System.Linq;
49 | class Test
50 | {
51 | void Method() {
52 | System.Linq.Enumerable.Empty ().Where(<-i => i > 0->);
53 | }
54 | }
55 | ";
56 |
57 | var context = MakeContext(input);
58 | var lambda = context.GetSelectedNodes().OfType().First();
59 | var type = LambdaHelper.GetLambdaReturnType(context, lambda);
60 |
61 | Assert.AreEqual("System.Boolean", type.ReflectionName);
62 | }
63 | }
64 | }
65 |
66 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/IndentationTests/GeneralTests.cs:
--------------------------------------------------------------------------------
1 | //
2 | // GeneralTests.cs
3 | //
4 | // Author:
5 | // Mike Krüger
6 | //
7 | // Copyright (c) 2013 Xamarin Inc. (http://xamarin.com)
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 | using NUnit.Framework;
27 |
28 | namespace ICSharpCode.NRefactory.IndentationTests
29 | {
30 | [TestFixture]
31 | public class GeneralTests
32 | {
33 | [Test]
34 | public void UsingDeclarationTests()
35 | {
36 | var indent = Helper.CreateEngine("using NUnit.Framework;\n$");
37 | Assert.AreEqual("", indent.ThisLineIndent);
38 | Assert.AreEqual("", indent.NextLineIndent);
39 | }
40 |
41 | [Test]
42 | public void NestedUsingDeclarationTest()
43 | {
44 | var indent = Helper.CreateEngine(@"
45 | namespace Foo {
46 | namespace Bar {
47 | using NUnit.Framework;$");
48 | Assert.AreEqual("\t\t", indent.ThisLineIndent);
49 | Assert.AreEqual("\t\t", indent.NextLineIndent);
50 | }
51 |
52 | [Test]
53 | public void TestMixedLineEndingPosition()
54 | {
55 | var indent = Helper.CreateEngine("\n\r\n$");
56 | Assert.AreEqual(new TextLocation(3, 1), indent.Location);
57 | }
58 | }
59 | }
60 |
61 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/IndentationTests/TestFiles/Comments.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Comment.cs
3 | //
4 | // Author:
5 | // Matej Miklečić
6 | //
7 | // Copyright (c) 2013 Matej Miklečić (matej.miklecic@gmail.com)
8 | //
9 |
10 | namespace Comments
11 | {
12 | ///
13 | /// This is a test file for all types of comments.
14 | ///
15 | class Comments
16 | {
17 | ///
18 | /// Comment method.
19 | ///
20 | ///
21 | /// Id.
22 | ///
23 | void Comment(int id, // id
24 | string text) // text
25 | {
26 | int i; // i
27 |
28 | for (i = 0; i < 42 /* 42; */; i++) /*
29 | * Multi-line
30 | */
31 | {
32 | // break
33 | break;
34 | } // for
35 |
36 | /////////*
37 |
38 | while (true)
39 | // comments don't affect continuation
40 | ;
41 |
42 | /********/ if (false) lock (this)
43 | // /*
44 | ;
45 |
46 | { /*/*/ }
47 | }
48 | /*/ still in comment } */
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/IndentationTests/TestFiles/InheritStatements.cs:
--------------------------------------------------------------------------------
1 | namespace InheritStatements
2 | {
3 | class A : B where T : B
4 | {
5 | A() : base()
6 | {
7 | base();
8 | }
9 | }
10 |
11 | class C
12 | : D where T
13 | : D
14 | {
15 | C()
16 | : this(this.ToString())
17 | {
18 | throw this;
19 | }
20 |
21 | C(object c)
22 | : base()
23 | {
24 | base();
25 | }
26 | }
27 |
28 | class E :
29 | F
30 | where T : F
31 | {
32 | E() :
33 | base()
34 | {
35 | base();
36 | }
37 | }
38 |
39 | class X
40 | {
41 | X()
42 | {
43 | var t = this.ToString();
44 | var b = t == "X"
45 | ? true
46 | : false;
47 |
48 | if (b) goto x;
49 |
50 | switch (t)
51 | {
52 | default:
53 | y: throw null;
54 | }
55 |
56 | x: ;
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/IndentationTests/TestFiles/PreProcessorDirectives.cs:
--------------------------------------------------------------------------------
1 | #if !DEBUG
2 | #define DEBUG
3 | #endif
4 |
5 | #if TRACE
6 | #undef TRACE
7 | #endif
8 |
9 | namespace PreProcessorDirectives
10 | {
11 | class PreProcessorDirectives
12 | {
13 | void IfDebug()
14 | {
15 | #region If/Elif Directives
16 |
17 | #if DEBUG
18 | {
19 | // This block should be correctly indented
20 | }
21 | #elif true
22 | {
23 | // This comment is not indented since the #if was true
24 | }
25 | #endif
26 |
27 | #if TRACE
28 | {
29 | // Not indented
30 | }
31 | #elif debug
32 | {
33 | // Also not indented
34 | }
35 | #else
36 | {
37 | // This should be indented
38 | }
39 | #endif
40 |
41 | #endregion
42 | }
43 |
44 | #region One-line directives
45 |
46 | void OneLiners
47 | {
48 | //
49 | #pragma warning disable 649
50 | //
51 | #warning 649
52 | //
53 | #line 649
54 | //
55 | #error 649
56 | //
57 | }
58 |
59 | #endregion
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/IndentationTests/TestFiles/Simple.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace SimpleNamespace
4 | {
5 | class SimpleClass
6 | {
7 | void SimpleMethod()
8 | {
9 | // simple comment
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/IndentationTests/TestFiles/Strings.cs:
--------------------------------------------------------------------------------
1 | namespace Strings
2 | {
3 | class Strings
4 | {
5 | void Strings(string s = "")
6 | {
7 | s = @"""
8 | can't escape a verbatim string \";
9 | s = @"" "not in verbatim anymore
10 | ;
11 | s = "";
12 | s = "\\";
13 | s = "\\\\\\\"";
14 | s = " // syntax error, but on the next line we start with the previous state
15 | ;
16 | s = "'c\'";
17 | string concat = "line 1" +
18 | "line 2" +
19 | "line 3";
20 |
21 | var c = '\\';
22 | c = '\'';
23 | c = ' // syntax error, but on the next line we start with the previous state
24 | ;
25 | c = ';';
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/IndentationTests/TestFiles/SwitchCase.cs:
--------------------------------------------------------------------------------
1 | ///
2 | /// Switch case with CSharpFormattingOptions.IndentBreakStatements = false;
3 | ///
4 | class SwitchCase
5 | {
6 | void Main(int param)
7 | {
8 | switch (param)
9 | {
10 | case 1:
11 | while (true)
12 | {
13 | break;
14 | continue;
15 | return;
16 | goto case 2;
17 | goto default;
18 | }
19 | break;
20 | case 2:
21 | // ...
22 | continue;
23 | case 3:
24 | // ...
25 | return;
26 | case 4:
27 | // ...
28 | goto default;
29 | default:
30 | // ...
31 | goto case 1;
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | #region Using directives
2 |
3 | using System;
4 | using System.Reflection;
5 | using System.Runtime.InteropServices;
6 |
7 | #endregion
8 |
9 | // General Information about an assembly is controlled through the following
10 | // set of attributes. Change these attribute values to modify the information
11 | // associated with an assembly.
12 | [assembly: AssemblyTitle("ICSharpCode.NRefactory.Tests")]
13 | [assembly: AssemblyDescription("NRefactory unit tests")]
14 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/TypeSystem/LazyLoadedCecilLoaderTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using ICSharpCode.NRefactory.TypeSystem.Implementation;
21 | using NUnit.Framework;
22 |
23 | namespace ICSharpCode.NRefactory.TypeSystem
24 | {
25 | [TestFixture]
26 | public class LazyLoadedCecilLoaderTests : TypeSystemTests
27 | {
28 | [TestFixtureSetUp]
29 | public void FixtureSetUp()
30 | {
31 | CecilLoader loader = new CecilLoader() { IncludeInternalMembers = true, LazyLoad = true };
32 | IUnresolvedAssembly pc = loader.LoadAssemblyFile(typeof(TestCase.SimplePublicClass).Assembly.Location);
33 | base.compilation = new SimpleCompilation(pc, CecilLoaderTests.Mscorlib);
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/TypeSystem/SerializedCecilLoaderTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using System.IO;
21 | using ICSharpCode.NRefactory.TypeSystem.Implementation;
22 | using ICSharpCode.NRefactory.Utils;
23 | using NUnit.Framework;
24 |
25 | namespace ICSharpCode.NRefactory.TypeSystem
26 | {
27 | [TestFixture]
28 | public class SerializedCecilLoaderTests : TypeSystemTests
29 | {
30 | [TestFixtureSetUp]
31 | public void FixtureSetUp()
32 | {
33 | CecilLoader loader = new CecilLoader() { IncludeInternalMembers = true };
34 | IUnresolvedAssembly pc = loader.LoadAssemblyFile(typeof(TestCase.SimplePublicClass).Assembly.Location);
35 | FastSerializer serializer = new FastSerializer();
36 | using (MemoryStream ms = new MemoryStream()) {
37 | serializer.Serialize(ms, pc);
38 | ms.Position = 0;
39 | var asm = (IUnresolvedAssembly)serializer.Deserialize(ms);
40 | base.compilation = new SimpleCompilation(asm, CecilLoaderTests.Mscorlib);
41 | }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/TypeSystem/SerializedIkvmLoaderTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using System.IO;
21 | using ICSharpCode.NRefactory.TypeSystem.Implementation;
22 | using ICSharpCode.NRefactory.Utils;
23 | using NUnit.Framework;
24 |
25 | namespace ICSharpCode.NRefactory.TypeSystem
26 | {
27 | [TestFixture]
28 | public class SerializedIkvmLoaderTests : TypeSystemTests
29 | {
30 | [TestFixtureSetUp]
31 | public void FixtureSetUp()
32 | {
33 | IkvmLoader loader = new IkvmLoader() { IncludeInternalMembers = true };
34 | IUnresolvedAssembly pc = loader.LoadAssemblyFile(typeof(TestCase.SimplePublicClass).Assembly.Location);
35 | FastSerializer serializer = new FastSerializer();
36 | using (MemoryStream ms = new MemoryStream()) {
37 | serializer.Serialize(ms, pc);
38 | ms.Position = 0;
39 | var asm = (IUnresolvedAssembly)serializer.Deserialize(ms);
40 | base.compilation = new SimpleCompilation(asm, IkvmLoaderTests.Mscorlib);
41 | }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/Utils/TreeTraversalTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using System.Collections.Generic;
21 | using System.Linq;
22 | using NUnit.Framework;
23 |
24 | namespace ICSharpCode.NRefactory.Utils
25 | {
26 | [TestFixture]
27 | public class TreeTraversalTests
28 | {
29 | sealed class Node
30 | {
31 | public int Data;
32 | public List Children = new List();
33 | }
34 |
35 | Node tree = new Node {
36 | Data = 1,
37 | Children = {
38 | new Node { Data = 2 },
39 | new Node { Data = 3,
40 | Children = {
41 | new Node { Data = 4 },
42 | new Node { Data = 5 }
43 | } },
44 | new Node { Data = 6, Children = null }
45 | }
46 | };
47 |
48 | [Test]
49 | public void PreOrder()
50 | {
51 | Assert.AreEqual(new int[] { 1, 2, 3, 4, 5, 6 },
52 | TreeTraversal.PreOrder(tree, n => n.Children).Select(n => n.Data).ToArray());
53 | }
54 |
55 | [Test]
56 | public void PostOrder()
57 | {
58 | Assert.AreEqual(new int[] { 2, 4, 5, 3, 6, 1 },
59 | TreeTraversal.PostOrder(tree, n => n.Children).Select(n => n.Data).ToArray());
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.Tests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dnSpy/NRefactory/79d99d6fc3ff5b2c95ffa4861f0294a6c6b894c6/ICSharpCode.NRefactory.snk
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/Documentation/IDocumentationProvider.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using System.IO;
21 | using ICSharpCode.NRefactory.TypeSystem;
22 |
23 | namespace ICSharpCode.NRefactory.Documentation
24 | {
25 | ///
26 | /// Provides XML documentation for entities.
27 | ///
28 | public interface IDocumentationProvider
29 | {
30 | ///
31 | /// Gets the XML documentation for the specified entity.
32 | ///
33 | DocumentationComment GetDocumentation(IEntity entity);
34 | }
35 |
36 | ///
37 | /// Provides XML documentation for entities.
38 | ///
39 | public interface IUnresolvedDocumentationProvider
40 | {
41 | ///
42 | /// Gets the XML documentation for the specified entity.
43 | ///
44 | string GetDocumentation(IUnresolvedEntity entity);
45 |
46 | ///
47 | /// Gets the XML documentation for the specified entity.
48 | ///
49 | DocumentationComment GetDocumentation(IUnresolvedEntity entity, IEntity resolvedEntity);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | True
7 | ..\ICSharpCode.NRefactory.snk
8 | 1591,1685
9 | false
10 | false
11 | false
12 | false
13 | false
14 | false
15 | false
16 | false
17 | false
18 | false
19 | Auto
20 |
21 |
22 |
23 | $(DefineConstants);NET_4_5;NET_4_6
24 | True
25 |
26 |
27 | $(DefineConstants);NET_4_5;NET_4_6
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/PatternMatching/AnyNode.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2011-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 |
21 | namespace ICSharpCode.NRefactory.PatternMatching
22 | {
23 | ///
24 | /// Matches any node.
25 | ///
26 | /// Does not match null nodes.
27 | public class AnyNode : Pattern
28 | {
29 | readonly string groupName;
30 |
31 | public string GroupName {
32 | get { return groupName; }
33 | }
34 |
35 | public AnyNode(string groupName = null)
36 | {
37 | this.groupName = groupName;
38 | }
39 |
40 | public override bool DoMatch(INode other, Match match)
41 | {
42 | match.Add(this.groupName, other);
43 | return other != null && !other.IsNull;
44 | }
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/PatternMatching/AnyNodeOrNull.cs:
--------------------------------------------------------------------------------
1 | //
2 | // AnyNodeOrNull.cs
3 | //
4 | // Author:
5 | // Mike Krüger
6 | //
7 | // Copyright (c) 2013 Xamarin Inc. (http://xamarin.com)
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 |
27 | using System;
28 |
29 | namespace ICSharpCode.NRefactory.PatternMatching
30 | {
31 | ///
32 | /// Matches any node.
33 | ///
34 | /// Does not match null nodes.
35 | public class AnyNodeOrNull : Pattern
36 | {
37 | readonly string groupName;
38 |
39 | public string GroupName {
40 | get { return groupName; }
41 | }
42 |
43 | public AnyNodeOrNull(string groupName = null)
44 | {
45 | this.groupName = groupName;
46 | }
47 |
48 | public override bool DoMatch(INode other, Match match)
49 | {
50 | if (other == null) {
51 | match.AddNull(this.groupName);
52 | } else {
53 | match.Add(this.groupName, other);
54 | }
55 | return true;
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/PatternMatching/Backreference.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2011-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using System.Linq;
21 |
22 | namespace ICSharpCode.NRefactory.PatternMatching
23 | {
24 | ///
25 | /// Matches the last entry in the specified named group.
26 | ///
27 | public class Backreference : Pattern
28 | {
29 | readonly string referencedGroupName;
30 |
31 | public string ReferencedGroupName {
32 | get { return referencedGroupName; }
33 | }
34 |
35 | public Backreference(string referencedGroupName)
36 | {
37 | if (referencedGroupName == null)
38 | throw new ArgumentNullException("referencedGroupName");
39 | this.referencedGroupName = referencedGroupName;
40 | }
41 |
42 | public override bool DoMatch(INode other, Match match)
43 | {
44 | var last = match.Get (referencedGroupName).Last ();
45 | if (last == null && other == null)
46 | return true;
47 | return last.IsMatch(other);
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/PatternMatching/BacktrackingInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2011-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using System.Collections.Generic;
21 | using System.Linq;
22 |
23 | namespace ICSharpCode.NRefactory.PatternMatching
24 | {
25 | ///
26 | /// Container for the backtracking info.
27 | ///
28 | public class BacktrackingInfo
29 | {
30 | internal Stack backtrackingStack = new Stack();
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/PatternMatching/NamedNode.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2011-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 |
21 | namespace ICSharpCode.NRefactory.PatternMatching
22 | {
23 | ///
24 | /// Represents a named node within a pattern.
25 | ///
26 | public class NamedNode : Pattern
27 | {
28 | readonly string groupName;
29 | readonly INode childNode;
30 |
31 | public string GroupName {
32 | get { return groupName; }
33 | }
34 |
35 | public INode ChildNode {
36 | get { return childNode; }
37 | }
38 |
39 | public NamedNode(string groupName, INode childNode)
40 | {
41 | if (childNode == null)
42 | throw new ArgumentNullException("childNode");
43 | this.groupName = groupName;
44 | this.childNode = childNode;
45 | }
46 |
47 | public override bool DoMatch(INode other, Match match)
48 | {
49 | match.Add(this.groupName, other);
50 | return childNode.DoMatch(other, match);
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/PatternMatching/OptionalNode.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2011-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using System.Collections.Generic;
21 | using System.Diagnostics;
22 |
23 | namespace ICSharpCode.NRefactory.PatternMatching
24 | {
25 | public class OptionalNode : Pattern
26 | {
27 | readonly INode childNode;
28 |
29 | public INode ChildNode {
30 | get { return childNode; }
31 | }
32 |
33 | public OptionalNode(INode childNode)
34 | {
35 | if (childNode == null)
36 | throw new ArgumentNullException("childNode");
37 | this.childNode = childNode;
38 | }
39 |
40 | public OptionalNode(string groupName, INode childNode) : this(new NamedNode(groupName, childNode))
41 | {
42 | }
43 |
44 | public override bool DoMatchCollection(Role role, INode pos, Match match, BacktrackingInfo backtrackingInfo)
45 | {
46 | backtrackingInfo.backtrackingStack.Push(new PossibleMatch(pos, match.CheckPoint()));
47 | return childNode.DoMatch(pos, match);
48 | }
49 |
50 | public override bool DoMatch(INode other, Match match)
51 | {
52 | if (other == null || other.IsNull)
53 | return true;
54 | else
55 | return childNode.DoMatch(other, match);
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/Properties/GlobalAssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | #region Using directives
20 |
21 | using System.Reflection;
22 | using System.Runtime.InteropServices;
23 |
24 | #endregion
25 |
26 | // General Information about an assembly is controlled through the following
27 | // set of attributes. Change these attribute values to modify the information
28 | // associated with an assembly.
29 | [assembly: AssemblyCompany("ICSharpCode")]
30 | [assembly: AssemblyProduct("SharpDevelop/MonoDevelop")]
31 | [assembly: AssemblyCopyright("Copyright 2010-2014 AlphaSierraPapa and Xamarin Inc.")]
32 |
33 | // This sets the default COM visibility of types in the assembly to invisible.
34 | // If you need to expose a type to COM, use [ComVisible(true)] on that type.
35 | [assembly: ComVisible(false)]
36 |
37 | // We keep the AssemblyVersion at 5.0.0.0 for all versions of NRefactory 5.
38 | // This eliminates the need for binding redirects.
39 | [assembly: AssemblyVersion("5.0.0.0")]
40 |
41 | // [AssemblyFileVersion] is the version of the NuGet package,
42 | // Versions with breaking changes / new features should increment the 'minor' (2nd) number.
43 | // Bugfix releases should increment the 'build' (3rd) number.
44 | [assembly: AssemblyFileVersion("5.5.1")]
45 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/Semantics/AmbiguousResolveResult.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using ICSharpCode.NRefactory.TypeSystem;
21 |
22 | namespace ICSharpCode.NRefactory.Semantics
23 | {
24 | ///
25 | /// Represents an ambiguous type resolve result.
26 | ///
27 | public class AmbiguousTypeResolveResult : TypeResolveResult
28 | {
29 | public AmbiguousTypeResolveResult(IType type) : base(type)
30 | {
31 | }
32 |
33 | public override bool IsError {
34 | get { return true; }
35 | }
36 | }
37 |
38 | ///
39 | /// Represents an ambiguous field/property/event access.
40 | ///
41 | public class AmbiguousMemberResolveResult : MemberResolveResult
42 | {
43 | public AmbiguousMemberResolveResult(ResolveResult targetResult, IMember member) : base(targetResult, member)
44 | {
45 | }
46 |
47 | public override bool IsError {
48 | get { return true; }
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/Semantics/ArrayAccessResolveResult.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using System.Collections.Generic;
21 | using System.Linq;
22 | using ICSharpCode.NRefactory.TypeSystem;
23 | using ICSharpCode.NRefactory.Utils;
24 |
25 | namespace ICSharpCode.NRefactory.Semantics
26 | {
27 | ///
28 | /// Resolve result representing an array access.
29 | ///
30 | public class ArrayAccessResolveResult : ResolveResult
31 | {
32 | public readonly ResolveResult Array;
33 | public readonly IList Indexes;
34 |
35 | public ArrayAccessResolveResult(IType elementType, ResolveResult array, IList indexes) : base(elementType)
36 | {
37 | if (array == null)
38 | throw new ArgumentNullException("array");
39 | if (indexes == null)
40 | throw new ArgumentNullException("indexes");
41 | this.Array = array;
42 | this.Indexes = indexes;
43 | }
44 |
45 | public override IEnumerable GetChildResults()
46 | {
47 | return new [] { Array }.Concat(Indexes);
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/Semantics/InitializedObjectResolveResult.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using ICSharpCode.NRefactory.TypeSystem;
21 |
22 | namespace ICSharpCode.NRefactory.Semantics
23 | {
24 | ///
25 | /// Refers to the object that is currently being initialized.
26 | /// Used within .
27 | ///
28 | public class InitializedObjectResolveResult : ResolveResult
29 | {
30 | public InitializedObjectResolveResult(IType type) : base(type)
31 | {
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/Semantics/NamespaceResolveResult.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using System.Globalization;
21 | using ICSharpCode.NRefactory.TypeSystem;
22 |
23 | namespace ICSharpCode.NRefactory.Semantics
24 | {
25 | ///
26 | /// Represents that an expression resolved to a namespace.
27 | ///
28 | public class NamespaceResolveResult : ResolveResult
29 | {
30 | readonly INamespace ns;
31 |
32 | public NamespaceResolveResult(INamespace ns) : base(SpecialType.UnknownType)
33 | {
34 | this.ns = ns;
35 | }
36 |
37 | public INamespace Namespace {
38 | get { return ns; }
39 | }
40 |
41 | public string NamespaceName {
42 | get { return ns.FullName; }
43 | }
44 |
45 | public override string ToString()
46 | {
47 | return string.Format(CultureInfo.InvariantCulture, "[{0} {1}]", GetType().Name, ns);
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/Semantics/ThisResolveResult.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using ICSharpCode.NRefactory.TypeSystem;
21 |
22 | namespace ICSharpCode.NRefactory.Semantics
23 | {
24 | ///
25 | /// Represents the 'this' reference.
26 | /// Also used for the 'base' reference.
27 | ///
28 | public class ThisResolveResult : ResolveResult
29 | {
30 | bool causesNonVirtualInvocation;
31 |
32 | public ThisResolveResult(IType type, bool causesNonVirtualInvocation = false) : base(type)
33 | {
34 | this.causesNonVirtualInvocation = causesNonVirtualInvocation;
35 | }
36 |
37 | ///
38 | /// Gets whether this resolve result causes member invocations to be non-virtual.
39 | ///
40 | public bool CausesNonVirtualInvocation {
41 | get { return causesNonVirtualInvocation; }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/Semantics/TypeIsResolveResult.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using ICSharpCode.NRefactory.TypeSystem;
21 |
22 | namespace ICSharpCode.NRefactory.Semantics
23 | {
24 | ///
25 | /// Resolve result for a C# 'is' expression.
26 | /// "Input is TargetType".
27 | ///
28 | public class TypeIsResolveResult : ResolveResult
29 | {
30 | public readonly ResolveResult Input;
31 | ///
32 | /// Type that is being compared with.
33 | ///
34 | public readonly IType TargetType;
35 |
36 | public TypeIsResolveResult(ResolveResult input, IType targetType, IType booleanType)
37 | : base(booleanType)
38 | {
39 | if (input == null)
40 | throw new ArgumentNullException("input");
41 | if (targetType == null)
42 | throw new ArgumentNullException("targetType");
43 | this.Input = input;
44 | this.TargetType = targetType;
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/Semantics/TypeOfResolveResult.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using ICSharpCode.NRefactory.TypeSystem;
21 |
22 | namespace ICSharpCode.NRefactory.Semantics
23 | {
24 | ///
25 | /// Represents the 'typeof'.
26 | ///
27 | public class TypeOfResolveResult : ResolveResult
28 | {
29 | readonly IType referencedType;
30 |
31 | public TypeOfResolveResult(IType systemType, IType referencedType)
32 | : base(systemType)
33 | {
34 | if (referencedType == null)
35 | throw new ArgumentNullException("referencedType");
36 | this.referencedType = referencedType;
37 | }
38 |
39 | ///
40 | /// The type referenced by the 'typeof'.
41 | ///
42 | public IType ReferencedType {
43 | get { return referencedType; }
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/Semantics/TypeResolveResult.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using ICSharpCode.NRefactory.TypeSystem;
21 |
22 | namespace ICSharpCode.NRefactory.Semantics
23 | {
24 | ///
25 | /// The resolved expression refers to a type name.
26 | ///
27 | public class TypeResolveResult : ResolveResult
28 | {
29 | public TypeResolveResult(IType type)
30 | : base(type)
31 | {
32 | }
33 |
34 | public override bool IsError {
35 | get { return this.Type.Kind == TypeKind.Unknown; }
36 | }
37 |
38 | public override DomRegion GetDefinitionRegion()
39 | {
40 | ITypeDefinition def = this.Type.GetDefinition();
41 | if (def != null)
42 | return def.Region;
43 | else
44 | return DomRegion.Empty;
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/TypeSystem/ICodeContext.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using System.Collections.Generic;
21 |
22 | namespace ICSharpCode.NRefactory.TypeSystem
23 | {
24 | public interface ICodeContext : ITypeResolveContext
25 | {
26 | ///
27 | /// Gets all currently visible local variables and lambda parameters.
28 | /// Does not include method parameters.
29 | ///
30 | IEnumerable LocalVariables { get; }
31 |
32 | ///
33 | /// Gets whether the context is within a lambda expression or anonymous method.
34 | ///
35 | bool IsWithinLambdaExpression { get; }
36 | }
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/TypeSystem/IConstantValue.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using System.Diagnostics.Contracts;
21 | using ICSharpCode.NRefactory.Semantics;
22 |
23 | namespace ICSharpCode.NRefactory.TypeSystem
24 | {
25 | ///
26 | /// Represents an unresolved constant value.
27 | ///
28 | public interface IConstantValue
29 | {
30 | ///
31 | /// Resolves the value of this constant.
32 | ///
33 | /// Context where the constant value will be used.
34 | /// Resolve result representing the constant value.
35 | /// This method never returns null; in case of errors, an ErrorResolveResult will be returned.
36 | ResolveResult Resolve(ITypeResolveContext context);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/TypeSystem/IFreezable.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 |
21 | namespace ICSharpCode.NRefactory.TypeSystem
22 | {
23 | public interface IFreezable
24 | {
25 | ///
26 | /// Gets if this instance is frozen. Frozen instances are immutable and thus thread-safe.
27 | ///
28 | bool IsFrozen { get; }
29 |
30 | ///
31 | /// Freezes this instance.
32 | ///
33 | void Freeze();
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/TypeSystem/IParameterizedMember.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using System.Collections.Generic;
21 | using System.Diagnostics.Contracts;
22 |
23 | namespace ICSharpCode.NRefactory.TypeSystem
24 | {
25 | ///
26 | /// Represents a method or property.
27 | ///
28 | public interface IUnresolvedParameterizedMember : IUnresolvedMember
29 | {
30 | IList Parameters { get; }
31 | }
32 |
33 | ///
34 | /// Represents a method or property.
35 | ///
36 | public interface IParameterizedMember : IMember
37 | {
38 | IList Parameters { get; }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/TypeSystem/ISolutionSnapshot.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 |
21 | namespace ICSharpCode.NRefactory.TypeSystem
22 | {
23 | ///
24 | /// Represents a snapshot of the whole solution (multiple compilations).
25 | ///
26 | public interface ISolutionSnapshot
27 | {
28 | ///
29 | /// Gets the project content with the specified file name.
30 | /// Returns null if no such project exists in the solution.
31 | ///
32 | ///
33 | /// This method is used by the class.
34 | ///
35 | IProjectContent GetProjectContent(string projectFileName);
36 |
37 | ///
38 | /// Gets the compilation for the specified project.
39 | /// The project must be a part of the solution (passed to the solution snapshot's constructor).
40 | ///
41 | ICompilation GetCompilation(IProjectContent project);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/TypeSystem/ISupportsInterning.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 |
21 | namespace ICSharpCode.NRefactory.TypeSystem
22 | {
23 | ///
24 | /// Interface for TypeSystem objects that support interning.
25 | /// See for more information.
26 | ///
27 | public interface ISupportsInterning
28 | {
29 | ///
30 | /// Gets a hash code for interning.
31 | ///
32 | int GetHashCodeForInterning();
33 |
34 | ///
35 | /// Equality test for interning.
36 | ///
37 | bool EqualsForInterning(ISupportsInterning other);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/TypeSystem/IVariable.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 |
21 | namespace ICSharpCode.NRefactory.TypeSystem
22 | {
23 | ///
24 | /// Represents a variable (name/type pair).
25 | ///
26 | public interface IVariable : ISymbol
27 | {
28 | ///
29 | /// Gets the name of the variable.
30 | ///
31 | new string Name { get; }
32 |
33 | ///
34 | /// Gets the declaration region of the variable.
35 | ///
36 | DomRegion Region { get; }
37 |
38 | ///
39 | /// Gets the type of the variable.
40 | ///
41 | IType Type { get; }
42 |
43 | ///
44 | /// Gets whether this variable is a constant (C#-like const).
45 | ///
46 | bool IsConst { get; }
47 |
48 | ///
49 | /// If this field is a constant, retrieves the value.
50 | /// For parameters, this is the default value.
51 | ///
52 | object ConstantValue { get; }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/TypeSystem/Implementation/AccessorOwnerMemberReference.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 |
21 | namespace ICSharpCode.NRefactory.TypeSystem.Implementation
22 | {
23 | ///
24 | /// Given a reference to an accessor, returns the accessor's owner.
25 | ///
26 | [Serializable]
27 | sealed class AccessorOwnerMemberReference : IMemberReference
28 | {
29 | readonly IMemberReference accessorReference;
30 |
31 | public AccessorOwnerMemberReference(IMemberReference accessorReference)
32 | {
33 | if (accessorReference == null)
34 | throw new ArgumentNullException("accessorReference");
35 | this.accessorReference = accessorReference;
36 | }
37 |
38 | public ITypeReference DeclaringTypeReference {
39 | get { return accessorReference.DeclaringTypeReference; }
40 | }
41 |
42 | public IMember Resolve(ITypeResolveContext context)
43 | {
44 | IMethod method = accessorReference.Resolve(context) as IMethod;
45 | if (method != null)
46 | return method.AccessorOwner;
47 | else
48 | return null;
49 | }
50 |
51 | ISymbol ISymbolReference.Resolve(ITypeResolveContext context)
52 | {
53 | return ((IMemberReference)this).Resolve(context);
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/TypeSystem/Implementation/FullNameAndTypeParameterCount.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using System.Collections.Generic;
21 |
22 | namespace ICSharpCode.NRefactory.TypeSystem.Implementation
23 | {
24 | [Obsolete("This struct was renamed to 'TopLevelTypeName'.", true)]
25 | public struct FullNameAndTypeParameterCount
26 | {
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/TypeSystem/Implementation/SpecializedField.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 |
21 | namespace ICSharpCode.NRefactory.TypeSystem.Implementation
22 | {
23 | ///
24 | /// Represents a specialized IField (field after type substitution).
25 | ///
26 | public class SpecializedField : SpecializedMember, IField
27 | {
28 | readonly IField fieldDefinition;
29 |
30 | public SpecializedField(IField fieldDefinition, TypeParameterSubstitution substitution)
31 | : base(fieldDefinition)
32 | {
33 | this.fieldDefinition = fieldDefinition;
34 | AddSubstitution(substitution);
35 | }
36 |
37 | public bool IsReadOnly {
38 | get { return fieldDefinition.IsReadOnly; }
39 | }
40 |
41 | public bool IsVolatile {
42 | get { return fieldDefinition.IsVolatile; }
43 | }
44 |
45 | IType IVariable.Type {
46 | get { return this.ReturnType; }
47 | }
48 |
49 | public bool IsConst {
50 | get { return fieldDefinition.IsConst; }
51 | }
52 |
53 | public bool IsFixed {
54 | get { return fieldDefinition.IsFixed; }
55 | }
56 |
57 | public object ConstantValue {
58 | get { return fieldDefinition.ConstantValue; }
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/TypeSystem/TypeVisitor.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 |
21 | namespace ICSharpCode.NRefactory.TypeSystem
22 | {
23 | ///
24 | /// Base class for the visitor pattern on .
25 | ///
26 | public abstract class TypeVisitor
27 | {
28 | public virtual IType VisitTypeDefinition(ITypeDefinition type)
29 | {
30 | return type.VisitChildren(this);
31 | }
32 |
33 | public virtual IType VisitTypeParameter(ITypeParameter type)
34 | {
35 | return type.VisitChildren(this);
36 | }
37 |
38 | public virtual IType VisitParameterizedType(ParameterizedType type)
39 | {
40 | return type.VisitChildren(this);
41 | }
42 |
43 | public virtual IType VisitArrayType(ArrayType type)
44 | {
45 | return type.VisitChildren(this);
46 | }
47 |
48 | public virtual IType VisitPointerType(PointerType type)
49 | {
50 | return type.VisitChildren(this);
51 | }
52 |
53 | public virtual IType VisitByReferenceType(ByReferenceType type)
54 | {
55 | return type.VisitChildren(this);
56 | }
57 |
58 | public virtual IType VisitOtherType(IType type)
59 | {
60 | return type.VisitChildren(this);
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/Utils/CompositeFormatStringParser/FormatStringSegmentBase.cs:
--------------------------------------------------------------------------------
1 | //
2 | // FormatStringSegmentBase.cs
3 | //
4 | // Author:
5 | // Simon Lindgren
6 | //
7 | // Copyright (c) 2012 Simon Lindgren
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 | using System.Collections.Generic;
27 | using System.Linq;
28 |
29 | namespace ICSharpCode.NRefactory.Utils
30 | {
31 | ///
32 | /// Composite format string parser.
33 | ///
34 | ///
35 | /// Implements a complete parser for valid strings as well as
36 | /// error reporting and best-effort parsing for invalid strings.
37 | ///
38 | public abstract class FormatStringSegmentBase : IFormatStringSegment
39 | {
40 | public FormatStringSegmentBase ()
41 | {
42 | Errors = new List ();
43 | }
44 |
45 | #region IFormatStringSegment implementation
46 | public int StartLocation { get; set; }
47 |
48 | public int EndLocation { get; set; }
49 |
50 | public bool HasErrors {
51 | get {
52 | return Errors.Any ();
53 | }
54 | }
55 |
56 | public IList Errors { get; set; }
57 |
58 | IEnumerable IFormatStringSegment.Errors {
59 | get {
60 | return Errors;
61 | }
62 | }
63 | #endregion
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/Utils/CompositeFormatStringParser/IFormatStringSegment.cs:
--------------------------------------------------------------------------------
1 | //
2 | // IFormatStringSegment.cs
3 | //
4 | // Author:
5 | // Simon Lindgren
6 | //
7 | // Copyright (c) 2012 Simon Lindgren
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 | using System.Collections.Generic;
27 |
28 | namespace ICSharpCode.NRefactory.Utils
29 | {
30 | ///
31 | /// Composite format string parser.
32 | ///
33 | ///
34 | /// Implements a complete parser for valid strings as well as
35 | /// error reporting and best-effort parsing for invalid strings.
36 | ///
37 | public interface IFormatStringSegment
38 | {
39 | int StartLocation { get; set; }
40 |
41 | int EndLocation { get; set; }
42 |
43 | bool HasErrors { get; }
44 |
45 | IEnumerable Errors { get; }
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/Utils/ExtensionMethods.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using System.Collections.Generic;
21 |
22 | namespace ICSharpCode.NRefactory.Utils
23 | {
24 | ///
25 | /// Contains extension methods for use within NRefactory.
26 | ///
27 | static class ExtensionMethods
28 | {
29 | public static void AddRange(this ICollection target, IEnumerable input)
30 | {
31 | foreach (T item in input)
32 | target.Add(item);
33 | }
34 |
35 | public static Predicate And(this Predicate filter1, Predicate filter2)
36 | {
37 | if (filter1 == null)
38 | return filter2;
39 | if (filter2 == null)
40 | return filter1;
41 | return m => filter1(m) && filter2(m);
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/Utils/LazyInit.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using System.Threading;
21 |
22 | namespace ICSharpCode.NRefactory.Utils
23 | {
24 | public static class LazyInit
25 | {
26 | public static T VolatileRead(ref T location) where T : class
27 | {
28 | #if NET_4_5
29 | return Volatile.Read(ref location);
30 | #else
31 | T result = location;
32 | Thread.MemoryBarrier();
33 | return result;
34 | #endif
35 | }
36 |
37 | ///
38 | /// Atomically performs the following operation:
39 | /// - If target is null: stores newValue in target and returns newValue.
40 | /// - If target is not null: returns target.
41 | ///
42 | public static T GetOrSet(ref T target, T newValue) where T : class
43 | {
44 | T oldValue = Interlocked.CompareExchange(ref target, newValue, null);
45 | return oldValue ?? newValue;
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/Utils/Platform.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 |
21 | namespace ICSharpCode.NRefactory.Utils
22 | {
23 | ///
24 | /// Platform-specific code.
25 | ///
26 | public static class Platform
27 | {
28 | public static StringComparer FileNameComparer {
29 | get {
30 | switch (Environment.OSVersion.Platform) {
31 | case PlatformID.Unix:
32 | case PlatformID.MacOSX:
33 | return StringComparer.Ordinal;
34 | default:
35 | return StringComparer.OrdinalIgnoreCase;
36 | }
37 | }
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/ICSharpCode.NRefactory/Utils/ReferenceComparer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | // software and associated documentation files (the "Software"), to deal in the Software
5 | // without restriction, including without limitation the rights to use, copy, modify, merge,
6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7 | // to whom the Software is furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in all copies or
10 | // substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 | // DEALINGS IN THE SOFTWARE.
18 |
19 | using System;
20 | using System.Collections.Generic;
21 | using System.Runtime.CompilerServices;
22 |
23 | namespace ICSharpCode.NRefactory.Utils
24 | {
25 | public sealed class ReferenceComparer : IEqualityComparer