GithubHelp home page GithubHelp logo

test-mass-forker-org-1 / codelyzer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aws/codelyzer

0.0 0.0 0.0 31.46 MB

Codelyzer is a framework that provides interfaces to build and analyze source code in various languages and generates a platform-independent representation as a universal abstract syntax tree (UAST) model or a JSON file.

License: Apache License 2.0

Shell 0.03% C# 99.94% F# 0.03%

codelyzer's Introduction

Codelyzer

Build Test

Codelyzer is a framework that provides interfaces to build and analyze source code in various languages and generates a platform-independent representation as a universal abstract syntax tree (UAST) model or a JSON file. It offers fine-grained controls to specify the kind of metadata (properties of classes, methods, etc.) to gather and how deep in the hierarchy of the code to search while generating these artifacts. Currently, the framework only supports the C# language.

By generating the output as a JSON file, this framework allows you to develop analysis tools in any language.

Codelyzer - Net

Codelyzer-Net is an analyzer engine for languages based on the Roslyn compiler platform, like C# and VB. The CSharpRoslynProcessor walks an AST to collect metadata of source file components (e.g. solution, projects, namespaces, classes, methods, method invocations, literal expressions, etc). It uses semantic information from a design-time build to collect properties with fully qualified names.

  1. Add the Codelyzer NuGet package source into your Nuget configuration.
  2. Add Codelyzer.Analysis to your project as a Nuget Package.

Getting Started

Follow the example below to see how the library can be integrated into your application for analyzing .NET application.

/* 1. Create logger object */
var loggerFactory = LoggerFactory.Create(builder => 
        builder.SetMinimumLevel(LogLevel.Debug).AddConsole());
var logger = loggerFactory.CreateLogger("Analyzer");
var outputPath = @"/home/users/steve/porting-analysis";

/* 2. Create Configuration settings */
var configuration = new AnalyzerConfiguration(LanguageOptions.CSharp);
configuration.ExportSettings.OutputPath = outputPath;

/* 3. Get Analyzer instance based on language */
var analyzer = CodeAnalyzerFactory.GetAnalyzer(configuration, logger);

/* 4. Analyze the project or solution */
var projectFilePath = @"/home/users/steve/projects/TestProject.csproj";
var analyzerResult = await analyzer.AnalyzeProject(projectFilePath);

Console.WriteLine("The results are exported to file : " + analyzerResult.OutputJsonFilePath);

/* 5. Consume the results as model objects */
var sourcefile = analyzerResult.ProjectResult.SourceFileResults.First();
foreach (var invocation in sourcefile.AllInvocationExpressions())
{
    Console.WriteLine(invocation.MethodName + ":" + invocation.SemanticMethodSignature);
}

var objectCreations = sourcefile.AllObjectCreationExpressions();
var allClasses = sourcefile.AllClasses();
var allMethods = sourcefile.AllMethods();
var allLiterals = sourcefile.AllLiterals();

How to use this code?

  • Clone the Git repository.
  • Load the solution Codelyzer.sln using Visual Studio or Rider.
  • Create a "Run/Debug" Configuration for the "Codelyzer.Analysis" project.
  • Provide command line arguments for a solution and output path, then run the application.

Getting Help

Please use these community resources for getting help. We use the GitHub issues for tracking bugs and feature requests.

Contributing

We welcome community contributions and pull requests. See CONTRIBUTING for information on how to set up a development environment and submit code.

Thank you

License

Libraries in this repository are licensed under the Apache 2.0 License.

See LICENSE and NOTICE for more information.

codelyzer's People

Contributors

marknfawaz avatar jonlouie avatar xueningl-az avatar beau-gosse-dev avatar saikiranakula-amzn avatar eruanion avatar shanshanhe avatar aniruddhadave avatar nshiramshetti avatar cslong avatar mrlloyd-amzn avatar dependabot[bot] avatar dongzw-amz avatar kanikaul-amazon avatar mingxue008 avatar birojnayak avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.