Skip to content

Latest commit

 

History

History
111 lines (69 loc) · 4.76 KB

CONTRIBUTING.md

File metadata and controls

111 lines (69 loc) · 4.76 KB

Contribution Guidelines

Contributing to Infer#

To contribute, fork InferSharp and file a pull request. When modifying OCaml source code, please follow Infer's contribution guidelines.

Prerequisites

Installation and Build

Both the C# and the OCaml components must be separately built. Each set of build commands is assumed to be executed from the repository root.

OCaml

cd infer
./build-infer.sh java
./autogen.sh
sudo make install 

Note -- you might need to complete these instructions with sudo if there are permission issues.

C#

For the core translation pipeline:

dotnet build Infersharp.sln

For C# library models (optional but highly recommended for reducing false positive warnings):

./build_csharp_models.sh

Debugging Infer#

To obtain an analysis on a directory tree of .NET binaries (comprised of both DLLs and PDBs), execute the following commands from the repository root:

# Extract CFGs from binary files.
dotnet Cilsil/bin/Debug/net6.0/Cilsil.dll translate {directory_to_binary_files} \
                                                --outcfg {output_directory}/cfg.json \
                                                --outtenv {output_directory}/tenv.json \
                                                --cfgtxt {output_directory}/cfg.txt

# Run Infer on extracted CFGs.
infer capture
mkdir infer-out/captured
infer analyzejson --debug \
                  --cfg-json {output_directory}/cfg.json \
                  --tenv-json {output_directory}/tenv.json

For debugging Infer# in your test, please note:

  • The CFG is expressed in a text format in {output_directory}/cfg.txt.
  • Reported bugs are located at {output_directory}/infer-out/bugs.txt.
  • Infer output is located at {output_directory}/infer-out/; detailed analysis information is located at {output_directory}/infer-out/captured/.

Coding Style

All Languages

  • Line width limit is 100 characters.
  • Conform to indentation conventions and other stylistic aspects of the surrounding code.

C#

Please adhere to Microsoft's C# Coding Conventions.

OCaml

Please adhere to Infer's OCaml Style Guide.

Testing Your Changes

The testing framework first programmatically generating pieces of C# code, the underlying bytecode of which isolates the instructions to be validated. It then builds the source code and runs the translation core on the resulting binaries in order to produce the CFG, represented as a JSON file. Finally, Infer analyzes the CFG and produces warnings, which in turn are validated against those which are expected.

Utilities for generating test code are located here. The test execution is orchestrated here. After making a technical contribution to the codebase, please also consider the following:

  • Build the modified codebase.

  • Add test cases to Cilsil.Test/E2E/NPETest.cs.

  • Try to reuse existing test assets, but make modifications as necessary.

  • Run the tests via: dotnet test.

Reporting Issues

If you encounter any issues, please open an issue.

Contributor License Agreement

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.