├── NRefactory ├── .gitattributes ├── .gitignore ├── ICSharpCode.NRefactory.snk ├── ICSharpCode.NRefactory.CSharp │ ├── Parser │ │ └── mcs │ │ │ └── visit.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Ast │ │ └── TokenRole.cs │ └── Refactoring │ │ ├── CodeActions │ │ └── SpecializedCodeAction.cs │ │ ├── ICodeActionProvider.cs │ │ ├── CodeIssues │ │ └── ParameterCanBeDemotedIssue │ │ │ └── IsArrayTypeCriterion.cs │ │ └── ContextActionAttribute.cs ├── ICSharpCode.NRefactory.GtkDemo │ ├── pixbuf │ │ ├── comment.png │ │ ├── element-class-16.png │ │ ├── element-field-16.png │ │ ├── element-literal-16.png │ │ ├── element-method-16.png │ │ └── element-namespace-16.png │ ├── CSharpDemo.cs │ ├── gtk-gui │ │ └── generated.cs │ └── Main.cs ├── ICSharpCode.NRefactory.ConsistencyCheck │ ├── app.config │ ├── Properties │ │ └── AssemblyInfo.cs │ └── Readme.txt ├── doc │ ├── copyright.txt │ ├── TODO │ └── license.txt ├── ICSharpCode.NRefactory.VB │ ├── Ast │ │ ├── INullable.cs │ │ ├── Statements │ │ │ ├── GoToStatement.cs │ │ │ ├── WhileStatement.cs │ │ │ ├── DoLoopStatement.cs │ │ │ ├── WithStatement.cs │ │ │ ├── SyncLockStatement.cs │ │ │ ├── UsingStatement.cs │ │ │ ├── LabelDeclarationStatement.cs │ │ │ ├── ExpressionStatement.cs │ │ │ ├── ThrowStatement.cs │ │ │ ├── LocalDeclarationStatement.cs │ │ │ ├── ReturnStatement.cs │ │ │ ├── ForEachStatement.cs │ │ │ ├── YieldStatement.cs │ │ │ ├── IfElseStatement.cs │ │ │ ├── ContinueStatement.cs │ │ │ ├── AddRemoveHandlerStatement.cs │ │ │ ├── ExitStatement.cs │ │ │ └── ForStatement.cs │ │ ├── Expressions │ │ │ ├── GetTypeExpression.cs │ │ │ ├── ParenthesizedExpression.cs │ │ │ ├── SimpleNameExpression.cs │ │ │ ├── GetXmlNamespaceExpression.cs │ │ │ ├── IdentifierExpression.cs │ │ │ ├── TypeOfIsExpression.cs │ │ │ ├── TypeReferenceExpression.cs │ │ │ ├── AnonymousObjectCreationExpression.cs │ │ │ ├── NamedArgumentExpression.cs │ │ │ ├── MemberAccessExpression.cs │ │ │ ├── FieldInitializerExpression.cs │ │ │ ├── AssignmentExpression.cs │ │ │ ├── InvocationExpression.cs │ │ │ ├── VariableInitializer.cs │ │ │ ├── CollectionRangeVariableDeclaration.cs │ │ │ └── ConditionalExpression.cs │ │ ├── General │ │ │ ├── EventMemberSpecifier.cs │ │ │ ├── AttributeBlock.cs │ │ │ ├── ParameterDeclaration.cs │ │ │ ├── InterfaceMemberSpecifier.cs │ │ │ └── TypeParameterDeclaration.cs │ │ ├── GlobalScope │ │ │ ├── ImportsStatement.cs │ │ │ ├── EnumMemberDeclaration.cs │ │ │ └── EnumDeclaration.cs │ │ ├── TypeMembers │ │ │ ├── ConstructorDeclaration.cs │ │ │ └── Accessor.cs │ │ └── TypeName │ │ │ └── PrimitiveType.cs │ ├── Lexer │ │ ├── Special │ │ │ ├── CommentType.cs │ │ │ ├── BlankLine.cs │ │ │ ├── TagComment.cs │ │ │ ├── ISpecial.cs │ │ │ └── Comment.cs │ │ ├── Extensions.cs │ │ ├── SavepointEventArgs.cs │ │ ├── XmlModeInfo.cs │ │ ├── ExpressionFinderState.cs │ │ ├── VBLexerMemento.cs │ │ ├── LATextReader.cs │ │ └── Block.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── OutputVisitor │ │ ├── VBFormattingOptions.cs │ │ └── IOutputFormatter.cs │ ├── PrettyPrinter │ │ ├── VBNet │ │ │ └── VBNetPrettyPrintOptions.cs │ │ ├── AbstractPrettyPrintOptions.cs │ │ └── IOutputAstVisitor.cs │ ├── VBParser.cs │ └── Parser │ │ └── Errors.cs ├── ICSharpCode.NRefactory.Tests │ ├── Properties │ │ └── AssemblyInfo.cs │ └── CSharp │ │ ├── Inspector │ │ └── InconsistentNamingIssueTests.cs │ │ └── Parser │ │ ├── Expression │ │ ├── ThisReferenceExpressionTests.cs │ │ ├── SizeOfExpressionTests.cs │ │ ├── BaseReferenceExpressionTests.cs │ │ └── ParenthesizedExpressionTests.cs │ │ └── Statements │ │ ├── EmptyStatementTests.cs │ │ ├── LockStatementTests.cs │ │ ├── UnsafeStatementTests.cs │ │ └── SwitchStatementTests.cs ├── ICSharpCode.NRefactory.Demo │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── VBEditDialog.cs │ └── Program.cs ├── ICSharpCode.NRefactory.Xml │ ├── Properties │ │ └── AssemblyInfo.cs │ └── SyntaxError.cs ├── ICSharpCode.NRefactory │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ └── GlobalAssemblyInfo.cs │ ├── TypeSystem │ │ ├── EntityType.cs │ │ ├── IFreezable.cs │ │ └── IParameterizedMember.cs │ ├── Completion │ │ ├── DisplayFlags.cs │ │ ├── IEntityCompletionData.cs │ │ └── IVariableCompletionData.cs │ ├── PatternMatching │ │ └── BacktrackingInfo.cs │ ├── Semantics │ │ └── InitializedObjectResolveResult.cs │ └── Utils │ │ ├── Platform.cs │ │ └── ReferenceComparer.cs ├── ICSharpCode.NRefactory.VB.Tests │ ├── Parser │ │ ├── Statements │ │ │ ├── ThrowStatementTests.cs │ │ │ ├── BlockStatementTests.cs │ │ │ ├── LockStatementTests.cs │ │ │ ├── TryCatchStatementTests.cs │ │ │ ├── ContinueStatementTests.cs │ │ │ ├── DoLoopStatementTests.cs │ │ │ ├── ExpressionStatementTests.cs │ │ │ ├── StopStatementTests.cs │ │ │ ├── ResumeStatement.cs │ │ │ ├── ErrorStatementTests.cs │ │ │ ├── EraseStatementTests.cs │ │ │ ├── WithStatementTests.cs │ │ │ ├── OnErrorStatementTest.cs │ │ │ ├── AddHandlerStatementTests.cs │ │ │ ├── GotoStatementTests.cs │ │ │ ├── RaiseEventStatementTest.cs │ │ │ ├── RemoveHandlerStatement.cs │ │ │ ├── ForeachStatementTests.cs │ │ │ ├── EndStatementTests.cs │ │ │ ├── LabelStatementTests.cs │ │ │ ├── ForNextStatementTests.cs │ │ │ ├── ReturnStatementTests.cs │ │ │ ├── SwitchStatementTests.cs │ │ │ └── UsingStatementTests.cs │ │ ├── SnippetParserTests.cs │ │ ├── Expressions │ │ │ ├── PrimitiveExpressionTests.cs │ │ │ ├── ThisReferenceExpressionTests.cs │ │ │ ├── BaseReferenceExpressionTests.cs │ │ │ ├── ClassReferenceExpressionTests.cs │ │ │ ├── ParenthesizedExpressionTest.cs │ │ │ ├── ConditionalExpressionTests.cs │ │ │ ├── GlobalReferenceExpressionTests.cs │ │ │ ├── TypeOfIsExpressionTests.cs │ │ │ ├── ArrayCreateExpressionTests.cs │ │ │ └── IdentifierExpressionTests.cs │ │ ├── TypeLevel │ │ │ ├── EventDeclarationTests.cs │ │ │ ├── OperatorDeclarationTests.cs │ │ │ ├── DeclareDeclarationTests.cs │ │ │ ├── ConstructorDeclarationTests.cs │ │ │ └── CustomEventTests.cs │ │ └── GlobalScope │ │ │ └── NamespaceDeclarationTests.cs │ ├── Lexer │ │ ├── TokenTests.cs │ │ └── LATextReaderTests.cs │ ├── Output │ │ └── CodeDOM │ │ │ ├── CodeDOMParenthesizedExpressionTest.cs │ │ │ ├── CodeDOMPrimitiveExpressionTest.cs │ │ │ └── CodeDOMTypeReferenceTest.cs │ └── AssemblyInfo.cs └── ICSharpCode.NRefactory.CSharp.AstVerifier │ └── AssemblyInfo.cs ├── .gitmodules ├── .gitattributes ├── ICSharpCode.Decompiler ├── Tests │ ├── packages.config │ ├── IL │ │ ├── StackTests.exe │ │ ├── SequenceOfNestedIfs.dll │ │ └── SequenceOfNestedIfs.Output.cs │ ├── nunit.framework.dll │ ├── Types │ │ ├── S_TypeDeclarations.cs │ │ ├── EnumTests.cs │ │ └── TypeTests.cs │ ├── CustomAttributes │ │ ├── S_AssemblyCustomAttribute.cs │ │ └── CustomAttributeTests.cs │ ├── CustomAttributes.code.cs │ ├── Helpers │ │ └── RemoveCompilerAttribute.cs │ ├── Lock.cs │ ├── DoubleConstants.cs │ └── BooleanConsumedAsInteger.il ├── Ast │ └── Transforms │ │ └── FlattenSwitchBlocks.cs └── Properties │ └── AssemblyInfo.template.cs ├── BuildTools ├── MSBuildCommunityTasks │ ├── ICSharpCode.SharpZipLib.dll │ └── MSBuild.Community.Tasks.dll ├── buildAndCreatePackage.bat └── UpdateAssemblyInfo │ └── UpdateAssemblyInfo.sln ├── .gitignore └── README.md /NRefactory/.gitattributes: -------------------------------------------------------------------------------- 1 | *.sln -crlf 2 | *.csproj -crlf -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "dnlib"] 2 | path = dnlib 3 | url = https://github.com/yck1509/dnlib.git 4 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.cs text diff=csharp 3 | *.sln text eol=crlf 4 | *.csproj text eol=crlf 5 | -------------------------------------------------------------------------------- /NRefactory/.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | obj 3 | /lib/*.dll 4 | /ICSharpCode.NRefactory.Tests/PartCover/* 5 | _ReSharper*/* 6 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yck1509/ICSharpCode.Decompiler-retired/master/NRefactory/ICSharpCode.NRefactory.snk -------------------------------------------------------------------------------- /ICSharpCode.Decompiler/Tests/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /ICSharpCode.Decompiler/Tests/IL/StackTests.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yck1509/ICSharpCode.Decompiler-retired/master/ICSharpCode.Decompiler/Tests/IL/StackTests.exe -------------------------------------------------------------------------------- /ICSharpCode.Decompiler/Tests/nunit.framework.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yck1509/ICSharpCode.Decompiler-retired/master/ICSharpCode.Decompiler/Tests/nunit.framework.dll -------------------------------------------------------------------------------- /ICSharpCode.Decompiler/Tests/IL/SequenceOfNestedIfs.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yck1509/ICSharpCode.Decompiler-retired/master/ICSharpCode.Decompiler/Tests/IL/SequenceOfNestedIfs.dll -------------------------------------------------------------------------------- /BuildTools/MSBuildCommunityTasks/ICSharpCode.SharpZipLib.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yck1509/ICSharpCode.Decompiler-retired/master/BuildTools/MSBuildCommunityTasks/ICSharpCode.SharpZipLib.dll -------------------------------------------------------------------------------- /BuildTools/MSBuildCommunityTasks/MSBuild.Community.Tasks.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yck1509/ICSharpCode.Decompiler-retired/master/BuildTools/MSBuildCommunityTasks/MSBuild.Community.Tasks.dll -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/visit.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yck1509/ICSharpCode.Decompiler-retired/master/NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/visit.cs -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.GtkDemo/pixbuf/comment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yck1509/ICSharpCode.Decompiler-retired/master/NRefactory/ICSharpCode.NRefactory.GtkDemo/pixbuf/comment.png -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.GtkDemo/pixbuf/element-class-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yck1509/ICSharpCode.Decompiler-retired/master/NRefactory/ICSharpCode.NRefactory.GtkDemo/pixbuf/element-class-16.png -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.GtkDemo/pixbuf/element-field-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yck1509/ICSharpCode.Decompiler-retired/master/NRefactory/ICSharpCode.NRefactory.GtkDemo/pixbuf/element-field-16.png -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.GtkDemo/pixbuf/element-literal-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yck1509/ICSharpCode.Decompiler-retired/master/NRefactory/ICSharpCode.NRefactory.GtkDemo/pixbuf/element-literal-16.png -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.GtkDemo/pixbuf/element-method-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yck1509/ICSharpCode.Decompiler-retired/master/NRefactory/ICSharpCode.NRefactory.GtkDemo/pixbuf/element-method-16.png -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.GtkDemo/pixbuf/element-namespace-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yck1509/ICSharpCode.Decompiler-retired/master/NRefactory/ICSharpCode.NRefactory.GtkDemo/pixbuf/element-namespace-16.png -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.ConsistencyCheck/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /NRefactory/doc/copyright.txt: -------------------------------------------------------------------------------- 1 | Copyright 2002-2012 by 2 | 3 | AlphaSierraPapa, Christoph Wille 4 | Vordernberger Strasse 27/8 5 | A-8700 Leoben 6 | Austria 7 | 8 | email: office@alphasierrapapa.com 9 | court of jurisdiction: Landesgericht Leoben 10 | 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | obj/ 3 | 4 | /ICSharpCode.Decompiler/Properties/AssemblyInfo.cs 5 | /ILSpy/Properties/AssemblyInfo.cs 6 | /ILSpy/app.config 7 | *.suo 8 | *.user 9 | /Resharper-ILSpy-Style.xml 10 | _ReSharper*/ 11 | *.ReSharper 12 | *.patch 13 | /packages 14 | *.ide/ 15 | -------------------------------------------------------------------------------- /ICSharpCode.Decompiler/Tests/Types/S_TypeDeclarations.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ClassMultiInterface 4 | { 5 | public interface IA 6 | { 7 | } 8 | public interface IA2 : IA 9 | { 10 | } 11 | public interface IB 12 | { 13 | } 14 | public class C : IA2, IB 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ICSharpCode.Decompiler/Tests/CustomAttributes/S_AssemblyCustomAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | 6 | [assembly: CLSCompliant(false)] 7 | -------------------------------------------------------------------------------- /BuildTools/buildAndCreatePackage.bat: -------------------------------------------------------------------------------- 1 | @echo This script simulates what the build server is doing 2 | @rem /p:AdditionalBuildProperties="/v:d /p:MSBuildTargetsVerbose=true" 3 | %windir%\microsoft.net\framework\v4.0.30319\msbuild Automated.proj /p:ArtefactsOutputDir="%CD%\build" /p:TestReportsDir="%CD%\build" 4 | @IF %ERRORLEVEL% NEQ 0 GOTO err 5 | @exit /B 0 6 | :err 7 | @PAUSE 8 | @exit /B 1 -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/INullable.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | namespace ICSharpCode.NRefactory.VB.Ast 5 | { 6 | public interface INullable 7 | { 8 | bool IsNull { 9 | get; 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /ICSharpCode.Decompiler/Tests/Types/EnumTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using NUnit.Framework; 6 | 7 | namespace ICSharpCode.Decompiler.Tests.Types 8 | { 9 | [TestFixture] 10 | public class EnumTests : DecompilerTestBase 11 | { 12 | [Test] 13 | public void EnumSamples() 14 | { 15 | ValidateFileRoundtrip(@"Types\S_EnumSamples.cs"); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.GtkDemo/CSharpDemo.cs: -------------------------------------------------------------------------------- 1 | // CSharpDemo.cs 2 | using System; 3 | using System.Linq; 4 | 5 | namespace Demo 6 | { 7 | #region Demo 8 | public class CSharpDemo 9 | { 10 | static void TestMe (int i) 11 | { 12 | Console.WriteLine (i); 13 | NotDefined (); 14 | } 15 | 16 | public static void Main (string[] args) 17 | { 18 | TestMe (args.Count ()); 19 | } 20 | } 21 | #endregion 22 | } 23 | 24 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Lexer/Special/CommentType.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | 6 | namespace ICSharpCode.NRefactory.VB 7 | { 8 | // public enum CommentType 9 | // { 10 | // Block, 11 | // SingleLine, 12 | // Documentation 13 | // } 14 | } 15 | -------------------------------------------------------------------------------- /ICSharpCode.Decompiler/Tests/Types/TypeTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using NUnit.Framework; 6 | 7 | namespace ICSharpCode.Decompiler.Tests.Types 8 | { 9 | [TestFixture] 10 | public class TypeTests : DecompilerTestBase 11 | { 12 | [Test] 13 | public void TypeMemberDeclarations() 14 | { 15 | ValidateFileRoundtrip(@"Types\S_TypeMemberDeclarations.cs"); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /NRefactory/doc/TODO: -------------------------------------------------------------------------------- 1 | 2 | Parser: 3 | - put newlines into the AST 4 | - add API to report errors 5 | - allow multithreaded parsing 6 | 7 | Type System: 8 | - Reduce memory usage 9 | - Interface Implementation Map 10 | 11 | Resolver: 12 | - Port all #D resolver unit tests to NR 13 | - Port all MD resolver unit tests to NR 14 | 15 | Features: 16 | - Code Completion 17 | - Extract Method refactoring 18 | 19 | For integration into SharpDevelop: 20 | - Review NR and DOM changes done in the timeframe 21 | 22 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/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.VB")] 13 | [assembly: AssemblyDescription("VB syntax tree")] 14 | -------------------------------------------------------------------------------- /NRefactory/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 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.CSharp/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.CSharp")] 13 | [assembly: AssemblyDescription("C# parser and semantic analysis")] 14 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/OutputVisitor/VBFormattingOptions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | 6 | namespace ICSharpCode.NRefactory.VB 7 | { 8 | /// 9 | /// Description of VBFormattingOptions. 10 | /// 11 | public class VBFormattingOptions 12 | { 13 | public VBFormattingOptions() 14 | { 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.Demo/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.Demo")] 13 | [assembly: AssemblyDescription("WinForms-based demo application for NRefactory")] 14 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.Xml/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.Xml")] 13 | [assembly: AssemblyDescription("Error-tolerant XML parser")] 14 | 15 | [assembly: CLSCompliant(true)] 16 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.ConsistencyCheck/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.ConsistencyCheck")] 13 | [assembly: AssemblyDescription("Loads a solution and performs various self-tests using the parsed code.")] 14 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory/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")] 13 | [assembly: AssemblyDescription("Type system and other language-independent parts of NRefactory")] 14 | 15 | [assembly: CLSCompliant(true)] 16 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ThrowStatementTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class ThrowStatementTests 14 | { 15 | // TODO : ThrowStatementTests 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/BlockStatementTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class BlockStatementTests 14 | { 15 | // TODO create BlockStatementTests 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/LockStatementTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class LockStatementTests 14 | { 15 | // TODO : write some tests on SyncLock 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/TryCatchStatementTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class TryCatchStatementTests 14 | { 15 | // TODO : TryCatchStatementTests 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ContinueStatementTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class ContinueStatementTests 14 | { 15 | // TODO : add ContinueStatementTests 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/DoLoopStatementTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class DoLoopStatementTests 14 | { 15 | // TODO write some DoLoopStatement tests 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ExpressionStatementTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class ExpressionStatementTests 14 | { 15 | // TODO : Create ExpressionStatementTests 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Lexer/Special/BlankLine.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | 6 | namespace ICSharpCode.NRefactory.VB 7 | { 8 | // public class BlankLine : AbstractSpecial 9 | // { 10 | // public BlankLine(Location point) : base(point) 11 | // { 12 | // } 13 | // 14 | // public override object AcceptVisitor(ISpecialVisitor visitor, object data) 15 | // { 16 | // return visitor.Visit(this, data); 17 | // } 18 | // } 19 | } 20 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Lexer/TokenTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using ICSharpCode.NRefactory.VB.Parser; 6 | using NUnit.Framework; 7 | 8 | namespace ICSharpCode.NRefactory.VB.Tests.Lexer 9 | { 10 | [TestFixture] 11 | public class TokenTests 12 | { 13 | [Test] 14 | public void TokenToStringDoesNotThrowException() 15 | { 16 | Assert.DoesNotThrow( 17 | () => { 18 | string text = new Token(71, 1, 1).ToString(); 19 | } 20 | ); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Lexer/Extensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | 9 | namespace ICSharpCode.NRefactory.VB.Parser 10 | { 11 | public static class Extensions 12 | { 13 | public static bool IsElement(this IEnumerable items, Func check) 14 | { 15 | T item = items.FirstOrDefault(); 16 | 17 | if (item != null) 18 | return check(item); 19 | return false; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/PrettyPrinter/VBNet/VBNetPrettyPrintOptions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | 6 | namespace ICSharpCode.NRefactory.VB.PrettyPrinter 7 | { 8 | /// 9 | /// Description of VBNetPrettyPrintOptions. 10 | /// 11 | public class VBNetPrettyPrintOptions : AbstractPrettyPrintOptions 12 | { 13 | /// 14 | /// Gets/Sets if the optional "ByVal" modifier should be written. 15 | /// 16 | public bool OutputByValModifier { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.GtkDemo/gtk-gui/generated.cs: -------------------------------------------------------------------------------- 1 | 2 | // This file has been generated by the GUI designer. Do not modify. 3 | namespace Stetic 4 | { 5 | internal class Gui 6 | { 7 | private static bool initialized; 8 | 9 | internal static void Initialize (Gtk.Widget iconRenderer) 10 | { 11 | if ((Stetic.Gui.initialized == false)) { 12 | Stetic.Gui.initialized = true; 13 | } 14 | } 15 | } 16 | 17 | internal class ActionGroups 18 | { 19 | public static Gtk.ActionGroup GetActionGroup (System.Type type) 20 | { 21 | return Stetic.ActionGroups.GetActionGroup (type.FullName); 22 | } 23 | 24 | public static Gtk.ActionGroup GetActionGroup (string name) 25 | { 26 | return null; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Lexer/SavepointEventArgs.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | namespace ICSharpCode.NRefactory.VB.Parser 8 | { 9 | public class SavepointEventArgs : EventArgs 10 | { 11 | public TextLocation SavepointLocation { get; private set; } 12 | public VBLexerMemento State { get; private set; } 13 | 14 | public SavepointEventArgs(TextLocation savepointLocation, VBLexerMemento state) 15 | { 16 | this.SavepointLocation = savepointLocation; 17 | this.State = state; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/StopStatementTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class StopStatementTests 14 | { 15 | #region VB.NET 16 | [Test] 17 | public void VBNetStopStatementTest() 18 | { 19 | StopStatement stopStatement = ParseUtil.ParseStatement("Stop"); 20 | } 21 | #endregion 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ResumeStatement.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class ResumeStatementTests 14 | { 15 | [Test] 16 | public void ResumeStatementTest() 17 | { 18 | ResumeStatement resumeStatement = ParseUtil.ParseStatement("Resume"); 19 | } 20 | 21 | // TODO : write some more 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ErrorStatementTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class ErrorStatementTests 14 | { 15 | #region VB.NET 16 | [Test] 17 | public void VBNetErrorStatementTest() 18 | { 19 | ErrorStatement errorStatement = ParseUtil.ParseStatement("Error a"); 20 | } 21 | #endregion 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/EraseStatementTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class EraseStatementTests 14 | { 15 | #region VB.NET 16 | [Test] 17 | public void VBNetEraseStatementTest() 18 | { 19 | EraseStatement eraseStatement = ParseUtil.ParseStatement("Erase a, b, c"); 20 | } 21 | #endregion 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/WithStatementTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class WithStatementTests 14 | { 15 | #region VB.NET 16 | [Test] 17 | public void VBNetWithStatementTest() 18 | { 19 | WithStatement withStatement = ParseUtil.ParseStatement("With MyObj : End With"); 20 | } 21 | #endregion 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/SnippetParserTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using ICSharpCode.NRefactory.VB.Ast; 5 | using System; 6 | using NUnit.Framework; 7 | 8 | namespace ICSharpCode.NRefactory.VB.Tests 9 | { 10 | [TestFixture] 11 | public class SnippetParserTests 12 | { 13 | // [Test] 14 | // public void InvalidExpressionSyntax() 15 | // { 16 | // // SD2-1584: ensure we don't crash on this invalid VB code 17 | // SnippetParser parser = new SnippetParser(); 18 | // INode node = parser.Parse("i == 5"); 19 | // Assert.IsTrue(parser.Errors.Count > 0); 20 | // } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/PrimitiveExpressionTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class PrimitiveExpressionTests 14 | { 15 | #region VB.NET 16 | [Test] 17 | public void PrimitiveExpression1Test() 18 | { 19 | InvocationExpression ie = ParseUtil.ParseExpression("546.ToString()"); 20 | } 21 | #endregion 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/OnErrorStatementTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class OnErrorStatementTest 14 | { 15 | #region VB.NET 16 | [Test] 17 | public void VBNetOnErrorStatementTest() 18 | { 19 | OnErrorStatement onErrorStatement = ParseUtil.ParseStatement("On Error Goto err"); 20 | } 21 | #endregion 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ThisReferenceExpressionTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class ThisReferenceExpressionTests 14 | { 15 | #region VB.NET 16 | [Test] 17 | public void VBNetThisReferenceExpressionTest1() 18 | { 19 | ThisReferenceExpression ie = ParseUtil.ParseExpression("Me"); 20 | } 21 | #endregion 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.CSharp/Ast/TokenRole.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ICSharpCode.NRefactory.CSharp 4 | { 5 | /// 6 | /// A specific role only used for C# tokens 7 | /// 8 | public sealed class TokenRole : Role 9 | { 10 | /// 11 | /// Gets the token as string. Note that the token Name and Token value may differ. 12 | /// 13 | public string Token { 14 | get; 15 | private set; 16 | } 17 | 18 | /// 19 | /// Gets the char length of the token. 20 | /// 21 | public int Length { 22 | get; 23 | private set; 24 | } 25 | 26 | public TokenRole (string token) : base (token, CSharpTokenNode.Null) 27 | { 28 | this.Token = token; 29 | this.Length = token.Length; 30 | } 31 | } 32 | } 33 | 34 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/AddHandlerStatementTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class AddHandlerStatementTests 14 | { 15 | [Test] 16 | public void AddHandlerTest() 17 | { 18 | AddHandlerStatement addHandlerStatement = ParseUtil.ParseStatement("AddHandler Obj.Ev_Event, AddressOf EventHandler"); 19 | // TODO : extend tests 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/GotoStatementTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class GotoStatementTests 14 | { 15 | #region VB.NET 16 | [Test] 17 | public void VBNetGotoStatementTest() 18 | { 19 | GotoStatement gotoStmt = ParseUtil.ParseStatement("GoTo myLabel"); 20 | Assert.AreEqual("myLabel", gotoStmt.Label); 21 | } 22 | #endregion 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/RaiseEventStatementTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class RaiseEventStatementTest 14 | { 15 | #region VB.NET 16 | [Test] 17 | public void VBNetRaiseEventStatementTest() 18 | { 19 | RaiseEventStatement raiseEventStatement = ParseUtil.ParseStatement("RaiseEvent MyEvent(a, 5, (6))"); 20 | } 21 | #endregion 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ICSharpCode.Decompiler/Tests/CustomAttributes/CustomAttributeTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using NUnit.Framework; 6 | 7 | namespace ICSharpCode.Decompiler.Tests.CustomAttributes 8 | { 9 | [TestFixture] 10 | public class CustomAttributeTests : DecompilerTestBase 11 | { 12 | [Test] 13 | public void CustomAttributeSamples() 14 | { 15 | ValidateFileRoundtrip(@"CustomAttributes\S_CustomAttributeSamples.cs"); 16 | } 17 | 18 | [Test] 19 | public void CustomAttributesMultiTest() 20 | { 21 | ValidateFileRoundtrip(@"CustomAttributes\S_CustomAttributes.cs"); 22 | } 23 | 24 | [Test] 25 | public void AssemblyCustomAttributesMultiTest() 26 | { 27 | ValidateFileRoundtrip(@"CustomAttributes\S_AssemblyCustomAttribute.cs"); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/RemoveHandlerStatement.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class RemoveHandlerStatementTests 14 | { 15 | #region VB.NET 16 | [Test] 17 | public void VBNetRemoveHandlerTest() 18 | { 19 | RemoveHandlerStatement removeHandlerStatement = ParseUtil.ParseStatement("RemoveHandler MyHandler, AddressOf MyMethod"); 20 | } 21 | #endregion 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ForeachStatementTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class ForeachStatementTests 14 | { 15 | #region VB.NET 16 | [Test] 17 | public void VBNetForeachStatementTest() 18 | { 19 | ForeachStatement foreachStmt = ParseUtil.ParseStatement("For Each i As Integer In myColl : Next"); 20 | // TODO : Extend test. 21 | } 22 | #endregion 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Output/CodeDOM/CodeDOMParenthesizedExpressionTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.CodeDom; 6 | using ICSharpCode.NRefactory.VB.Ast; 7 | using ICSharpCode.NRefactory.VB.Visitors; 8 | using NUnit.Framework; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Output.CodeDom.Tests 11 | { 12 | [TestFixture] 13 | public class CodeDOMParenthesizedExpressionTest 14 | { 15 | [Test] 16 | public void TestParenthesizedExpression() 17 | { 18 | object output = new ParenthesizedExpression(new PrimitiveExpression(5, "5")).AcceptVisitor(new CodeDomVisitor(), null); 19 | Assert.IsTrue(output is CodePrimitiveExpression); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /ICSharpCode.Decompiler/Ast/Transforms/FlattenSwitchBlocks.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using ICSharpCode.NRefactory.CSharp; 6 | 7 | namespace ICSharpCode.Decompiler.Ast.Transforms 8 | { 9 | class FlattenSwitchBlocks : IAstTransform 10 | { 11 | public void Run(AstNode compilationUnit) 12 | { 13 | foreach (var switchSection in compilationUnit.Descendants.OfType()) 14 | { 15 | if (switchSection.Statements.Count != 1) 16 | continue; 17 | 18 | var blockStatement = switchSection.Statements.First() as BlockStatement; 19 | if (blockStatement == null || blockStatement.Statements.Any(st => st is VariableDeclarationStatement)) 20 | continue; 21 | 22 | blockStatement.Remove(); 23 | blockStatement.Statements.MoveTo(switchSection.Statements); 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/BaseReferenceExpressionTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class BaseReferenceExpressionTests 14 | { 15 | #region VB.NET 16 | [Test] 17 | public void VBNetBaseReferenceExpressionTest1() 18 | { 19 | MemberReferenceExpression fre = ParseUtil.ParseExpression("MyBase.myField"); 20 | Assert.IsTrue(fre.TargetObject is BaseReferenceExpression); 21 | } 22 | #endregion 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ClassReferenceExpressionTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class ClassReferenceExpressionTests 14 | { 15 | #region VB.NET 16 | [Test] 17 | public void VBNetClassReferenceExpressionTest1() 18 | { 19 | MemberReferenceExpression fre = ParseUtil.ParseExpression("MyClass.myField"); 20 | Assert.IsTrue(fre.TargetObject is ClassReferenceExpression); 21 | } 22 | #endregion 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Lexer/XmlModeInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | 6 | namespace ICSharpCode.NRefactory.VB.Parser 7 | { 8 | public class XmlModeInfo : ICloneable 9 | { 10 | public bool inXmlTag, inXmlCloseTag, isDocumentStart; 11 | public int level; 12 | 13 | public XmlModeInfo(bool isSpecial) 14 | { 15 | level = isSpecial ? -1 : 0; 16 | inXmlTag = inXmlCloseTag = isDocumentStart = false; 17 | } 18 | 19 | public object Clone() 20 | { 21 | return new XmlModeInfo(false) { 22 | inXmlCloseTag = this.inXmlCloseTag, 23 | inXmlTag = this.inXmlTag, 24 | isDocumentStart = this.isDocumentStart, 25 | level = this.level 26 | }; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Output/CodeDOM/CodeDOMPrimitiveExpressionTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.CodeDom; 6 | using ICSharpCode.NRefactory.VB.Ast; 7 | using ICSharpCode.NRefactory.VB.Visitors; 8 | using NUnit.Framework; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Output.CodeDom.Tests 11 | { 12 | [TestFixture] 13 | public class CodeDOMPrimitiveExpressionsTests 14 | { 15 | [Test] 16 | public void TestPrimitiveExpression() 17 | { 18 | object output = new PrimitiveExpression(5, "5").AcceptVisitor(new CodeDomVisitor(), null); 19 | Assert.IsTrue(output is CodePrimitiveExpression); 20 | Assert.AreEqual(((CodePrimitiveExpression)output).Value, 5); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/EventDeclarationTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using ICSharpCode.NRefactory.VB.Ast; 6 | using NUnit.Framework; 7 | 8 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 9 | { 10 | [TestFixture] 11 | public class EventDeclarationTests 12 | { 13 | #region VB.NET 14 | [Test] 15 | public void VBNetSimpleEventDeclarationTest() 16 | { 17 | EventDeclaration ed = ParseUtil.ParseTypeMember("event MyEvent(x as Integer)"); 18 | Assert.AreEqual(1, ed.Parameters.Count); 19 | Assert.AreEqual("MyEvent", ed.Name); 20 | Assert.IsFalse(ed.HasAddRegion); 21 | Assert.IsFalse(ed.HasRemoveRegion); 22 | } 23 | #endregion 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Lexer/Special/TagComment.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | 6 | namespace ICSharpCode.NRefactory.VB.Parser 7 | { 8 | /// 9 | /// Description of TagComment. 10 | /// 11 | // public class TagComment : Comment 12 | // { 13 | // string tag; 14 | // 15 | // public string Tag { 16 | // get { 17 | // return tag; 18 | // } 19 | // set { 20 | // tag = value; 21 | // } 22 | // } 23 | // 24 | // public TagComment(string tag, string comment, bool commentStartsLine, Location startPosition, Location endPosition) : base(CommentType.SingleLine, comment, commentStartsLine, startPosition, endPosition) 25 | // { 26 | // this.tag = tag; 27 | // } 28 | // } 29 | } 30 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Lexer/ExpressionFinderState.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | 9 | namespace ICSharpCode.NRefactory.VB.Parser 10 | { 11 | public class ExpressionFinderState 12 | { 13 | public bool WasQualifierTokenAtStart { get; set; } 14 | public bool NextTokenIsPotentialStartOfExpression { get; set; } 15 | public bool ReadXmlIdentifier { get; set; } 16 | public bool IdentifierExpected { get; set; } 17 | public bool NextTokenIsStartOfImportsOrAccessExpression { get; set; } 18 | public Stack StateStack { get; set; } 19 | public Stack BlockStack { get; set; } 20 | public int CurrentState { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Lexer/VBLexerMemento.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | namespace ICSharpCode.NRefactory.VB.Parser 8 | { 9 | public sealed class VBLexerMemento 10 | { 11 | public int Line { get; set; } 12 | public int Column { get; set; } 13 | public int PrevTokenKind { get; set; } 14 | public bool LineEnd { get; set; } 15 | public bool IsAtLineBegin { get; set; } 16 | public bool MisreadExclamationMarkAsTypeCharacter { get; set; } 17 | public bool EncounteredLineContinuation { get; set; } 18 | public ExpressionFinderState ExpressionFinder { get; set; } 19 | public Stack XmlModeInfoStack { get; set; } 20 | public bool InXmlMode { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/EndStatementTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class EndStatementTests 14 | { 15 | #region VB.NET 16 | [Test] 17 | public void VBNetEndStatementTest() 18 | { 19 | EndStatement endStatement = ParseUtil.ParseStatement("End"); 20 | } 21 | 22 | [Test] 23 | public void VBNetEndStatementInIfThenTest2() 24 | { 25 | IfElseStatement endStatement = ParseUtil.ParseStatement("IF a THEN End"); 26 | } 27 | #endregion 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /BuildTools/UpdateAssemblyInfo/UpdateAssemblyInfo.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | # SharpDevelop 4.0.1.7088 5 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpdateAssemblyInfo", "UpdateAssemblyInfo.csproj", "{605C8CDB-F0AD-4A21-9F4A-959B8DECB0F3}" 6 | EndProject 7 | Global 8 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 9 | Debug|Any CPU = Debug|Any CPU 10 | Release|Any CPU = Release|Any CPU 11 | EndGlobalSection 12 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 13 | {605C8CDB-F0AD-4A21-9F4A-959B8DECB0F3}.Debug|Any CPU.Build.0 = Debug|Any CPU 14 | {605C8CDB-F0AD-4A21-9F4A-959B8DECB0F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {605C8CDB-F0AD-4A21-9F4A-959B8DECB0F3}.Release|Any CPU.Build.0 = Release|Any CPU 16 | {605C8CDB-F0AD-4A21-9F4A-959B8DECB0F3}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | EndGlobalSection 18 | EndGlobal 19 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ParenthesizedExpressionTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class ParenthesizedExpressionTests 14 | { 15 | #region VB.NET 16 | [Test] 17 | public void VBNetPrimitiveParenthesizedExpression() 18 | { 19 | ParenthesizedExpression p = ParseUtil.ParseExpression("((1))"); 20 | Assert.IsTrue(p.Expression is ParenthesizedExpression); 21 | p = p.Expression as ParenthesizedExpression;; 22 | Assert.IsTrue(p.Expression is PrimitiveExpression); 23 | } 24 | #endregion 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/LabelStatementTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class LabelStatementTests 14 | { 15 | #region VB.NET 16 | [Test] 17 | public void VBNetLabelStatementTest() 18 | { 19 | MethodDeclaration method = ParseUtil.ParseTypeMember("Sub Test \n myLabel: Console.WriteLine() \n End Sub"); 20 | Assert.AreEqual(2, method.Body.Children.Count); 21 | LabelStatement labelStmt = (LabelStatement)method.Body.Children[0]; 22 | Assert.AreEqual("myLabel", labelStmt.Label); 23 | } 24 | #endregion 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Statements/GoToStatement.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | 7 | namespace ICSharpCode.NRefactory.VB.Ast 8 | { 9 | public class GoToStatement : Statement 10 | { 11 | /// either PrimitiveExpression or IdentifierExpression 12 | public Expression Label { 13 | get { return GetChildByRole(Roles.Expression); } 14 | set { SetChildByRole(Roles.Expression, value); } 15 | } 16 | 17 | protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) 18 | { 19 | throw new NotImplementedException(); 20 | } 21 | 22 | public override S AcceptVisitor(IAstVisitor visitor, T data) 23 | { 24 | return visitor.VisitGoToStatement(this, data); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/GetTypeExpression.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | 6 | namespace ICSharpCode.NRefactory.VB.Ast 7 | { 8 | public class GetTypeExpression : Expression 9 | { 10 | public GetTypeExpression() 11 | { 12 | } 13 | 14 | public AstType Type { 15 | get { return GetChildByRole(Roles.Type); } 16 | set { SetChildByRole(Roles.Type, value); } 17 | } 18 | 19 | protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) 20 | { 21 | var expr = other as GetTypeExpression; 22 | return expr != null && 23 | Type.DoMatch(expr.Type, match); 24 | } 25 | 26 | public override S AcceptVisitor(IAstVisitor visitor, T data) 27 | { 28 | return visitor.VisitGetTypeExpression(this, data); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/PrettyPrinter/AbstractPrettyPrintOptions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | namespace ICSharpCode.NRefactory.VB.PrettyPrinter 5 | { 6 | /// 7 | /// Description of PrettyPrintOptions. 8 | /// 9 | public class AbstractPrettyPrintOptions 10 | { 11 | char indentationChar = '\t'; 12 | int tabSize = 4; 13 | int indentSize = 4; 14 | 15 | public char IndentationChar { 16 | get { 17 | return indentationChar; 18 | } 19 | set { 20 | indentationChar = value; 21 | } 22 | } 23 | 24 | public int TabSize { 25 | get { 26 | return tabSize; 27 | } 28 | set { 29 | tabSize = value; 30 | } 31 | } 32 | 33 | public int IndentSize { 34 | get { 35 | return indentSize; 36 | } 37 | set { 38 | indentSize = value; 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ConditionalExpressionTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class ConditionalExpressionTests 14 | { 15 | #region VB.NET 16 | 17 | [Test] 18 | public void VBNetConditionalExpressionTest() 19 | { 20 | ConditionalExpression ce = ParseUtil.ParseExpression("If(x IsNot Nothing, x.Test, \"nothing\")"); 21 | 22 | Assert.IsTrue(ce.Condition is BinaryOperatorExpression); 23 | Assert.IsTrue(ce.TrueExpression is MemberReferenceExpression); 24 | Assert.IsTrue(ce.FalseExpression is PrimitiveExpression); 25 | } 26 | 27 | #endregion 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ForNextStatementTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class ForNextStatementTests 14 | { 15 | #region VB.NET 16 | [Test] 17 | public void VBNetForNextStatementTest() 18 | { 19 | ForNextStatement forNextStatement = ParseUtil.ParseStatement("For i=0 To 10 Step 2 : Next i"); 20 | } 21 | 22 | [Test] 23 | public void VBNetForNextStatementWithComplexExpressionTest() 24 | { 25 | ForNextStatement forNextStatement = ParseUtil.ParseStatement("For SomeMethod().Property = 0 To 10 : Next SomeMethod().Property"); 26 | } 27 | #endregion 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Statements/WhileStatement.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | 7 | namespace ICSharpCode.NRefactory.VB.Ast 8 | { 9 | public class WhileStatement : Statement 10 | { 11 | public Expression Condition { 12 | get { return GetChildByRole(Roles.Expression); } 13 | set { SetChildByRole(Roles.Expression, value); } 14 | } 15 | 16 | public BlockStatement Body { 17 | get { return GetChildByRole(Roles.Body); } 18 | set { SetChildByRole(Roles.Body, value); } 19 | } 20 | 21 | protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) 22 | { 23 | throw new NotImplementedException(); 24 | } 25 | 26 | public override S AcceptVisitor(IAstVisitor visitor, T data) 27 | { 28 | return visitor.VisitWhileStatement(this, data); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ICSharpCode.Decompiler/Tests/IL/SequenceOfNestedIfs.Output.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | [Serializable] 3 | public class Material 4 | { 5 | public static implicit operator bool(Material m) 6 | { 7 | return m == null; 8 | } 9 | } 10 | [Serializable] 11 | public class SequenceOfNestedIfs 12 | { 13 | public bool _clear; 14 | public Material _material; 15 | public override bool CheckShader() 16 | { 17 | return false; 18 | } 19 | public override void CreateMaterials() 20 | { 21 | if (!this._clear) 22 | { 23 | if (!this.CheckShader()) 24 | { 25 | return; 26 | } 27 | this._material = new Material(); 28 | } 29 | if (!this._material) 30 | { 31 | if (!this.CheckShader()) 32 | { 33 | return; 34 | } 35 | this._material = new Material(); 36 | } 37 | if (!this._material) 38 | { 39 | if (!this.CheckShader()) 40 | { 41 | return; 42 | } 43 | this._material = new Material(); 44 | } 45 | if (!this._material) 46 | { 47 | if (this.CheckShader()) 48 | { 49 | this._material = new Material(); 50 | } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/OperatorDeclarationTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using ICSharpCode.NRefactory.VB.Ast; 6 | using NUnit.Framework; 7 | 8 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 9 | { 10 | [TestFixture] 11 | public class OperatorDeclarationTests 12 | { 13 | #region VB.NET 14 | 15 | [Test] 16 | public void VBNetImplictOperatorDeclarationTest() 17 | { 18 | string programm = @"Public Shared Operator + (ByVal v As Complex) As Complex 19 | Return v 20 | End Operator"; 21 | 22 | OperatorDeclaration od = ParseUtil.ParseTypeMember(programm); 23 | Assert.IsFalse(od.IsConversionOperator); 24 | Assert.AreEqual(1, od.Parameters.Count); 25 | Assert.AreEqual(ConversionType.None, od.ConversionType); 26 | Assert.AreEqual("Complex", od.TypeReference.Type); 27 | } 28 | #endregion 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Lexer/LATextReaderTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using ICSharpCode.NRefactory.VB.Parser; 7 | using NUnit.Framework; 8 | 9 | namespace ICSharpCode.NRefactory.VB.Tests.Lexer 10 | { 11 | [TestFixture] 12 | public class LATextReaderTests 13 | { 14 | [Test] 15 | public void TestPeek() 16 | { 17 | LATextReader reader = new LATextReader(new StringReader("abcd")); 18 | 19 | CheckPeek(reader, 0, 'a'); 20 | CheckPeek(reader, 2, 'c'); 21 | CheckPeek(reader, 3, 'd'); 22 | CheckPeek(reader, 1, 'b'); 23 | CheckPeek(reader, 0, 'a'); 24 | Assert.AreEqual((int)'a', reader.Read()); 25 | CheckPeek(reader, 1, 'c'); 26 | CheckPeek(reader, 2, 'd'); 27 | CheckPeek(reader, 0, 'b'); 28 | } 29 | 30 | void CheckPeek(LATextReader reader, int num1, char char2) 31 | { 32 | Assert.AreEqual((int)char2, reader.Peek(num1)); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory/Properties/GlobalAssemblyInfo.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: AssemblyCompany("ICSharpCode")] 13 | [assembly: AssemblyProduct("SharpDevelop/MonoDevelop")] 14 | [assembly: AssemblyCopyright("Copyright 2010-2012 AlphaSierraPapa")] 15 | 16 | // This sets the default COM visibility of types in the assembly to invisible. 17 | // If you need to expose a type to COM, use [ComVisible(true)] on that type. 18 | [assembly: ComVisible(false)] 19 | 20 | // We keep the AssemblyVersion at 5.0.0.0 for all versions of NRefactory 5. 21 | // This eliminates the need for binding redirects. 22 | [assembly: AssemblyVersion("5.0.0.0")] 23 | 24 | // [AssemblyFileVersion] is the version of the NuGet package, 25 | // should follow http://semver.org/ rules 26 | [assembly: AssemblyFileVersion("5.2.0")] 27 | -------------------------------------------------------------------------------- /NRefactory/doc/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010-2012 AlphaSierraPapa 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 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Statements/DoLoopStatement.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | 7 | namespace ICSharpCode.NRefactory.VB.Ast 8 | { 9 | public class DoLoopStatement : Statement 10 | { 11 | public ConditionType ConditionType { get; set; } 12 | 13 | public Expression Expression { 14 | get { return GetChildByRole(Roles.Expression); } 15 | set { SetChildByRole(Roles.Expression, value); } 16 | } 17 | 18 | public BlockStatement Body { 19 | get { return GetChildByRole(Roles.Body); } 20 | set { SetChildByRole(Roles.Body, value); } 21 | } 22 | 23 | protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) 24 | { 25 | throw new NotImplementedException(); 26 | } 27 | 28 | public override S AcceptVisitor(IAstVisitor visitor, T data) 29 | { 30 | return visitor.VisitDoLoopStatement(this, data); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ReturnStatementTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class ReturnStatementTests 14 | { 15 | #region VB.NET 16 | [Test] 17 | public void VBNetEmptyReturnStatementTest() 18 | { 19 | ReturnStatement returnStatement = ParseUtil.ParseStatement("Return"); 20 | Assert.IsTrue(returnStatement.Expression.IsNull); 21 | } 22 | 23 | [Test] 24 | public void VBNetReturnStatementTest() 25 | { 26 | ReturnStatement returnStatement = ParseUtil.ParseStatement("Return 5"); 27 | Assert.IsFalse(returnStatement.Expression.IsNull); 28 | Assert.IsTrue(returnStatement.Expression is PrimitiveExpression); 29 | } 30 | #endregion 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/DeclareDeclarationTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using ICSharpCode.NRefactory.VB.Ast; 6 | using NUnit.Framework; 7 | 8 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 9 | { 10 | [TestFixture] 11 | public class DeclareDeclarationTests 12 | { 13 | #region VB.NET 14 | [Test] 15 | public void VBNetDeclareDeclarationTest() 16 | { 17 | string program = "Declare Ansi Function GetUserName Lib \"advapi32.dll\" Alias \"GetUserNameA\" (ByVal lpBuffer As String, ByRef nSize As Integer) As Integer\n"; 18 | DeclareDeclaration dd = ParseUtil.ParseTypeMember(program); 19 | Assert.AreEqual("System.Int32", dd.TypeReference.Type); 20 | Assert.AreEqual("GetUserName", dd.Name); 21 | Assert.AreEqual("advapi32.dll", dd.Library); 22 | Assert.AreEqual("GetUserNameA", dd.Alias); 23 | Assert.AreEqual(CharsetModifier.Ansi, dd.Charset); 24 | } 25 | #endregion 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Statements/WithStatement.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | 7 | namespace ICSharpCode.NRefactory.VB.Ast 8 | { 9 | /// 10 | /// With Expression
11 | /// Block
12 | /// End With 13 | ///
14 | public class WithStatement : Statement 15 | { 16 | public Expression Expression { 17 | get { return GetChildByRole(Roles.Expression); } 18 | set { SetChildByRole(Roles.Expression, value); } 19 | } 20 | 21 | public BlockStatement Body { 22 | get { return GetChildByRole(Roles.Body); } 23 | set { SetChildByRole(Roles.Body, value); } 24 | } 25 | 26 | public override S AcceptVisitor (IAstVisitor visitor, T data) 27 | { 28 | return visitor.VisitWithStatement(this, data); 29 | } 30 | 31 | protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) 32 | { 33 | throw new NotImplementedException(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.CSharp.AstVerifier/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | // Information about this assembly is defined by the following attributes. 5 | // Change them to the values specific to your project. 6 | 7 | [assembly: AssemblyTitle("ICSharpCode.NRefactory.CSharp.AstVerifier")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("")] 12 | [assembly: AssemblyCopyright("mike")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". 17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision, 18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision. 19 | 20 | [assembly: AssemblyVersion("1.0.*")] 21 | 22 | // The following attributes are used to specify the signing key for the assembly, 23 | // if desired. See the Mono documentation for more information about signing. 24 | 25 | //[assembly: AssemblyDelaySign(false)] 26 | //[assembly: AssemblyKeyFile("")] 27 | 28 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/ParenthesizedExpression.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | 6 | namespace ICSharpCode.NRefactory.VB.Ast 7 | { 8 | /// 9 | /// Description of ParenthesizedExpression. 10 | /// 11 | public class ParenthesizedExpression : Expression 12 | { 13 | public ParenthesizedExpression() 14 | { 15 | } 16 | 17 | public Expression Expression { 18 | get { return GetChildByRole(Roles.Expression); } 19 | set { SetChildByRole(Roles.Expression, value); } 20 | } 21 | 22 | protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) 23 | { 24 | var expr = other as ParenthesizedExpression; 25 | return expr != null && 26 | Expression.DoMatch(expr.Expression, match); 27 | } 28 | 29 | public override S AcceptVisitor(IAstVisitor visitor, T data) 30 | { 31 | return visitor.VisitParenthesizedExpression(this, data); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/SimpleNameExpression.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | 6 | namespace ICSharpCode.NRefactory.VB.Ast 7 | { 8 | /// 9 | /// Description of SimpleNameExpression. 10 | /// 11 | public class SimpleNameExpression : Expression 12 | { 13 | public Identifier Identifier { get; set; } 14 | 15 | public AstNodeCollection TypeArguments { 16 | get { return GetChildrenByRole(Roles.TypeArgument); } 17 | } 18 | 19 | protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) 20 | { 21 | var node = other as SimpleNameExpression; 22 | return node != null 23 | && Identifier.DoMatch(node.Identifier, match) 24 | && TypeArguments.DoMatch(node.TypeArguments, match); 25 | } 26 | 27 | public override S AcceptVisitor(IAstVisitor visitor, T data) 28 | { 29 | return visitor.VisitSimpleNameExpression(this, data); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Statements/SyncLockStatement.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | 7 | namespace ICSharpCode.NRefactory.VB.Ast 8 | { 9 | /// 10 | /// SyncLock Expression
11 | /// Block
12 | /// End SyncLock 13 | ///
14 | public class SyncLockStatement : Statement 15 | { 16 | public Expression Expression { 17 | get { return GetChildByRole(Roles.Expression); } 18 | set { SetChildByRole(Roles.Expression, value); } 19 | } 20 | 21 | public BlockStatement Body { 22 | get { return GetChildByRole(Roles.Body); } 23 | set { SetChildByRole(Roles.Body, value); } 24 | } 25 | 26 | public override S AcceptVisitor (IAstVisitor visitor, T data) 27 | { 28 | return visitor.VisitSyncLockStatement(this, data); 29 | } 30 | 31 | protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) 32 | { 33 | throw new NotImplementedException(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/GetXmlNamespaceExpression.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | 6 | namespace ICSharpCode.NRefactory.VB.Ast 7 | { 8 | public class GetXmlNamespaceExpression : Expression 9 | { 10 | public GetXmlNamespaceExpression(XmlIdentifier namespaceName) 11 | { 12 | SetChildByRole(Roles.XmlIdentifier, namespaceName); 13 | } 14 | 15 | public XmlIdentifier NamespaceName { 16 | get { return GetChildByRole(Roles.XmlIdentifier); } 17 | set { SetChildByRole(Roles.XmlIdentifier, value); } 18 | } 19 | 20 | protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) 21 | { 22 | var expr = other as GetXmlNamespaceExpression; 23 | return expr != null && 24 | NamespaceName.DoMatch(expr.NamespaceName, match); 25 | } 26 | 27 | public override S AcceptVisitor(IAstVisitor visitor, T data) 28 | { 29 | return visitor.VisitGetXmlNamespaceExpression(this, data); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /ICSharpCode.Decompiler/Tests/CustomAttributes.code.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | namespace aa 3 | { 4 | public static class CustomAtributes 5 | { 6 | [Flags] 7 | public enum EnumWithFlag 8 | { 9 | All = 15, 10 | None = 0, 11 | Item1 = 1, 12 | Item2 = 2, 13 | Item3 = 4, 14 | Item4 = 8 15 | } 16 | [AttributeUsage(AttributeTargets.All)] 17 | public class MyAttribute : Attribute 18 | { 19 | public MyAttribute(CustomAtributes.EnumWithFlag en) 20 | { 21 | } 22 | } 23 | [CustomAtributes.MyAttribute(CustomAtributes.EnumWithFlag.Item1 | CustomAtributes.EnumWithFlag.Item2)] 24 | private static int field; 25 | [CustomAtributes.MyAttribute(CustomAtributes.EnumWithFlag.All)] 26 | public static string Property 27 | { 28 | get 29 | { 30 | return "aa"; 31 | } 32 | } 33 | [Obsolete("some message")] 34 | public static void ObsoletedMethod() 35 | { 36 | Console.WriteLine("{0} $$$ {1}", AttributeTargets.Interface, AttributeTargets.Property | AttributeTargets.Field); 37 | AttributeTargets attributeTargets = AttributeTargets.Property | AttributeTargets.Field; 38 | Console.WriteLine("{0} $$$ {1}", AttributeTargets.Interface, attributeTargets); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Statements/UsingStatement.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | 7 | namespace ICSharpCode.NRefactory.VB.Ast 8 | { 9 | public class UsingStatement : Statement 10 | { 11 | public static readonly Role ResourceRole = new Role("Resource", AstNode.Null); 12 | 13 | /// either multiple VariableInitializers or one Expression 14 | public AstNodeCollection Resources { 15 | get { return GetChildrenByRole(ResourceRole); } 16 | } 17 | 18 | public BlockStatement Body { 19 | get { return GetChildByRole(Roles.Body); } 20 | set { SetChildByRole(Roles.Body, value); } 21 | } 22 | 23 | protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) 24 | { 25 | throw new NotImplementedException(); 26 | } 27 | 28 | public override S AcceptVisitor(IAstVisitor visitor, T data) 29 | { 30 | return visitor.VisitUsingStatement(this, data); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Lexer/LATextReader.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.IO; 7 | 8 | namespace ICSharpCode.NRefactory.VB.Parser 9 | { 10 | public class LATextReader : TextReader 11 | { 12 | List buffer; 13 | TextReader reader; 14 | 15 | public LATextReader(TextReader reader) 16 | { 17 | this.buffer = new List(); 18 | this.reader = reader; 19 | } 20 | 21 | public override int Peek() 22 | { 23 | return Peek(0); 24 | } 25 | 26 | public override int Read() 27 | { 28 | int c = Peek(); 29 | buffer.RemoveAt(0); 30 | return c; 31 | } 32 | 33 | public int Peek(int step) 34 | { 35 | while (step >= buffer.Count) { 36 | buffer.Add(reader.Read()); 37 | } 38 | 39 | if (step < 0) 40 | return -1; 41 | 42 | return buffer[step]; 43 | } 44 | 45 | protected override void Dispose(bool disposing) 46 | { 47 | if (disposing) 48 | reader.Dispose(); 49 | base.Dispose(disposing); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/IdentifierExpression.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | 6 | namespace ICSharpCode.NRefactory.VB.Ast 7 | { 8 | public class IdentifierExpression : Expression 9 | { 10 | public IdentifierExpression() 11 | { 12 | 13 | } 14 | 15 | public IdentifierExpression(Identifier identifier) 16 | { 17 | this.Identifier = identifier; 18 | } 19 | 20 | public Identifier Identifier { 21 | get { return GetChildByRole(Roles.Identifier); } 22 | set { SetChildByRole(Roles.Identifier, value); } 23 | } 24 | 25 | public AstNodeCollection TypeArguments { 26 | get { return GetChildrenByRole(Roles.TypeArgument); } 27 | } 28 | 29 | protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) 30 | { 31 | throw new NotImplementedException(); 32 | } 33 | 34 | public override S AcceptVisitor(IAstVisitor visitor, T data) 35 | { 36 | return visitor.VisitIdentifierExpression(this, data); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/GlobalReferenceExpressionTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class GlobalReferenceExpressionTests 14 | { 15 | [Test] 16 | public void VBNetGlobalReferenceExpressionTest() 17 | { 18 | TypeReferenceExpression tre = ParseUtil.ParseExpression("Global.System"); 19 | Assert.IsTrue(tre.TypeReference.IsGlobal); 20 | Assert.AreEqual("System", tre.TypeReference.Type); 21 | } 22 | 23 | [Test] 24 | public void VBNetGlobalTypeDeclaration() 25 | { 26 | LocalVariableDeclaration lvd = ParseUtil.ParseStatement("Dim a As Global.System.String"); 27 | TypeReference typeRef = lvd.GetTypeForVariable(0); 28 | Assert.IsTrue(typeRef.IsGlobal); 29 | Assert.AreEqual("System.String", typeRef.Type); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Statements/LabelDeclarationStatement.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | 7 | namespace ICSharpCode.NRefactory.VB.Ast 8 | { 9 | /// 10 | /// Label: 11 | /// 12 | public class LabelDeclarationStatement : Statement 13 | { 14 | /// either PrimitiveExpression or IdentifierExpression 15 | public Expression Label { 16 | get { return GetChildByRole(Roles.Expression); } 17 | set { SetChildByRole(Roles.Expression, value); } 18 | } 19 | 20 | public VBTokenNode Colon { 21 | get { return GetChildByRole(Roles.Colon); } 22 | } 23 | 24 | public override S AcceptVisitor (IAstVisitor visitor, T data) 25 | { 26 | return visitor.VisitLabelDeclarationStatement(this, data); 27 | } 28 | 29 | protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) 30 | { 31 | LabelDeclarationStatement o = other as LabelDeclarationStatement; 32 | return o != null && this.Label.DoMatch(o.Label, match); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/TypeOfIsExpression.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | 6 | namespace ICSharpCode.NRefactory.VB.Ast 7 | { 8 | public class TypeOfIsExpression : Expression 9 | { 10 | public TypeOfIsExpression() 11 | { 12 | } 13 | 14 | public Expression TypeOfExpression { 15 | get { return GetChildByRole(Roles.Expression); } 16 | set { SetChildByRole(Roles.Expression, value); } 17 | } 18 | 19 | public AstType Type { 20 | get { return GetChildByRole(Roles.Type); } 21 | set { SetChildByRole(Roles.Type, value); } 22 | } 23 | 24 | protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) 25 | { 26 | var expr = other as TypeOfIsExpression; 27 | return expr != null && 28 | TypeOfExpression.DoMatch(expr.TypeOfExpression, match) && 29 | Type.DoMatch(expr.Type, match); 30 | } 31 | 32 | public override S AcceptVisitor(IAstVisitor visitor, T data) 33 | { 34 | return visitor.VisitTypeOfIsExpression(this, data); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/TypeOfIsExpressionTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class TypeOfIsExpressionTests 14 | { 15 | #region VB.NET 16 | [Test] 17 | public void VBNetSimpleTypeOfIsExpression() 18 | { 19 | TypeOfIsExpression ce = ParseUtil.ParseExpression("TypeOf o Is MyObject"); 20 | Assert.AreEqual("MyObject", ce.TypeReference.Type); 21 | Assert.IsTrue(ce.Expression is SimpleNameExpression); 22 | } 23 | 24 | [Test] 25 | public void VBNetGenericTypeOfIsExpression() 26 | { 27 | TypeOfIsExpression ce = ParseUtil.ParseExpression("TypeOf o Is List(of T)"); 28 | Assert.AreEqual("List", ce.TypeReference.Type); 29 | Assert.AreEqual("T", ce.TypeReference.GenericTypes[0].Type); 30 | Assert.IsTrue(ce.Expression is SimpleNameExpression); 31 | } 32 | #endregion 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Statements/ExpressionStatement.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | 7 | namespace ICSharpCode.NRefactory.VB.Ast 8 | { 9 | /// 10 | /// Expression 11 | /// 12 | // TODO this does not directly reflect the VB grammar! 13 | public class ExpressionStatement : Statement 14 | { 15 | public Expression Expression { 16 | get { return GetChildByRole (Roles.Expression); } 17 | set { SetChildByRole (Roles.Expression, value); } 18 | } 19 | 20 | public override S AcceptVisitor (IAstVisitor visitor, T data) 21 | { 22 | return visitor.VisitExpressionStatement(this, data); 23 | } 24 | 25 | public ExpressionStatement() 26 | { 27 | } 28 | 29 | public ExpressionStatement(Expression expression) 30 | { 31 | this.Expression = expression; 32 | } 33 | 34 | protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) 35 | { 36 | ExpressionStatement o = other as ExpressionStatement; 37 | return o != null && this.Expression.DoMatch(o.Expression, match); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/TypeReferenceExpression.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | 6 | namespace ICSharpCode.NRefactory.VB.Ast 7 | { 8 | /// 9 | /// Represents an AstType as an expression. 10 | /// This is used when calling a method on a primitive type: "Integer.Parse()" 11 | /// 12 | public class TypeReferenceExpression : Expression 13 | { 14 | public AstType Type { 15 | get { return GetChildByRole(Roles.Type); } 16 | set { SetChildByRole(Roles.Type, value); } 17 | } 18 | 19 | public override S AcceptVisitor(IAstVisitor visitor, T data) 20 | { 21 | return visitor.VisitTypeReferenceExpression(this, data); 22 | } 23 | 24 | public TypeReferenceExpression () 25 | { 26 | } 27 | 28 | public TypeReferenceExpression (AstType type) 29 | { 30 | SetChildByRole(Roles.Type, type); 31 | } 32 | 33 | protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) 34 | { 35 | TypeReferenceExpression o = other as TypeReferenceExpression; 36 | return o != null && this.Type.DoMatch(o.Type, match); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Statements/ThrowStatement.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | 7 | namespace ICSharpCode.NRefactory.VB.Ast 8 | { 9 | /// 10 | /// Throw Expression 11 | /// 12 | public class ThrowStatement : Statement 13 | { 14 | public VBTokenNode ThrowToken { 15 | get { return GetChildByRole (Roles.Keyword); } 16 | } 17 | 18 | public Expression Expression { 19 | get { return GetChildByRole(Roles.Expression); } 20 | set { SetChildByRole(Roles.Expression, value); } 21 | } 22 | 23 | public ThrowStatement() 24 | { 25 | } 26 | 27 | public ThrowStatement(Expression expression) 28 | { 29 | AddChild (expression, Roles.Expression); 30 | } 31 | 32 | public override S AcceptVisitor(IAstVisitor visitor, T data) 33 | { 34 | return visitor.VisitThrowStatement(this, data); 35 | } 36 | 37 | protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) 38 | { 39 | ThrowStatement o = other as ThrowStatement; 40 | return o != null && this.Expression.DoMatch(o.Expression, match); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/SpecializedCodeAction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ICSharpCode.NRefactory.CSharp.Refactoring 4 | { 5 | /// 6 | /// A specialized code action creates a code action assoziated with one special type of ast nodes. 7 | /// 8 | public abstract class SpecializedCodeAction : ICodeActionProvider where T : AstNode 9 | { 10 | /// 11 | /// Gets the action for the specified ast node. 12 | /// 13 | /// 14 | /// The code action. May return null, if no action can be provided. 15 | /// 16 | /// 17 | /// The refactoring conext. 18 | /// 19 | /// 20 | /// The AstNode it's ensured that the node is always != null, if called. 21 | /// 22 | protected abstract CodeAction GetAction(RefactoringContext context, T node); 23 | 24 | #region ICodeActionProvider implementation 25 | public System.Collections.Generic.IEnumerable GetActions(RefactoringContext context) 26 | { 27 | var node = context.GetNode(); 28 | if (node == null) 29 | yield break; 30 | var action = GetAction(context, node); 31 | if (action == null) 32 | yield break; 33 | yield return action; 34 | } 35 | #endregion 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Statements/LocalDeclarationStatement.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | 7 | namespace ICSharpCode.NRefactory.VB.Ast 8 | { 9 | /// 10 | /// ( Dim | Static | Const ) VariableDeclarator { , VariableDeclarator } 11 | /// 12 | public class LocalDeclarationStatement : Statement 13 | { 14 | public AstNodeCollection Variables { 15 | get { return GetChildrenByRole(VariableDeclarator.VariableDeclaratorRole); } 16 | } 17 | 18 | public Modifiers Modifiers { 19 | get { return AttributedNode.GetModifiers(this); } 20 | set { AttributedNode.SetModifiers(this, value); } 21 | } 22 | 23 | public VBModifierToken ModifierToken { 24 | get { return GetChildByRole(AttributedNode.ModifierRole); } 25 | } 26 | 27 | public override S AcceptVisitor (IAstVisitor visitor, T data) 28 | { 29 | return visitor.VisitLocalDeclarationStatement(this, data); 30 | } 31 | 32 | protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) 33 | { 34 | throw new NotImplementedException(); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Statements/ReturnStatement.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | 7 | namespace ICSharpCode.NRefactory.VB.Ast 8 | { 9 | /// 10 | /// Return Expression 11 | /// 12 | public class ReturnStatement : Statement 13 | { 14 | public VBTokenNode ReturnToken { 15 | get { return GetChildByRole (Roles.Keyword); } 16 | } 17 | 18 | public Expression Expression { 19 | get { return GetChildByRole(Roles.Expression); } 20 | set { SetChildByRole(Roles.Expression, value); } 21 | } 22 | 23 | public ReturnStatement() 24 | { 25 | } 26 | 27 | public ReturnStatement(Expression expression) 28 | { 29 | AddChild (expression, Roles.Expression); 30 | } 31 | 32 | public override S AcceptVisitor(IAstVisitor visitor, T data) 33 | { 34 | return visitor.VisitReturnStatement(this, data); 35 | } 36 | 37 | protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) 38 | { 39 | ReturnStatement o = other as ReturnStatement; 40 | return o != null && this.Expression.DoMatch(o.Expression, match); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Statements/ForEachStatement.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | 7 | namespace ICSharpCode.NRefactory.VB.Ast 8 | { 9 | public class ForEachStatement : Statement 10 | { 11 | public static readonly Role VariableRole = new Role("Variable", AstNode.Null); 12 | 13 | public AstNode Variable { 14 | get { return GetChildByRole(VariableRole); } 15 | set { SetChildByRole(VariableRole, value); } 16 | } 17 | 18 | public Expression InExpression { 19 | get { return GetChildByRole(Roles.Expression); } 20 | set { SetChildByRole(Roles.Expression, value); } 21 | } 22 | 23 | public BlockStatement Body { 24 | get { return GetChildByRole(Roles.Body); } 25 | set { SetChildByRole(Roles.Body, value); } 26 | } 27 | 28 | protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) 29 | { 30 | throw new NotImplementedException(); 31 | } 32 | 33 | public override S AcceptVisitor(IAstVisitor visitor, T data) 34 | { 35 | return visitor.VisitForEachStatement(this, data); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Output/CodeDOM/CodeDOMTypeReferenceTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.CodeDom; 6 | using System.Collections.Generic; 7 | 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | using ICSharpCode.NRefactory.VB.Visitors; 10 | using NUnit.Framework; 11 | 12 | namespace ICSharpCode.NRefactory.VB.Tests.Output.CodeDom.Tests 13 | { 14 | [TestFixture] 15 | public class CodeDOMTypeReferenceTest 16 | { 17 | [TestAttribute] 18 | public void InnerClassTypeReferencTest() 19 | { 20 | InnerClassTypeReference ictr = new InnerClassTypeReference( 21 | new TypeReference("OuterClass", new List { new TypeReference("String") }), 22 | "InnerClass", 23 | new List { new TypeReference("Int32"), new TypeReference("Int64") }); 24 | Assert.AreEqual("OuterClass+InnerClass", ictr.ToString()); 25 | CodeTypeOfExpression result = (CodeTypeOfExpression)new TypeOfExpression(ictr).AcceptVisitor(new CodeDomVisitor(), null); 26 | Assert.AreEqual("OuterClass`1+InnerClass`2", result.Type.BaseType); 27 | Assert.AreEqual(3, result.Type.TypeArguments.Count); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/SwitchStatementTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class SwitchStatementTests 14 | { 15 | #region VB.NET 16 | [Test] 17 | public void VBSwitchStatementTest() 18 | { 19 | SwitchStatement switchStmt = ParseUtil.ParseStatement("Select Case a\n Case 4, 5\n Case 6\n Case Else\n End Select"); 20 | Assert.AreEqual("a", ((SimpleNameExpression)switchStmt.SwitchExpression).Identifier); 21 | // TODO: Extend test 22 | } 23 | 24 | [Test] 25 | public void InvalidVBSwitchStatementTest() 26 | { 27 | SwitchStatement switchStmt = ParseUtil.ParseStatement("Select Case a\n Case \n End Select", true); 28 | Assert.AreEqual("a", ((SimpleNameExpression)switchStmt.SwitchExpression).Identifier); 29 | SwitchSection sec = switchStmt.SwitchSections[0]; 30 | Assert.AreEqual(0, sec.SwitchLabels.Count); 31 | } 32 | #endregion 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /ICSharpCode.Decompiler/Tests/Helpers/RemoveCompilerAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | using ICSharpCode.Decompiler.Ast.Transforms; 7 | using ICSharpCode.NRefactory.CSharp; 8 | 9 | namespace ICSharpCode.Decompiler.Tests.Helpers 10 | { 11 | class RemoveCompilerAttribute : DepthFirstAstVisitor, IAstTransform 12 | { 13 | public override object VisitAttribute(NRefactory.CSharp.Attribute attribute, object data) 14 | { 15 | var section = (AttributeSection)attribute.Parent; 16 | SimpleType type = attribute.Type as SimpleType; 17 | if (section.AttributeTarget == "assembly" && 18 | (type.Identifier == "CompilationRelaxations" || type.Identifier == "RuntimeCompatibility" || type.Identifier == "SecurityPermission" || type.Identifier == "AssemblyVersion" || type.Identifier == "Debuggable")) 19 | { 20 | attribute.Remove(); 21 | if (section.Attributes.Count == 0) 22 | section.Remove(); 23 | } 24 | if (section.AttributeTarget == "module" && type.Identifier == "UnverifiableCode") 25 | { 26 | attribute.Remove(); 27 | if (section.Attributes.Count == 0) 28 | section.Remove(); 29 | } 30 | return null; 31 | } 32 | 33 | public void Run(AstNode node) 34 | { 35 | node.AcceptVisitor(this, null); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/OutputVisitor/IOutputFormatter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | 6 | namespace ICSharpCode.NRefactory.VB 7 | { 8 | /// 9 | /// Output formatter for the Output visitor. 10 | /// 11 | public interface IOutputFormatter 12 | { 13 | void StartNode(AstNode node); 14 | void EndNode(AstNode node); 15 | 16 | /// 17 | /// Writes an identifier. 18 | /// If the identifier conflicts with a keyword, the output visitor will 19 | /// call WriteToken("[") before and WriteToken("]") after calling WriteIdentifier(). 20 | /// 21 | void WriteIdentifier(string identifier); 22 | 23 | /// 24 | /// Writes a keyword to the output. 25 | /// 26 | void WriteKeyword(string keyword); 27 | 28 | /// 29 | /// Writes a token to the output. 30 | /// 31 | void WriteToken(string token); 32 | void Space(); 33 | 34 | void Indent(); 35 | void Unindent(); 36 | 37 | void NewLine(); 38 | 39 | void WriteComment(bool isDocumentation, string content); 40 | 41 | void MarkFoldStart(); 42 | void MarkFoldEnd(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Statements/YieldStatement.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | 7 | namespace ICSharpCode.NRefactory.VB.Ast 8 | { 9 | /// 10 | /// Yield Expression 11 | /// 12 | /// VB 11 13 | public class YieldStatement : Statement 14 | { 15 | public VBTokenNode YieldToken { 16 | get { return GetChildByRole (Roles.Keyword); } 17 | } 18 | 19 | public Expression Expression { 20 | get { return GetChildByRole(Roles.Expression); } 21 | set { SetChildByRole(Roles.Expression, value); } 22 | } 23 | 24 | public YieldStatement() 25 | { 26 | } 27 | 28 | public YieldStatement(Expression expression) 29 | { 30 | AddChild (expression, Roles.Expression); 31 | } 32 | 33 | public override S AcceptVisitor(IAstVisitor visitor, T data) 34 | { 35 | return visitor.VisitYieldStatement(this, data); 36 | } 37 | 38 | protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) 39 | { 40 | YieldStatement o = other as YieldStatement; 41 | return o != null && this.Expression.DoMatch(o.Expression, match); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ICSharpCode.Decompiler is a library extract from ILSpy. 2 | 3 | ILSpy license: 4 | ``` 5 | Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 8 | software and associated documentation files (the "Software"), to deal in the Software 9 | without restriction, including without limitation the rights to use, copy, modify, merge, 10 | publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 11 | to whom the Software is furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all copies or 14 | substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | DEALINGS IN THE SOFTWARE. 22 | ``` 23 | 24 | ICSharpCode.Decompiler is modified to use dnlib by Ki (yck1509). -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/PrettyPrinter/IOutputAstVisitor.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using ICSharpCode.NRefactory.VB.Parser; 6 | using ICSharpCode.NRefactory.VB.Ast; 7 | 8 | namespace ICSharpCode.NRefactory.VB.PrettyPrinter 9 | { 10 | // public interface IOutputDomVisitor : IAstVisitor 11 | // { 12 | // event Action BeforeNodeVisit; 13 | // event Action AfterNodeVisit; 14 | // 15 | // string Text { 16 | // get; 17 | // } 18 | // 19 | // Errors Errors { 20 | // get; 21 | // } 22 | // 23 | // AbstractPrettyPrintOptions Options { 24 | // get; 25 | // } 26 | // IOutputFormatter OutputFormatter { 27 | // get; 28 | // } 29 | // } 30 | 31 | public interface IOutputFormatter 32 | { 33 | int IndentationLevel { 34 | get; 35 | set; 36 | } 37 | string Text { 38 | get; 39 | } 40 | bool IsInMemberBody { 41 | get; 42 | set; 43 | } 44 | void NewLine(); 45 | void Indent(); 46 | // void PrintComment(Comment comment, bool forceWriteInPreviousBlock); 47 | // void PrintPreprocessingDirective(PreprocessingDirective directive, bool forceWriteInPreviousBlock); 48 | void PrintBlankLine(bool forceWriteInPreviousBlock); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/ConstructorDeclarationTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using ICSharpCode.NRefactory.VB.Ast; 6 | using NUnit.Framework; 7 | 8 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 9 | { 10 | [TestFixture] 11 | public class ConstructorDeclarationTests 12 | { 13 | #region VB.NET 14 | [Test] 15 | public void VBNetConstructorDeclarationTest1() 16 | { 17 | string program = @"Sub New() 18 | End Sub"; 19 | ConstructorDeclaration cd = ParseUtil.ParseTypeMember(program); 20 | Assert.IsTrue(cd.ConstructorInitializer.IsNull); 21 | } 22 | 23 | [Test] 24 | public void VBNetConstructorDeclarationTest2() 25 | { 26 | ConstructorDeclaration cd = ParseUtil.ParseTypeMember("Sub New(x As Integer, Optional y As String) \nEnd Sub"); 27 | Assert.AreEqual(2, cd.Parameters.Count); 28 | Assert.AreEqual("System.Int32", cd.Parameters[0].TypeReference.Type); 29 | Assert.AreEqual("System.String", cd.Parameters[1].TypeReference.Type); 30 | Assert.AreEqual(ParameterModifiers.Optional, cd.Parameters[1].ParamModifier & ParameterModifiers.Optional); 31 | } 32 | #endregion 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/General/EventMemberSpecifier.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | 6 | namespace ICSharpCode.NRefactory.VB.Ast 7 | { 8 | public class EventMemberSpecifier : AstNode 9 | { 10 | public static readonly Role EventMemberSpecifierRole = new Role("EventMemberSpecifier"); 11 | 12 | public EventMemberSpecifier() 13 | { 14 | } 15 | 16 | public Expression Target { 17 | get { return GetChildByRole(Roles.Expression); } 18 | set { SetChildByRole(Roles.Expression, value); } 19 | } 20 | 21 | public Identifier Member { 22 | get { return GetChildByRole(Roles.Identifier); } 23 | set { SetChildByRole(Roles.Identifier, value); } 24 | } 25 | 26 | protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) 27 | { 28 | var expr = other as EventMemberSpecifier; 29 | return expr != null && 30 | Target.DoMatch(expr.Target, match) && 31 | Member.DoMatch(expr.Member, match); 32 | } 33 | 34 | public override S AcceptVisitor(IAstVisitor visitor, T data) 35 | { 36 | return visitor.VisitEventMemberSpecifier(this, data); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/General/AttributeBlock.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | 6 | namespace ICSharpCode.NRefactory.VB.Ast 7 | { 8 | public class AttributeBlock : AstNode 9 | { 10 | public readonly static Role AttributeBlockRole = new Role("AttributeBlock"); 11 | public readonly static Role ReturnTypeAttributeBlockRole = new Role("ReturnTypeAttributeBlock"); 12 | 13 | public VBTokenNode LChevron { 14 | get { return GetChildByRole(Roles.LChevron); } 15 | } 16 | 17 | public AstNodeCollection Attributes { 18 | get { return GetChildrenByRole(Attribute.AttributeRole); } 19 | } 20 | 21 | public VBTokenNode RChevron { 22 | get { return GetChildByRole(Roles.RChevron); } 23 | } 24 | 25 | protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) 26 | { 27 | var node = other as AttributeBlock; 28 | return node != null && Attributes.DoMatch(node.Attributes, match); 29 | } 30 | 31 | public override S AcceptVisitor(IAstVisitor visitor, T data) 32 | { 33 | return visitor.VisitAttributeBlock(this, data); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ArrayCreateExpressionTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class ArrayCreateExpressionTests 14 | { 15 | [Test] 16 | public void ArrayCreateExpressionTest1() 17 | { 18 | ArrayCreateExpression ace = ParseUtil.ParseExpression("new Integer() {1, 2, 3, 4}"); 19 | 20 | Assert.AreEqual("System.Int32", ace.CreateType.Type); 21 | Assert.AreEqual(0, ace.Arguments.Count); 22 | Assert.AreEqual(new int[] {0}, ace.CreateType.RankSpecifier); 23 | } 24 | 25 | [Test] 26 | public void ArrayCreateExpressionTest2() 27 | { 28 | ArrayCreateExpression ace = ParseUtil.ParseExpression("New Integer(0 To 5){0, 1, 2, 3, 4, 5}"); 29 | 30 | Assert.AreEqual("System.Int32", ace.CreateType.Type); 31 | Assert.AreEqual(1, ace.Arguments.Count); 32 | Assert.AreEqual(5, (ace.Arguments[0] as PrimitiveExpression).Value); 33 | Assert.AreEqual(new int[] {0}, ace.CreateType.RankSpecifier); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/GlobalScope/ImportsStatement.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | using System; 4 | using System.Collections.Generic; 5 | using ICSharpCode.NRefactory.PatternMatching; 6 | 7 | namespace ICSharpCode.NRefactory.VB.Ast 8 | { 9 | public class ImportsStatement : AstNode 10 | { 11 | public static readonly Role ImportsClauseRole = new Role("ImportsClause", ImportsClause.Null); 12 | 13 | public VBTokenNode Imports { 14 | get { return GetChildByRole(Roles.Keyword); } 15 | } 16 | 17 | public AstNodeCollection ImportsClauses { 18 | get { return GetChildrenByRole(ImportsClauseRole); } 19 | } 20 | 21 | // public override string ToString() { 22 | // return string.Format("[ImportsStatement ImportsClauses={0}]", GetCollectionString(ImportsClauses)); 23 | // } 24 | 25 | protected internal override bool DoMatch(AstNode other, Match match) 26 | { 27 | ImportsStatement stmt = other as ImportsStatement; 28 | return stmt != null && stmt.ImportsClauses.DoMatch(ImportsClauses, match); 29 | } 30 | 31 | public override S AcceptVisitor(IAstVisitor visitor, T data) 32 | { 33 | return visitor.VisitImportsStatement(this, data); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/VBParser.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Diagnostics; 7 | using System.IO; 8 | 9 | using ICSharpCode.NRefactory.VB.Ast; 10 | using ICSharpCode.NRefactory.VB.Parser; 11 | 12 | namespace ICSharpCode.NRefactory.VB 13 | { 14 | public enum SnippetType 15 | { 16 | None, 17 | CompilationUnit, 18 | Expression, 19 | Statements, 20 | TypeMembers 21 | } 22 | 23 | public class VBParser 24 | { 25 | bool hasErrors; 26 | Errors errors; 27 | 28 | public CompilationUnit Parse(string content) 29 | { 30 | return Parse(new StringReader(content)); 31 | } 32 | 33 | public CompilationUnit Parse(TextReader reader) 34 | { 35 | var parser = new ICSharpCode.NRefactory.VB.Parser.VBParser(new VBLexer(reader)); 36 | parser.Parse(); 37 | hasErrors = parser.Errors.Count > 0; 38 | errors = parser.Errors; 39 | return parser.CompilationUnit; 40 | } 41 | 42 | public AstNode ParseSnippet(TextReader reader) 43 | { 44 | throw new NotImplementedException(); 45 | } 46 | 47 | public bool HasErrors { 48 | get { return hasErrors; } 49 | } 50 | 51 | public Errors Errors { 52 | get { return errors; } 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/GlobalScope/EnumMemberDeclaration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | 8 | namespace ICSharpCode.NRefactory.VB.Ast 9 | { 10 | public class EnumMemberDeclaration : AstNode 11 | { 12 | public AstNodeCollection Attributes { 13 | get { return GetChildrenByRole(AttributeBlock.AttributeBlockRole); } 14 | } 15 | 16 | public Identifier Name { 17 | get { return GetChildByRole(Roles.Identifier); } 18 | set { SetChildByRole(Roles.Identifier, value); } 19 | } 20 | 21 | public Expression Value { 22 | get { return GetChildByRole(Roles.Expression); } 23 | set { SetChildByRole(Roles.Expression, value); } 24 | } 25 | 26 | protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) 27 | { 28 | var member = other as EnumMemberDeclaration; 29 | return Attributes.DoMatch(member.Attributes, match) && 30 | Name.DoMatch(member.Name, match) && 31 | Value.DoMatch(member.Value, match); 32 | } 33 | 34 | public override S AcceptVisitor(IAstVisitor visitor, T data) 35 | { 36 | return visitor.VisitEnumMemberDeclaration(this, data); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/AnonymousObjectCreationExpression.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | namespace ICSharpCode.NRefactory.VB.Ast 8 | { 9 | public class AnonymousObjectCreationExpression : Expression 10 | { 11 | public AstNodeCollection Initializer { 12 | get { return GetChildrenByRole(Roles.Expression); } 13 | } 14 | 15 | public AnonymousObjectCreationExpression () 16 | { 17 | } 18 | 19 | public AnonymousObjectCreationExpression (IEnumerable initializer) 20 | { 21 | foreach (var ini in initializer) { 22 | AddChild (ini, Roles.Expression); 23 | } 24 | } 25 | 26 | public AnonymousObjectCreationExpression (params Expression[] initializer) : this ((IEnumerable)initializer) 27 | { 28 | } 29 | 30 | public override S AcceptVisitor (IAstVisitor visitor, T data) 31 | { 32 | return visitor.VisitAnonymousObjectCreationExpression(this, data); 33 | } 34 | 35 | protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) 36 | { 37 | var o = other as AnonymousObjectCreationExpression; 38 | return o != null && this.Initializer.DoMatch(o.Initializer, match); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/General/ParameterDeclaration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | 6 | namespace ICSharpCode.NRefactory.VB.Ast 7 | { 8 | public class ParameterDeclaration : AttributedNode 9 | { 10 | public Identifier Name { 11 | get { return GetChildByRole(Roles.Identifier); } 12 | set { SetChildByRole(Roles.Identifier, value); } 13 | } 14 | 15 | public Expression OptionalValue { 16 | get { return GetChildByRole(Roles.Expression); } 17 | set { SetChildByRole(Roles.Expression, value); } 18 | } 19 | 20 | public AstType Type { 21 | get { return GetChildByRole(Roles.Type); } 22 | set { SetChildByRole(Roles.Type, value); } 23 | } 24 | 25 | protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) 26 | { 27 | var param = other as ParameterDeclaration; 28 | return param != null && 29 | MatchAttributesAndModifiers(param, match) && 30 | Name.DoMatch(param.Name, match) && 31 | OptionalValue.DoMatch(param.OptionalValue, match) && 32 | Type.DoMatch(param.Type, match); 33 | } 34 | 35 | public override S AcceptVisitor(IAstVisitor visitor, T data) 36 | { 37 | return visitor.VisitParameterDeclaration(this, data); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Statements/IfElseStatement.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | 7 | namespace ICSharpCode.NRefactory.VB.Ast 8 | { 9 | public class IfElseStatement : Statement 10 | { 11 | public static readonly Role FalseStatementRole = new Role("False", Ast.Statement.Null); 12 | public static readonly Role TrueStatementRole = new Role("True", Ast.Statement.Null); 13 | 14 | public Expression Condition { 15 | get { return GetChildByRole(Roles.Condition); } 16 | set { SetChildByRole(Roles.Condition, value); } 17 | } 18 | 19 | public Statement Body { 20 | get { return GetChildByRole(TrueStatementRole); } 21 | set { SetChildByRole(TrueStatementRole, value); } 22 | } 23 | 24 | public Statement ElseBlock { 25 | get { return GetChildByRole(FalseStatementRole); } 26 | set { SetChildByRole(FalseStatementRole, value); } 27 | } 28 | 29 | public override S AcceptVisitor (IAstVisitor visitor, T data) 30 | { 31 | return visitor.VisitIfElseStatement(this, data); 32 | } 33 | 34 | protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) 35 | { 36 | throw new NotImplementedException(); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/NamedArgumentExpression.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | namespace ICSharpCode.NRefactory.VB.Ast 8 | { 9 | /// 10 | /// Represents a named argument passed to a method or attribute. 11 | /// 12 | public class NamedArgumentExpression : Expression 13 | { 14 | public Identifier Identifier { 15 | get { return GetChildByRole(Roles.Identifier); } 16 | set { SetChildByRole(Roles.Identifier, value); } 17 | } 18 | 19 | public VBTokenNode AssignToken { 20 | get { return GetChildByRole (Roles.Assign); } 21 | } 22 | 23 | public Expression Expression { 24 | get { return GetChildByRole (Roles.Expression); } 25 | set { SetChildByRole (Roles.Expression, value); } 26 | } 27 | 28 | public override S AcceptVisitor(IAstVisitor visitor, T data) 29 | { 30 | return visitor.VisitNamedArgumentExpression(this, data); 31 | } 32 | 33 | protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) 34 | { 35 | NamedArgumentExpression o = other as NamedArgumentExpression; 36 | return o != null && this.Identifier.DoMatch(o.Identifier, match) && this.Expression.DoMatch(o.Expression, match); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/MemberAccessExpression.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | 6 | namespace ICSharpCode.NRefactory.VB.Ast 7 | { 8 | public class MemberAccessExpression : Expression 9 | { 10 | public MemberAccessExpression() 11 | { 12 | } 13 | 14 | public Expression Target { 15 | get { return GetChildByRole(Roles.Expression); } 16 | set { SetChildByRole(Roles.Expression, value); } 17 | } 18 | 19 | public Identifier MemberName { 20 | get { return GetChildByRole(Roles.Identifier); } 21 | set { SetChildByRole(Roles.Identifier, value); } 22 | } 23 | 24 | public AstNodeCollection TypeArguments { 25 | get { return GetChildrenByRole(Roles.TypeArgument); } 26 | } 27 | 28 | protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) 29 | { 30 | var expr = other as MemberAccessExpression; 31 | return expr != null && 32 | Target.DoMatch(expr.Target, match) && 33 | MemberName.DoMatch(expr.MemberName, match) && 34 | TypeArguments.DoMatch(expr.TypeArguments, match); 35 | } 36 | 37 | public override S AcceptVisitor(IAstVisitor visitor, T data) 38 | { 39 | return visitor.VisitMemberAccessExpression(this, data); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/TypeMembers/ConstructorDeclaration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | 6 | namespace ICSharpCode.NRefactory.VB.Ast 7 | { 8 | public abstract class MemberDeclaration : AttributedNode 9 | { 10 | 11 | } 12 | 13 | /// 14 | /// Description of ConstructorDeclaration. 15 | /// 16 | public class ConstructorDeclaration : MemberDeclaration 17 | { 18 | public ConstructorDeclaration() 19 | { 20 | } 21 | 22 | public AstNodeCollection Parameters { 23 | get { return GetChildrenByRole(Roles.Parameter); } 24 | } 25 | 26 | public BlockStatement Body { 27 | get { return GetChildByRole(Roles.Body); } 28 | set { SetChildByRole(Roles.Body, value); } 29 | } 30 | 31 | protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) 32 | { 33 | var ctor = other as ConstructorDeclaration; 34 | return ctor != null && 35 | MatchAttributesAndModifiers(ctor, match) && 36 | Parameters.DoMatch(ctor.Parameters, match) && 37 | Body.DoMatch(ctor.Body, match); 38 | } 39 | 40 | public override S AcceptVisitor(IAstVisitor visitor, T data) 41 | { 42 | return visitor.VisitConstructorDeclaration(this, data); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Lexer/Block.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | 9 | namespace ICSharpCode.NRefactory.VB.Parser 10 | { 11 | public enum Context 12 | { 13 | Global, 14 | TypeDeclaration, 15 | ObjectCreation, 16 | ObjectInitializer, 17 | CollectionInitializer, 18 | Type, 19 | Member, 20 | Parameter, 21 | Identifier, 22 | Body, 23 | Xml, 24 | Attribute, 25 | Importable, 26 | Query, 27 | Expression, 28 | Debug, 29 | Default 30 | } 31 | 32 | public class Block : ICloneable 33 | { 34 | public static readonly Block Default = new Block() { 35 | context = Context.Global, 36 | lastExpressionStart = TextLocation.Empty 37 | }; 38 | 39 | public Context context; 40 | public TextLocation lastExpressionStart; 41 | public bool isClosed; 42 | 43 | public override string ToString() 44 | { 45 | return string.Format("[Block Context={0}, LastExpressionStart={1}, IsClosed={2}]", context, lastExpressionStart, isClosed); 46 | } 47 | 48 | public object Clone() 49 | { 50 | return new Block() { 51 | context = this.context, 52 | lastExpressionStart = this.lastExpressionStart, 53 | isClosed = this.isClosed 54 | }; 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.ConsistencyCheck/Readme.txt: -------------------------------------------------------------------------------- 1 | This is an automatic consistency check for NRefactory. 2 | It loads a solution file and parses all the source code and referenced libraries, 3 | and then performs a set of consistency checks. 4 | These checks assume that the code is valid C# without any compilation errors, 5 | so make sure to only pass in compilable source code. 6 | 7 | Checks currently being performed: 8 | - IDStringConsistencyCheck: Checks that ID strings are unique and refer back to the correct entity 9 | - RoundtripTest: parses C# code and outputs it again using CSharpOutputVisitor, checking that only whitespace is changing 10 | - ResolverTest: fully resolves all ASTs and validates that no errors are detected (no false positives in semantic error checking) 11 | - RandomizedOrderResolverTest: checks that the order of Resolve()/GetResolverState() calls has no effect on the result 12 | - FindReferencesConsistencyCheck: checks that FindReferences is the inverse of FindReferencedEntities 13 | 14 | XML Tests: 15 | - IncrementalXmlParserTests: tests that incremental parsing produces results identical to a full reparse 16 | - XmlReaderTests: compares AXmlParser.Parse().CreateReader() with new XmlTextReader() 17 | 18 | 19 | 20 | Ideas for further tests: 21 | - Test token positions (see AstVerifier) 22 | - Compare resolve results with csc compiler output (using Cecil) 23 | - Randomly mutate a C# file (e.g. remove tokens) and verify that the parser does not crash 24 | -------------------------------------------------------------------------------- /ICSharpCode.Decompiler/Tests/Lock.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 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 | public class Lock 22 | { 23 | public void LockThis() 24 | { 25 | lock (this) 26 | { 27 | Console.WriteLine(); 28 | } 29 | } 30 | 31 | public void LockOnType() 32 | { 33 | lock (typeof(Lock)) 34 | { 35 | Console.WriteLine(); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Statements/ContinueStatement.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | 7 | namespace ICSharpCode.NRefactory.VB.Ast 8 | { 9 | /// 10 | /// Continue ( Do | For | While ) 11 | /// 12 | public class ContinueStatement : Statement 13 | { 14 | public static readonly Role ContinueKindTokenRole = new Role("ContinueKindToken"); 15 | 16 | public ContinueKind ContinueKind { get; set; } 17 | 18 | public VBTokenNode ContinueToken { 19 | get { return GetChildByRole (Roles.Keyword); } 20 | } 21 | 22 | public VBTokenNode ContinueKindToken { 23 | get { return GetChildByRole (ContinueKindTokenRole); } 24 | } 25 | 26 | public ContinueStatement(ContinueKind kind) 27 | { 28 | this.ContinueKind = kind; 29 | } 30 | 31 | public override S AcceptVisitor(IAstVisitor visitor, T data) 32 | { 33 | return visitor.VisitContinueStatement(this, data); 34 | } 35 | 36 | protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) 37 | { 38 | ContinueStatement o = other as ContinueStatement; 39 | return o != null && this.ContinueKind == o.ContinueKind; 40 | } 41 | } 42 | 43 | public enum ContinueKind 44 | { 45 | None, 46 | Do, 47 | For, 48 | While 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/UsingStatementTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class UsingStatementTests 14 | { 15 | [Test] 16 | public void UsingStatement() 17 | { 18 | string usingText = @" 19 | Using nf As New System.Drawing.Font(""Arial"", 12.0F, FontStyle.Bold) 20 | c.Font = nf 21 | c.Text = ""This is 12-point Arial bold"" 22 | End Using"; 23 | UsingStatement usingStmt = ParseUtil.ParseStatement(usingText); 24 | // TODO : Extend test. 25 | } 26 | [Test] 27 | public void UsingStatement2() 28 | { 29 | string usingText = @" 30 | Using nf As Font = New Font() 31 | Bla(nf) 32 | End Using"; 33 | UsingStatement usingStmt = ParseUtil.ParseStatement(usingText); 34 | // TODO : Extend test. 35 | } 36 | [Test] 37 | public void UsingStatement3() 38 | { 39 | string usingText = @" 40 | Using nf As New Font(), nf2 As New List(Of Font)(), nf3 = Nothing 41 | Bla(nf) 42 | End Using"; 43 | UsingStatement usingStmt = ParseUtil.ParseStatement(usingText); 44 | // TODO : Extend test. 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Statements/AddRemoveHandlerStatement.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | 6 | namespace ICSharpCode.NRefactory.VB.Ast 7 | { 8 | /// 9 | /// ( AddHandler | RemoveHandler ) Expression, Expression 10 | /// 11 | public class AddRemoveHandlerStatement : Statement 12 | { 13 | public static readonly Role EventExpressionRole = new Role("EventExpression", Expression.Null); 14 | public static readonly Role DelegateExpressionRole = new Role("DelegateExpression", Expression.Null); 15 | 16 | public bool IsAddHandler { get; set; } 17 | 18 | public Expression EventExpression { 19 | get { return GetChildByRole(EventExpressionRole); } 20 | set { SetChildByRole(EventExpressionRole, value); } 21 | } 22 | 23 | public Expression DelegateExpression { 24 | get { return GetChildByRole(DelegateExpressionRole); } 25 | set { SetChildByRole(DelegateExpressionRole, value); } 26 | } 27 | 28 | public override S AcceptVisitor(IAstVisitor visitor, T data) 29 | { 30 | return visitor.VisitAddRemoveHandlerStatement(this, data); 31 | } 32 | 33 | protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) 34 | { 35 | throw new NotImplementedException(); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory/TypeSystem/EntityType.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 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 enum EntityType : byte 24 | { 25 | None, 26 | TypeDefinition, 27 | Field, 28 | Property, 29 | Indexer, 30 | Event, 31 | Method, 32 | Operator, 33 | Constructor, 34 | Destructor, 35 | Accessor 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ICSharpCode.Decompiler/Tests/DoubleConstants.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 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 | public class DoubleConstants 22 | { 23 | public const double Zero = 0.0; 24 | public const double MinusZero = -0.0; 25 | public const double NaN = double.NaN; 26 | public const double PositiveInfinity = double.PositiveInfinity; 27 | public const double NegativeInfinity = double.NegativeInfinity; 28 | } 29 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.Demo/VBEditDialog.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 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.Drawing; 21 | using System.Windows.Forms; 22 | 23 | namespace ICSharpCode.NRefactory.Demo 24 | { 25 | public partial class VBEditDialog 26 | { 27 | public VBEditDialog(object element) 28 | { 29 | InitializeComponent(); 30 | propertyGrid.SelectedObject = element; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Statements/ExitStatement.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | 7 | namespace ICSharpCode.NRefactory.VB.Ast 8 | { 9 | /// 10 | /// Exit ( Do | For | While | Select | Sub | Function | Property | Try ) 11 | /// 12 | public class ExitStatement : Statement 13 | { 14 | public static readonly Role ExitKindTokenRole = new Role("ExitKindToken"); 15 | 16 | public ExitKind ExitKind { get; set; } 17 | 18 | public VBTokenNode ExitToken { 19 | get { return GetChildByRole (Roles.Keyword); } 20 | } 21 | 22 | public VBTokenNode ExitKindToken { 23 | get { return GetChildByRole (ExitKindTokenRole); } 24 | } 25 | 26 | public ExitStatement(ExitKind kind) 27 | { 28 | this.ExitKind = kind; 29 | } 30 | 31 | public override S AcceptVisitor(IAstVisitor visitor, T data) 32 | { 33 | return visitor.VisitExitStatement(this, data); 34 | } 35 | 36 | protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) 37 | { 38 | ExitStatement o = other as ExitStatement; 39 | return o != null && this.ExitKind == o.ExitKind; 40 | } 41 | } 42 | 43 | public enum ExitKind 44 | { 45 | None, 46 | Sub, 47 | Function, 48 | Property, 49 | Do, 50 | For, 51 | While, 52 | Select, 53 | Try 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System.Reflection; 5 | using System.Runtime.CompilerServices; 6 | 7 | // Information about this assembly is defined by the following 8 | // attributes. 9 | // 10 | // change them to the information which is associated with the assembly 11 | // you compile. 12 | 13 | [assembly: AssemblyTitle("NRefactory Test")] 14 | [assembly: AssemblyDescription("Unit tests for the parser and refactoring library for C# and VB.NET")] 15 | [assembly: AssemblyConfiguration("")] 16 | [assembly: AssemblyCompany("ic#code")] 17 | [assembly: AssemblyProduct("SharpDevelop")] 18 | [assembly: AssemblyCopyright("2004-2006 AlphaSierraPapa")] 19 | [assembly: AssemblyTrademark("")] 20 | [assembly: AssemblyCulture("")] 21 | 22 | // The assembly version has following format : 23 | // 24 | // Major.Minor.Build.Revision 25 | // 26 | // You can specify all values by your own or you can build default build and revision 27 | // numbers with the '*' character (the default): 28 | 29 | [assembly: AssemblyVersion("2.0.0.1")] 30 | 31 | // The following attributes specify the key for the sign of your assembly. See the 32 | // .NET Framework documentation for more information about signing. 33 | // This is not required, if you don't want signing let these attributes like they're. 34 | [assembly: AssemblyDelaySign(false)] 35 | [assembly: AssemblyKeyFile("")] 36 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/IdentifierExpressionTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class IdentifierExpressionTests 14 | { 15 | #region VB.NET 16 | [Test] 17 | public void VBNetIdentifierExpressionTest1() 18 | { 19 | IdentifierExpression ie = ParseUtil.ParseExpression("MyIdentifier"); 20 | Assert.AreEqual("MyIdentifier", ie.Identifier); 21 | } 22 | 23 | [Test] 24 | public void VBNetIdentifierExpressionTest2() 25 | { 26 | IdentifierExpression ie = ParseUtil.ParseExpression("[Public]"); 27 | Assert.AreEqual("Public", ie.Identifier); 28 | } 29 | 30 | [Test] 31 | public void VBNetContextKeywordsTest() 32 | { 33 | Assert.AreEqual("Assembly", ParseUtil.ParseExpression("Assembly").Identifier); 34 | Assert.AreEqual("Custom", ParseUtil.ParseExpression("Custom").Identifier); 35 | Assert.AreEqual("Off", ParseUtil.ParseExpression("Off").Identifier); 36 | Assert.AreEqual("Explicit", ParseUtil.ParseExpression("Explicit").Identifier); 37 | } 38 | #endregion 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/NamespaceDeclarationTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using ICSharpCode.NRefactory.VB.Ast; 6 | using NUnit.Framework; 7 | 8 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 9 | { 10 | [TestFixture] 11 | public class NamespaceDeclarationTests 12 | { 13 | // #region VB.NET 14 | // [Test] 15 | // public void VBNetSimpleNamespaceTest() 16 | // { 17 | // string program = "Namespace TestNamespace" + Environment.NewLine + 18 | // "End Namespace" +Environment.NewLine; 19 | // NamespaceDeclaration ns = ParseUtil.ParseGlobal(program); 20 | // Assert.AreEqual("TestNamespace", ns.Name); 21 | // } 22 | // 23 | // [Test] 24 | // public void VBNetJuggedNamespaceTest() 25 | // { 26 | // string program = "Namespace N1 'TestNamespace\n" + 27 | // " Namespace N2 ' Declares a namespace named N2 within N1.\n" + 28 | // " End Namespace\n" + 29 | // "End Namespace\n"; 30 | // 31 | // NamespaceDeclaration ns = ParseUtil.ParseGlobal(program); 32 | // 33 | // Assert.AreEqual("N1", ns.Name); 34 | // 35 | // Assert.IsTrue(ns.Children[0] is NamespaceDeclaration); 36 | // 37 | // ns = (NamespaceDeclaration)ns.Children[0]; 38 | // 39 | // Assert.AreEqual("N2", ns.Name); 40 | // } 41 | // #endregion 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Parser/Errors.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.Text; 6 | 7 | namespace ICSharpCode.NRefactory.VB.Parser 8 | { 9 | public delegate void ErrorCodeProc(int line, int col, int n); 10 | public delegate void ErrorMsgProc(int line, int col, string msg); 11 | 12 | public class Errors 13 | { 14 | int count = 0; // number of errors detected 15 | public ErrorCodeProc SynErr; 16 | public ErrorCodeProc SemErr; 17 | public ErrorMsgProc Error; 18 | StringBuilder errorText = new StringBuilder(); 19 | 20 | public string ErrorOutput { 21 | get { 22 | return errorText.ToString(); 23 | } 24 | } 25 | 26 | public Errors() 27 | { 28 | SynErr = new ErrorCodeProc(DefaultCodeError); // syntactic errors 29 | SemErr = new ErrorCodeProc(DefaultCodeError); // semantic errors 30 | Error = new ErrorMsgProc(DefaultMsgError); // user defined string based errors 31 | } 32 | 33 | public int Count { 34 | get { 35 | return count; 36 | } 37 | } 38 | 39 | void DefaultCodeError(int line, int col, int n) 40 | { 41 | errorText.AppendLine(String.Format("-- line {0} col {1}: error {2}", line, col, n)); 42 | count++; 43 | } 44 | 45 | void DefaultMsgError(int line, int col, string s) { 46 | errorText.AppendLine(String.Format("-- line {0} col {1}: {2}", line, col, s)); 47 | count++; 48 | } 49 | } // Errors 50 | } 51 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory/Completion/DisplayFlags.cs: -------------------------------------------------------------------------------- 1 | // 2 | // DisplayFlags.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 | 28 | namespace ICSharpCode.NRefactory.Completion 29 | { 30 | [Flags] 31 | public enum DisplayFlags 32 | { 33 | None = 0, 34 | Hidden = 1, 35 | Obsolete = 2, 36 | DescriptionHasMarkup = 4 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /NRefactory/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 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.Xml/SyntaxError.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Created by SharpDevelop. 3 | * User: Daniel 4 | * Date: 2/20/2012 5 | * Time: 17:46 6 | * 7 | * To change this template use Tools | Options | Coding | Edit Standard Headers. 8 | */ 9 | using System; 10 | using ICSharpCode.NRefactory.Editor; 11 | 12 | namespace ICSharpCode.NRefactory.Xml 13 | { 14 | /// 15 | /// A syntax error. 16 | /// 17 | public class SyntaxError : ISegment 18 | { 19 | readonly int startOffset; 20 | readonly int endOffset; 21 | readonly string description; 22 | 23 | /// 24 | /// Creates a new syntax error. 25 | /// 26 | public SyntaxError(int startOffset, int endOffset, string description) 27 | { 28 | if (description == null) 29 | throw new ArgumentNullException("description"); 30 | this.startOffset = startOffset; 31 | this.endOffset = endOffset; 32 | this.description = description; 33 | } 34 | 35 | /// 36 | /// Gets a description of the syntax error. 37 | /// 38 | public string Description { 39 | get { return description; } 40 | } 41 | 42 | /// 43 | /// Gets the start offset of the segment. 44 | /// 45 | public int StartOffset { 46 | get { return startOffset; } 47 | } 48 | 49 | int ISegment.Offset { 50 | get { return startOffset; } 51 | } 52 | 53 | /// 54 | public int Length { 55 | get { return endOffset - startOffset; } 56 | } 57 | 58 | /// 59 | public int EndOffset { 60 | get { return endOffset; } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory/PatternMatching/BacktrackingInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 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.PatternMatching 23 | { 24 | /// 25 | /// Container for the backtracking info. 26 | /// 27 | public class BacktrackingInfo 28 | { 29 | internal Stack backtrackingStack = new Stack(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/ThisReferenceExpressionTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 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 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/TypeMembers/Accessor.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | 6 | namespace ICSharpCode.NRefactory.VB.Ast 7 | { 8 | /// 9 | /// Get/Set/AddHandler/RemoveHandler/RaiseEvent 10 | /// 11 | public class Accessor : AttributedNode 12 | { 13 | public static readonly new Accessor Null = new NullAccessor (); 14 | sealed class NullAccessor : Accessor 15 | { 16 | public override bool IsNull { 17 | get { 18 | return true; 19 | } 20 | } 21 | 22 | public override S AcceptVisitor (IAstVisitor visitor, T data) 23 | { 24 | return default (S); 25 | } 26 | } 27 | 28 | public BlockStatement Body { 29 | get { return GetChildByRole(Roles.Body); } 30 | set { SetChildByRole(Roles.Body, value); } 31 | } 32 | 33 | public AstNodeCollection Parameters { 34 | get { return GetChildrenByRole(Roles.Parameter); } 35 | } 36 | 37 | public override S AcceptVisitor(IAstVisitor visitor, T data) 38 | { 39 | return visitor.VisitAccessor(this, data); 40 | } 41 | 42 | protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) 43 | { 44 | Accessor o = other as Accessor; 45 | return o != null && !o.IsNull && this.MatchAttributesAndModifiers(o, match) && 46 | this.Body.DoMatch(o.Body, match) && Parameters.DoMatch(o.Parameters, match); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/EmptyStatementTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 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 | EmptyStatement emptyStmt = ParseUtilCSharp.ParseStatement(";"); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/CustomEventTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | using NUnit.Framework; 7 | using ICSharpCode.NRefactory.VB.Parser; 8 | using ICSharpCode.NRefactory.VB.Ast; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Tests.Ast 11 | { 12 | [TestFixture] 13 | public class CustomEventTests 14 | { 15 | #region VB.NET 16 | [Test] 17 | public void VBNetCustomEventsStatementTest() 18 | { 19 | string code = @" Public Custom Event TestEvent As EventHandler 20 | AddHandler(ByVal value As EventHandler) 21 | Handlers = CType([Delegate].Combine(Handlers, value), _ 22 | EventHandler) 23 | End AddHandler 24 | 25 | RemoveHandler(ByVal value as EventHandler) 26 | Handlers = CType([Delegate].Remove(Handlers, value), _ 27 | EventHandler) 28 | End RemoveHandler 29 | 30 | RaiseEvent(ByVal sender As Object, ByVal e As EventArgs) 31 | Dim TempHandlers As EventHandler = Handlers 32 | 33 | If TempHandlers IsNot Nothing Then 34 | TempHandlers(sender, e) 35 | End If 36 | End RaiseEvent 37 | End Event"; 38 | EventDeclaration customEventDecl = ParseUtil.ParseTypeMember(code); 39 | Assert.IsNotNull(customEventDecl); 40 | Assert.AreEqual("TestEvent", customEventDecl.Name); 41 | } 42 | #endregion 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory/Completion/IEntityCompletionData.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IEntityCompletionData.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 ICSharpCode.NRefactory.TypeSystem; 28 | 29 | namespace ICSharpCode.NRefactory.Completion 30 | { 31 | public interface IEntityCompletionData : ICompletionData 32 | { 33 | IEntity Entity { 34 | get; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory/TypeSystem/IFreezable.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 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 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory/Completion/IVariableCompletionData.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IVariableCompletionData.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 ICSharpCode.NRefactory.TypeSystem; 28 | 29 | namespace ICSharpCode.NRefactory.Completion 30 | { 31 | public interface IVariableCompletionData : ICompletionData 32 | { 33 | IVariable Variable { 34 | get; 35 | } 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /ICSharpCode.Decompiler/Tests/BooleanConsumedAsInteger.il: -------------------------------------------------------------------------------- 1 | .assembly extern mscorlib 2 | { 3 | .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) 4 | .ver 4:0:0:0 5 | } 6 | .assembly BooleanConsumedAsInteger 7 | { 8 | .hash algorithm 0x00008004 9 | .ver 1:0:0:0 10 | } 11 | .module BooleanConsumedAsInteger.exe 12 | .imagebase 0x00400000 13 | .file alignment 0x00000200 14 | .stackreserve 0x00100000 15 | .subsystem 0x0003 // WINDOWS_CUI 16 | .corflags 0x00000003 // ILONLY 32BITREQUIRED 17 | 18 | .class private auto ansi beforefieldinit BooleanConsumedAsInteger.Program extends [mscorlib]System.Object 19 | { 20 | .method public hidebysig static void Main(string[] args) cil managed 21 | { 22 | .entrypoint 23 | .maxstack 8 24 | 25 | ret 26 | } 27 | 28 | .method public hidebysig static int32 ReturnBoolAsInt() cil managed 29 | { 30 | ldnull 31 | ldnull 32 | call bool [mscorlib] System.Object::Equals(object, object) 33 | ret 34 | } 35 | 36 | .method public hidebysig static int32 BitwiseOperationOnBool() cil managed 37 | { 38 | ldnull 39 | ldnull 40 | call bool [mscorlib] System.Object::Equals(object, object) 41 | ldc.i4 255 42 | and 43 | ret 44 | } 45 | 46 | .method public hidebysig specialname rtspecialname 47 | instance void .ctor() cil managed 48 | { 49 | // Code size 7 (0x7) 50 | .maxstack 8 51 | IL_0000: ldarg.0 52 | IL_0001: call instance void [mscorlib]System.Object::.ctor() 53 | IL_0006: ret 54 | } // end of method Program::.ctor 55 | 56 | } // end of class StackTests.Program 57 | 58 | 59 | // ============================================================= 60 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/TypeName/PrimitiveType.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | 7 | namespace ICSharpCode.NRefactory.VB.Ast 8 | { 9 | public class PrimitiveType : AstType 10 | { 11 | public string Keyword { get; set; } 12 | public TextLocation Location { get; set; } 13 | 14 | public PrimitiveType() 15 | { 16 | } 17 | 18 | public PrimitiveType(string keyword) 19 | { 20 | this.Keyword = keyword; 21 | } 22 | 23 | public PrimitiveType(string keyword, TextLocation location) 24 | { 25 | this.Keyword = keyword; 26 | this.Location = location; 27 | } 28 | 29 | public override TextLocation StartLocation { 30 | get { 31 | return Location; 32 | } 33 | } 34 | public override TextLocation EndLocation { 35 | get { 36 | return new TextLocation (Location.Line, Location.Column + (Keyword != null ? Keyword.Length : 0)); 37 | } 38 | } 39 | 40 | public override S AcceptVisitor (IAstVisitor visitor, T data) 41 | { 42 | return visitor.VisitPrimitiveType(this, data); 43 | } 44 | 45 | protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) 46 | { 47 | PrimitiveType o = other as PrimitiveType; 48 | return o != null && MatchString(this.Keyword, o.Keyword); 49 | } 50 | 51 | public override string ToString() 52 | { 53 | return Keyword ?? base.ToString(); 54 | } 55 | } 56 | } 57 | 58 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.GtkDemo/Main.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Main.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 Gtk; 28 | 29 | namespace ICSharpCode.NRefactory.GtkDemo 30 | { 31 | class MainClass 32 | { 33 | public static void Main (string[] args) 34 | { 35 | Application.Init (); 36 | MainWindow win = new MainWindow (); 37 | win.Show (); 38 | Application.Run (); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/LockStatementTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 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 | LockStatement lockStmt = ParseUtilCSharp.ParseStatement("lock (myObj) {}"); 31 | // TODO : Extend test. 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/ICodeActionProvider.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ContextAction.cs 3 | // 4 | // Author: 5 | // Mike Krüger 6 | // 7 | // Copyright (c) 2011 Mike Krüger 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.Threading; 28 | using System.Collections.Generic; 29 | 30 | namespace ICSharpCode.NRefactory.CSharp.Refactoring 31 | { 32 | public interface ICodeActionProvider 33 | { 34 | IEnumerable GetActions (RefactoringContext context); 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /ICSharpCode.Decompiler/Properties/AssemblyInfo.template.cs: -------------------------------------------------------------------------------- 1 | #region Using directives 2 | 3 | using System; 4 | using System.Resources; 5 | using System.Reflection; 6 | using System.Runtime.InteropServices; 7 | 8 | #endregion 9 | 10 | [assembly: AssemblyTitle("ICSharpCode.Decompiler")] 11 | [assembly: AssemblyDescription("IL decompiler engine")] 12 | [assembly: AssemblyCompany("ic#code")] 13 | [assembly: AssemblyProduct("ILSpy")] 14 | [assembly: AssemblyCopyright("Copyright 2011-2014 AlphaSierraPapa for the SharpDevelop Team")] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | 18 | // This sets the default COM visibility of types in the assembly to invisible. 19 | // If you need to expose a type to COM, use [ComVisible(true)] on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | [assembly: AssemblyVersion("$INSERTVERSION$")] 23 | [assembly: AssemblyInformationalVersion("$INSERTVERSION$$INSERTBRANCHPOSTFIX$$INSERTVERSIONNAMEPOSTFIX$-$INSERTSHORTCOMMITHASH$")] 24 | [assembly: NeutralResourcesLanguage("en-US")] 25 | 26 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2243:AttributeStringLiteralsShouldParseCorrectly", 27 | Justification = "AssemblyInformationalVersion does not need to be a parsable version")] 28 | 29 | internal static class RevisionClass { 30 | public const string Major = "2"; 31 | public const string Minor = "1"; 32 | public const string Build = "0"; 33 | public const string Revision = "$INSERTREVISION$"; 34 | public const string VersionName = null; 35 | 36 | public const string FullVersion = Major + "." + Minor + "." + Build + ".$INSERTREVISION$$INSERTBRANCHPOSTFIX$$INSERTVERSIONNAMEPOSTFIX$"; 37 | } -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/UnsafeStatementTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 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 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/SizeOfExpressionTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 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 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/General/InterfaceMemberSpecifier.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | 6 | namespace ICSharpCode.NRefactory.VB.Ast 7 | { 8 | public class InterfaceMemberSpecifier : AstNode 9 | { 10 | public static readonly Role InterfaceMemberSpecifierRole = new Role("InterfaceMemberSpecifier"); 11 | 12 | public InterfaceMemberSpecifier(Expression target, Identifier member) 13 | { 14 | Target = target; 15 | Member = member; 16 | } 17 | 18 | public InterfaceMemberSpecifier(AstType target, string member) 19 | { 20 | Target = new TypeReferenceExpression(target); 21 | Member = new Identifier(member, TextLocation.Empty); 22 | } 23 | 24 | public Expression Target { 25 | get { return GetChildByRole(Roles.Expression); } 26 | set { SetChildByRole(Roles.Expression, value); } 27 | } 28 | 29 | public Identifier Member { 30 | get { return GetChildByRole(Roles.Identifier); } 31 | set { SetChildByRole(Roles.Identifier, value); } 32 | } 33 | 34 | protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) 35 | { 36 | var expr = other as InterfaceMemberSpecifier; 37 | return expr != null && 38 | Target.DoMatch(expr.Target, match) && 39 | Member.DoMatch(expr.Member, match); 40 | } 41 | 42 | public override S AcceptVisitor(IAstVisitor visitor, T data) 43 | { 44 | return visitor.VisitInterfaceMemberSpecifier(this, data); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/GlobalScope/EnumDeclaration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | 8 | namespace ICSharpCode.NRefactory.VB.Ast 9 | { 10 | public class EnumDeclaration : AttributedNode 11 | { 12 | public readonly static Role MemberRole = new Role("Member"); 13 | public readonly static Role UnderlyingTypeRole = new Role("UnderlyingType", AstType.Null); 14 | 15 | public Identifier Name { 16 | get { return GetChildByRole(Roles.Identifier); } 17 | set { SetChildByRole(Roles.Identifier, value); } 18 | } 19 | 20 | public AstType UnderlyingType { 21 | get { return GetChildByRole(UnderlyingTypeRole); } 22 | set { SetChildByRole(UnderlyingTypeRole, value); } 23 | } 24 | 25 | public AstNodeCollection Members { 26 | get { return GetChildrenByRole(MemberRole); } 27 | } 28 | 29 | protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) 30 | { 31 | var decl = other as EnumDeclaration; 32 | return decl != null && 33 | MatchAttributesAndModifiers(decl, match) && 34 | Name.DoMatch(decl.Name, match) && 35 | UnderlyingType.DoMatch(decl.UnderlyingType, match) && 36 | Members.DoMatch(decl.Members, match); 37 | } 38 | 39 | public override S AcceptVisitor(IAstVisitor visitor, T data) 40 | { 41 | return visitor.VisitEnumDeclaration(this, data); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/BaseReferenceExpressionTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 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 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/FieldInitializerExpression.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | namespace ICSharpCode.NRefactory.VB.Ast 8 | { 9 | /// 10 | /// [ Key ] .Identifier = Expression 11 | /// 12 | public class FieldInitializerExpression : Expression 13 | { 14 | public bool IsKey { get; set; } 15 | 16 | public VBTokenNode KeyToken { 17 | get { return GetChildByRole (Roles.Keyword); } 18 | } 19 | 20 | public VBTokenNode DotToken { 21 | get { return GetChildByRole (Roles.Dot); } 22 | } 23 | 24 | public Identifier Identifier { 25 | get { return GetChildByRole(Roles.Identifier); } 26 | set { SetChildByRole(Roles.Identifier, value); } 27 | } 28 | 29 | public VBTokenNode AssignToken { 30 | get { return GetChildByRole (Roles.Assign); } 31 | } 32 | 33 | public Expression Expression { 34 | get { return GetChildByRole (Roles.Expression); } 35 | set { SetChildByRole (Roles.Expression, value); } 36 | } 37 | 38 | public override S AcceptVisitor(IAstVisitor visitor, T data) 39 | { 40 | return visitor.VisitFieldInitializerExpression(this, data); 41 | } 42 | 43 | protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) 44 | { 45 | FieldInitializerExpression o = other as FieldInitializerExpression; 46 | return o != null && this.IsKey == o.IsKey && this.Identifier.DoMatch(o.Identifier, match) && this.Expression.DoMatch(o.Expression, match); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory/Semantics/InitializedObjectResolveResult.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 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 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Statements/ForStatement.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.IO; 6 | 7 | namespace ICSharpCode.NRefactory.VB.Ast 8 | { 9 | public class ForStatement : Statement 10 | { 11 | public static readonly Role VariableRole = new Role("Variable", AstNode.Null); 12 | public static readonly Role ToExpressionRole = new Role("ToExpression", Expression.Null); 13 | public static readonly Role StepExpressionRole = new Role("StepExpression", Expression.Null); 14 | 15 | public AstNode Variable { 16 | get { return GetChildByRole(VariableRole); } 17 | set { SetChildByRole(VariableRole, value); } 18 | } 19 | 20 | public Expression ToExpression { 21 | get { return GetChildByRole(ToExpressionRole); } 22 | set { SetChildByRole(ToExpressionRole, value); } 23 | } 24 | 25 | public Expression StepExpression { 26 | get { return GetChildByRole(StepExpressionRole); } 27 | set { SetChildByRole(StepExpressionRole, value); } 28 | } 29 | 30 | public BlockStatement Body { 31 | get { return GetChildByRole(Roles.Body); } 32 | set { SetChildByRole(Roles.Body, value); } 33 | } 34 | 35 | protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) 36 | { 37 | throw new NotImplementedException(); 38 | } 39 | 40 | public override S AcceptVisitor(IAstVisitor visitor, T data) 41 | { 42 | return visitor.VisitForStatement(this, data); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/General/TypeParameterDeclaration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | 8 | using ICSharpCode.NRefactory.TypeSystem; 9 | 10 | namespace ICSharpCode.NRefactory.VB.Ast 11 | { 12 | /// 13 | /// [In|Out] Name [As Contraints] 14 | /// 15 | /// Represents a type parameter. 16 | /// 17 | public class TypeParameterDeclaration : AstNode 18 | { 19 | public static readonly Role TypeConstraintRole = TypeDeclaration.InheritsTypeRole; 20 | public static readonly Role VarianceRole = new Role("Variance"); 21 | 22 | public VarianceModifier Variance { get; set; } 23 | 24 | public string Name { 25 | get { return GetChildByRole (Roles.Identifier).Name; } 26 | set { SetChildByRole(Roles.Identifier, new Identifier (value, TextLocation.Empty)); } 27 | } 28 | 29 | public AstNodeCollection Constraints { 30 | get { return GetChildrenByRole(TypeConstraintRole); } 31 | } 32 | 33 | public override S AcceptVisitor(IAstVisitor visitor, T data) 34 | { 35 | return visitor.VisitTypeParameterDeclaration(this, data); 36 | } 37 | 38 | protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) 39 | { 40 | TypeParameterDeclaration o = other as TypeParameterDeclaration; 41 | return o != null && this.Variance == o.Variance 42 | && MatchString(this.Name, o.Name) 43 | && this.Constraints.DoMatch(o.Constraints, match); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/AssignmentExpression.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | namespace ICSharpCode.NRefactory.VB.Ast 8 | { 9 | public class AssignmentExpression : Expression 10 | { 11 | public readonly static Role LeftExpressionRole = BinaryOperatorExpression.LeftExpressionRole; 12 | public readonly static Role OperatorRole = BinaryOperatorExpression.OperatorRole; 13 | public readonly static Role RightExpressionRole = BinaryOperatorExpression.RightExpressionRole; 14 | 15 | public AssignmentExpression(Expression left, AssignmentOperatorType type, Expression right) 16 | { 17 | AddChild(left, LeftExpressionRole); 18 | AddChild(right, RightExpressionRole); 19 | Operator = type; 20 | } 21 | 22 | public Expression Left { 23 | get { return GetChildByRole(LeftExpressionRole); } 24 | set { SetChildByRole(LeftExpressionRole, value); } 25 | } 26 | 27 | public AssignmentOperatorType Operator { get; set; } 28 | 29 | public Expression Right { 30 | get { return GetChildByRole(RightExpressionRole); } 31 | set { SetChildByRole(RightExpressionRole, value); } 32 | } 33 | 34 | protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) 35 | { 36 | throw new NotImplementedException(); 37 | } 38 | 39 | public override S AcceptVisitor(IAstVisitor visitor, T data) 40 | { 41 | return visitor.VisitAssignmentExpression(this, data); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory/Utils/Platform.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 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 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Lexer/Special/ISpecial.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | 6 | namespace ICSharpCode.NRefactory.VB 7 | { 8 | // /// 9 | // /// Interface for all specials. 10 | // /// 11 | // public interface ISpecial 12 | // { 13 | // Location StartPosition { get; } 14 | // Location EndPosition { get; } 15 | // 16 | // object AcceptVisitor(ISpecialVisitor visitor, object data); 17 | // } 18 | // 19 | // public interface ISpecialVisitor 20 | // { 21 | // object Visit(ISpecial special, object data); 22 | // object Visit(BlankLine special, object data); 23 | // object Visit(Comment special, object data); 24 | // object Visit(PreprocessingDirective special, object data); 25 | // } 26 | // 27 | // public abstract class AbstractSpecial : ISpecial 28 | // { 29 | // public abstract object AcceptVisitor(ISpecialVisitor visitor, object data); 30 | // 31 | // protected AbstractSpecial(Location position) 32 | // { 33 | // this.StartPosition = position; 34 | // this.EndPosition = position; 35 | // } 36 | // 37 | // protected AbstractSpecial(Location startPosition, Location endPosition) 38 | // { 39 | // this.StartPosition = startPosition; 40 | // this.EndPosition = endPosition; 41 | // } 42 | // 43 | // public Location StartPosition { get; set; } 44 | // public Location EndPosition { get; set; } 45 | // 46 | // public override string ToString() 47 | // { 48 | // return String.Format("[{0}: Start = {1}, End = {2}]", 49 | // GetType().Name, StartPosition, EndPosition); 50 | // } 51 | // } 52 | } 53 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.Demo/Program.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 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.Windows.Forms; 21 | 22 | namespace ICSharpCode.NRefactory.Demo 23 | { 24 | /// 25 | /// Class with program entry point. 26 | /// 27 | internal sealed class Program 28 | { 29 | /// 30 | /// Program entry point. 31 | /// 32 | [STAThread] 33 | private static void Main(string[] args) 34 | { 35 | Application.EnableVisualStyles(); 36 | Application.SetCompatibleTextRenderingDefault(false); 37 | Application.Run(new MainForm()); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory/Utils/ReferenceComparer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 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 26 | { 27 | public readonly static ReferenceComparer Instance = new ReferenceComparer(); 28 | 29 | public new bool Equals(object x, object y) 30 | { 31 | return x == y; 32 | } 33 | 34 | public int GetHashCode(object obj) 35 | { 36 | return RuntimeHelpers.GetHashCode(obj); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/ParameterCanBeDemotedIssue/IsArrayTypeCriterion.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IsArrayTypeCriterion.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; 27 | using ICSharpCode.NRefactory.TypeSystem; 28 | 29 | namespace ICSharpCode.NRefactory.CSharp.Refactoring 30 | { 31 | public class IsArrayTypeCriterion : ITypeCriterion 32 | { 33 | #region ITypeCriterion implementation 34 | 35 | public bool SatisfiedBy(IType type) 36 | { 37 | return type is ArrayType; 38 | } 39 | 40 | #endregion 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/InvocationExpression.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | namespace ICSharpCode.NRefactory.VB.Ast 8 | { 9 | /// 10 | /// Target(Arguments) 11 | /// 12 | public class InvocationExpression : Expression 13 | { 14 | public Expression Target { 15 | get { return GetChildByRole (Roles.TargetExpression); } 16 | set { SetChildByRole(Roles.TargetExpression, value); } 17 | } 18 | 19 | public AstNodeCollection Arguments { 20 | get { return GetChildrenByRole(Roles.Argument); } 21 | } 22 | 23 | public override S AcceptVisitor (IAstVisitor visitor, T data) 24 | { 25 | return visitor.VisitInvocationExpression(this, data); 26 | } 27 | 28 | public InvocationExpression () 29 | { 30 | } 31 | 32 | public InvocationExpression (Expression target, IEnumerable arguments) 33 | { 34 | AddChild (target, Roles.TargetExpression); 35 | if (arguments != null) { 36 | foreach (var arg in arguments) { 37 | AddChild (arg, Roles.Argument); 38 | } 39 | } 40 | } 41 | 42 | public InvocationExpression (Expression target, params Expression[] arguments) : this (target, (IEnumerable)arguments) 43 | { 44 | } 45 | 46 | protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) 47 | { 48 | InvocationExpression o = other as InvocationExpression; 49 | return o != null && this.Target.DoMatch(o.Target, match) && this.Arguments.DoMatch(o.Arguments, match); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/VariableInitializer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | namespace ICSharpCode.NRefactory.VB.Ast 8 | { 9 | /// 10 | /// Identifier As Type = Expression 11 | /// 12 | public class VariableInitializer : AstNode 13 | { 14 | public static readonly Role VariableInitializerRole = new Role("VariableInitializer"); 15 | 16 | public VariableIdentifier Identifier { 17 | get { return GetChildByRole(VariableIdentifier.VariableIdentifierRole); } 18 | set { SetChildByRole(VariableIdentifier.VariableIdentifierRole, value); } 19 | } 20 | 21 | public AstType Type { 22 | get { return GetChildByRole(Roles.Type); } 23 | set { SetChildByRole(Roles.Type, value); } 24 | } 25 | 26 | public VBTokenNode AssignToken { 27 | get { return GetChildByRole (Roles.Assign); } 28 | } 29 | 30 | public Expression Expression { 31 | get { return GetChildByRole (Roles.Expression); } 32 | set { SetChildByRole (Roles.Expression, value); } 33 | } 34 | 35 | public override S AcceptVisitor(IAstVisitor visitor, T data) 36 | { 37 | return visitor.VisitVariableInitializer(this, data); 38 | } 39 | 40 | protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) 41 | { 42 | VariableInitializer o = other as VariableInitializer; 43 | return o != null && this.Identifier.DoMatch(o.Identifier, match) && this.Type.DoMatch(o.Type, match) && this.Expression.DoMatch(o.Expression, match); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/SwitchStatementTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 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 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Lexer/Special/Comment.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | 6 | namespace ICSharpCode.NRefactory.VB 7 | { 8 | // public class Comment : AbstractSpecial 9 | // { 10 | // CommentType commentType; 11 | // string comment; 12 | // 13 | // public CommentType CommentType { 14 | // get { 15 | // return commentType; 16 | // } 17 | // set { 18 | // commentType = value; 19 | // } 20 | // } 21 | // 22 | // public string CommentText { 23 | // get { 24 | // return comment; 25 | // } 26 | // set { 27 | // comment = value; 28 | // } 29 | // } 30 | // 31 | // /// 32 | // /// Is true, when the comment is at line start or only whitespaces 33 | // /// between line and comment start. 34 | // /// 35 | // public bool CommentStartsLine { 36 | // get; 37 | // set; 38 | // } 39 | // 40 | // public Comment(CommentType commentType, string comment, bool commentStartsLine, Location startPosition, Location endPosition) 41 | // : base(startPosition, endPosition) 42 | // { 43 | // this.commentType = commentType; 44 | // this.comment = comment; 45 | // this.CommentStartsLine = commentStartsLine; 46 | // } 47 | // 48 | // public override string ToString() 49 | // { 50 | // return String.Format("[{0}: Type = {1}, Text = {2}, Start = {3}, End = {4}]", 51 | // GetType().Name, CommentType, CommentText, StartPosition, EndPosition); 52 | // } 53 | // 54 | // public override object AcceptVisitor(ISpecialVisitor visitor, object data) 55 | // { 56 | // return visitor.Visit(this, data); 57 | // } 58 | // } 59 | } 60 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/CollectionRangeVariableDeclaration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | namespace ICSharpCode.NRefactory.VB.Ast 8 | { 9 | /// 10 | /// Identifier As Type In Expression 11 | /// 12 | public class CollectionRangeVariableDeclaration : AstNode 13 | { 14 | public static readonly Role CollectionRangeVariableDeclarationRole = new Role("CollectionRangeVariableDeclaration"); 15 | 16 | public VariableIdentifier Identifier { 17 | get { return GetChildByRole(VariableIdentifier.VariableIdentifierRole); } 18 | set { SetChildByRole(VariableIdentifier.VariableIdentifierRole, value); } 19 | } 20 | 21 | public AstType Type { 22 | get { return GetChildByRole(Roles.Type); } 23 | set { SetChildByRole(Roles.Type, value); } 24 | } 25 | 26 | public Expression Expression { 27 | get { return GetChildByRole (Roles.Expression); } 28 | set { SetChildByRole (Roles.Expression, value); } 29 | } 30 | 31 | public override S AcceptVisitor(IAstVisitor visitor, T data) 32 | { 33 | return visitor.VisitCollectionRangeVariableDeclaration(this, data); 34 | } 35 | 36 | protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) 37 | { 38 | CollectionRangeVariableDeclaration o = other as CollectionRangeVariableDeclaration; 39 | return o != null && this.Identifier.DoMatch(o.Identifier, match) && this.Type.DoMatch(o.Type, match) && this.Expression.DoMatch(o.Expression, match); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/ContextActionAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ProviderDescriptionAttribute.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 | using System; 27 | 28 | namespace ICSharpCode.NRefactory.CSharp 29 | { 30 | [AttributeUsage(AttributeTargets.Class)] 31 | public class ContextActionAttribute : System.Attribute 32 | { 33 | public string Title { get; private set;} 34 | public string Description { get; set; } 35 | public string Category { get; set; } 36 | 37 | public ContextActionAttribute (string title) 38 | { 39 | Title = title; 40 | } 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/ParenthesizedExpressionTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 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 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory/TypeSystem/IParameterizedMember.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 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 | -------------------------------------------------------------------------------- /NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/ConditionalExpression.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under MIT X11 license (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | namespace ICSharpCode.NRefactory.VB.Ast 8 | { 9 | public class ConditionalExpression : Expression 10 | { 11 | public readonly static Role ConditionExpressionRole = new Role("ConditionExpressionRole", Expression.Null); 12 | public readonly static Role TrueExpressionRole = new Role("TrueExpressionRole", Expression.Null); 13 | public readonly static Role FalseExpressionRole = new Role("FalseExpressionRole", Expression.Null); 14 | 15 | public VBTokenNode IfToken { 16 | get { return GetChildByRole (Roles.Keyword); } 17 | } 18 | 19 | public Expression ConditionExpression { 20 | get { return GetChildByRole (ConditionExpressionRole); } 21 | set { SetChildByRole (ConditionExpressionRole, value); } 22 | } 23 | 24 | public Expression TrueExpression { 25 | get { return GetChildByRole (TrueExpressionRole); } 26 | set { SetChildByRole (TrueExpressionRole, value); } 27 | } 28 | 29 | public Expression FalseExpression { 30 | get { return GetChildByRole (FalseExpressionRole); } 31 | set { SetChildByRole (FalseExpressionRole, value); } 32 | } 33 | 34 | protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) 35 | { 36 | throw new NotImplementedException(); 37 | } 38 | 39 | public override S AcceptVisitor(IAstVisitor visitor, T data) 40 | { 41 | return visitor.VisitConditionalExpression(this, data); 42 | } 43 | } 44 | } 45 | --------------------------------------------------------------------------------