Thursday, July 17, 2014

How to debug eXpandFramework

In this post I will go through the process of debugging eXpandFramework for each of the distribution channel.

The sources

If you download the sources either from GitHub or our download page or our build server you need to run the buildall64.cmd file located in the root folder. The batch will generate the symbol files (pdb) and will register the assemblies in the GAC. Debugging is enabled by default since symbols and sources are in place.

The Nuget packages

eXpandFramework is distributed through Nuget and since version 14.1.4.8 and with the excellent GitHubLink project provides frictionless debug experience as long as Symbol Server support is enabled under your VS/Options/Debugging settings. The symbols are in the same package as the dll so expect the package size to be at least double in size. We will consider a better implementation if there are requests. GitHubLink patches the symbols so to request the assembly sources from the online GitHub repo so there is not need to have the sources in place.

The Binaries / The Installer

Either way you choose you will end up with a folder containing the eXpandFramework assemblies + the patched symbols. So, debugging is enabled by default and sources will be queried from the online GitHub repo as long as Symbol Server support is enabled under your VS/Options/Debugging settings

PS: In the installer case you can also find the sources under the Sources folder in your installation directory.

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Wednesday, June 18, 2014

How confident I am with my code?

With smart frameworks like XAF it is inevitable that you will create applications one would except they developed by a whole team and not from just one person. A side effect of rich/large applications is that it is impossible to determine if all parts of the application function unless you have tests.

Enter AutoTest from EasyTest

XAF comes together with EasyTest a functional testing framework. EasyTest has an undocumented command the AutoTest. In short  the AutoTest command will go through all your Navigation Items and for all related views will execute the New action if available and open/close the related detailview.

So, lets talk by example. In eXpandFramework there are 38 Demos with a large number of views, each one demonstrating certain features. By using the AutoTest command we can automate the opening of all views therefore we can expect a code coverage larger than 80%.

Following is the RunEasyTests target used in eXpandFramework build script (Xpand.build).

  <Target Name="RunEasyTests" >
    <MSBuild Projects="@(EasyProjects)" Targets="Build" Properties="Configuration=EasyTest" />
    <CallTarget Targets="EasyTestUpdateDBTimeout" />
    <Delete Files="@EasyTestLogs"/>
    <CreateItem Include="@(EasyTestReqs)" AdditionalMetadata="CopiedToDir=%(EasyTests.RelativeDir);" >
      <Output ItemName="EasyTestReqsToDelete" TaskParameter="Include"/>
    </CreateItem>
    <Copy SourceFiles="@(EasytestReqs)" DestinationFolder="%(EasyTests.RelativeDir)"/>
    <Exec ContinueOnError="true"
          WorkingDirectory="%(EasyTests.RelativeDir)"
          Command='%(EasyTests.RelativeDir)\ProcessAsUser.exe $(TestExecutorName) %(EasyTests.Filename).ets'>
      <Output TaskParameter="ExitCode" PropertyName="ErrorCode"/>
    </Exec>
    <Delete Files="%(EasyTestReqsToDelete.CopiedToDir)%(EasyTestReqsToDelete.Filename)%(EasyTestReqsToDelete.Extension)"/>
    <Error Text="Login failed" Condition="'$(ErrorCode)' == '255'" />
    <CallTarget Targets='PrintEasyTestLogs' ></CallTarget>
  </Target>


Next we will discuss in detail each line of the RunEasyTests target.



<MSBuild Projects="@(EasyProjects)" Targets="Build" Properties="Configuration=EasyTest" />



First we need to build all demos under the EasyTest configuration where the required EasyTest components are functional.



<CallTarget Targets="EasyTestUpdateDBTimeout" />



In the above line we call the EasyTestUpdateDBTimeout target that will run DBUpdater for all demos that have long operations in their ModuleUpdaters. We need to explicitly execute the DBUpdater because there is a threshold in time between each EasyTest command so the Login action may fail if moduleupdater takes more than 25sec to complete. 



<Delete Files="@EasyTestLogs"/>



This command will delete all EasyTest logs to make sure that our build script will not pick up any previous failed tests.



<Copy SourceFiles="@(EasytestReqs)" DestinationFolder="%(EasyTests.RelativeDir)"/>



This will copy a set of required files for EasyTest like the TestExecutor, XpandTestAdapters etc in the same path as the test. In the build server assemblies are not in the GAC so by putting them in the same path we minimize assembly binding errors due to version conflicts.



<Exec ContinueOnError="true"           WorkingDirectory="%(EasyTests.RelativeDir)"           Command='%(EasyTests.RelativeDir)\ProcessAsUser.exe $(TestExecutorName) %(EasyTests.Filename).ets'>





