Click here to Skip to main content
Click here to Skip to main content
Articles » Languages » C# » General » Downloads
 

Roslyn CTP: Three Introductory Projects

By , 8 May 2012
 
RoslynCTPSamples.zip
CodeGenerator
bin
Debug
CodeGenerator.vshost.exe
CodeGenerator.vshost.exe.manifest
Release
CodeGenerator.csproj.user
obj
x86
Debug
DesignTimeResolveAssemblyReferences.cache
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
Properties
CodeGeneratorTest
bin
Debug
obj
Debug
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
Properties
EventImplementer
bin
Debug
Release
EventImplementer.csproj.user
obj
Debug
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
Properties
source.extension.vsixmanifest
RefactoringConsole
bin
Debug
RefactoringConsole.vshost.exe
RefactoringConsole.vshost.exe.manifest
obj
x86
Debug
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
Properties
RefactoringExtension
bin
Debug
Release
obj
Debug
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
Properties
RefactoringExtension.csproj.user
source.extension.vsixmanifest
RoslynCTPLibrary
bin
Debug
RoslynCTPSamples.dll
RoslynCTPSamples.pdb
Release
obj
Debug
DesignTimeResolveAssemblyReferencesInput.cache
RoslynCTPSamples.dll
RoslynCTPSamples.pdb
TempPE
Properties
RoslynCTPSamples.suo
RoslynCTPSamples.vsmdi
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Roslyn.Compilers.CSharp;

namespace RoslynCTPLibrary.Extensions {
    public static class Extensions {
        public static IEnumerable<TFiltered> DescendentNodes<TFiltered>(this SyntaxNode node, Func<TFiltered, bool> predicate) where TFiltered : SyntaxNode { return node.DescendentNodes(root => !(root is TFiltered)).OfType<TFiltered>().Where(predicate); }

        public static TRoot ReplaceNodes<TRoot, TNode>(this TRoot root, IEnumerable<TNode> oldNodes, Func<TNode, SyntaxNode> computeReplacementNode)
            where TRoot : SyntaxNode
            where TNode : SyntaxNode { return root.ReplaceNodes(oldNodes, (oldNode, wth) => computeReplacementNode(oldNode)); }

        public static TypeDeclarationSyntax GetOwnerType<TMember>(this TMember member) where TMember : MemberDeclarationSyntax { return member.FirstAncestorOrSelf<TypeDeclarationSyntax>(); }


        public static bool IsAutoImplemented(this PropertyDeclarationSyntax property) { return property.DescendentNodes().OfType<AccessorDeclarationSyntax>().All(ac => ac.BodyOpt == null); }

        public static AccessorDeclarationSyntax GetGetAccessor(this PropertyDeclarationSyntax property) { return property.DescendentNodes().OfType<AccessorDeclarationSyntax>().SingleOrDefault(ac => ac.Kind == SyntaxKind.GetAccessorDeclaration); }
        public static AccessorDeclarationSyntax GetSetAccessor(this PropertyDeclarationSyntax property) { return property.DescendentNodes().OfType<AccessorDeclarationSyntax>().SingleOrDefault(ac => ac.Kind == SyntaxKind.SetAccessorDeclaration); }

    }
}

By viewing downloads associated with this article you agree to the Terms of use and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Whaeth
Hungary Hungary
Member
No Biography provided

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 8 May 2012
Article Copyright 2011 by Whaeth
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid