private static string GetClassName(ParserStateValues state) { bool hadClassName = false; StringBuilder classNameBuilder = new StringBuilder(state.ClassDeclaration.Length); IlParsingUtils.ParseIlSnippet(state.ClassDeclaration, ParsingDirection.Forward, (Func <IlParsingUtils.IlSnippetLocation, bool>)(s => { if (s.WithinString) { hadClassName = true; if (s.CurrentChar != '\'') { classNameBuilder.Append(s.CurrentChar); } } else if (hadClassName) { if (s.CurrentChar == '.' || s.CurrentChar == '/') { classNameBuilder.Append(s.CurrentChar); } else if (s.CurrentChar != '\'') { return(false); } } return(true); }), (Action <IlParsingUtils.IlSnippetFinalizaton>)null); return(classNameBuilder.ToString()); }
private static void ExtractResultModifier( ref string foundResult, out string foundResultModifier) { int bracketEnd = -1; string localFoundResult = foundResult; string localfoundResultModifier = (string)null; IlParsingUtils.ParseIlSnippet(foundResult, ParsingDirection.Backward, (Func <IlParsingUtils.IlSnippetLocation, bool>)(s => { if (s.WithinString || !s.AtOuterBracket) { return(true); } if (s.CurrentChar == ')') { bracketEnd = s.Index; return(true); } string str = s.InputText.Substring(0, s.Index); int num = str.LastIndexOf(' '); if (num > -1 && str.Substring(num + 1) == "marshal") { localfoundResultModifier = s.InputText.Substring(num + 1, bracketEnd - num); localFoundResult = s.InputText.Remove(num + 1, bracketEnd - num); } return(true); }), (Action <IlParsingUtils.IlSnippetFinalizaton>)null); foundResult = localFoundResult; foundResultModifier = localfoundResultModifier; }
private bool GetPartBeforeParameters( string line, out string methodName, out string afterMethodName, out string foundResult, out string foundResultModifier, out string foundMethodAttributes) { methodName = (string)null; foundResult = (string)null; foundResultModifier = (string)null; afterMethodName = (string)null; foundMethodAttributes = (string)null; line = line.TrimStart(); if (!line.StartsWith(".method")) { return(false); } line = line.Substring(".method".Length).TrimStart(); StringBuilder afterMethodNameBuilder = new StringBuilder(line.Length); string result = (string)null; IlParsingUtils.ParseIlSnippet(line, ParsingDirection.Backward, (Func <IlParsingUtils.IlSnippetLocation, bool>)(s => { if (!s.WithinString && s.AtOuterBracket) { if (s.CurrentChar != ')') { result = line.Substring(0, s.Index); afterMethodNameBuilder.Insert(0, s.CurrentChar); return(false); } MethodDeclarationParserAction.RemoveCilManagedFromMethodSuffix(ref afterMethodNameBuilder); } afterMethodNameBuilder.Insert(0, s.CurrentChar); return(true); }), (Action <IlParsingUtils.IlSnippetFinalizaton>)null); if (afterMethodNameBuilder.Length > 0) { afterMethodName = afterMethodNameBuilder.ToString(); } if (result != null) { string attributesWithResult; methodName = MethodDeclarationParserAction.ExtractMethodName(result, out attributesWithResult); if (this.SplitAttributesAndResult(attributesWithResult, out foundResult, out foundMethodAttributes)) { if (foundResult != null && foundResult.Contains("(")) { MethodDeclarationParserAction.ExtractResultModifier(ref foundResult, out foundResultModifier); } return(true); } } return(false); }
private static string ExtractMethodName(string result, out string attributesWithResult) { string localAttributesWithResult = (string)null; StringBuilder methodNameBuilder = new StringBuilder(result.Length); IlParsingUtils.ParseIlSnippet(result, ParsingDirection.Backward, (Func <IlParsingUtils.IlSnippetLocation, bool>)(s => { if (s.CurrentChar == '\'') { return(true); } if (!s.WithinString && s.CurrentChar != '.' && (s.CurrentChar != ',' && s.CurrentChar != '/') && (s.CurrentChar != '<' && s.CurrentChar != '>' && s.CurrentChar != '!')) { return(false); } methodNameBuilder.Insert(0, s.CurrentChar); return(true); }), (Action <IlParsingUtils.IlSnippetFinalizaton>)(f => localAttributesWithResult = f.LastPosition > -1 ? result.Substring(0, f.LastPosition) : (string)null)); string str = methodNameBuilder.ToString(); attributesWithResult = localAttributesWithResult; return(str); }
private bool IsExternalAssemblyReference( string trimmedLine, out string assemblyName, out string aliasName) { assemblyName = (string)null; aliasName = (string)null; if (trimmedLine.Length < ".assembly extern ".Length || !trimmedLine.StartsWith(".assembly extern ", StringComparison.Ordinal)) { return(false); } List <string> identifiers = new List <string>(); IlParsingUtils.ParseIlSnippet(trimmedLine.Substring(".assembly extern ".Length), ParsingDirection.Forward, (Func <IlParsingUtils.IlSnippetLocation, bool>)(current => { if (!current.WithinString && current.CurrentChar == '\'' && current.LastIdentifier != null) { identifiers.Add(current.LastIdentifier); if (identifiers.Count > 1) { return(false); } } return(true); }), (Action <IlParsingUtils.IlSnippetFinalizaton>)null); if (identifiers.Count == 0) { return(false); } if (identifiers.Count > 0) { assemblyName = identifiers[0]; } aliasName = identifiers.Count > 1 ? identifiers[1] : identifiers[0]; return(true); }