This line executes the TestExecutor for all EasyTests, It uses the ProcessAsUser.exe because the build script is actually executed from our build server service using the System Account which has no windows session therefore useful EasyTest features like screenshots are not available. In general we do not want to mess with the system account in order to make our tests run. So the ProcessAsUser reads a username and password from a registry key and by using an RDC connection (Windows Server) creates a new session and executes the tests there under the specified user security privileges. Finally because we are interested to execute all tests without failing the build to fail we set ContinueOnError to true.



<Delete Files="%(EasyTestReqsToDelete.CopiedToDir)%(EasyTestReqsToDelete.Filename)%(EasyTestReqsToDelete.Extension)"/>



This line will delete all EasyTest required files copied in previous steps



<Error Text="Login failed" Condition="'$(ErrorCode)' == '255'" />



If the ProcessAsUser returns 255 then we fail the build with the Login failed message.

<CallTarget Targets='PrintEasyTestLogs' ></CallTarget>



The PrintEasyTestLogs target will go through all EasyTest logs and for any entry with non passed Result it will fail the build with the related error message from the EasyTest xml log.



  <Target Name="PrintEasyTestLogs" >
    <MSBuild.ExtensionPack.Xml.XmlFile
      TaskAction="ReadElements" File="%(EasyTestLogs.FullPath)" Condition="'@(EasyTestLogs->Count())'!='0'"
      XPath="/Tests/Test[@Result='Warning' or @Result='Failed']" ReadChildrenToMetadata="true">
      <Output TaskParameter="Elements" ItemName="Test"/>
    </MSBuild.ExtensionPack.Xml.XmlFile>
    <Error Text="%0D%0AApplicationName: %(Test.ApplicationName)%0D%0AError: %(Test.Error)" Condition="'@(Test->Count())'!='0'"  ContinueOnError="True"></Error>
  </Target>


A big thanks this time to the AutoTest command that provided 80% code coverage for our community framework. I am sure AutoTest will be extended to provide even smarter automated tested in future versions. If you got into that trouble and have interesting ideas to share or contribute for AutoTestV2 please use our community framework forums.

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Tuesday, April 22, 2014

DX-Nuspec files hosted on GitHub

DevExpress offers a great installer for their components and frameworks. But if you work in a continuous integration environment or have to deal with different versions of the components NuGet packages are the better way to deploy and version-control  dependencies. This project contains .nuspec files for  DevExpress WinForms, Web and XAF assemblies. It is not an official release and it is not supported by DevExpress.

This is the description of the DX-Nuspec files, open sourced from Sergej Derjabkin a casual community contributor! The files are available in https://github.com/derjabkin/DX-Nuspec and of course they will be distributed as a submodule from eXpandFramework v13.2.9.1.

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Tuesday, December 31, 2013

A few more reasons to upgrade to v13.2

13.2 was a great release and many of you already upgraded your applications. For everyone else I am here to help you make that decision sooner and easier, by reminding you what our reviewers had to say, when they upgraded their apps to our latest major release.

These are real world feedback without any kind of interaction from us.

Gustavo Marzioni
Making Business Applications Easier

Gustavo is a veteran programmer (20 years+) with a great presence in our community (most active user in eXpandFramework). He posted a very complete review of all new XAF features and a few other interesting things we released with 13.2 as part of our DXperience subscription. In addition you can find a performance comparison for our new ReportsV2 module.

Mario Blataric
Dungeons of XAF and Magic 13.2

Mario reviews v13.2 and explains how XAF helps him to fight monsters in today’s modern dungeon of dev technologies and platforms. His XAF app has more than 1500 reports so he focuses on the ReportsV2 module.

Martynas Dauciunas
Devexpress 13.2 Review - why bother upgrading ? 

Martynas known from his very useful Excel Import Wizard module wrote an extensive review of all new features and problems encountered when he updated his 12.x ERP/CMMS application to v13.2.

Manuel Grundner

DevExpress 13.2 Review Part 1
DevExpress 13.2 Review Part 2
DevExpress 13.2 Review Part 3

Manuel has already contributed many solutions. This time he wrote a great review for all new XAF features. He also reviewed components not integrated with XAF like the new TaskBarAssistant and as a bonus in part 3 he wrote how to create a module that integrated this component with XAF. This module will soon be integrated into our community project eXpandFramework.

Robert Anderson
DevExpress 13.2 Review - Part 1
DevExpress 13.2 Review - Part 2

Robert is a casual blogger and community contributor. He wrote about all new 13.2 features along with a few more tricks and thoughts which cannot be found in our official posts.

Until next time,

Happy New Year to all!

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Saturday, November 30, 2013

State machine enhancements

