SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

Laputa

This is a mirror of http://laputa.sharpdevelop.net/, the core team's central news blog.

NRefactory TypeReference - breaking change

In version 3.0.0.3660, I changed how NRefactory's TypeReference.Type works. This is a potentially breaking change to users of NRefactory.

Previously, TypeReference had both a "Type" and a "SystemType". If you parsed "long a;", you got a TypeReference with Type="long" and SystemType="System.Int64".

However, this got a little problematic if you wanted to modify the AST - do you have to change both Type and SystemType? Actually, setting Type to "int" was automatically setting SystemType to "System.Int32" - even if you were modifying VB code which doesn't have the "int" keyword but uses "Integer". The other way round, setting Type to "DATE" would set SystemType to "System.DateTime" - not only for VB, but also for C#. Because the parser internally also uses the Type setter, "DATE d;" would parse to "System.DateTime d;" in C#!

To solve this, I removed the language-specific "Type". Now the Type property always contains the SystemType. You can use the new boolean IsKeyword property to tell if the type was specified using the language keyword or if the CLR type was specified explicitly.

Another related problem was that there was no way to output "System.Int32 a;" using NRefactory - the output visitor would always automatically convert it to "int a;". I changed this, too - now the output visitors will use the short form only if the IsKeyword property is set. So code generators using NRefactory will output the long form when using the new NRefactory version unless they are modified to set IsKeyword=true.

Read the complete post at http://laputa.sharpdevelop.net/NRefactoryTypeReferenceBreakingChange.aspx

Published Dec 06 2008, 07:49 PM by Laputa
Filed under:
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.