FAQ's for Developers: Difference between revisions

From OpenPetra Wiki
Jump to navigation Jump to search
Line 17: Line 17:
===Q: Do you have notifications for source code commits?===
===Q: Do you have notifications for source code commits?===
You can subscribe to https://github.com/openpetra/openpetra/ by clicking Watch at the top.
You can subscribe to https://github.com/openpetra/openpetra/ by clicking Watch at the top.
==IDE (Integrated Development Environment)-related==
===Designer===
'''Q:''' When I try do display some Forms or UserControls in the IDE's built-in WinForms Designer I get a screenful of warnings and errors when I'm trying to display them in designer. What's causing this?
'''A:'''<br>
The reason for that is that we are not using the WinForms Designer for designing OpenPetra’s Forms and UserControls, but a generator that is driven by YAML files (that process is often called ‘scaffolding’ and has got many advantages over designing Forms/UserControls by hand). For some reason the WinForms Designer isn’t quite happy with the code that the generator ‘spits out’ in many cases and the displaying of the Form/UserControl in the Designer will abort with an error (though the Forms/UserControls work absolutely fine at run time). We never were desperate enough to put the necessary time in to address that issue, but we believe that it could be fixed if we really want it to work.<br>
You can read more about the YAML files and the WinForms/UserControl code generation in the wiki:
* [[Documentation YAML for OpenPetra Forms]]
* [[Screen scaffolding: controls]]
A detailed example walk-through for a typical OpenPetra List/Detail screen (e.g. Partner Module -> Setup -> Special Types) can be found here: [[How-To: Creating a Maintain Table screen]]
===Compiling/Debugging===
====IDE error while trying to debug - the compiler can't copy files to output directory====
'''Q:''' If the OpenPetra server or the OpenPetra client is running, I'm getting errors when I want to enter a debug session in the IDE: the IDE says it can't copy files to bin.  The server or client seem to be locking up the current copy of the files?
'''A:'''<br>
The reason for that is the Windows OS itself: as long as a program is running (here PetraServerConsole.exe or PetraClient.exe), the file(s) that make up the program (the exe and the many DLL’s) are locked by the OS – they are read-only. Now once one wants to start a debug session from the IDE, the IDE wants to do a full compile of all Projects and therefore the compiler wants to overwrite the resulting exe and DLL’s, which it can’t as they are locked by Windows. <br>
The solution to this is to stop the PetraServer and PetraClient before entering into debugging in the IDE. (The [[OpenPetra Developer's Assistant]] has got a nice feature that can add a ‘stop the PetraServer once compilation is requested’ feature to relevant Projects. The feature is found on the ‘Options’ Tab of the OpenPetra Developer's Assistant by clicking the ‘Advanced’ Button. Ensure that both checkboxes are ticked and follow the instructions in the label of that dialog and you will have those handy features enabled.)<br>
The other option for debugging is to attach the IDE to a running process (PetraServerConsole.exe or PetraClient.exe) as one doesn't need to do a compile in the IDE for this to work and the locking of the exe and DLL's won't be a problem. How the attaching is achieved varies from IDE to IDE; for SharpDevelop 4 it works like this: Menu 'Debug' -> 'Attach to Process...'. Select either PetraServerConsole.exe or PetraClient.exe in the list and click 'Attach'.
==== Compiler Errors ====
===== Q: I get 'File name xyz is too long or invalid' message=====
[solution] Building 'Ict.Petra.Client.MReporting.Gui.MConference' [Debug] ...
[solution] CSC: Error CS2021: File name '..\..\..\..\_bin\ObjCode\Ict.Petra.Client.MReporting.Gui.MConference.TFrmAttendanceSummaryReport.resources' is too long or invalid
[solution] Project 'Ict.Petra.Client.MReporting.Gui.MConference' failed!
[solution] Continuing build with non-dependent projects.
[solution] Building 'Ict.Petra.Client.MFinance.Gui.Gift' [Debug] ...
[solution] Building 'Ict.Petra.Client.MPartner.Gui' [Debug] ...
[solution] Building 'Ict.Petra.Client.MReporting.Gui.MPersonnel' [Debug] ...
File name '..\..\..\..\_bin\ObjCode\Ict.Petra.Client.MReporting.Gui.MConference.TFrmAttendanceSummaryReport.resources' is too long or invalid
[solution] CSC: Error CS2021: File name '..\..\..\..\_bin\ObjCode\Ict.Petra.Client.MReporting.Gui.MPersonnel.TFrmEmergencyContactReportStaff.resources' is too long or invalid
[solution] Project 'Ict.Petra.Client.MReporting.Gui.MPersonnel' failed!
'''Solution''': my working path had too many characters "C:\Documents and Settings\timotheusp\My Documents\openpetra\bzr\dev_0000159_exportimportgiftbatch". I renamed the branch part, and compilation works fine again!


==Unit Testing==
==Unit Testing==

Revision as of 06:56, 26 March 2020

Source Code Repository

Q: Which source code repository system are you using?

We use Git, and the main repository is hosted at https://github.com/openpetra/openpetra/.

Continuous Integration/Build Server

Q: Do you build regularly?

Yes, we do. See Continuous Integration with LightBuildServer

Notifications of What is Happening

Q: Do you have a Developer's Blog or Mailing Lists?

We don't have a developer's blog and we don't have mailing lists either. We have Forums instead. The Forum provides a better structure than a blog for the purposes of communication between developers/potential developers because the Forum provides a threaded format rather than just a long list of entries that is ordered by date.

In addition to that we have hourly notification emails for Forum changes and wiki changes that our developers all are subscribed to (such emails are sent only if changes happen, of course). These email notifications can't be subscribed to directly. Instead, an administrator needs to set those up for each developer as they are a done with a custom solution.

Note: We have a Project Blog which is accessible from the 'News' section of the web site.

Q: Do you have notifications for source code commits?

You can subscribe to https://github.com/openpetra/openpetra/ by clicking Watch at the top.

Unit Testing

NUnit

Q: I get 'Assembly Not Loaded: System.BadImageFormatException' Exception

When starting NUnit on 64-bit Windows, you might get this error:

Assembly Not Loaded
System.BadImageFormatException : Could not load file or assembly 'Tests.Common, Version=0.0.9.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. 
An attempt was made to load a program with an incorrect format.
You may be attempting to load an assembly built with a later version of the CLR than the version 
under which NUnit is currently running (2.0.50727) or trying to load a 64-bit assembly into a 32-bit process.

Solution: run the nunit-x86.exe instead of the nunit.exe from your directory C:\Program Files (x86)\NUnit 2.5.8\bin\net-2.0 or similar.


Q: How can I include the sources of NUnit-Forms in my test software developement?

The standard unit tests of openpetra are handled by NUnit extended by NUnit-Forms. NUnit-Forms seems to be a project which has terminated some years ago and so it may be necessary to develop some own little extensions. In the very first level you can create a “development tool” combined by the NUnit-Forms-Sources and NUnit.

Actually the NUnit-Forms-dll is delivered inside the source tree and stored in the path \csharp\ThirdParty\NUnit.

Furthermore there exists a zip file which contains the our internal status of the NUnit-Forms sources. The zip-file can be unzipped anywhere else on the pc. Inside of the nunitforms\source-folder you’ll find the solution file NUnitForms.sln. Inside of this file you find the relevant project NUnitForms.

  1. Select this project, select “properties” and
  2. then select the tab “Compiling”
  3. then let the output path point to \csharp\ThirdParty\NUnit
  4. start a dll-build by using F8 (Sharp-Develop)

Then in case of an error not only the test routines are shown in NUnit but the other NUnitForms-Routines too. Of course, it is a something simple development suite because you cannot single step debug or something else. You only can use this static viewer and in the TextOutput-Tab you can place some messages using System.Console.Writeln.

OpenPetra Client-related

Unable to Log in - Version Mismatch Message

Q: I have been running the IDE in debug mode against the client project. However, I am now unable to get past the OpenPetra Client login due to the following error:

OpenPetra Client/Server Program Version Mismatch!
The Program Version of your OpenPetra Client (0.2.23.0) does not match the Program Version of the OpenPetra Server (0.22.10).
An Open Petra Client cannot connect to an OpenPetra Server unless the Program versions match.

How do I avoid/fix this? Except for the original generate solution, I have made no intentional changes to this source and no compiles except for what debug itself does.

A: You had a PetraServer instance from the release version of OpenPetra (which you previously installed) running in the background. The PetraClient you have compiled from within the IDE has got a different version number than the PetraServer from the release, hence the PetraClient refuses to connect to that server. Solution: First kill the PetraServer.exe process from the release by using the Windows Task Manager, ensuring that there is no instance of it left in memory. Then start the PetraServer from your codebase by issuing 'nant startPetraServer' in a command window in your branch directory. Then press the 'Login' button again on the still running PetraClient instance that you are currently debugging. This will now go ahead as the PetraClient is now connecting to a compatible PetraServer version instance.


Unsorted questions

Q: You seem to be relying on command shell operations (using nant scripts) for a lot of the development process. I don't like command shell operations particularly; is there another way of doing those operations?

Yes, there is: use the graphical OpenPetra Developer's Assistant, which can execute most nant script operations that are commonly used in the development process. When an operation is invoked from the OpenPetra Developer's Assistant, the operation performs exactly the same as the nant script operations when run in the command shell. Moreover, the OpenPetra Developer's Assistant adds a lot of convenience to the development process.

Q: I cannot find a string which is shown in a dialog, why?

Refering to this screen shoot you may search for a string like "ImportGL Transactions From Bank Statement" in order to find the piece of code responsible for that entry. The string you should look for is ImportGLTransactionsFromBankStatement, and this leads you directly to the file UINavigation.yml.

Q: I came across C# code like '... = @TServerLookup.TMCommon.GetData;' - what does it do, what is it for?

In the C# programming language the '@MethodName' notation is used for referencing the callee of a Delegate. The @ operator is optional, but it helps when 'scanning program code by eye' to identify such callees (and to find those quickly when using the find functionality of a code editor).

An example code line for that can be found in \csharp\ICT\Petra\Client\app\MainWindow\PetraClientMain.cs, Method 'InitialiseClasses':

TSharedValidationHelper.SharedGetDataDelegate = TServerLookup.TMCommon.GetData; 

The code line means in English: ‘Set up the Delegate of Type TSharedGetData which is held in the static Field FDelegateSharedGetData in Class TSharedValidationHelper through its static Property SharedGetDataDelegate to point to the static Method TServerLookup.TMCommon.GetData’. The purpose of setting this up is that the Method GetData in Ict.Petra.Shared.MCommon.Validation.TSharedValidationHelper (which is in a Project that can’t have a reference to any client-side projects as it is shared code that can be executed by both client and server) can still execute a client-side (or a server-side) method - although it is lacking Project References to those DLLs! 'What exactly' is getting executed at run time in Method GetData depends on whether the client or the server is setting up the SharedGetDataDelegate Delegate, and to which Method on ‘his side’ that points.

Note: The server-side set-up of the Delegate can be found in \csharp\ICT\Petra\Server\lib\CallForwarding\CallForwarding.cs, in the static Constructor of 'TCallForwarding'.

TSharedValidationHelper.SharedGetDataDelegate = @TCommonDataReader.GetData;

Q: What is the 'SiteKey' and how do I retrieve it?

Have a look here: Retrieving the 'SiteKey' of an OpenPetra installation.

More questions?

Just ask a question in this [Forum].

Other FAQ Pages

FAQ's for the General Community