Yesterday, I had a few interesting suggestions from an eXpandFramework user (Sheldmandu), about a few real world State Machine enhasements. Since XAF makes development amazingly fast, today we can discuss a bit about the implementaion released with (v13.1.8.22).

The full discussion can be found at this thread.

In sort Sheldmandu suggested.

  1. Allow certain roles to bypass State machine transition validation and make transitions without any restriction in order to correct mistakes.

    This implemented by adding an extra tab in the State Machine detailview so the end user can associate it with the admin roles as illustrated in the next image.

    image
  2. Support more efficient transitions by changing directly the property value without the need of executing the ChangeStateAction

    For this a new property “EnableFilteredProperty” introduced in the State Machine attribute to make the life of our real worlds easier.

    image

Most useful suggestions Sheldmandu! Many thanks form all and keep them coming.
We also looking forward for such great suggestions from the rest of the XAF world Smile.

Until next time,

Happy XAF’ing!

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Thursday, November 28, 2013

XAF: Soft Validation (What’s New in 13.2)

Our next major release (13.2), updates our Validation Module with more features that come with different behavior rules, such as Warnings and Information. These can be applied to your existing validation rules using code or the Model Editor.

The XAF validation module is a mature and flexible validation system, which allows you to create rules that can validate any business problem, For more information, check out the module documentation.

Suppose we have a Business Object that disallows saving a Customer if the Name property is blank. If this attempted the UI should respond with a “Everybody has a name!” message.

[DefaultClassOptions]

public class Customer : BaseObject {

    public Customer(Session session) : base(session) { }

    [RuleRequiredField("Customer_Name_Required", DefaultContexts.Save, "Everybody has a name!")]

    public string Name { get; set; }

    public string City { get; set; }

    public int Age { get; set; }

}

When an end user tries to save the Customer without a name, XAF will show the Validation Error listview and consequently abort.

image

Creating a warning rule

A common requirement for our Customer class is to warn the end user that, if possible, he/she should provide the Customer’s city. To do this, we need to mark the City property with a  RuleRequiredField. However, this time we have to set the ResultType to Warning as illustrated below.

[DefaultClassOptions]

public class Customer : BaseObject {

    public Customer(Session session) : base(session) { }

    [RuleRequiredField("Customer_Name_Required", DefaultContexts.Save, "Everybody has a name!")]

    public string Name { get; set; }

    [RuleRequiredField("Customer_City_Warning", DefaultContexts.Save, "Provide the City if possible",

        ResultType = ValidationResultType.Warning)]

    public string City { get; set; }

    public int Age { get; set; }

}

When the end user saves the Customer (in runtime) providing a Name and not a City, XAF will again show the Validation Error listview however, this time there will be an extra Ignore action.

image

If the end user executes the Close action, the object will not be saved however if he executes the Ignore action it will be saved. In both cases in the detailview there will be a warning action by the City textbox to draw the end user’s attention.

image

Creating an Information rule

XAF allows you to create validation rules even at runtime using the Model Editor. So let’s say we want to just inform the end user, if he enters a Customer Age not between 10 and 60. This means that we need to use a RuleRangeField rule as illustrated in the next two images.

image

image

When the end user saves a Customer (in runtime) with an invalid Age range, XAF will not display the Validation Error listview at all. However, it will display an Information icon to draw his/her attention to the Age property.

image

Where to see more examples?

You may explore our FeatureCenter application located in your C:\Users\Public\Documents\DXperience 13.2 Demos\eXpressApp Framework\FeatureCenter\CS folder to see a few rules in action.

What about the web?

The validation module as a platform agnostic module works similarly for the web.

image

The soft validation is in its first release (CTP), thus we look forward to your feedback as we get it ready for it’s official release. Let me know what you think.

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Monday, November 25, 2013

eXpandFramework 13.2 beta 1 is out

It has been almost a week since the XAF beta 1 and I hope you already tried the 13.2 bits of XAF. I am happy to announce that in our build servers you can find the 13.2 beta 1 of eXpandFramework.

I am also happy to tell you that even if eXpand has a huge code base the 13.2 migration was lighting fast. Thanks to the great job from the XAF team. So, I am pretty sure that the 13.2 migration will not affect your code bases or time either.

To get your hands in the XAF beta1 login to your account in the DevExpress site and download the release in red.

image

To get your hand in the eXpandFramework bits login to our build servers and download the latest 13.2.3.x bit.

image

p.s.: eXpandFramework as a community project is based on your feedback in order to be stable so for those of you that want to report issues and suggestions I opened a beta only forum.

image

Note: You cannot have both 13.1 and 13.2 eXpand assemblies in the GAC. It is however totally possible to work using different version as long as you reference the assemblies directly from their locations.

Subscribe to XAF feed
Subscribe to community feed

DiggIt!