当前位置: 首页>>代码示例>>C#>>正文


C# ISymbol.GetReturnType方法代码示例

本文整理汇总了C#中ISymbol.GetReturnType方法的典型用法代码示例。如果您正苦于以下问题:C# ISymbol.GetReturnType方法的具体用法?C# ISymbol.GetReturnType怎么用?C# ISymbol.GetReturnType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISymbol的用法示例。


在下文中一共展示了ISymbol.GetReturnType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateEventInvocator

        public static MethodDeclarationSyntax CreateEventInvocator(Document document, ISymbol eventMember, bool useExplictType = false)
        {
            var options = document.Project.ParseOptions as CSharpParseOptions;

            if (options != null && options.LanguageVersion < LanguageVersion.CSharp6)
                return CreateOldEventInvocator(eventMember.ContainingType.Name, eventMember.ContainingType.IsSealed, eventMember.IsStatic, eventMember.Name, eventMember.GetReturnType().GetDelegateInvokeMethod(), useExplictType);

            return CreateEventInvocator(eventMember.ContainingType.Name, eventMember.ContainingType.IsSealed, eventMember.IsStatic, eventMember.Name, eventMember.GetReturnType().GetDelegateInvokeMethod(), useExplictType);
        }
开发者ID:alecor191,项目名称:RefactoringEssentials,代码行数:9,代码来源:CreateEventInvocatorCodeRefactoringProvider.cs

示例2: RoslynSymbolCompletionData

		public RoslynSymbolCompletionData (ICompletionDataKeyHandler keyHandler, RoslynCodeCompletionFactory factory, ISymbol symbol, string text = null) : base (keyHandler)
		{
			this.factory = factory;
			this.text = text;
			Symbol = symbol;
			if (IsObsolete (Symbol))
				DisplayFlags |= DisplayFlags.Obsolete;
			rightSideDescription = new Lazy<string> (delegate {
				var returnType = symbol.GetReturnType ();
				if (returnType == null || factory == null)
					return null;
				try {
					return "<span font='Sans 10'>" + GLib.Markup.EscapeText (SafeMinimalDisplayString (returnType, factory.SemanticModel, ext.Editor.CaretOffset)) + "</span>";
				} catch (Exception e) {
					LoggingService.LogError ("Format error.", e);
				}
				return null;
			});
		}
开发者ID:pjcollins,项目名称:monodevelop,代码行数:19,代码来源:RoslynSymbolCompletionData.cs

示例3: Init

		void Init (ISymbol member)
		{
			if (member == null)
				throw new ArgumentNullException ("member");
			FillDocumentation (GetBaseDocumentation (member));
			//			if (provider != null && !member.Location.IsEmpty && member.BodyRegion.EndLine > 1) {
			//				LineSegment start = data.Document.GetLine (member.Region.BeginLine);
			//				LineSegment end = data.Document.GetLine (member.BodyRegion.EndLine);
			//				if (start != null && end != null) {
			//					var result = provider.ParseFile ("class A {" + data.Document.GetTextAt (start.Offset, end.EndOffset - start.Offset) + "}");
			//					result.AcceptVisitor (visitor, null);
			//				}
			//			}
			foreach (var macro in DocConfig.Instance.Macros) {
				tags.Add (macro.Key, macro.Value);
			}
			if (member.ContainingType != null) {
				tags ["DeclaringType"] = "<see cref=\"" + member.ContainingType.GetDocumentationCommentId () + "\"/>";
				switch (member.ContainingType.TypeKind) {
				case TypeKind.Class:
					tags ["DeclaringTypeKind"] = "class";
					break;
				case TypeKind.Delegate:
					tags ["DeclaringTypeKind"] = "delegate";
					break;
				case TypeKind.Enum:
					tags ["DeclaringTypeKind"] = "enum";
					break;
				case TypeKind.Interface:
					tags ["DeclaringTypeKind"] = "interface";
					break;
				case TypeKind.Struct:
					tags ["DeclaringTypeKind"] = "struct";
					break;
				}
			}
			var returnType = member.GetReturnType ();
			tags ["ReturnType"] = returnType != null ? "<see cref=\"" + returnType.GetDocumentationCommentId () + "\"/>" : "";
			tags ["Member"] = "<see cref=\"" + member.Name + "\"/>";

			
			if (member is IPropertySymbol || member is IMethodSymbol) {
				var parameters = member.GetParameters ();
				var parameterNames = new List<string> (from p in parameters select p.Name);
				tags ["ParameterSentence"] = string.Join (" ", parameterNames.ToArray ());
				StringBuilder paramList = new StringBuilder ();
				for (int i = 0; i < parameterNames.Count; i++) {
					if (i > 0) {
						if (i == parameterNames.Count - 1) {
							paramList.Append (" and ");
						} else {
							paramList.Append (", ");
						}
					}
					paramList.Append (parameterNames [i]);
				}
				tags ["ParameterList"] = paramList.ToString ();
				for (int i = 0; i < parameters.Length; i++) {
					tags ["Parameter" + i + ".Type"] = parameters [i].Type != null ? "<see cref=\"" + parameters [i].Type + "\"/>" : "";
					tags ["Parameter" + i + ".Name"] = "<c>" + parameters [i].Name + "</c>";
				}
				
				var property = member as IPropertySymbol;
				if (property != null) {
					var hasPublicGetter = property.GetMethod != null && property.GetMethod.DeclaredAccessibility != Accessibility.Private;
					var hasPublicSetter = property.SetMethod != null && property.SetMethod.DeclaredAccessibility != Accessibility.Private;

					if (property.GetMethod != null && property.SetMethod != null && hasPublicGetter && hasPublicSetter) {
						tags ["AccessText"] = "Gets or sets";
					} else if (property.GetMethod != null && hasPublicGetter) {
						tags ["AccessText"] = "Gets";
					} else if (hasPublicSetter) {
						tags ["AccessText"] = "Sets";
					} else if (property.GetMethod != null && property.SetMethod != null) {
						tags ["AccessText"] = "Gets or sets";
					} else if (property.GetMethod != null) {
						tags ["AccessText"] = "Gets";
					} else {
						tags ["AccessText"] = "Sets";
					}
				}
			}
			
			SplitWords (member, member.Name);
		}
