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


C# ISymbol.IsUnsafe方法代码示例

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


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

示例1: GenerateMember

			private ISymbol GenerateMember(
				ISymbol member,
				CancellationToken cancellationToken)
			{
				cancellationToken.ThrowIfCancellationRequested();

				// Check if we need to add 'unsafe' to the signature we're generating.
				var addUnsafe = member.IsUnsafe() && !_state.Location.IsUnsafeContext();

				return GenerateMember(member, addUnsafe, cancellationToken);
			}
开发者ID:sushihangover,项目名称:monodevelop,代码行数:11,代码来源:AbstractImplementAbstractClassService.Editor.cs

示例2: GenerateMember

            private ISymbol GenerateMember(
                ISymbol member,
                CancellationToken cancellationToken)
            {
                cancellationToken.ThrowIfCancellationRequested();

                // Check if we need to add 'unsafe' to the signature we're generating.
                var syntaxFacts = _document.Project.LanguageServices.GetService<ISyntaxFactsService>();
                var addUnsafe = member.IsUnsafe() && !syntaxFacts.IsUnsafeContext(_state.Location);

                return GenerateMember(member, addUnsafe, cancellationToken);
            }
开发者ID:GloryChou,项目名称:roslyn,代码行数:12,代码来源:AbstractImplementAbstractClassService.Editor.cs

示例3: GenerateMemberAsync

        protected override async Task<ISymbol> GenerateMemberAsync(ISymbol newOverriddenMember, INamedTypeSymbol newContainingType, Document newDocument, MemberInsertionCompletionItem completionItem, CancellationToken cancellationToken)
        {
            // Figure out what to insert, and do it. Throw if we've somehow managed to get this far and can't.
            var syntaxFactory = newDocument.GetLanguageService<SyntaxGenerator>();
            var codeGenService = newDocument.GetLanguageService<ICodeGenerationService>();

            var modifiers = completionItem.Modifiers.WithIsUnsafe(completionItem.Modifiers.IsUnsafe | newOverriddenMember.IsUnsafe());
            if (newOverriddenMember.Kind == SymbolKind.Method)
            {
                return await syntaxFactory.OverrideMethodAsync((IMethodSymbol)newOverriddenMember,
                    modifiers, newContainingType, newDocument, cancellationToken).ConfigureAwait(false);
            }
            else if (newOverriddenMember.Kind == SymbolKind.Property)
            {
                return await syntaxFactory.OverridePropertyAsync((IPropertySymbol)newOverriddenMember,
                    modifiers, newContainingType, newDocument, cancellationToken).ConfigureAwait(false);
            }
            else
            {
                return syntaxFactory.OverrideEvent((IEventSymbol)newOverriddenMember,
                    modifiers, newContainingType);
            }
        }
开发者ID:Eyas,项目名称:roslyn,代码行数:23,代码来源:AbstractOverrideCompletionProvider.cs

示例4: GenerateMember

            private ISymbol GenerateMember(
                Compilation compilation,
                ISymbol member,
                List<ISymbol> implementedVisibleMembers,
                CancellationToken cancellationToken)
            {
                // First check if we already generate a member that matches the member we want to
                // generate.  This can happen in C# when you have interfaces that have the same
                // method, and you are implementing implicitly.  For example:
                //
                // interface IFoo { void Foo(); }
                //
                // interface IBar : IFoo { new void Foo(); }
                //
                // class C : IBar
                //
                // In this case we only want to generate 'Foo' once.
                if (HasMatchingMember(implementedVisibleMembers, member))
                {
                    return null;
                }

                var memberName = DetermineMemberName(member, implementedVisibleMembers);

                // See if we need to generate an invisible member.  If we do, then reset the name
                // back to what then member wants it to be.
                var generateInvisibleMember = GenerateInvisibleMember(member, memberName);
                memberName = generateInvisibleMember ? member.Name : memberName;

                var generateAbstractly = !generateInvisibleMember && Abstractly;

                // Check if we need to add 'new' to the signature we're adding.  We only need to do this
                // if we're not generating something explicit and we have a naming conflict with
                // something in our base class hierarchy.
                var addNew = !generateInvisibleMember && HasNameConflict(member, memberName, State.ClassOrStructType.GetBaseTypes());

                // Check if we need to add 'unsafe' to the signature we're generating.
                var syntaxFacts = Document.GetLanguageService<ISyntaxFactsService>();
                var addUnsafe = member.IsUnsafe() && !syntaxFacts.IsUnsafeContext(State.Location);

                return GenerateMember(compilation, member, memberName, generateInvisibleMember, generateAbstractly, addNew, addUnsafe, cancellationToken);
            }
开发者ID:noahfalk,项目名称:roslyn,代码行数:42,代码来源:AbstractImplementInterfaceService.CodeAction.cs

示例5: BuildMemberModifiers

        private void BuildMemberModifiers(ISymbol memberSymbol)
        {
            if (memberSymbol.ContainingType != null && memberSymbol.ContainingType.TypeKind == TypeKind.Interface)
            {
                return;
            }

            var methodSymbol = memberSymbol as IMethodSymbol;
            var fieldSymbol = memberSymbol as IFieldSymbol;

            if (methodSymbol != null &&
                methodSymbol.MethodKind == MethodKind.Destructor)
            {
                return;
            }

            if (fieldSymbol != null &&
                fieldSymbol.ContainingType.TypeKind == TypeKind.Enum)
            {
                return;
            }

            // TODO: 'new' modifier isn't exposed on symbols. Do we need it?

            // Note: we don't display the access modifier for static constructors
            if (methodSymbol == null ||
                methodSymbol.MethodKind != MethodKind.StaticConstructor)
            {
                BuildAccessibility(memberSymbol);
            }

            if (memberSymbol.IsUnsafe())
            {
                AddText("unsafe ");
            }

            // Note: we don't display 'static' for constant fields
            if (memberSymbol.IsStatic &&
                (fieldSymbol == null || !fieldSymbol.IsConst))
            {
                AddText("static ");
            }

            if (memberSymbol.IsExtern)
            {
                AddText("extern ");
            }

            if (fieldSymbol != null && fieldSymbol.IsReadOnly)
            {
                AddText("readonly ");
            }

            if (fieldSymbol != null && fieldSymbol.IsConst)
            {
                AddText("const ");
            }

            if (fieldSymbol != null && fieldSymbol.IsVolatile)
            {
                AddText("volatile ");
            }

            if (memberSymbol.IsAbstract)
            {
                AddText("abstract ");
            }
            else if (memberSymbol.IsOverride)
            {
                if (memberSymbol.IsSealed)
                {
                    AddText("sealed ");
                }

                AddText("override ");
            }
            else if (memberSymbol.IsVirtual)
            {
                AddText("virtual ");
            }
        }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:81,代码来源:DescriptionBuilder.cs


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