Giter VIP home page Giter VIP logo

philpuglisi / samples Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dotnet/samples

0.0 2.0 0.0 57.62 MB

Sample code and snippets used in the .NET documentation

License: Creative Commons Attribution 4.0 International

C# 39.88% Visual Basic 34.53% F# 0.35% C++ 12.74% Dockerfile 0.01% PowerShell 0.01% CSS 0.13% ASP 10.93% HTML 0.20% JavaScript 0.42% Batchfile 0.03% XSLT 0.12% Makefile 0.38% C 0.13% 1C Enterprise 0.01% Smalltalk 0.13% Roff 0.01% Ada 0.01% HLSL 0.01% Lex 0.01%

samples's Introduction

.NET Samples

This repo contains all the sample code that is part of any topic under the .NET documentation. There are several different projects that are organized in sub-folders. These sub-folders are organized similar to the organization of the docs for .NET.

Some of the articles will have more than one sample associated with them.

There are two classes of code in this repository:

  • Snippets represent small focused examples that demonstrate one feature or syntax. These should be no more than a single screen of code.
  • Samples represent programs that demonstrate application or library scenarios. These samples are typically larger than snippets, and often use more than one technology, feature, or toolkit. The readme.md file for each sample will refer to the article so that you can read more about the concepts covered in each sample.

Both samples and snippets should be buildable projects. Those projects should build and run on the widest set of platforms possible for the given sample. In practice, that means building .NET Core based console applications where possible. Samples that are specific to the web or a UI framework should add those tools as needed. Examples include web applications, mobile apps, WPF or WinForms apps and so on.

We are working toward having a CI system in place for all code. When you make any updates to samples, make sure each update is part of a buildable project. Ideally, add tests for correctness on samples as well.

Snippets

Snippets are extracted from small programs that include the snippet. Snippets are all located in the top level /snippets folder. While snippets are small blocks of code, we want to move toward snippets that are part of buildable sample projects.

Building a sample

You build any .NET Core sample using the .NET Core CLI, which can be installed with the .NET Core SDK. Then, execute these commands from the CLI in the directory of any sample:

dotnet build
dotnet run

These will install any needed dependencies, build the project, and run the project respectively.

Multi-project samples have instructions in their root directory in a README.md file.

Except where noted, all samples build from the command line on any platform supported by .NET Core. There are a few samples that are specific to Visual Studio and require Visual Studio 2017 or later. In addition, some samples show platform specific features and will require a specific platform. Other samples and snippets require the .NET Framework and will run on Windows platforms, and will need the Developer Pack for the target Framework version.

Creating new samples

If you wish to add a code sample:

  1. Your sample must be part of a buildable project. Where possible, the projects should build on all platforms suppported by .NET Core. Exceptions to this are samples that demonstrate a platform specific feature or platform specific tool.
  2. Your sample should conform to the corefx coding style to maintain consistency.
    • Additionally, we prefer the use of static methods rather than instance methods when demonstrating something that doesn't require instantiating a new object.
  3. If your sample builds a standalone package, you must include the runtimes used by our CI build system, in addition to any runtimes used by your sample:
    • win7-x64
    • win8-x64
    • win81-x64
    • ubuntu.16.04-x64

We will have a CI system in place to build these projects shortly.

To create a sample:

  1. File an issue or add a comment to an existing one that you are working on it.
  2. Write the topic that explains the concepts demonstrated in your sample (example: docs/standard/linq/where-clause.md)
  3. Write your sample (example: WhereClause-Sample1.cs)
  4. Create a Program.cs with a Main entry point that calls your samples. If there is already one there, add the call to your sample:
    public class Program
    {
        public void Main(string[] args)
        {
            WhereClause1.QuerySyntaxExample();
    
            // Add the method syntax as an example.
            WhereClause1.MethodSyntaxExample();
        }
    }

To build and run your sample:

  1. Go to the sample folder and Build to check for errors.

    dotnet build
    
  2. Run!

    dotnet run
    
  3. Add a readme.md to the root directory of your sample.

    • This should include a brief description of the code, and refer people to the article that references the sample.

samples's People

Contributors

bethmassi avatar billwagner avatar bleroy avatar cartermp avatar chenkennt avatar chrismaddock avatar conniey avatar doctordns avatar douglaslms avatar guardrex avatar jralexander avatar mairaw avatar mikkelbu avatar paulroho avatar pkulikov avatar qinezh avatar richlander avatar rick-anderson avatar rprouse avatar sboptimal avatar sputier avatar styxxy avatar svick avatar the-wazz avatar tianqizhang avatar tompratt-aq avatar user135711 avatar vbjay avatar vicancy avatar yishengjin1413 avatar

Watchers

 avatar  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.