10000 GitHub - MihaMarkic/roslyn-prank: The .NET Compiler Platform ("Roslyn") provides open-source C# and Visual Basic compilers with rich code analysis APIs.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Mar 31, 2023. It is now read-only.
/ roslyn-prank Public archive
forked from dotnet/roslyn

The .NET Compiler Platform ("Roslyn") provides open-source C# and Visual Basic compilers with rich code analysis APIs.

License

Notifications You must be signed in to change notification settings

MihaMarkic/roslyn-prank

 
 

Repository files navigation

Welcome to the prank version of .NET Compiler Platform ("Roslyn")

The motivation

I created this version as a demo for my presentation What's new in C# 6.0 where the open source Roslyn plays a big role. The reasoning is to show that Roslyn is open source and everybody can contribute/fork/modify/whatever.

The prank

I've reversed the meaning of true and false literals. The core change is in CSharpCodeAnalysis project's method Microsoft.CodeAnalysis.CSharp.SyntaxFacts.GetKeywordKind where I return SyntaxKind.TrueKeyword when "false" and viceversa. To make this really work one needs to disable a couple of asserts. The two asserts verifies the string length and thus would fail ('false' is longer text than 'true'). The Debug.Assert lines are located in CodeAnalysis project SyntaxTreeExtensions.cs line 76 and CSharpCodeAnalysis project QuickScanner.cs line 254. I've just commented the two.

Perhpas there is a cleaner way to achieve this prank but the one described just works.

The Test

Try compling and running this piece of code.

using System.IO;
using System;

namespace Yolo
{
	
	public class Yolo 
	{
		public static void Main()
		{
			if (true) {
				Console.WriteLine("Yolo");
			}
			else
			{
				Console.WriteLine("Yolo false");
			}
		}
	}
}

About

The .NET Compiler Platform ("Roslyn") provides open-source C# and Visual Basic compilers with rich code analysis APIs.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 55.1%
  • Visual Basic .NET 44.9%
  • Shell 0.0%
  • Batchfile 0.0%
  • PowerShell 0.0%
  • C++ 0.0%
0