InI Posted a very simple question about "a ? b : c" expression to Stackoverflow last night. I was at Cafe with my friend discussing a case of this expression: if b and c are different types. Since we did not have Visual Studio available to test my codes out. I posted the question to Stackoverflow. Within minutes, we got several answers to confirm my guess: a Cast can be used before either one to make them the same type. The question is indeed a very simple one. However, this lead to a new discovery, at least for me, of a great IDE tool, only one EXE with 2MB size, for .Net C# snippet codes.
The tool is called as LINQPad. Its user interface is very simple. On the top are menus and tool bars. The left panel is for Database connection or database structure list. The right panel is composed of top and bottom parts: code IDE and result view. This tool supports C# & VB expression, statements, programs, and SQL. It is very easy to use. However, it is very buggy. This morning I give it a try. After I added a reference to my library and added several my namespace lists. I could not to get a simple Console out work in a new tab when I tried to show it to my work colleges. I had to restart the application and removed references and namespaces to get it back to work.
All the codes can be saved an xml file. Within the xml file, all the references, namespaces, and code snips are saved there. It is really cool. No wonder a user who answered my question recommended me to try this tool. I guess he knew I had no VIsual Studio available. We actually had a Mac computer.
The project is not an open source project. It is a closed project. The standard version is free and an advanced version with auto-completion feature is for sale. After I give it a thought for this back engine, I guess that application is not hard to create. I would use the .Net CodeCom namespace as .Net compiler engine to create a dynamic project with a template for a snippet as plug in codes, just as I posted in my previous blogs. The dynamic project could be a simple console application> if it compiles OK, then run it through Process class. The process is hidden and all the outputs can be redirected as output back to the application. The application interface parts can be done with MEF framework so that each view parts can be plugged with various UIs to support IDE code editor (such as supporting syntax color schemas for various languages), result view (grid or table layout) and other views.
With this structure, LinPad should be an open source project so that talent developers can make it much better and extendable. One person's dedication is great, but with Web world available, great resources from the world should be utilized.
Thursday, September 17, 2009
LINQPad as a .Net Snippet Code IDE
Posted by D Chu at 8:06 PM 0 comments
Labels: C#, Visual Studio Tools
Sunday, September 13, 2009
Free CodeRush Xpress Tool by DevExpress
DevExpress released a free tool for .Net Visual Studio 2008 users: CodeRush Xpress. I found this out from DVRTV show 143: Mark Miller on CodeRush Xpress.
I knew this tool for long time but I have never tried the tool as I used Resharper before. With the free offering, I tried this re-factory tool right away. It is a nice tool for .Net developers. But I found that some features are not working such as Tab to Next Reference and Template snip codes for switch and for loops. Maybe there are some option settings I have not set up yet. I also realize that the tool does provide hint on the left scroll bar to indicate questionable codes such as greying out unreferenced using statements, like Resharper has (which provides hints as yellow marks).
Here are some additional links related to this tool:
- MSDN Announcing CodeRush Xpress for C#
- Charlie Calvert;s blog on CudeRush Xpress 9.2 with a video demo.
- Mark Miller;s blog on CodeRush Xpress features and comments on this tool. I posted a question on Tab to next Reference.
Posted by D Chu at 12:18 PM 4 comments
Labels: Visual Studio Tools
Sunday, July 19, 2009
Network Drive Mapping Class
Today my friend asked me a question about how to map to a network share-point as a local logical drive with user name and password. I recalled that I had written a utility class to do that.
Basically this static class contains two methods: MappingDrive() and UnMappingDrive(). The first one is used to map to a network share point by its path, user name and password, as well as a specified local logic drive name. The unmap method just takes one parameter of a mapped drive name.
There are many ways to do that. I saw many people using Windows API method. However, I don't like that. The reason is that 1) API are un-managed codes based on dynamic library dll files; and 2)possible un-catchable exceptions, which are very nasty for applications. To map to a network shared point, it is very possible to pass incorrect parameters. Then I found a simple way to do it: by using .Net Process to shell net.exe, which is one of core Windows utilities. Actually, I have used this many times in cmd console. I think most Windows UI tools, including File Explorer, may rely on this tool to do the job.
When I revisit my codes today, I saw that MappingDrive() method is checking if the specified drive is already mapped or not first. If it is true, it will un-map and remap it again. It is done behind sense. This may un-map other people's mapping. I keep this logic and remind my friend about the logic.
I also updated the class with some changes. First, I expose the previously private method of IsMappedDrive() as public. Secondly, I added two methods: GetLocalDrives() and GetLocalUnusedDrives(). The first one is very simple. It is based on System.IO.Directory.GetLogicalDrives(), but I think the second one is more useful. It will get all the un-used local logical drives, which depends on the first method.
Finally, I uploaded this simple NetworkDrive class to my code project. Enjoy it!
Posted by D Chu at 1:44 PM 0 comments
Labels: C#, Visual Studio Tools
Monday, June 09, 2008
SVN, Its Tools and Checkins
Subversion (SVN) is an open source version control system. I used it for source code control or repository. There are two open source SVN tools available for Windows and Visual Studio: TortoiseSVN and AnkhSVN.
Normally, I use Tortoise to check out source codes, a solution or project, to a folder and then it will create SVN client folders and files (hidden) to mark files as a copy out from a SVN reposity. Then, open the sln or project by VS. AnknSVN will detect this project is from SVN and prompt you AnkhSVN is available for use for the project.
If you make a change to a file, the file then is marked as a changed one with red icon. You can commit the change back to the SVN server or check in to the repository. Ankhn works well for editing files. However, it does not support file renaming. You have to remove the file and add a new one as two steps for renaming.
In many cases, I have to revert some changes or the whole changes by using Ankhn's context menu. Revert means no change to the file in local and re-copy the file from repository to local. In case of removing a file, you will be prompt to remove the file from the repository. If you choose Yes, this actually is commit or change to the repository! You cannot just revert the change to get it back. You have to revert to previous versions. If you have several check-ins in a day, it may be hard to find the correct one restored back. Therefore, if you want to make a trial change in local, do not remove the file from the repository. Then you can simply revert the local project back and use Update to refresh the local files if you do not want to commit the change.
If you removed file from local (not in the repository!), and verified the change is OK and want to commit you changes to the repository. Remember, the removed files are still in the repository after your check-in. Use Tortoise's repo-browser to open the repository and remove the file from the browser. That's another commit change to the repository.
In a sense, those SVN tools do not have a check out session, or SVN does not support check out set or locking a check out set. That means several developers can work on a same source code file at same time. Any developer can drop their change and that's fine for others. However, if one checks in the code file, others may have to merge their changes before check in. Ankh provides diff for comparing repository file to local files and will prompt, I think, you if your check out version has been changed by others.
Posted by D Chu at 9:40 PM 0 comments
Labels: Subversion, Visual Studio Tools
Wednesday, December 05, 2007
PageFlow, WorkFlow classes and Designer
Widnows WorkFlow Foundation provides an in-process workflow engine for many classes with visual work flow process in design mode in VS, such as Sequential WorkFlow, Machine WorkFlow, Activities, PageFlow, and so on.
By using the visual designer, you can easily define work flow, process item relationships and constrains as a work flow class. In addition to WWF core WorkFlow classes, other third parties or organizations or open source groups (such as PnP) adds other useful WorkFlow classes. The APS.NET solution I have been working on includes a project with PageFlow class.
The PageFlow class is defined within Microsoft.Practices.PageFlow.WorkFlowFoundation.dll by Microsoft Patterns and Practices group. The problem I encountered is that after I created the project by using Guidance Package Manger Recipe of Add PageFlow Project, I got an error message when I tried to open PageFlow1.cs in design mode in VS, but I don't have problem to compile the project. It looks like that its related designer class is not available.
Actually, the designer class is Microsoft.Workflow.VSDesigner.dll. I have to search for this file first. Then I copy this file to the folder where ...WorkFlowFoundation.dll file sits. After making the designer class directly available to the owner assembly, I can see the class in design mode in VS after I re-open the VS again.
Posted by D Chu at 6:40 PM 0 comments
Labels: Visual Studio Tools
Thursday, November 29, 2007
A Solution for Assembly Version Issue
Continuing with the issue I described in Rhino.Mocks and AutoMockingContainer, I found another solution to resolve the problem instead of recompiling AutoMockingContainer.
It is not always the case that you can get dependent library source codes. The alternative solution to redirect the .Net CLR to load a new version of the specified assembly. I'll take the my test project with Rhino.Mocks and AutoMockingContainer as an example. The Rhino.Mocks version I used in my project is version 3.3.0.906, while AutoMockingContainer was built with Rhino.Mocks version 2.8.1.2631 as its dependency. My test project will be compiled as TestClasses.dll. By default, all the binaries will be copied to Output directory with the latest Rhino.Mocks (3.3.0.906).
When my test class tries to call any AutoMockingContainer class which depends on Rhino.Mocks (2.8.1.2631), the .Net CLR cannot find the specified strong named assembly dll, and then exception was thrown.
I remembered that when .Net was released, it claimed to resolve COM-hell issue with versions and it allows two or more different versions of assembly running within a process. One way to resolve the version issue is to promote the version by using assembly's configuration file. For more information about .Net configuration, see Configuration File Schema for the .NET Framework.
That link provides a way to redirect old version to new version by using configuration's bindingRedirect element. Here is what I did in my test project:
- Add a configuration file to the project where AutoMockingContainer is referenced. The file name should be as same as the project name with congif extension. For example, I used "TestClasses.dll.config".
- Right click on this file and set Copy to Output Directory to Copy Always.
- Add the following line to the configuration file (make changes depending on your case):
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Rhino.Mocks"
publicKeyToken="0b3305902db7183f"
culture="neutral" />
<bindingRedirect oldVersion="2.8.1.2631"
newVersion="3.3.0.906"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>- Finally compile the project. The project should run (with NUnit test program) without exception.
I used the tool of Lutz' .Net Reflector to find assembly's version. It's a great tool for developers.
Posted by D Chu at 11:41 AM 0 comments
Labels: Visual Studio Tips, Visual Studio Tools
Wednesday, November 28, 2007
Update Assembly Version
Continuing from the previous blog, I found two places talking the related issue: how to manage assembly version:
- Managing assembly version numbers using Visual Studio .NET and ..., and
- UpdateVersion utility with source codes.
The utility program's author, Matt, also posted two interesting tools: one for system tray icon with tooltips, and another PrefTimer timer class based on API.
Posted by D Chu at 9:52 PM 0 comments
Labels: Visual Studio Tips, Visual Studio Tools