Created
September 18, 2012 07:58
-
-
Save mkrueger/3741898 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| string GetShortType(IType type, CSharpResolver state) | |
| { | |
| var builder = new TypeSystemAstBuilder(state); | |
| var dt = state.CurrentTypeDefinition; | |
| var declaring = type.DeclaringType != null ? type.DeclaringType.GetDefinition() : null; | |
| if (declaring != null) { | |
| while (dt != null) { | |
| if (dt.Equals(declaring)) { | |
| builder.AlwaysUseShortTypeNames = true; | |
| break; | |
| } | |
| dt = dt.DeclaringTypeDefinition; | |
| } | |
| } | |
| var shortType = builder.ConvertType(type); | |
| return shortType.GetText(FormattingPolicy); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment