[mono-android] sharing code between mono touch and mono for android
Miljenko Cvjetko
mcvjetko at holisticware.net
Mon Jan 30 23:46:31 UTC 2012
Hi
Few years ago I tried to reuse code (Domain, Business logic) from
Silverlight on "binary"
level in WPF and that was doable, but just not feasible.
That's the reason I prefer and we argued a lot, but came to conclusion
that sharing code
is better.
1. Sharing code with Project Linker
1. hack if necessary in csproject file for extra extensions M4A.cs,
MTch.cs
normally Project Linker is used for WPF/Silverlight targeting
projects
2. process
1. determine smalles subset usually WP7
WP7 has smaller subset of features
example all methods are Async while MTch and M4A allow sync
(WebClient)
2. link other projects (MTch and M4A) to WP7
3. each new cs file added to WP7 proj shows in other projects
ability to add multiple src files.
Files with *.Silverlight.cs extension will not be linked
into other projs.
4. classes should be partial so if there is platform diff add
deltas like:
1. Class.Silverlight.cs to WP7 project
2. Class.MTch.cs to MTch project
3. Class.M4A.cs to M4A project
5. If needed some stuff can be manually added as link with
copy-as-link/paste
VSCommands, Power Commands or Productivity Tools (not sure)
6. If project linker does not pickup some links, just go to
source project (WP7)
do exclude/include and voila everything comes as link in
linked projects.
7. all above works in MonoDev so when needed to switch there
shouldn't be any
problems
2. heavy use of partial classes
common stuff in Class.cs this is propagated by Project Linker
through other linked
projects (except extensions - hack from 1.1)
3. team consent and discipline - naming
all controls same names across projects.
We had to make table with what is called what and where.
Sample:
we call all labelName if that is the purpose of Control/Widget
(short text)
WinForms - Label
WPF - TextBlock
SL - TextBlock
SLWP - TextBlock
MTch - UITextView
M4A - TextView
4. For more VS centric devs small shell script to add/remove MonoTouch
ProjectType GUID
for easier loading into VS (dos batch using sed.exe and bash on MacOSX)
Other things would be that
* code can be linked into desktop projects and as we know unit testing
for desktop
projects is still ahead of WP7 test projects or MTch and M4A.
And the question is whether we need UnitTests for each platform
(we do only if there are diffs)
o unit test for mobile still involve emulators/simulators, so
testing with nUnit is faster
* source is really compiled for each platform, so some problems might
show up earlier than
when just tossing assembly as reference into project.
HTH
mel
On 2012.01.30 15:58, Wally McClure wrote:
> I've been talking with Mark Bradley about sharing code between MT and
> MfA projects. I'm curious what are the strategies that you are using
> to share code between the two platforms. Any thoughts/advice are
> appreciated. We've each got a way that we're doing. I'm using
> separate projects and am linking files. Mark is doing something a
> little different where he references the .dll directly in his MT and
> MfA projects. I think both have pluses/minuses. What are you doing?
> Is there some macdaddy project type that we have missed that would
> allow us to share things easily? Are we both missing something?
>
> Wally
>
>
> _______________________________________________
> Monodroid mailing list
> Monodroid at lists.ximian.com
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
--
Miljenko Cvjetko dipl.ing. ET
Direktor/CEO
Projektant rjes(enja/Solution Architect
Razvojni programer/Senior developer
Voditelj projekta/Project Manager
IX juz(na obala 13
Kajzerica Zagreb
T: 385 1 7775555
M: 385 91 557 447 3
F: 385 1 7779556
e: mcvjetko at holisticware.net
w: http://www.holisticware.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/monodroid/attachments/20120131/509fe335/attachment.html>
More information about the Monodroid
mailing list