Posted
almost 13 years
ago
by
MattWard
SharpDevelop 4.3 now has support for T4MVC.
T4MVC is a set of T4 templates, created by David Ebbo, that will generate strongly typed helpers for an ASP.NET MVC application. It will allow you to remove strings from your MVC application making your
... [More]
application easier to maintain.
So let us take a look at how to use T4MVC with SharpDevelop. First you should open or create a new ASP.NET MVC application in SharpDevelop.
Installing T4MVC
T4MVC is available as a NuGet package. The NuGet package you should download is T4MVC.SharpDevelop. This contains a modified version of the original T4MVC template that can be used with SharpDevelop. Further details on all the modifications made to the T4MVC template can be found at the end of this post. Install the T4MVC.SharpDevelop NuGet package either from the NuGet package management console or by using the Manage Packages dialog.
After installation two new T4 template files will be added to your project.
T4MVC.tt - main template that generates the strongly typed helpers.
T4MVC.tt.settings.t4 - holds configuration settings used by main T4MVC.tt template.
Generating T4MVC's Strongly Typed Helpers
To run the T4MVC template manually, select it in the Projects window, right click and select Execute Custom Tool. This will generate a set of files as dependencies of the T4MVC.tt file.
It will also make some modifications to your controller classes. The T4MVC template will change your controller classes so they are partial. It will also change your controller methods so they are virtual. What has been changed will be recorded as warnings in the Errors window.
When you make modifications to your application you do not want to have to keep running the T4MVC template manually each time to regenerate the strongly typed helpers. Instead you can configure your project to re-generate the strongly typed helpers on each build.
Generating T4MVC's Strongly Typed Helpers on each Build
To do this you should open the options for the project. From the Projects menu and select Project Options. Open the Custom Tool tab. In this tab you can choose to run custom tools on each build. In the screenshot below the project is configured to run T4MVC on each build.
If you want to run other custom tools you can add filenames for items in your project either as a comma separated list or with each file on a separate line. Currently there is no support for wildcards when specifying filenames.
Now that we have generated the strongly typed helpers let us take a look at how to use a selection of them.
Using T4MVC's Strongly Typed Helpers
View Names
In your _ViewStart.cshtml you may have a reference to a Razor layout page.
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
You can replace this string with a strongly typed helper.
@{
Layout = MVC.Shared.Views._Layout;
}
Action Links
In your views you may be passing action names and controller names as strings HtmlHelper.ActionLink(string linkText, string actionName, string controllerName).
<li>@Html.ActionLink("Home", "Index", "Home")</li>
<li>@Html.ActionLink("Contact", "Contact", "Home")</li>
Instead you can use code that looks like you are calling the controller method.
<li>@Html.ActionLink("Home", MVC.Home.Index())</li>
<li>@Html.ActionLink("Contact", MVC.Home.Contact())</li>
CSS Links
You may be using strings for links, such as for CSS files, in your views.
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css">
These can be changed to use the Links.Content helper class.
<link href="@Links.Content.Site_css" rel="stylesheet" type="text/css">
That is a very quick introduction to T4MVC and covers only a few of the helpers it provides. Further information on T4MVC can be found on the T4MVC Codeplex site.
Changes Made to Original T4MVC Template
Visual Studio assembly references have been removed and replaced with a SharpDevelop assembly reference.
Visual Studio namespace imports have been removed and replaced with namespace imports for SharpDevelop.
EnvDTE.ProjectItem.get_FileNames() replaced with ProjectItem.FileNames() - SharpDevelop currently implements this as a method and not a parameterised property.
EnvDTE.CodeType.get_IsDerivedFrom() replaced with CodeType.IsDerivedFrom() - SharpDevelop currently implements this as a method and not a parameterised property.
Removed use of BeginInvoke/EndInvoke which was causing SharpDevelop to hang.
The SharpDevelop specific T4MVC template is maintained in a repository on github. [Less]
|
Posted
almost 13 years
ago
by
ChristophWille
With Windows 8 released to MSDN and TechNet subscribers today, I thought it'd be a good idea to give a short guide for installing SharpDevelop on a blank Windows 8 installation - because it will fail with an error message (although the screenshot is
... [More]
for SharpDevelop 4.3, the same applies for 4.2):
The easiest way to fix this is to install .NET 3.5 (used by lots of other applications / drivers, thus if you don't install SharpDevelop first thing on Windows 8, it might just install right away because somebody else auto-installed this dependency).
You are looking for "Turn Windows features on or off" - this will open the "Windows Features" dialog on the desktop:
Make sure to check ".NET Framework 3.5", click OK, let it connect to Windows Update and finish the installation. Once done, you can go back to installing SharpDevelop, as it now has all required dependencies!
Note You can alternatively install just the VC++ 2008 SP1 runtime. [Less]
|
Posted
almost 13 years
ago
by
ChristophWille
Yesterday, Siegfried put finishing touches on the import/export of color schemes in SharpDevelop. To give you an idea, let's take a look at the following screenshot:
This is an imported color scheme from StudioStyl.es, more specifically
... [More]
http://studiostyl.es/schemes/son-of-obsidian-with-resharper.
Now, how do you get one of those color schemes installed in SharpDevelop? You have to go to the Tools / Options dialog, Text Editor / Highlighting section:
There you will find the "Import highlighting colors" button, that allows you to pick a highlighting definition - either one that was exported from SharpDevelop, or one that came from Visual Studio (as is the case with StudioStyl.es):
Please do note that if you have existing customizations, the import will warn you that those will be reset (otherwise you might end up with very interesting intersections of color schemes).
Speaking of interesting effects: if you compare the first screenshot with the first listing on the StudioStyl.es page, you will notice differences such as the type coloring or the constructor (eg line 15). The reason for this is that sometimes VS supports more options, other times it is SharpDevelop - thus there can't be a perfect mapping when you import from a VS settings file. You might need to make slight adjustments in SharpDevelop after the import to get a perfect look. [Less]
|
Posted
almost 13 years
ago
by
MattWard
SharpDevelop 4.3 has been updated to use NUnit 2.6.1 which was recently released. The full details on what has changed in NUnit 2.6.1 can be found in the NUnit release notes. One change in this release caused some of SharpDevelop's own unit tests to
... [More]
break so this change is highlighted in the following section.
Running unit tests with an STA thread
NUnit 2.6 no longer reads settings from your test configuration file (app.config). This means that you can no longer make NUnit use the STA thread by setting the default apartment state in your app.config file. So the following app.config file will not work:
<configuration>
<configSections>
<sectionGroup name="NUnit">
<section name="TestRunner" type="System.Configuration.NameValueSectionHandler" />
</sectionGroup>
</configSections>
<NUnit>
<TestRunner>
<!-- The ApartmentState value here is ignored. -->
<add key="ApartmentState" value="STA" />
</TestRunner>
</NUnit>
</configuration>
Instead you should use the RequiresSTA attribute.
The RequiresSTA attribute can be used at the assembly, class or method level. To make NUnit to run all your unit tests with an STA thread you can add the following code to your AssemblyInfo.cs file in the project containing your unit tests.
using NUnit.Framework;
[assembly: RequiresSTA]
[Less]
|
Posted
almost 13 years
ago
by
DanielGrunwald
I have published a CodeProject article documenting NRefactory 5: Using NRefactory for analyzing C# code
While NRefactory 5 itself is pretty much stable, there's still a lot of work to do for SharpDevelop 5 to use it -- pretty much everything in
... [More]
SharpDevelop dealing with source code needs to be ported to the new NRefactory 5 API.
But I think this article shows that NRefactory 5 will open up a lot of new feature possibilities. For example, we could detect problems like the missing StringComparison described in the article directly in the SharpDevelop editor while you're typing, no need to recompile. In fact, the MonoDevelop project has two GSoC students working on such live issue detection and other code actions (small refactorings), and most of their code will be usable in both IDEs.
So you can look forward to a much improved C# editing experience in SharpDevelop 5 :) [Less]
|
Posted
almost 13 years
ago
by
MattWard
SharpDevelop 4.3 now has integrated support for OpenCover thanks to Lex Li.
OpenCover is an open source code coverage tool created by Shaun Wilde. It can be used to measure how much of your code is covered by your unit tests. OpenCover was created
... [More]
to fix the following problems in PartCover, another open source code coverage tool.
64 bit support
Memory usage
Returning no coverage results
For a more detailed look into why OpenCover was created you should read Shaun Wilde's OpenCover First Beta Release post.
Back in 2006 SharpDevelop added support for NCover, then it switched to using PartCover a year later when NCover was turned into a commercial product. Now it supports and ships with OpenCover so let us take a tour of using OpenCover with SharpDevelop.
OpenCover Feature Tour
First you should install SharpDevelop 4.3. Version 4.3.0.8911 or above will have OpenCover support. Then you will need to use a project with unit tests or alternatively you can download a zip file which contains the set of projects created whilst writing this feature tour. Open your solution with SharpDevelop 4.3 and let us get started.
Running Unit Tests with Code Coverage
To run the unit tests with code coverage open the Unit Tests window by selecting Tools - Unit Tests from the View menu. Right click the project or tests that you want to check for code coverage and select Run with code coverage.
At the top of the Unit Tests window there is the run with code coverage toolbar button which can be also used to run code coverage for all the tests.
Another way to run the unit tests with code coverage is to right click in the text editor and select the Run with code coverage menu option.
The unit tests will then be run and OpenCover will profile your code. The output from OpenCover will be displayed in the Output window. Once OpenCover is finished the code coverage results will be displayed in the Code Coverage window.
Code Coverage Results
The code coverage window will show you the percentage of code covered for each class, method and property. On the right hand side you can see the visit count information or if you select the Show Source Code option you can see the corresponding source code with covered code highlighted in green and uncovered code highlighted in red.
The Code Coverage window also allows you to enable or disable code coverage highlighting in the text editor. The top left button in the Code Coverage window is used to enable or disable code coverage highlighting in the text editor.
In the screenshot below the text editor has covered code in highlighted in green and uncovered code in highlighted in red.
Filtering Code Coverage Results
By default OpenCover will show you code coverage for all your code including your tests. Typically you are not interested in code coverage for your unit tests. To exclude classes you can use a filter. The filters you can use are described on the OpenCover wiki. To specify a filter in your unit tests project select Project Options from the Project menu. Then open the Code Coverage tab. Here you can specify an include or exclude filter. In the screenshot below all types in the OpenCoverageFeatureTour.Tests assembly will be excluded.
64 bit or 32 bit
On Windows x64 if your test project is set to target a 32 bit processor then the 32 bit version of NUnit will be used to run your unit tests. If it is set to Any CPU or a 64 bit processor then NUnit will run as a 64 bit process as OpenCover profiles your code.
Code Coverage Options
The colours used to highlight code coverage in the text editor and Code Coverage window can be configured in the Options dialog. From the Tools menu select Options. Then expand the Tools category and select Code Coverage.
That ends the tour of using OpenCover with SharpDevelop. [Less]
|
Posted
about 13 years
ago
by
ChristophWille
ILSpy 2.1 is available as of now - it supports async/await decompilation:
ILSpy_Master_2.1.0.1603_RTW_Binaries.zipILSpy_Master_2.1.0.1603_RTW_Source.zip
A few weeks ago, Daniel blogged about the details of how decompiling async / await is
... [More]
implemented. If you are only interested in the results, see the below screenshot for a proof of decompilation working (on Windows 8 RP):
As a reminder: next week on Friday we'll do a Webcast on ILSpy. [Less]
|
Posted
about 13 years
ago
by
siegi44
Good news for all Chinese, Japanese and Korean users of AvalonEdit (and others using complex script). Recently we were able to add integrated support for IMEs (Input Method Editors) in the latest version of AvalonEdit.
Before: The IME is floating
... [More]
outside of the text area.
After: The IME is directly integrated into the editor. In the first part you can see Korean IME, in the second one Japanese IME in Hiragana Mode.
Tested on: Windows 7
In the development team we don't use IME and we couldn't test it very well, due to a lack of knowledge of the specific languages. (I only know a little Korean and even less Japanese.) So if you run into a bug while using it, please report it on the forums. [Less]
|
Posted
about 13 years
ago
by
ChristophWille
From June 7th to June 10th the SharpDevelop team meets in Bad Ischl, Austria for their annual #develop developers days (#d^3). This year you have a chance to take part in a virtual Q&A session, where you can ask the team (almost) anything about
... [More]
roadmap, architecture, implementation and extensibility.
If you have tough questions, want to give us a chance to prepare, or already know you can’t make it: please post your questions as comments to this blog post, and we’ll make sure to get to them during the Webcast.
When: Saturday June 9th 2012, 5PM CEST (8AM PST).Where: The meeting URL will be posted at this location a few hours before the Webcast. Duration: One hour.
The meeting will be recorded, and the recording posted at this location – thus if you can’t make it, you still can watch it later.
Software requirements for the Webcast: Lync Attendee (the online version won’t work, you need the full client). [Less]
|
Posted
about 13 years
ago
by
ChristophWille
From June 7th to June 10th the SharpDevelop team meets in Bad Ischl, Austria for their annual #develop developers days (#d^3). This year you have a chance to take part in a virtual Q&A session, where you can ask the team (almost) anything about
... [More]
roadmap, architecture, implementation and extensibility.
If you have tough questions, want to give us a chance to prepare, or already know you can’t make it: please post your questions as comments to this blog post, and we’ll make sure to get to them during the Webcast.
When: Friday June 8th 2012, 5PM CEST (8AM PST).Where: The meeting URL will be posted at this location a few hours before the Webcast. Duration: One hour.
The meeting will be recorded, and the recording posted at this location – thus if you can’t make it, you still can watch it later.
Software requirements for the Webcast: Lync Attendee (the online version won’t work, you need the full client). [Less]
|