开发者ID:sushihangover,项目名称:monodevelop,代码行数:85,代码来源:DocGenerator.cs

示例4: EvaluateCondition

		public bool EvaluateCondition (List<KeyValuePair<string, string>> conditions, ISymbol member)
		{
			foreach (var condition in conditions) {
				bool result = false;
				foreach (string val in condition.Value.Split (',')) {
					switch (condition.Key) {
					case "type":
						result |= val == currentType;
						break;
					case "modifier":
						if (val.ToUpperInvariant () == "STATIC"){
							result |= member.IsStatic;
						} else {
							try {
								var mod = (Accessibility)Enum.Parse (typeof(Accessibility), val);
								result |=  member.DeclaredAccessibility == mod;
							} catch (Exception) {
							}
						}
						break;
					case "paramCount":
						var parameters = member.GetParameters ();
						result |= Int32.Parse (val) == parameters.Length;
						break;
					case "parameter":
						parameters = member.GetParameters ();
						string[] par = val.Split(':');
						int idx = Int32.Parse (par[0]);
						string name = par[1];
						result |= idx < parameters.Length && name == parameters[idx].Name;
						break;
					case "returns":
						if (member is IParameterSymbol) {
							result |= val == ((IParameterSymbol)member).Type.ToString ();
							break;
						}

						result |= val == member.GetReturnType ().ToString ();
						break;
					case "name":
						var method = member as IMethodSymbol;
						if (method != null && method.MethodKind == MethodKind.UserDefinedOperator) {
							string op = GetOperator (method.Name);
							if (op != null) {
								result |= val == op;
								break;
							}
						}
							
						result |= val == GetName (member);
						break;
					case "endsWith":
						if (member == null)
							break;
						result |= GetName (member).EndsWith (val, StringComparison.Ordinal);
						break;
					case "startsWith":
						if (member == null)
							break;
						result |= GetName (member).StartsWith (val, StringComparison.Ordinal);
						break;
					case "startsWithWord":
						if (member == null)
							break;
						var name2 = SeparateWords (GetName (member));
						result |= name2.StartsWith (val + " ");
						break;
					case "wordCount":
						result |= Int32.Parse (val) == wordCount;
						break;
					default:
						throw new Exception ("unknown condition:" + condition.Key);
					}
				}
				if (!result)
					return false;
			}
			return true;
		}
开发者ID:sushihangover,项目名称:monodevelop,代码行数:79,代码来源:DocGenerator.cs

示例5: IsAltered

        bool IsAltered(SemanticModel model, MemberDeclarationSyntax member, ISymbol symbol, CancellationToken token, out bool wasUsed)
        {
            wasUsed = false;
            foreach (var usage in member.DescendantNodesAndSelf().Where(n => n.IsKind(SyntaxKind.IdentifierName)).OfType<ExpressionSyntax>())
            {
                var info = model.GetSymbolInfo(usage).Symbol;
                if (info == symbol)
                    wasUsed = true;
                if (!usage.IsWrittenTo())
                {
                    // Special case: If variable is of a value type, check if one of its members is altered.
                    var memberAccExpr = usage.Parent as MemberAccessExpressionSyntax;
                    if (symbol.GetReturnType().IsReferenceType
                        || (memberAccExpr == null)
                        || (info != symbol)
                        || (memberAccExpr.Name == usage)
                        || !memberAccExpr.IsWrittenTo())
                        continue;
                }

                if (member.IsKind(SyntaxKind.ConstructorDeclaration) && !usage.Ancestors().Any(a => a.IsKind(SyntaxKind.AnonymousMethodExpression) || a.IsKind(SyntaxKind.SimpleLambdaExpression) || a.IsKind(SyntaxKind.ParenthesizedLambdaExpression)))
                {
                    if (member.GetModifiers().Any(m => m.IsKind(SyntaxKind.StaticKeyword)) == info.IsStatic)
                        continue;
                }
                if (info == symbol)
                    return true;
            }
            return false;
        }
开发者ID:ceddlyburge,项目名称:RefactoringEssentials,代码行数:30,代码来源:FieldCanBeMadeReadOnlyAnalyzer.cs


注:本文中的ISymbol.GetReturnType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。