Linq To XSD in Compact Framework 3.5 Working

Oct 19, 2010 at 12:22 PM

Hi,

I've created a version of Linq To XSD 1.1.0 that works under Compact Framwork 3.5.

I shall describe the basic steps here:

1.       Grab changeset 41754 and extract the \tags\1.1.0 folder

2.       Create a new Smart Device DLL (XObjects_NETCF) and copy into it the Src folder from XObjects, include all of the code files. Set the Assembly name to be the same as XObjects but add .Netcf to the end

3.       Selectively exclude any code files that require anything from System.CodeDom

4.       Using Redgate’s .NET Reflector, decompile mscorlib to get some code to implement a few bits missing from the Compact Framework:

a.       DebuggerBrowsableAttribute.cs

b.      DebuggerBrowsableState.cs

c.       DebuggerDisplayAttribute.cs

d.      DebuggerTypeProxyAttribute.cs

e.      StringSplitOptions.cs

5.       Replace the reference to System.Type.EmptyTypes with new Type[0]

6.       Copy the .targets file adding _netcf before .targets (It’s in XOTask)

7.       Add it to the XOTask project, set Copy To Output to Copy If Newer.

Now, when using LinqToXSD in a NETCF project, add the _NETCF.targets file instead and it should work.

A better way to do this would be to separate Xml.Schema.Linq.dll into 2 DLLs.

Xml.Schema.Linq.dll – Just the runtime code, minus everything that references System.CodeDom

Xml.Schema.Linq.CodeGen.dll – Everything that was removed from the first DLL.

LinqToXSD.exe would then reference both of those DLLs to work, desktop and compact framework apps would just reference the runtime.

Rather that pinching bits from mscorlib, add #if NETCF switches everywhere to not compile the bits that aren’t in the Compact Framework and have two csproj files pointing at the same Src folder.

If the guy that writes LinqToXSD wants a copy of my working code, give me a shout and I’ll zip it up and email it to you.

Regards,

J1M.

Oct 19, 2010 at 12:23 PM

Also, you'll need this code:

using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Xml.Schema.Linq
{
    public static class StringExtensions
    {
        public static string[] Split(this string s, Char[] seperator, StringSplitOptions options)
        {
            string[] output;

            if (options == StringSplitOptions.RemoveEmptyEntries)
            {
                output = (from allstrings in s.Split(seperator)
                         where allstrings != ""
                         select allstrings).ToArray();
            }
            else
            {
                output = s.Split(seperator);
            }

            return output;
        }
    }


}

Oct 19, 2010 at 3:34 PM
Edited Oct 19, 2010 at 3:35 PM

Of course, when I say working...

It seems that the regeneration of LinqToXsdSource.cs is flaky at best, the only way to reliably keep it up to date it to delete the file and rebuild the solution.

Is there an error log anywhere?