v1.6 .NET compilation issues

v1.6 .NET compilation issues

gbenettgbenett Posts: 14Questions: 5Answers: 0

While upgrading my app from 1.5.6 to 1.6.0, I ran into some thorny compile-time bugs in the new DataTables .NET code. I fixed them, but would like to know whether others are seeing the same issue, or whether my hacks will break something else down the road. Here are the problems I encountered in Visual Studio Premium 2013.

In abstract class Query.cs, the following lines gave syntax errors:

        internal virtual string _bindChar => "@";
        internal virtual string[] _identifierLimiter => null;
        internal virtual string _fieldQuote => "'";

so I regressed them to the 1.5.6 code:

        // Copied from v1.5.6 to fix compilation errors
        virtual internal string _bindChar { get { return "@"; } }
        virtual internal string _identifierLimiter { get { return ""; } }
        virtual internal string _fieldQuote { get { return "'"; } }

In addition, in method void _Prepare(string sql), I had to change the vars left and right to strings to work with String.Join:

         // did not compile in line 1012) return left + String.Join(right + '.' + left, a) + right + alias;
         var left = idl[0];
         var right = idl[1];

         // fix
         var left = idl[0].ToString();
         var right = idl[1].ToString();

There was one other issue as well but I can't recall it now. I'll append if I remember it later. Thanks for any guidance.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    I think it will be the same as discussed here. Basically the Editor code uses a newer version of C# than ships with VS2013. You can install the updated compiler from NuGet for VS2013.

    Allan

  • gbenettgbenett Posts: 14Questions: 5Answers: 0
    edited February 2017

    Plus ça change! I had no idea C# had major new syntax features. However, it looks like more than a NuGet package. This helpful summary says the new features are in VS2015 (aka Roslyn). I have the latest version of NuGet packages Microsoft.Net.Compilers (1.3.2) and Microsoft.CSharp (4.3.0), but the C# 6 syntax won't compile in VS2013.

    My workarounds are just regressions to C# 5 and should work fine, right? I'm not doing an IDE version upgrade right now.

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Yes I think so. To be honest, I think I got a bit carried away by the C# 6 features and should probably have stuck with 5 a bit longer.

    Did you change the compiler to v6 after installing the NuGet package? Properties > Build > Advanced... > Language Version.

    Allan

  • gbenettgbenett Posts: 14Questions: 5Answers: 0

    I was unaware of the Advanced Build options, thanks. The dropdown in my version of VS 2013 only goes up to C# 5 so that's clarifying. I think this link may be the last word on the matter. It says, NO.

    As for not rushing into every new feature in an upgrade, I believe conservatism is a virtue in software design. But it's hard not to use the cool new stuff. That's how they get you hooked on the next version! Thanks for the discussion.

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    The advantage of .NET is that you shouldn't actually need to compile the DataTables.dll yourself. If you reference it in a project that is not the Editor source project (since that will compile it), it should run without issue due to the CLR.

    Allan

  • gbenettgbenett Posts: 14Questions: 5Answers: 0

    Allan, I am so used to compiling everything from source I didn't even see the DLL in the download. Using it now -- works perfectly. Thanks again.

This discussion has been closed.