Where are my MSDN downloads, Microsoft????

Virtually every website nowadays follows a God-awful trend in UI that generally replaces hyperlinked text with illustration-heavy art work arranged in a grid layout, making it not easier but HARDER for people to find a specific page. You cannot search for text on the page as it’s all now pictures; and, each page shows less links as a picture takes up more real estate than simple text.

Microsoft has joined that trend, making it almost impossible to find MSDN subscription downloads (https://msdn.microsoft.com/en-us/subscriptions/downloads). (Thank goodness Google search still works.) When you set your browser to http://msdn.microsoft.com, you get a large page that is nice to look at but shows virtually nothing:

Now, where are the downloads for your MSDN subscription? Click on the “Downloads” tab, and you get three items you can navigate to, none of which help.

All the other menu items in the page are the same–no MSDN downloads. if you click on the “Subscriber portal” in the upper-right, then you get a page with a 6 by 3 grid of icons for various downloads, but none of which say are an OS, or the VS C++ Build Tools:

From The Next Web, “In 2017, websites are likely to start moving back to basics and placing more emphasis on content. Whether that means we remove all of the other distractions we’ve spent years adding, or just making them take up less real estate is yet to be determined. Getting back to the heart of a website — the content — will be prevalent moving forward.” I certainly hope so. Maybe someone could define a measure that identifies when simple text is more appropriate than a grid of illustrations?

Please, let’s go back to the future and just use text where it’s appropriate!

Swig, LLVM, LLILC

As I work to enhance Campy, a C# library for GPU programming I wrote, I’m trying to capitalize on some new code from the NET Foundation Projects. These include LLILC, a MS IL compiler based on LLVM. I want to be able to use some of the APIs in LLVM to perform SSA analysis rather than roll my own. But, that turns out to be easier said than done. This note describes some of the issues in building LLILC, LLVM, and SWIG.

Continue reading “Swig, LLVM, LLILC”

Getting Windows Subshell for Linux working

If you’ve been working with Cygwin or MinGW, you may want to step over to Windows Subsystem for Linux (WSL) to take advantage of building and running tools in that environment. While the goal of Cygwin and MinGW has been to provide a Linux command-line tool set to Windows, it’s too easy to run the wrong tool (e.g., forgetting to install a tool in one environment, and picking up the identically named tool in another). In fact, many tools install their own private copy of MinGW (Git for Windows, SourceTree, Vagrant, …), so you find yourself constantly manipulating the search path.

Continue reading “Getting Windows Subshell for Linux working”

Hackintosh for Development

Years ago, I bought a MacIntosh–the original 128K 68000 Motorola CPU  box. Like the Apple 2 before that, I upgraded it as best I could, and tried to develop programs for it. But, it was all not easy. And, it was exceedingly expensive–from the computer, to the upgrades, to the software, to the books detailing how to program the system. The decision by Apple to make the system so closed and so expensive made an impression that hasn’t changed over 30 years. I won’t buy an Apple product.

Unfortunately, if you are software developer, you have to use crap you really don’t want to use. The share of iPhones in the U.S. seems to be increasing, not decreasing, and I want to be able to write software for the iPhone. My dad, sisters, brother, and their families all own these exceedingly expensive cellphones. But, as Apple doesn’t give discounts for developers for their hardware, I decided to put together a hackintosh.

After a week or so, I finally found a hardware/software combination that seems to do the trick. My hackintosh is an Acer Aspire e5-574, with 6 GB memory, and an external 1 TB USB harddrive (Kingwin EZ-Dock 2535). It runs Sierra OS X, which I downloaded from a virtual machined hackintosh. It uses a USB keyboard and mouse as there are no drivers for the integrated keyboard and mouse. There are also no drivers for access to the internal SATA drive, which is why it runs with an external USB drive.

The hack wasn’t easy to set up. I’ve tried setting up El Capitan on two other Intel boxes and had no luck. I found the laptop hack after trying it out with the instructions on TonyMacX86.com. I’ll repeat the steps here.

Step 1: Download Sierra OS X.

  1. Start up an existing Mac.
  2. Download Sierra OS X.
  3. The files for OS X will be in /Applications.

Step 2: Create a bootable USB drive with UniBeast.

  1. Insert a USB thumb drive into the Mac. The USB drive should be 10 GB or more. If it doesn’t recognize the drive, try another.
  2. Open /Applications/Utilities/Disk Utility.
  3. Select the USB drive and erase it. The default should be OS X Extended (Journaled), and GUID Partition Map.
  4. Download Unibeast and run. You will need to sign up for a TonyMacX86.com account. I used UniBeast 7.0.1.
  5. In Unibeast, go through the preliminaries. Then select the destination USB drive, Sierra for the OS Installation, UEFI Boot mode. Then install.
  6. You should download MultiBeast and copy it to the USB drive. I used version 9.0.1.

Step 3: Set up BIOS settings on the laptop.

  1. Use “F2” repeatedly to get to the BIOS screen for the Acer.
  2. The only setting for the Acer laptop that is important is the Secure boot mode. Make sure it is turned off.

Step 4: Install OS X Sierra on the laptop.

  1. Insert the USB thumb drive on the laptop.
  2. Use “F12” to get the boot selector for the Acer laptop.
  3. Boot from the USB drive.
  4. In Clover, select the appropriate drive, then boot.
  5. After a long time, you should see an installation screen fro OS X.
  6. Insert the EZ-Dock drive.
  7. Format the EZ-Dock drive.
  8. Install Sierra on it.
  9. Reboot. Select the new drive. Sierra should come up.

Step 5: Post install

  1. Run MultiBeast on Sierra.
  2. Select Network and add in Atheros2200Ethernet 2.2.0, then install on the Sierra OS.
  3. Pull out the thumb drive, and reboot. It should now work.

Ken

Another Visual Studio Extension for Antlr4 Files: AntlrVSIX

There are several Visual Studio extensions for Antlr: Antlr4Code, ANTLR Language Support, Actipro SyntaxEditor for WPF, and Syntax Highlighting Pack. However, each has problems (works on Antlr3, has advertisements, does not offer a “go to definition” right-click context menu command, etc). So, over the last few days, I implemented a simple VS 2015/2017 extension for Antlr4 grammars. You can find the sources on Github (https://github.com/kaby76/AntlrVSIX). The extension implements “go to definition” and “find all references” for grammar symbols. There are some restrictions, but it’s a start, works well, and is very simple code. Enjoy!

(Edited Jan 14, 2017)

Getting Xamarin.Forms apps working with .NET Standard and Roslyn

Recently, I was trying to write a Xamarin.Forms app that uses Roslyn, Microsoft’s NET languages compiler framework. But, no matter what I did, it seemed as though it wasn’t possible. But, I tried a few things, and noticed that the Roslyn library could link with Android and iOS applications. That’s when I realized it might be possible.

That said, it depends on what you will be interested in of the Roslyn API. While one can parse and compile code from the .NET Standard/PCL library, Assembly.Load is essentially unavailable. Full functionality is available in Xamarin Android version 7. If you want to run compiled code, you need to use a bait/switch layer to accomplish that, in which case, you don’t need to make your PCL into a .NET Standard library, but it’s a good idea anyways.

Also, I’ve noticed VS 2015 is quite brittle in setting up an app to use .NET Standard. The following steps show that it can be done. Note: after each step, verify with a build and run.

  1. To set up a Xamarin Forms app to use the .NET Standard, open Visual Studio 2015 and create a blank cross-platform app that uses portable class libraries. You will see a portable class library and apps for each of the platforms.
  2. In the Project Explorer, Remove the Windows, Windows Phone apps, and leave the Android and iOS apps.
  3. Set the default project to the Android project. Build and run to make sure all is OK.
  4. Update the Xamarin.Forms in the three projects, to the latest version of Xamarin.Forms (2.3.3.175). Rebuild and run to make sure it works.
  5. In the Project Explorer, right-click on the References for the Xamarin Forms app portable class library, and “Manage NuGet Packages.” Remove the Xamarin.Forms library.
  6. Right-click on the portable class library, select Properties. Click on the Target .NET Standard hyperlink, then select NET Standard 1.5. Note, if you use .NET Standard 1.6, the References suddenly drops all DLL references, so don’t use that! In VS 2017, that appears to be fixed. Once VS has made the conversion, project.json will appear. After making the conversion, the default project has been reset. Set it back to the Android project.
  7. In the file project.json, change the ‘frameworks’ section with the following code, which allows the .NET Standard library to be compatible with certain PCL libraries.
 "frameworks": {
   "netstandard1.5": {
     "imports": [
       "portable-net45+wpa81+wp8+win8"
     ]
   }
 }
  1. Go back to the NuGet package management for the Xamarin Forms app PCL, add in Xamarin.Forms (the latest version).
  2. Rebuild and test. It should all work fine. If not, there is probably something wrong with your VS. Make sure it has the latest updates.

Roslyn works with .NET Standard, but adding it blindly causes a dependency/version issue. Roslyn requires Microsoft.Composition, but the version that it requires is old and incompatible with the .NET Standard (Package Microsoft.Composition 1.0.27 is not compatible with netstandard1.4 (.NETStandard,Version=v1.4). Package Microsoft.Composition 1.0.27 supports: portable-net45+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile259)). Instead, add Microsoft.Composition first, then Microsoft.CodeAnalysis.

  1. In the Project Explorer, right-click on the References for the portable class library, and “Manage NuGet Packages.” Add in Microsoft.Composition (1.0.30), then Microsoft.CodeAnalysis (1.3.2). Make sure to add that to the Android project as well or you get “Severity Code Description Project File Line Source Suppression State
    Error Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly ‘Microsoft.CodeAnalysis, Version=1.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’. Perhaps it doesn’t exist in the Mono for Android profile….”

For a check, add source referencing some Roslyn classes, build and run.

using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;

namespace App15
{
    public class Class1
    {
        public Class1()
        { }

        public static void YoDoit()
        {
            SyntaxTree tree = CSharpSyntaxTree.ParseText(@"
            public class MyClass
            {
                public int MyMethod()
                {
                    return 1+2;
                }
            }");
        }
    }
}

This code is in Github: https://github.com/kaby76/XamForms-Roslyn-Example

C# v7.0 pattern matching

Visual Studio “15” Preview 4 was recently released, so I decided to take it for a spin. In the upcoming C# 7.0, of the features being implemented, pattern matching is probably the most interesting. Consider how often we’ve designed code that uses a switch statement with complex cases, but then when we go to implement the design, a nested if-then-else statement must be coded instead because switch labels must be constant expressions. With pattern matching, this will finally change.

In theory, when the feature is fully implemented, we could write complex switch statements such as:

Unfortunately, while this example compiles, it does not run properly yet, in Visual Studio “15” Preview 4.

Years ago, I used to write C code that would contain declaration expressions. This would simultaneously assign a value and test to see if the value was non-zero. You can do this in C++, e.g.,

In C#, we can use patterns to declare local variables within an expression, extending the declaration expression existing in C++:

If the switch is rewritten as a nested if-then-else, the code works fine. Note, the scope of pattern matching variables is within the then clause, not the else clause of the if statement. I’m not sure why this would be the design, as in C/C++, the scope of declaration expression variables extend into the else clause. But perhaps it is to allow reuse of the same variable in a nested if-then-else.

Further Information

https://www.infoq.com/news/2016/04/CSharp-7

Essential .NET – Designing C# 7, Mark Michaelis, December 2015 https://msdn.microsoft.com/en-us/magazine/mt595758.aspx

Pattern Matching for C# https://github.com/dotnet/roslyn/blob/future/docs/features/patterns.md

https://github.com/dotnet/roslyn/issues/2136

https://github.com/dotnet/roslyn/issues/206

https://github.com/dotnet/roslyn/blob/future/docs/features/patterns.md

Advanced Pattern Matching Features Removed From C# 7 https://www.infoq.com/news/2016/05/csharp7-pattern-matching-removed

C# 7 Features Previewed https://www.infoq.com/news/2016/04/CSharp-7

Unification: pattern matching, but twice as nice! By: on May 31, 2011  http://www.lshift.net/blog/2011/05/31/unification-pattern-matching-but-twice-as-nice/

https://github.com/dotnet/roslyn/blob/master/docs/Language%20Feature%20Status.md