├── TOC.md ├── images ├── async │ ├── ui.jpg │ ├── io-1.jpg │ ├── io-2.jpg │ ├── webserver-1.jpg │ └── webserver-2.jpg ├── Logo_DotNet.png └── core │ └── list-bullet.png ├── docs ├── images │ ├── IC393001.png │ ├── IC393002.png │ ├── IC393003.png │ ├── IC658909.png │ ├── IC658910.png │ ├── PLINQ-diagram.png │ ├── alex-api-layers.png │ ├── vscodedebugger.png │ ├── assembly-headers.png │ ├── compiler-pipeline.png │ ├── package-framework.png │ ├── portability_report.png │ ├── corefx-platforms-loc.png │ ├── compiler-pipeline-api.png │ ├── portability_screenshot.png │ ├── workspace-obj-relations.png │ ├── dotnet-test-execute-tests.png │ ├── compiler-pipeline-lang-svc.png │ ├── dotnet-test-discover-tests.png │ ├── portability_solution_explorer.png │ ├── pcl-targets-dialog-net46-aspnetcore10.png │ └── new-project-dialog-class-library-portable.png ├── csharp │ ├── csharp-6.md │ ├── syntax.md │ ├── generics.md │ ├── concepts.md │ ├── type-system.md │ ├── features.md │ ├── parallel.md │ ├── codedoc.md │ ├── lambda-expressions.md │ ├── interop.md │ ├── reflection.md │ ├── linq.md │ └── tutorials │ │ └── index.md ├── core │ ├── tutorials │ │ ├── aspnet-core.md │ │ ├── libraries-with-vs.md │ │ ├── index.md │ │ └── cli-console-app-tutorial-advanced.md │ ├── deploying │ │ └── applications.md │ ├── porting │ │ └── nuget-packages.md │ ├── tools │ │ └── global-json.md │ └── versions │ │ └── servicing.md └── fsharp │ └── index.md ├── samples ├── core-projects │ ├── console-apps │ │ ├── NewTypes │ │ │ ├── global.json │ │ │ ├── src │ │ │ │ └── NewTypes │ │ │ │ │ ├── Pets │ │ │ │ │ ├── IPet.cs │ │ │ │ │ ├── Cat.cs │ │ │ │ │ └── Dog.cs │ │ │ │ │ ├── project.json │ │ │ │ │ └── Program.cs │ │ │ ├── test │ │ │ │ └── NewTypesTests │ │ │ │ │ ├── PetTests.cs │ │ │ │ │ └── project.json │ │ │ └── README.md │ │ ├── Hello │ │ │ ├── Program.cs │ │ │ ├── project.json │ │ │ └── README.md │ │ ├── HelloNative │ │ │ ├── Program.cs │ │ │ ├── project.json │ │ │ └── README.md │ │ ├── Fibonacci │ │ │ ├── project.json │ │ │ ├── Program.cs │ │ │ └── README.md │ │ └── FibonacciBetter │ │ │ ├── project.json │ │ │ ├── Program.cs │ │ │ ├── FibonacciGenerator.cs │ │ │ └── README.md │ └── libraries │ │ ├── new-library │ │ ├── global.json │ │ ├── src │ │ │ ├── DependencyLibrary │ │ │ │ ├── project.json │ │ │ │ └── DependencyLibrary.cs │ │ │ └── Library │ │ │ │ ├── project.json │ │ │ │ └── Library.cs │ │ └── test │ │ │ └── LibraryTests │ │ │ ├── project.json │ │ │ └── LibraryTest.cs │ │ ├── frameworks-library │ │ └── src │ │ │ └── Library │ │ │ ├── project.json │ │ │ └── Library.cs │ │ ├── net45-compat-library │ │ └── src │ │ │ └── Library │ │ │ ├── project.json │ │ │ └── Library.cs │ │ ├── net40-library │ │ └── src │ │ │ └── Library │ │ │ ├── project.json │ │ │ └── Library.cs │ │ └── pcl-library │ │ └── src │ │ └── Library │ │ ├── Library.cs │ │ └── project.json ├── getting-started │ └── golden │ │ ├── global.json │ │ ├── src │ │ ├── library │ │ │ ├── thing.cs │ │ │ └── project.json │ │ └── app │ │ │ ├── Program.cs │ │ │ └── project.json │ │ ├── test │ │ └── test-library │ │ │ ├── Tests.cs │ │ │ └── project.json │ │ └── .vscode │ │ └── tasks.json ├── unit-testing │ └── using-dotnet-test │ │ ├── global.json │ │ ├── src │ │ └── PrimeService │ │ │ ├── project.json │ │ │ └── PrimeService.cs │ │ ├── test │ │ └── PrimeService.Tests │ │ │ ├── project.json │ │ │ └── PrimeServie_IsPrimeShould.cs │ │ └── README.md ├── csharp-language │ ├── expression-trees │ │ ├── Sample.cs │ │ ├── project.json │ │ ├── NuGet.Config │ │ ├── ExpressionTreeExecutionSampleOne.cs │ │ ├── ParameterVisitor.cs │ │ ├── UnaryVisitor.cs │ │ ├── ExpressionTreeClassesSampleTwo.cs │ │ ├── ConstantVisitor.cs │ │ ├── ExpressionTreeInterpretingSampleOne.cs │ │ ├── ExpressionTreeInterpretingSampleFour.cs │ │ ├── ExpressionTreeClassesSample.cs │ │ ├── GotoVisitor.cs │ │ ├── BinaryVisitor.cs │ │ ├── README.md │ │ ├── LoopVisitor.cs │ │ ├── ExpressionTreeInterpretingSampleThree.cs │ │ ├── ConditionalVisitor.cs │ │ ├── expression-trees.xproj │ │ ├── LambdaVisitor.cs │ │ ├── BlockVisitor.cs │ │ ├── Program.cs │ │ ├── ExpressionTreeTranslationSampleOne.cs │ │ ├── MethodCallVisitor.cs │ │ ├── ExpressionTreeTranslationSampleTwo.cs │ │ └── ExpressionTreeBuildingSampleOne.cs │ ├── indexers │ │ ├── Common │ │ │ └── Measurements.cs │ │ ├── project.json │ │ ├── NuGet.Config │ │ ├── README.md │ │ ├── SampleThree │ │ │ └── Mandelbrot.cs │ │ ├── SampleTwo │ │ │ └── ArgsProcessor.cs │ │ └── indexers.xproj │ ├── events │ │ ├── project.json │ │ ├── NuGet.Config │ │ ├── README.md │ │ └── events.xproj │ ├── iterators │ │ ├── project.json │ │ ├── program.cs │ │ ├── ForeachExamples.cs │ │ └── README.md │ ├── delegates-and-events │ │ ├── project.json │ │ ├── NuGet.Config │ │ ├── Program.cs │ │ ├── README.md │ │ ├── Logger.cs │ │ └── FileLogger.cs │ ├── WeatherMicroservice │ │ ├── Dockerfile │ │ ├── wwwroot │ │ │ └── web.config │ │ ├── Extensions.cs │ │ ├── Properties │ │ │ └── launchSettings.json │ │ ├── project.json │ │ ├── README.md │ │ ├── WeatherMicroservice.xproj │ │ └── WeatherReport.cs │ ├── console-linq │ │ ├── project.json │ │ ├── playiingcard.cs │ │ ├── README.md │ │ ├── console-linq.xproj │ │ └── extensions.cs │ ├── console-teleprompter │ │ ├── project.json │ │ ├── config.cs │ │ ├── README.md │ │ └── console-teleprompter.xproj │ └── console-webapiclient │ │ ├── project.json │ │ ├── README.md │ │ └── repo.cs └── linq │ └── csharp │ ├── projection │ ├── Order.cs │ ├── project.json │ ├── Product.cs │ ├── Customer.cs │ ├── Select-Sample-7.cs │ ├── SelectMany-Sample-1.cs │ └── Program.cs │ ├── join │ ├── project.json │ ├── Product.cs │ └── Program.cs │ ├── restriction │ ├── project.json │ ├── Product.cs │ ├── Program.cs │ └── Where-Sample-4.cs │ ├── grouping │ ├── project.json │ ├── Order.cs │ ├── Product.cs │ ├── Customer.cs │ ├── Program.cs │ ├── AnagramEqualityComparer.cs │ ├── GroupBy-Comparer-Sample-1.cs │ └── GroupBy-Comparer-Sample-2.cs │ ├── partitioning │ ├── project.json │ ├── Program.cs │ ├── Take-Sample-1.cs │ ├── Skip-Sample-1.cs │ ├── TakeWhile-Sample-1.cs │ ├── TakeWhile-Sample-2.cs │ ├── SkipWhile-Sample-2.cs │ └── SkipWhile-Sample-1.cs │ ├── aggregate │ ├── Order.cs │ ├── project.json │ ├── Product.cs │ ├── Customer.cs │ ├── Min-Sample-1.cs │ ├── Sum-Sample-1.cs │ ├── Average-Sample-1.cs │ ├── Max-Sample-1.cs │ ├── Count-Sample-2.cs │ ├── Max-Sample-2.cs │ ├── Min-Sample-2.cs │ ├── Sum-Sample-2.cs │ ├── Aggregate-Sample-1.cs │ ├── Aggregate-Sample-2.cs │ ├── Count-Sample-3.cs │ ├── Count-Sample-1.cs │ └── program.cs │ ├── element │ ├── project.json │ ├── Product.cs │ ├── Program.cs │ ├── FirstSample-2.cs │ ├── FirstOrDefault-Sample-1.cs │ ├── FirstOrDefault-Sample-2.cs │ └── ElementAt-Sample1-.cs │ ├── equality │ ├── project.json │ ├── program.cs │ ├── SequenceEqual-Sample-1.cs │ ├── SequenceEqual-Sample-2.cs │ ├── CaseInsensitiveComparer.cs │ └── SequenceEqual-Comparer-Sample-3.cs │ ├── ordering │ ├── project.json │ ├── Product.cs │ ├── CaseInsensitiveComparer.cs │ ├── OrderBy-Comparer-Sample-1.cs │ ├── OrderByDescending-Comparer-Sample-1.cs │ ├── ThenBy-Comparer-Sample-1.cs │ ├── ThenByDescending-Comparer-Sample-2.cs │ ├── program.cs │ ├── OrderBy-Sample-1.cs │ └── OrderBy-Sample-2.cs │ ├── conversion │ ├── project.json │ ├── Program.cs │ ├── OfType-Sample-1.cs │ ├── ToDictionary-Sample-1.cs │ └── ToList-Sample-1.cs │ ├── generation │ ├── project.json │ ├── Program.cs │ └── Repeat-Example-1.cs │ ├── quantifier │ ├── project.json │ ├── Product.cs │ ├── Program.cs │ ├── All-Sample-1.cs │ └── Any-Sample-1.cs │ ├── concatenation │ ├── project.json │ ├── program.cs │ ├── Product.cs │ ├── Customer.cs │ └── Concat-Sample-1.cs │ ├── setoperators │ ├── Order.cs │ ├── project.json │ ├── Product.cs │ ├── Customer.cs │ ├── Set-Distinct-Sample-1.cs │ ├── Program.cs │ ├── Set-Intersect-Sample-1.cs │ ├── Set-Union-Sample-1.cs │ ├── Set-Except-Sample-1.cs │ ├── Set-Intersect-Sample-2.cs │ ├── Set-Except-Sample-2.cs │ └── Set-Union-Sample-2.cs │ ├── customsequence │ ├── project.json │ ├── Program.cs │ └── CustomSequence-Sample-1.cs │ └── queryexecution │ ├── project.json │ └── Program.cs ├── toc.yml ├── license.txt ├── .openpublishing.build.ps1 ├── README.md ├── .openpublishing.publish.config.json └── appveyor.yml /TOC.md: -------------------------------------------------------------------------------- 1 | # [Index](index.md) -------------------------------------------------------------------------------- /images/async/ui.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/options/core-docs/master/images/async/ui.jpg -------------------------------------------------------------------------------- /images/async/io-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/options/core-docs/master/images/async/io-1.jpg -------------------------------------------------------------------------------- /images/async/io-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/options/core-docs/master/images/async/io-2.jpg -------------------------------------------------------------------------------- /docs/images/IC393001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/options/core-docs/master/docs/images/IC393001.png -------------------------------------------------------------------------------- /docs/images/IC393002.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/options/core-docs/master/docs/images/IC393002.png -------------------------------------------------------------------------------- /docs/images/IC393003.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/options/core-docs/master/docs/images/IC393003.png -------------------------------------------------------------------------------- /docs/images/IC658909.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/options/core-docs/master/docs/images/IC658909.png -------------------------------------------------------------------------------- /docs/images/IC658910.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/options/core-docs/master/docs/images/IC658910.png -------------------------------------------------------------------------------- /images/Logo_DotNet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/options/core-docs/master/images/Logo_DotNet.png -------------------------------------------------------------------------------- /samples/core-projects/console-apps/NewTypes/global.json: -------------------------------------------------------------------------------- 1 | { 2 | "projects": [ 3 | "src", "test" 4 | ] 5 | } -------------------------------------------------------------------------------- /samples/core-projects/libraries/new-library/global.json: -------------------------------------------------------------------------------- 1 | { 2 | "projects": [ 3 | "src", "test" 4 | ] 5 | } -------------------------------------------------------------------------------- /docs/images/PLINQ-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/options/core-docs/master/docs/images/PLINQ-diagram.png -------------------------------------------------------------------------------- /images/async/webserver-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/options/core-docs/master/images/async/webserver-1.jpg -------------------------------------------------------------------------------- /images/async/webserver-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/options/core-docs/master/images/async/webserver-2.jpg -------------------------------------------------------------------------------- /images/core/list-bullet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/options/core-docs/master/images/core/list-bullet.png -------------------------------------------------------------------------------- /docs/images/alex-api-layers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/options/core-docs/master/docs/images/alex-api-layers.png -------------------------------------------------------------------------------- /docs/images/vscodedebugger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/options/core-docs/master/docs/images/vscodedebugger.png -------------------------------------------------------------------------------- /docs/images/assembly-headers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/options/core-docs/master/docs/images/assembly-headers.png -------------------------------------------------------------------------------- /docs/images/compiler-pipeline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/options/core-docs/master/docs/images/compiler-pipeline.png -------------------------------------------------------------------------------- /docs/images/package-framework.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/options/core-docs/master/docs/images/package-framework.png -------------------------------------------------------------------------------- /docs/images/portability_report.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/options/core-docs/master/docs/images/portability_report.png -------------------------------------------------------------------------------- /samples/getting-started/golden/global.json: -------------------------------------------------------------------------------- 1 | { 2 | "projects": [ 3 | "src", 4 | "test" 5 | ] 6 | } -------------------------------------------------------------------------------- /docs/images/corefx-platforms-loc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/options/core-docs/master/docs/images/corefx-platforms-loc.png -------------------------------------------------------------------------------- /samples/core-projects/libraries/frameworks-library/src/Library/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "frameworks": { 3 | "net40":{} 4 | } 5 | } -------------------------------------------------------------------------------- /samples/unit-testing/using-dotnet-test/global.json: -------------------------------------------------------------------------------- 1 | { 2 | "projects": [ 3 | "src", 4 | "test" 5 | ] 6 | } -------------------------------------------------------------------------------- /docs/images/compiler-pipeline-api.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/options/core-docs/master/docs/images/compiler-pipeline-api.png -------------------------------------------------------------------------------- /docs/images/portability_screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/options/core-docs/master/docs/images/portability_screenshot.png -------------------------------------------------------------------------------- /docs/images/workspace-obj-relations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/options/core-docs/master/docs/images/workspace-obj-relations.png -------------------------------------------------------------------------------- /docs/images/dotnet-test-execute-tests.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/options/core-docs/master/docs/images/dotnet-test-execute-tests.png -------------------------------------------------------------------------------- /docs/images/compiler-pipeline-lang-svc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/options/core-docs/master/docs/images/compiler-pipeline-lang-svc.png -------------------------------------------------------------------------------- /docs/images/dotnet-test-discover-tests.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/options/core-docs/master/docs/images/dotnet-test-discover-tests.png -------------------------------------------------------------------------------- /docs/images/portability_solution_explorer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/options/core-docs/master/docs/images/portability_solution_explorer.png -------------------------------------------------------------------------------- /docs/images/pcl-targets-dialog-net46-aspnetcore10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/options/core-docs/master/docs/images/pcl-targets-dialog-net46-aspnetcore10.png -------------------------------------------------------------------------------- /docs/images/new-project-dialog-class-library-portable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/options/core-docs/master/docs/images/new-project-dialog-class-library-portable.png -------------------------------------------------------------------------------- /samples/core-projects/console-apps/NewTypes/src/NewTypes/Pets/IPet.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Pets 4 | { 5 | public interface IPet 6 | { 7 | string TalkToOwner(); 8 | } 9 | } -------------------------------------------------------------------------------- /samples/core-projects/console-apps/NewTypes/src/NewTypes/Pets/Cat.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Pets 4 | { 5 | public class Cat : IPet 6 | { 7 | public string TalkToOwner() => "Meow!"; 8 | } 9 | } -------------------------------------------------------------------------------- /samples/core-projects/console-apps/NewTypes/src/NewTypes/Pets/Dog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Pets 4 | { 5 | public class Dog : IPet 6 | { 7 | public string TalkToOwner() => "Woof!"; 8 | } 9 | } -------------------------------------------------------------------------------- /samples/core-projects/libraries/net45-compat-library/src/Library/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "frameworks": { 3 | "dotnet51":{ 4 | "dependencies": { 5 | "System.Runtime":"4.0.0-rc1-*" 6 | } 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /samples/core-projects/libraries/new-library/src/DependencyLibrary/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "frameworks": { 3 | "dotnet55":{ 4 | "dependencies": { 5 | "System.Runtime":"4.0.0-rc1-*" 6 | } 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /samples/core-projects/libraries/frameworks-library/src/Library/Library.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FrameworkLibraries 4 | { 5 | public static class Library 6 | { 7 | public static string Foo => "Hello, World!"; 8 | } 9 | } -------------------------------------------------------------------------------- /samples/core-projects/libraries/net45-compat-library/src/Library/Library.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Library 4 | { 5 | public static class Net45CompatLibrary 6 | { 7 | public static string Hello => "Hello .NET Core and .NET Framework 4.5!"; 8 | } 9 | } -------------------------------------------------------------------------------- /samples/core-projects/libraries/new-library/src/Library/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "DependencyLibrary":"" 4 | }, 5 | "frameworks": { 6 | "dotnet55":{ 7 | "dependencies": { 8 | "System.Runtime":"4.0.0-rc1-*" 9 | } 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /samples/csharp-language/expression-trees/Sample.cs: -------------------------------------------------------------------------------- 1 | namespace ExpressionTreeSamples 2 | { 3 | // Base class for all samples. 4 | public abstract class Sample 5 | { 6 | public abstract string Name { get; } 7 | public abstract void Run(); 8 | } 9 | } -------------------------------------------------------------------------------- /samples/core-projects/libraries/new-library/src/DependencyLibrary/DependencyLibrary.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DependencyLibrary 4 | { 5 | public static class NewDependencyLibrary 6 | { 7 | public static string ImportantMessage => "Live long and prosper"; 8 | } 9 | } -------------------------------------------------------------------------------- /samples/linq/csharp/projection/Order.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Projection 4 | { 5 | public class Order 6 | { 7 | public int OrderId { get; set; } 8 | public DateTime OrderDate { get; set; } 9 | public decimal Total { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /samples/getting-started/golden/src/library/thing.cs: -------------------------------------------------------------------------------- 1 | using static Newtonsoft.Json.JsonConvert; 2 | 3 | namespace Library 4 | { 5 | public class Thing 6 | { 7 | public int Get(int left, int right) => 8 | DeserializeObject($"{left + right}"); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /samples/core-projects/console-apps/Hello/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ConsoleApplication 4 | { 5 | public class Program 6 | { 7 | public static void Main(string[] args) 8 | { 9 | Console.WriteLine("Hello World!"); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /samples/core-projects/console-apps/HelloNative/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ConsoleApplication 4 | { 5 | public class Program 6 | { 7 | public static void Main(string[] args) 8 | { 9 | Console.WriteLine("Hello World!"); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /samples/csharp-language/indexers/Common/Measurements.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace IndexersSamples.Common 3 | { 4 | public class Measurements 5 | { 6 | public int HiTemp { get; set; } 7 | public int LoTemp { get; set; } 8 | 9 | public double AirPressure { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /samples/linq/csharp/join/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "System.Runtime": "4.0.0-*", 4 | "System.Linq": "4.0.0-*", 5 | "System.Console": "4.0.0-*" 6 | }, 7 | "commands": { 8 | "run": "join" 9 | }, 10 | "frameworks": { 11 | "dnxcore50":{} 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /samples/linq/csharp/restriction/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "System.Runtime": "4.0.0-*", 4 | "System.Linq": "4.0.0-*", 5 | "System.Console": "4.0.0-*" 6 | }, 7 | "commands": { 8 | "run": "restriction" 9 | }, 10 | "frameworks": { 11 | "dnxcore50": { } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /samples/linq/csharp/grouping/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "System.Runtime": "4.0.0-*", 4 | "System.Linq": "4.0.0-*", 5 | "System.Console": "4.0.0-*" 6 | }, 7 | "commands": { 8 | "run": "grouping" 9 | }, 10 | "frameworks" : { 11 | "dnxcore50" : { } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /samples/linq/csharp/partitioning/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "System.Runtime": "4.0.0-*", 4 | "System.Linq": "4.0.0-*", 5 | "System.Console": "4.0.0-*" 6 | }, 7 | "commands": { 8 | "run": "partitioning" 9 | }, 10 | "frameworks" : { 11 | "dnxcore50" : { } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /samples/csharp-language/events/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0-*", 3 | "compilationOptions": { 4 | "emitEntryPoint": true 5 | }, 6 | 7 | "dependencies": { 8 | "NETStandard.Library": "1.0.0-rc2-23704" 9 | }, 10 | 11 | "frameworks": { 12 | "dnxcore50": { } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /samples/csharp-language/indexers/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0-*", 3 | "compilationOptions": { 4 | "emitEntryPoint": true 5 | }, 6 | 7 | "dependencies": { 8 | "NETStandard.Library": "1.0.0-rc2-23704" 9 | }, 10 | 11 | "frameworks": { 12 | "dnxcore50": { } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /samples/getting-started/golden/test/test-library/Tests.cs: -------------------------------------------------------------------------------- 1 | using Library; 2 | using Xunit; 3 | 4 | namespace TestApp 5 | { 6 | public class LibraryTests 7 | { 8 | [Fact] 9 | public void TestThing() 10 | { 11 | Assert.Equal(42, new Thing().Get(19, 23)); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /samples/linq/csharp/aggregate/Order.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Aggregate 4 | { 5 | public class Order 6 | { 7 | public int OrderId { get; set; } 8 | public int CustomerId { get; set; } 9 | public DateTime OrderDate { get; set; } 10 | public decimal Total { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /samples/linq/csharp/element/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "System.Runtime":"4.0.0-*", 4 | "System.Linq":"4.0.0-*", 5 | "System.Console": "4.0.0-*" 6 | }, 7 | "commands": { 8 | "run": "element" 9 | }, 10 | "frameworks": { 11 | "dnxcore50":{} 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /samples/linq/csharp/equality/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "System.Runtime":"4.0.0-*", 4 | "System.Linq":"4.0.0-*", 5 | "System.Console": "4.0.0-*" 6 | }, 7 | "commands": { 8 | "run": "equality" 9 | }, 10 | "frameworks": { 11 | "dnxcore50":{} 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /samples/linq/csharp/grouping/Order.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Grouping 4 | { 5 | public class Order 6 | { 7 | public int OrderId { get; set; } 8 | public int CustomerId { get; set; } 9 | public DateTime OrderDate { get; set; } 10 | public decimal Total { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /samples/linq/csharp/ordering/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "System.Runtime":"4.0.0-*", 4 | "System.Linq":"4.0.0-*", 5 | "System.Console": "4.0.0-*" 6 | }, 7 | "commands": { 8 | "run": "ordering" 9 | }, 10 | "frameworks": { 11 | "dnxcore50":{} 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /samples/csharp-language/iterators/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "System.Runtime":"4.0.0-*", 4 | "System.Linq":"4.0.0-*", 5 | "System.Console": "4.0.0-*" 6 | }, 7 | "commands": { 8 | "run": "iterators" 9 | }, 10 | "frameworks": { 11 | "dnxcore50":{} 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /samples/linq/csharp/aggregate/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "System.Runtime":"4.0.0-*", 4 | "System.Linq":"4.0.0-*", 5 | "System.Console": "4.0.0-*" 6 | }, 7 | "commands": { 8 | "run": "aggregate" 9 | }, 10 | "frameworks": { 11 | "dnxcore50":{} 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /samples/linq/csharp/conversion/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "System.Runtime":"4.0.0-*", 4 | "System.Linq":"4.0.0-*", 5 | "System.Console": "4.0.0-*" 6 | }, 7 | "commands": { 8 | "run": "conversion" 9 | }, 10 | "frameworks": { 11 | "dnxcore50":{} 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /samples/linq/csharp/generation/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "System.Runtime":"4.0.0-*", 4 | "System.Linq":"4.0.0-*", 5 | "System.Console": "4.0.0-*" 6 | }, 7 | "commands": { 8 | "run": "generation" 9 | }, 10 | "frameworks": { 11 | "dnxcore50":{} 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /samples/linq/csharp/quantifier/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "System.Runtime":"4.0.0-*", 4 | "System.Linq":"4.0.0-*", 5 | "System.Console": "4.0.0-*" 6 | }, 7 | "commands": { 8 | "run": "quantifier" 9 | }, 10 | "frameworks": { 11 | "dnxcore50":{} 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /samples/csharp-language/delegates-and-events/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0-*", 3 | "compilationOptions": { 4 | "emitEntryPoint": true 5 | }, 6 | 7 | "dependencies": { 8 | "NETStandard.Library": "1.0.0-rc2-23704" 9 | }, 10 | 11 | "frameworks": { 12 | "dnxcore50": { } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /samples/linq/csharp/concatenation/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "System.Runtime":"4.0.0-*", 4 | "System.Linq":"4.0.0-*", 5 | "System.Console": "4.0.0-*" 6 | }, 7 | "commands": { 8 | "run": "concatenation" 9 | }, 10 | "frameworks": { 11 | "dnxcore50":{} 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /samples/linq/csharp/setoperators/Order.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SetOperators 4 | { 5 | public class Order 6 | { 7 | public int OrderId { get; set; } 8 | public int CustomerId { get; set; } 9 | public DateTime OrderDate { get; set; } 10 | public decimal Total { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /samples/linq/csharp/setoperators/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "System.Runtime": "4.0.0-*", 4 | "System.Linq": "4.0.0-*", 5 | "System.Console": "4.0.0-*" 6 | }, 7 | "commands": { 8 | "run": "setoperators" 9 | }, 10 | "frameworks": { 11 | "dnxcore50": {} 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /samples/getting-started/golden/src/app/Program.cs: -------------------------------------------------------------------------------- 1 | using static System.Console; 2 | using Library; 3 | 4 | namespace ConsoleApplication 5 | { 6 | public class Program 7 | { 8 | public static void Main(string[] args) 9 | { 10 | WriteLine($"The answer is {new Thing().Get(19, 23)}"); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /samples/linq/csharp/generation/Program.cs: -------------------------------------------------------------------------------- 1 | namespace Generation 2 | { 3 | public class Program 4 | { 5 | public void Main(string[] args) 6 | { 7 | RangeExample1.MethodSyntaxExample(); 8 | 9 | RangeExample1.QuerySyntaxExample(); 10 | 11 | RepeatExample1.Example(); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /samples/linq/csharp/projection/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "System.Runtime": "4.0.0-*", 4 | "System.Linq": "4.0.0-*", 5 | "System.Console": "4.0.0-*", 6 | "System.Xml.XDocument": "4.0.0-*" 7 | }, 8 | "commands": { 9 | "run": "projection" 10 | }, 11 | "frameworks": { 12 | "dnxcore50": { } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /samples/linq/csharp/customsequence/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "System.Runtime": "4.0.0-*", 4 | "System.Linq": "4.0.0-*", 5 | "System.Console": "4.0.0-*", 6 | "System.Xml.XDocument": "4.0.0-*" 7 | }, 8 | "commands": { 9 | "run": "customsequence" 10 | }, 11 | "frameworks": { 12 | "dnxcore50": { } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /samples/linq/csharp/join/Product.cs: -------------------------------------------------------------------------------- 1 | namespace Join 2 | { 3 | public class Product 4 | { 5 | public int ProductId { get; set; } 6 | public string ProductName { get; set; } 7 | public string Category { get; set; } 8 | public decimal UnitPrice { get; set; } 9 | public int UnitsInStock { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /samples/linq/csharp/queryexecution/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "System.Runtime": "4.0.0-*", 4 | "System.Linq": "4.0.0-*", 5 | "System.Console": "4.0.0-*", 6 | "System.Xml.XDocument": "4.0.0-*" 7 | }, 8 | "commands": { 9 | "run": "queryexecution" 10 | }, 11 | "frameworks": { 12 | "dnxcore50": { } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /samples/unit-testing/using-dotnet-test/src/PrimeService/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0-*", 3 | "dependencies": { 4 | "Microsoft.NETCore.App": { 5 | "type": "platform", 6 | "version": "1.0.0-rc2-3002702" 7 | } 8 | }, 9 | "frameworks": { 10 | "netcoreapp1.0": { 11 | "imports": "dnxcore50" 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /samples/core-projects/libraries/new-library/test/LibraryTests/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "commands": { 3 | "test":"xunit.runner.dnx" 4 | }, 5 | "frameworks": { 6 | "dnxcore50":{ 7 | "dependencies": { 8 | "Library":"", 9 | "System.Runtime":"4.0.0-rc1-*", 10 | "xunit":"2.1.0", 11 | "xunit.runner.dnx": "2.1.0-rc1-*" 12 | } 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /samples/linq/csharp/concatenation/program.cs: -------------------------------------------------------------------------------- 1 | namespace Concatenation 2 | { 3 | public class Program 4 | { 5 | public void Main(string[] args) 6 | { 7 | Concat1.MethodSyntaxExample(); 8 | 9 | Concat2.QuerySyntaxExample(); 10 | Concat2.MethodSyntaxExample(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /samples/linq/csharp/element/Product.cs: -------------------------------------------------------------------------------- 1 | namespace Element 2 | { 3 | public class Product 4 | { 5 | public int ProductId { get; set; } 6 | public string ProductName { get; set; } 7 | public string Category { get; set; } 8 | public decimal UnitPrice { get; set; } 9 | public int UnitsInStock { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /samples/linq/csharp/ordering/Product.cs: -------------------------------------------------------------------------------- 1 | namespace Ordering 2 | { 3 | public class Product 4 | { 5 | public int ProductId { get; set; } 6 | public string ProductName { get; set; } 7 | public string Category { get; set; } 8 | public decimal UnitPrice { get; set; } 9 | public int UnitsInStock { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /samples/linq/csharp/aggregate/Product.cs: -------------------------------------------------------------------------------- 1 | namespace Aggregate 2 | { 3 | public class Product 4 | { 5 | public int ProductId { get; set; } 6 | public string ProductName { get; set; } 7 | public string Category { get; set; } 8 | public decimal UnitPrice { get; set; } 9 | public int UnitsInStock { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /samples/linq/csharp/projection/Product.cs: -------------------------------------------------------------------------------- 1 | namespace Projection 2 | { 3 | public class Product 4 | { 5 | public int ProductId { get; set; } 6 | public string ProductName { get; set; } 7 | public string Category { get; set; } 8 | public decimal UnitPrice { get; set; } 9 | public int UnitsInStock { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /samples/linq/csharp/quantifier/Product.cs: -------------------------------------------------------------------------------- 1 | namespace Quantifier 2 | { 3 | public class Product 4 | { 5 | public int ProductId { get; set; } 6 | public string ProductName { get; set; } 7 | public string Category { get; set; } 8 | public decimal UnitPrice { get; set; } 9 | public int UnitsInStock { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /samples/linq/csharp/concatenation/Product.cs: -------------------------------------------------------------------------------- 1 | namespace Concatenation 2 | { 3 | public class Product 4 | { 5 | public int ProductId { get; set; } 6 | public string ProductName { get; set; } 7 | public string Category { get; set; } 8 | public decimal UnitPrice { get; set; } 9 | public int UnitsInStock { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /samples/linq/csharp/grouping/Product.cs: -------------------------------------------------------------------------------- 1 | namespace Grouping 2 | { 3 | public class Product 4 | { 5 | public int ProductId { get; set; } 6 | public string ProductName { get; set; } 7 | public string Category { get; set; } 8 | public decimal UnitPrice { get; set; } 9 | public int UnitsInStock { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /samples/linq/csharp/restriction/Product.cs: -------------------------------------------------------------------------------- 1 | namespace Restriction 2 | { 3 | public class Product 4 | { 5 | public int ProductId { get; set; } 6 | public string ProductName { get; set; } 7 | public string Category { get; set; } 8 | public decimal UnitPrice { get; set; } 9 | public int UnitsInStock { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /samples/linq/csharp/customsequence/Program.cs: -------------------------------------------------------------------------------- 1 | namespace CustomSequence 2 | { 3 | public class Program 4 | { 5 | //Entry point of application 6 | public void Main(string[] args) 7 | { 8 | //Invoke the linq custom sequence execution examples within the project 9 | CustomSequenceSample1.Example(); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /samples/linq/csharp/setoperators/Product.cs: -------------------------------------------------------------------------------- 1 | namespace SetOperators 2 | { 3 | public class Product 4 | { 5 | public int ProductId { get; set; } 6 | public string ProductName { get; set; } 7 | public string Category { get; set; } 8 | public decimal UnitPrice { get; set; } 9 | public int UnitsInStock { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /toc.yml: -------------------------------------------------------------------------------- 1 | - name: Docs 2 | href: / 3 | homepage: / 4 | items: 5 | - name: .NET Home 6 | href: /dotnet/ 7 | homepage: /dotnet/index 8 | items: 9 | - name: Documentation 10 | href: /dotnet/articles/ 11 | homepage: /dotnet/articles/welcome 12 | - name: API reference 13 | href: /dotnet/core/api/ 14 | homepage: /dotnet/core/api/index 15 | -------------------------------------------------------------------------------- /samples/core-projects/libraries/new-library/src/Library/Library.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using DependencyLibrary; 3 | 4 | namespace Library 5 | { 6 | public static class NewLibrary 7 | { 8 | public static string Hello => "Hello, .NET Core!"; 9 | 10 | public static string GenerateImportantMessage(string name) => 11 | $"{NewDependencyLibrary.ImportantMessage}, {name}!"; 12 | } 13 | } -------------------------------------------------------------------------------- /samples/getting-started/golden/src/library/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0-*", 3 | "buildOptions": { 4 | "debugType": "portable" 5 | }, 6 | "dependencies": { 7 | "Newtonsoft.Json": "9.0.1-beta1" 8 | }, 9 | "frameworks": { 10 | "netstandard1.6": { 11 | "dependencies": { 12 | "NETStandard.Library": "1.6.0" 13 | } 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /samples/linq/csharp/equality/program.cs: -------------------------------------------------------------------------------- 1 | namespace Equality 2 | { 3 | public class Program 4 | { 5 | public void Main(string[] args) 6 | { 7 | SequenceEqual1.MethodSyntaxExample(); 8 | 9 | SequenceEqual2.MethodSyntaxExample(); 10 | 11 | SequenceEqualComparer1.MethodSyntaxExample(); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /samples/core-projects/console-apps/Hello/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0-*", 3 | "buildOptions": { 4 | "emitEntryPoint": true 5 | }, 6 | "dependencies": { 7 | "Microsoft.NETCore.App": { 8 | "type": "platform", 9 | "version": "1.0.0-rc2-3002702" 10 | } 11 | }, 12 | "frameworks": { 13 | "netcoreapp1.0": { 14 | "imports": "dnxcore50" 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /samples/core-projects/console-apps/NewTypes/src/NewTypes/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0-*", 3 | "buildOptions": { 4 | "emitEntryPoint": true 5 | }, 6 | "dependencies": { 7 | "Microsoft.NETCore.App": { 8 | "type": "platform", 9 | "version": "1.0.0" 10 | } 11 | }, 12 | "frameworks": { 13 | "netcoreapp1.0": { 14 | "imports": "dnxcore50" 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /samples/csharp-language/expression-trees/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0-*", 3 | "compilationOptions": { 4 | "emitEntryPoint": true 5 | }, 6 | 7 | "dependencies": { 8 | "NETStandard.Library": "1.0.0-rc2-23704", 9 | "System.Dynamic.Runtime": "4.0.11-beta-23516" 10 | }, 11 | 12 | "frameworks": { 13 | "dnxcore50": { 14 | "dependencies": { 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /samples/csharp-language/WeatherMicroservice/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM microsoft/dotnet:onbuild 2 | 3 | RUN printf "deb http://ftp.us.debian.org/debian jessie main\n" >> /etc/apt/sources.list 4 | RUN apt-get -qq update && apt-get install -qqy sqlite3 libsqlite3-dev && rm -rf /var/lib/apt/lists/* 5 | 6 | COPY . /dotnetapp 7 | WORKDIR /dotnetapp 8 | 9 | RUN ["dotnet", "restore"] 10 | EXPOSE 80 11 | ENTRYPOINT ["dotnet", "run"] 12 | -------------------------------------------------------------------------------- /samples/csharp-language/console-linq/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0-*", 3 | "buildOptions": { 4 | "emitEntryPoint": true 5 | }, 6 | "dependencies": { 7 | "Microsoft.NETCore.App": { 8 | "version": "1.0.0-rc2-3002702", 9 | "type": "platform" 10 | } 11 | }, 12 | "frameworks": { 13 | "netcoreapp1.0": { 14 | "imports":"dnxcore50" 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /samples/csharp-language/events/NuGet.Config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /samples/csharp-language/indexers/NuGet.Config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /samples/core-projects/console-apps/Fibonacci/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0-*", 3 | "buildOptions": { 4 | "emitEntryPoint": true 5 | }, 6 | "dependencies": { 7 | "Microsoft.NETCore.App": { 8 | "version": "1.0.0-rc2-3002702" 9 | } 10 | }, 11 | "frameworks": { 12 | "netcoreapp1.0": { 13 | "imports": "dnxcore50" 14 | } 15 | }, 16 | "runtimes": { 17 | "win10-x64": {}, 18 | "osx.10.11-x64": {} 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /samples/csharp-language/delegates-and-events/NuGet.Config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /samples/csharp-language/expression-trees/NuGet.Config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /samples/csharp-language/console-teleprompter/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0-*", 3 | "buildOptions": { 4 | "emitEntryPoint": true 5 | }, 6 | 7 | "dependencies": { 8 | "Microsoft.NETCore.App": { 9 | "version": "1.0.0-rc2-3002702", 10 | "type": "platform" 11 | } 12 | }, 13 | "frameworks": { 14 | "netcoreapp1.0": { 15 | "imports":"dnxcore50" 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /samples/core-projects/console-apps/FibonacciBetter/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0-*", 3 | "buildOptions": { 4 | "emitEntryPoint": true 5 | }, 6 | "dependencies": { 7 | "Microsoft.NETCore.App": { 8 | "version": "1.0.0-rc2-3002702" 9 | } 10 | }, 11 | "frameworks": { 12 | "netcoreapp1.0": { 13 | "imports": "dnxcore50" 14 | } 15 | }, 16 | "runtimes": { 17 | "win10-x64": {}, 18 | "osx.10.11-x64": {} 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /samples/core-projects/console-apps/HelloNative/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0-*", 3 | "buildOptions": { 4 | "emitEntryPoint": true 5 | }, 6 | "dependencies": { 7 | "Microsoft.NETCore.App": { 8 | "version": "1.0.0-rc2-3002702" 9 | } 10 | }, 11 | "frameworks": { 12 | "netcoreapp1.0": { 13 | "imports": "dnxcore50" 14 | } 15 | }, 16 | "runtimes": { 17 | "win10-x64": {}, 18 | "osx.10.11-x64": {} 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /samples/linq/csharp/concatenation/Customer.cs: -------------------------------------------------------------------------------- 1 | namespace Concatenation 2 | { 3 | public class Customer 4 | { 5 | public int CustomerId { get; set; } 6 | public string CustomerName { get; set; } 7 | public string Address { get; set; } 8 | public string City { get; set; } 9 | public string PostalCode { get; set; } 10 | public string CountryOrRegion { get; set; } 11 | public string Phone { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /samples/linq/csharp/projection/Customer.cs: -------------------------------------------------------------------------------- 1 | namespace Projection 2 | { 3 | public class Customer 4 | { 5 | public string CustomerId; 6 | public string CompanyName; 7 | public string Address; 8 | public string City; 9 | public string Region; 10 | public string PostalCode; 11 | public string Country; 12 | public string Phone; 13 | public string Fax; 14 | public Order[] Orders; 15 | } 16 | } -------------------------------------------------------------------------------- /samples/core-projects/libraries/net40-library/src/Library/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "frameworks": { 3 | "dotnet55":{ 4 | "dependencies": { 5 | "System.Runtime":"4.0.0-rc1-*", 6 | "System.Net.Http":"4.0.0-rc1-*", 7 | "System.Threading.Tasks":"4.0.0-rc1-*", 8 | "System.Text.RegularExpressions": "4.0.0-rc1-*" 9 | } 10 | }, 11 | "net40":{ 12 | "frameworkAssemblies": { 13 | "System.Net":"", 14 | "System.Text.RegularExpressions":"" 15 | } 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /samples/csharp-language/WeatherMicroservice/wwwroot/web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /samples/core-projects/console-apps/FibonacciBetter/Program.cs: -------------------------------------------------------------------------------- 1 | using static System.Console; 2 | using Fibonacci; 3 | 4 | namespace ConsoleApplication 5 | { 6 | public class Program 7 | { 8 | public static void Main(string[] args) 9 | { 10 | var generator = new FibonacciGenerator(); 11 | foreach (var digit in generator.Generate(15)) 12 | { 13 | WriteLine(digit); 14 | } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /samples/linq/csharp/conversion/Program.cs: -------------------------------------------------------------------------------- 1 | namespace Conversion 2 | { 3 | public class Program 4 | { 5 | public void Main(string[] args) 6 | { 7 | ToArraySample1.MethodSyntaxExample(); 8 | ToArraySample1.QuerySyntaxExample(); 9 | 10 | ToListSample1.MethodSyntaxExample(); 11 | ToListSample1.QuerySyntaxExample(); 12 | 13 | ToDictionarySample1.Example(); 14 | 15 | OfTypeSample1.Example(); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /samples/csharp-language/console-linq/playiingcard.cs: -------------------------------------------------------------------------------- 1 | namespace LinqFaroShuffle 2 | { 3 | public class PlayingCard 4 | { 5 | public Suit CardSuit { get; } 6 | public Rank CardRank { get; } 7 | 8 | public PlayingCard(Suit s, Rank r) 9 | { 10 | CardSuit = s; 11 | CardRank = r; 12 | } 13 | 14 | public override string ToString() 15 | { 16 | return $"{CardRank} of {CardSuit}"; 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | Documentation is licensed under the Creative Commons Attribution 4.0 4 | International License (http://creativecommons.org/licenses/by/4.0/legalcode). 5 | 6 | Code is licensed under the MIT License (https://opensource.org/licenses/MIT). 7 | 8 | This license does not grant you rights to use any trademarks or logos of 9 | Microsoft. For Microsoft’s general trademark guidelines, go to 10 | http://go.microsoft.com/fwlink/?LinkID=254653. 11 | -------------------------------------------------------------------------------- /samples/getting-started/golden/src/app/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0-*", 3 | "buildOptions": { 4 | "debugType": "portable", 5 | "emitEntryPoint": true 6 | }, 7 | "dependencies": { 8 | "library": { 9 | "target": "project" 10 | } 11 | }, 12 | "frameworks": { 13 | "netcoreapp1.0": { 14 | "dependencies": { 15 | "Microsoft.NETCore.App": { 16 | "type": "platform", 17 | "version": "1.0.0" 18 | } 19 | }, 20 | "imports": "dnxcore50" 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /samples/core-projects/console-apps/NewTypes/test/NewTypesTests/PetTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit; 3 | using Pets; 4 | 5 | public class PetTests 6 | { 7 | [Fact] 8 | public void DogTalkToOwnerTest() 9 | { 10 | string expected = "Woof!"; 11 | string actual = new Dog().TalkToOwner(); 12 | 13 | Assert.Equal(expected, actual); 14 | } 15 | 16 | [Fact] 17 | public void CatTalkToOwnerTest() 18 | { 19 | string expected = "Meow!"; 20 | string actual = new Cat().TalkToOwner(); 21 | 22 | Assert.Equal(expected, actual); 23 | } 24 | } -------------------------------------------------------------------------------- /samples/core-projects/libraries/pcl-library/src/Library/Library.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | #if !PORTABLE259 4 | // .NET Core libraries can go here. 5 | #else 6 | // Use a library here that is compatible with PCL Profile 329. 7 | #endif 8 | 9 | namespace Library 10 | { 11 | public static class PCL329CompatLibrary 12 | { 13 | public static void Foo() 14 | { 15 | #if !PORTABLE259 16 | // Using a .NET Core library unavailable to PCL Profile 329 17 | #else 18 | // Need to use a a PCL Profile 329-compatible library here. 19 | #endif 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /samples/csharp-language/WeatherMicroservice/Extensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace WeatherMicroservice 7 | { 8 | public static class Extensions 9 | { 10 | public static double? TryParse(this string input) 11 | { 12 | double result; 13 | if (double.TryParse(input, out result)) 14 | return result; 15 | else 16 | return default(double?); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /samples/core-projects/libraries/pcl-library/src/Library/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "frameworks": { 3 | "dotnet55":{ 4 | "dependencies":{ 5 | "System.Runtime":"4.0.0-rc1-*" 6 | } 7 | }, 8 | ".NETPortable,Version=v4.0,Profile=Profile344":{ 9 | "compilationOptions": { 10 | "define": [ 11 | "PORTABLE259" 12 | ] 13 | }, 14 | "frameworkAssemblies":{ 15 | "mscorlib":"", 16 | "System":"", 17 | "System.Core":"" 18 | } 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /samples/linq/csharp/element/Program.cs: -------------------------------------------------------------------------------- 1 | namespace Element 2 | { 3 | public class Program 4 | { 5 | public void Main(string[] args) 6 | { 7 | FirstSample1.MethodSyntaxExample(); 8 | FirstSample1.QuerySyntaxExample(); 9 | 10 | FirstSample2.Example(); 11 | 12 | FirstOrDefaultSample1.Example(); 13 | 14 | FirstOrDefaultSample2.Example(); 15 | 16 | ElementAtSample1.MethodSyntaxExample(); 17 | ElementAtSample1.QuerySyntaxExample(); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /samples/unit-testing/using-dotnet-test/test/PrimeService.Tests/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0-*", 3 | "testRunner": "xunit", 4 | 5 | "dependencies": { 6 | "Microsoft.NETCore.App": { 7 | "type":"platform", 8 | "version": "1.0.0-rc2-3002702" 9 | }, 10 | "xunit":"2.1.0", 11 | "dotnet-test-xunit": "1.0.0-rc2-build10015", 12 | "PrimeService": "1.0.0" 13 | }, 14 | "frameworks": { 15 | "netcoreapp1.0": { 16 | "imports": [ 17 | "dnxcore50", 18 | "portable-net45+win8" 19 | ] 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /samples/core-projects/console-apps/NewTypes/test/NewTypesTests/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0-*", 3 | "testRunner": "xunit", 4 | 5 | "dependencies": { 6 | "Microsoft.NETCore.App": { 7 | "type":"platform", 8 | "version": "1.0.0" 9 | }, 10 | "xunit":"2.2.0-beta2-build3300", 11 | "dotnet-test-xunit": "2.2.0-preview2-build1029", 12 | "NewTypes": "1.0.0" 13 | }, 14 | "frameworks": { 15 | "netcoreapp1.0": { 16 | "imports": [ 17 | "dnxcore50", 18 | "portable-net45+win8" 19 | ] 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /samples/linq/csharp/aggregate/Customer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Aggregate 4 | { 5 | public class Customer 6 | { 7 | public int CustomerId { get; set; } 8 | public string CustomerName { get; set; } 9 | public string Address { get; set; } 10 | public string City { get; set; } 11 | public string PostalCode { get; set; } 12 | public string CountryOrRegion { get; set; } 13 | public string Phone { get; set; } 14 | public IEnumerable Orders { get; set; } = new List(); 15 | } 16 | } -------------------------------------------------------------------------------- /docs/csharp/csharp-6.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: What's New in C# 6 3 | description: What's New in C# 6 4 | keywords: .NET, .NET Core 5 | author: tdykstra 6 | manager: wpickett 7 | ms.date: 06/20/2016 8 | ms.topic: article 9 | ms.prod: .net-core 10 | ms.technology: .net-core-technologies 11 | ms.devlang: dotnet 12 | ms.assetid: 4d879f69-f889-4d3f-a781-75194e143400 13 | --- 14 | 15 | # What's New in C# 6 16 | 17 | For information about new features in C# 6, we suggest you head over to [the Roslyn repository in GitHub](https://github.com/dotnet/roslyn/wiki/New-Language-Features-in-C%23-6). 18 | -------------------------------------------------------------------------------- /samples/linq/csharp/grouping/Customer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Grouping 4 | { 5 | public class Customer 6 | { 7 | public int CustomerId { get; set; } 8 | public string CustomerName { get; set; } 9 | public string Address { get; set; } 10 | public string City { get; set; } 11 | public string PostalCode { get; set; } 12 | public string CountryOrRegion { get; set; } 13 | public string Phone { get; set; } 14 | public IEnumerable Orders { get; set; } = new List(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /samples/linq/csharp/aggregate/Min-Sample-1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Aggregate 5 | { 6 | public static class MinSample1 7 | { 8 | //This sample uses Min to get the lowest number in an array. 9 | // 10 | //Output: 11 | // The minimum number is 0. 12 | public static void Example() 13 | { 14 | int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 }; 15 | 16 | int minNum = numbers.Min(); 17 | 18 | Console.WriteLine($"The minimum number is {minNum}."); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /samples/linq/csharp/aggregate/Sum-Sample-1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Aggregate 5 | { 6 | public static class SumSample1 7 | { 8 | //This sample uses Sum to add all the numbers in an array. 9 | // 10 | // Output: 11 | // The sum of the numbers is 45. 12 | public static void Example() 13 | { 14 | int[] numbers = {5, 4, 1, 3, 9, 8, 6, 7, 2, 0}; 15 | 16 | double numSum = numbers.Sum(); 17 | 18 | Console.WriteLine($"The sum of the numbers is {numSum}."); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /samples/linq/csharp/setoperators/Customer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace SetOperators 4 | { 5 | public class Customer 6 | { 7 | public int CustomerId { get; set; } 8 | public string CustomerName { get; set; } 9 | public string Address { get; set; } 10 | public string City { get; set; } 11 | public string PostalCode { get; set; } 12 | public string CountryOrRegion { get; set; } 13 | public string Phone { get; set; } 14 | public IEnumerable Orders { get; set; } = new List(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /docs/core/tutorials/aspnet-core.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Getting started with ASP.NET Core 3 | description: Getting started with ASP.NET Core 4 | keywords: .NET, .NET Core 5 | author: tdykstra 6 | manager: wpickett 7 | ms.date: 06/20/2016 8 | ms.topic: article 9 | ms.prod: .net-core 10 | ms.technology: .net-core-technologies 11 | ms.devlang: dotnet 12 | ms.assetid: 4172512e-b93d-4169-abdb-bd0b0b2d657e 13 | --- 14 | 15 | # Getting started with ASP.NET Core 16 | 17 | For tutorials about developing ASP.NET Core web applications, we suggest you head over to [ASP.NET Core documentation](https://docs.asp.net). -------------------------------------------------------------------------------- /samples/csharp-language/expression-trees/ExpressionTreeExecutionSampleOne.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq.Expressions; 3 | 4 | namespace ExpressionTreeSamples 5 | { 6 | public class ExpressionTreeExecutionSampleOne : Sample 7 | { 8 | public override string Name { get; } = "Executing Expression Trees, Sample 1"; 9 | 10 | public override void Run() 11 | { 12 | Expression> add = () => 1 + 2; 13 | var func = add.Compile(); 14 | var answer = func(); 15 | Console.WriteLine(answer); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /samples/linq/csharp/quantifier/Program.cs: -------------------------------------------------------------------------------- 1 | namespace Quantifier 2 | { 3 | public class Program 4 | { 5 | //Entry point of application 6 | public void Main(string[] args) 7 | { 8 | //Invoke the linq quantifiers examples within the project 9 | AnySample1.Example(); 10 | 11 | AnySample2.MethodSyntaxExample(); 12 | AnySample2.QuerySyntaxExample(); 13 | 14 | AllSample1.Example(); 15 | 16 | AllSample2.MethodSyntaxExample(); 17 | AllSample2.QuerySyntaxExample(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /samples/csharp-language/console-webapiclient/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0-*", 3 | "buildOptions": { 4 | "emitEntryPoint": true 5 | }, 6 | 7 | "dependencies": { 8 | "Microsoft.NETCore.App": { 9 | "version": "1.0.0-rc2-3002702", 10 | "type": "platform" 11 | }, 12 | "System.Runtime.Serialization.Json": "4.0.2-rc2-24027", 13 | "System.Runtime.Serialization.Primitives": "4.1.1-rc2-24027" 14 | }, 15 | 16 | "frameworks": { 17 | "netcoreapp1.0": { 18 | "imports":"dnxcore50" 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /samples/getting-started/golden/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "0.1.0", 5 | "command": "dotnet", 6 | "isShellCommand": true, 7 | "args": [], 8 | "options": { 9 | "cwd": "${workspaceRoot}/src/app" 10 | }, 11 | "tasks": [ 12 | { 13 | "taskName": "build", 14 | "args": [ ], 15 | "isBuildCommand": true, 16 | "showOutput": "silent", 17 | "problemMatcher": "$msCompile" 18 | } 19 | ] 20 | } -------------------------------------------------------------------------------- /samples/core-projects/console-apps/NewTypes/src/NewTypes/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Pets; 3 | using System.Collections.Generic; 4 | 5 | namespace ConsoleApplication 6 | { 7 | public class Program 8 | { 9 | public static void Main(string[] args) 10 | { 11 | List pets = new List 12 | { 13 | new Dog(), 14 | new Cat() 15 | }; 16 | 17 | foreach (var pet in pets) 18 | { 19 | Console.WriteLine(pet.TalkToOwner()); 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /samples/core-projects/libraries/new-library/test/LibraryTests/LibraryTest.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | using Library; 3 | using System; 4 | 5 | public class LibraryTest 6 | { 7 | [Fact] 8 | public void HelloTest() 9 | { 10 | string expected = "Hello, .NET Core!"; 11 | 12 | string actual = NewLibrary.Hello; 13 | 14 | Assert.Equal(expected, actual); 15 | } 16 | 17 | [Fact] 18 | public void ImportantMessageTest() 19 | { 20 | string expected = "Live long and prosper, Captain Kirk!"; 21 | 22 | string actual = NewLibrary.GenerateImportantMessage("Captain Kirk"); 23 | 24 | Assert.Equal(expected, actual); 25 | } 26 | } -------------------------------------------------------------------------------- /samples/linq/csharp/aggregate/Average-Sample-1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Aggregate 5 | { 6 | public static class AverageSample1 7 | { 8 | //This sample uses Average to get the average of all numbers in an array. 9 | // 10 | //Outputs: 11 | // The average number is 4.5. 12 | public static void Example() 13 | { 14 | int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 }; 15 | 16 | double averageNum = numbers.Average(); 17 | 18 | Console.WriteLine($"The average number is {averageNum}."); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /samples/linq/csharp/partitioning/Program.cs: -------------------------------------------------------------------------------- 1 | using Partitioning; 2 | 3 | namespace Partitioning 4 | { 5 | public class Program 6 | { 7 | //Entry point of application 8 | public void Main(string[] args) 9 | { 10 | //Invoke the linq partitioning examples within the project 11 | TakeSample1.Example(); 12 | 13 | SkipSample1.Example(); 14 | 15 | TakeWhileSample1.Example(); 16 | 17 | TakeWhileSample2.Example(); 18 | 19 | SkipWhileSample1.Example(); 20 | 21 | SkipWhileSample2.Example(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /samples/linq/csharp/aggregate/Max-Sample-1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Aggregate 5 | { 6 | public static class MaxSample1 7 | { 8 | //This sample uses Max to get the highest number in an array. Note that the method returns a single value. 9 | // 10 | //Outputs: 11 | // The maximum number is 9. 12 | public static void Example() 13 | { 14 | int[] numbers = {5, 4, 1, 3, 9, 8, 6, 7, 2, 0}; 15 | 16 | int maxNum = numbers.Max(); 17 | 18 | Console.WriteLine($"The maximum number is {maxNum}."); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /samples/linq/csharp/quantifier/All-Sample-1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Quantifier 5 | { 6 | public class AllSample1 7 | { 8 | //This sample uses All to determine whether an array contains only odd numbers. 9 | // 10 | //Output: 11 | // The list contains only odd numbers: True 12 | public static void Example() 13 | { 14 | int[] numbers = {1, 11, 3, 19, 41, 65, 19}; 15 | 16 | bool onlyOdd = numbers.All(n => n%2 == 1); 17 | 18 | Console.WriteLine("The list contains only odd numbers: {0}", onlyOdd); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /samples/linq/csharp/aggregate/Count-Sample-2.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System; 3 | 4 | namespace Aggregate 5 | { 6 | public static class CountSample2 7 | { 8 | //This sample uses Count to get the number of odd ints in the array. 9 | // 10 | //Output: 11 | // There are 5 odd numbers in the list. 12 | public static void Example() 13 | { 14 | int[] numbers = {5, 4, 1, 3, 9, 8, 6, 7, 2, 0}; 15 | 16 | int oddNumbers = numbers.Count(n => n%2 == 1); 17 | 18 | Console.WriteLine($"There are {oddNumbers} odd numbers in the list."); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /samples/linq/csharp/aggregate/Max-Sample-2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Aggregate 5 | { 6 | public static class MaxSample2 7 | { 8 | 9 | //This sample uses Max to get the length of the longest word in an array. 10 | // 11 | //Output: 12 | // The longest word is 9 characters long. 13 | public static void Example() 14 | { 15 | string[] words = {"cherry", "apple", "blueberry"}; 16 | 17 | int longestLength = words.Max(w => w.Length); 18 | 19 | Console.WriteLine($"The longest word is {longestLength} characters long."); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /samples/linq/csharp/aggregate/Min-Sample-2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Aggregate 5 | { 6 | public static class MinSample2 7 | { 8 | //This sample uses Min to get the length of the shortest word in an array. 9 | // 10 | //Output: 11 | // The shortest word is 5 characters long. 12 | public static void Example() 13 | { 14 | string[] words = { "cherry", "apple", "blueberry" }; 15 | 16 | int shortestWord = words.Min(w => w.Length); 17 | 18 | Console.WriteLine($"The shortest word is {shortestWord} characters long."); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /samples/linq/csharp/restriction/Program.cs: -------------------------------------------------------------------------------- 1 | namespace Restriction 2 | { 3 | public class Program 4 | { 5 | //Entry point of application 6 | public void Main(string[] args) 7 | { 8 | //Invoke the linq restriction examples within the project 9 | WhereClause1.QuerySyntaxExample(); 10 | WhereClause1.MethodSyntaxExample(); 11 | 12 | WhereClause2.QuerySyntaxExample(); 13 | WhereClause2.MethodSyntaxExample(); 14 | 15 | WhereClause3.QuerySyntaxExample(); 16 | WhereClause3.MethodSyntaxExample(); 17 | 18 | WhereClause4.Example(); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /samples/unit-testing/using-dotnet-test/src/PrimeService/PrimeService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Prime.Services 4 | { 5 | public class PrimeService 6 | { 7 | public bool IsPrime(int candidate) 8 | { 9 | if(candidate < 2) 10 | { 11 | return false; 12 | } 13 | for(int divisor=2; divisor <= Math.Sqrt(candidate); divisor++) 14 | { 15 | if(candidate % divisor == 0) 16 | { 17 | return false; 18 | } 19 | } 20 | return true; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /samples/linq/csharp/aggregate/Sum-Sample-2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Aggregate 5 | { 6 | public static class SumSample2 7 | { 8 | //This sample uses Sum to get the total number of characters of all words in the array. 9 | // 10 | // Output: 11 | // There are a total of 20 characters in these words. 12 | public static void Example() 13 | { 14 | string[] words = {"cherry", "apple", "blueberry"}; 15 | 16 | double totalChars = words.Sum(w => w.Length); 17 | 18 | Console.WriteLine($"There are a total of {totalChars} characters in these words."); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /samples/csharp-language/WeatherMicroservice/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:20883/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "Hosting:Environment": "Development" 16 | } 17 | }, 18 | "web": { 19 | "commandName": "web", 20 | "environmentVariables": { 21 | "Hosting:Environment": "Development" 22 | } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /samples/csharp-language/expression-trees/ParameterVisitor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq.Expressions; 3 | 4 | namespace ExpressionVisitor 5 | { 6 | public class ParameterVisitor : Visitor 7 | { 8 | private readonly ParameterExpression node; 9 | public ParameterVisitor(ParameterExpression node) : base(node) 10 | { 11 | this.node = node; 12 | } 13 | 14 | public override void Visit(string prefix) 15 | { 16 | Console.WriteLine($"{prefix}This is an {NodeType} expression type"); 17 | Console.WriteLine($"{prefix}Type: {node.Type.ToString()}, Name: {node.Name}, ByRef: {node.IsByRef}"); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /samples/csharp-language/iterators/program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Iterators 5 | { 6 | public class Program 7 | { 8 | public void Main() 9 | { 10 | ForeachExamples.ExampleOne(); 11 | 12 | foreach (var item in IteratorMethods.GetSingleDigitNumbers()) 13 | Console.WriteLine(item); 14 | 15 | foreach (var item in IteratorMethods.GetSingleDigitNumbersV2()) 16 | Console.WriteLine(item); 17 | 18 | foreach (var item in IteratorMethods.GetSingleDigitNumbersAndNumbersOver100()) 19 | Console.WriteLine(item); 20 | 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /samples/linq/csharp/generation/Repeat-Example-1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Generation 5 | { 6 | public static class RepeatExample1 7 | { 8 | //This sample uses Repeat to generate a sequence that contains the number 7 seven times. 9 | // 10 | //Output: 11 | // 7 12 | // 7 13 | // 7 14 | // 7 15 | // 7 16 | // 7 17 | // 7 18 | public static void Example() 19 | { 20 | var numbers = Enumerable.Repeat(7, 7); 21 | 22 | foreach (var n in numbers) 23 | { 24 | Console.WriteLine(n); 25 | } 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /samples/core-projects/console-apps/FibonacciBetter/FibonacciGenerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Fibonacci 5 | { 6 | public class FibonacciGenerator 7 | { 8 | private Dictionary _cache = new Dictionary(); 9 | 10 | private int Fib(int n) => n < 2 ? n : FibValue(n - 1) + FibValue(n - 2); 11 | 12 | public int FibValue(int n) 13 | { 14 | if (!_cache.ContainsKey(n)) 15 | { 16 | _cache.Add(n, Fib(n)); 17 | } 18 | 19 | return _cache[n]; 20 | } 21 | 22 | public IEnumerable Generate(int n) 23 | { 24 | for (int i = 0; i < n; i++) 25 | { 26 | yield return FibValue(i); 27 | } 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /samples/linq/csharp/ordering/CaseInsensitiveComparer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Ordering 5 | { 6 | // This comparer is used to perform case insensitive string comparison 7 | // in the comparer samples. See: 8 | // OrderBy-Comparer-Sample-1.cs 9 | // OrderByDescending-Comparer-Sample-1.cs 10 | // ThenBy-Comparer-Sample-1.cs 11 | // ThenByDescending-Comparer-Sample-2.cs 12 | public class CaseInsensitiveComparer : IComparer 13 | { 14 | public int Compare(string x, string y) 15 | { 16 | return string.Compare(x, y, StringComparison.OrdinalIgnoreCase); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /samples/linq/csharp/quantifier/Any-Sample-1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Quantifier 5 | { 6 | public class AnySample1 7 | { 8 | //This sample uses Any to determine if any of the words in the array contain the substring 'ei'. 9 | // 10 | //Outputs: 11 | //There is a word in the list that contains 'ei': True 12 | public static void Example() 13 | { 14 | string[] words = {"believe", "relief", "receipt", "field"}; 15 | 16 | bool iAfterE = words.Any(w => w.Contains("ei")); 17 | 18 | Console.WriteLine("There is a word in the list that contains 'ei': {0}", iAfterE); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /samples/linq/csharp/element/FirstSample-2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Element 5 | { 6 | public static class FirstSample2 7 | { 8 | //This sample uses First to find the first element in the array that starts with 'o'. 9 | // 10 | //Output: 11 | // A string starting with 'o': one 12 | public static void Example() 13 | { 14 | string[] strings = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }; 15 | 16 | string startsWithO = strings.First(s => s[0] == 'o'); 17 | 18 | Console.WriteLine("A string starting with 'o': {0}", startsWithO); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /docs/fsharp/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: F# Guide 3 | description: F# Guide 4 | keywords: .NET, .NET Core 5 | author: jackfoxy 6 | manager: wpickett 7 | ms.date: 06/20/2016 8 | ms.topic: article 9 | ms.prod: .net-core 10 | ms.technology: .net-core-technologies 11 | ms.devlang: dotnet 12 | ms.assetid: ea27fb37-dad1-4bd4-a3cc-4f5c70767ae9 13 | --- 14 | 15 | # F# Guide 16 | 17 | * [F# Learning Resources](http://fsharp.org/learn.html) 18 | * [F# Language Reference](https://msdn.microsoft.com/en-us/visualfsharpdocs/conceptual/fsharp-language-reference) 19 | * [Visual F# Development Portal](https://msdn.microsoft.com/en-us/visualfsharpdocs/conceptual/visual-fsharp-development-portal) 20 | * [Asynchronous programming](async.md) 21 | -------------------------------------------------------------------------------- /samples/linq/csharp/queryexecution/Program.cs: -------------------------------------------------------------------------------- 1 | namespace QueryExecution 2 | { 3 | public class Program 4 | { 5 | //Entry point of application 6 | public void Main(string[] args) 7 | { 8 | //Invoke the linq query execution examples within the project 9 | DeferredExecutionExample1.QuerySyntaxExample(); 10 | DeferredExecutionExample1.MethodSyntaxExample(); 11 | 12 | ImmediateExecutionExample1.QuerySyntaxExample(); 13 | ImmediateExecutionExample1.MethodSyntaxExample(); 14 | 15 | DeferredExecutionExample2.QuerySyntaxExample(); 16 | DeferredExecutionExample2.MethodSyntaxExample(); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /samples/csharp-language/iterators/ForeachExamples.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace Iterators 7 | { 8 | public static class ForeachExamples 9 | { 10 | public static void ExampleOne() 11 | { 12 | var collection = new List 13 | { 14 | "Hello", 15 | "World", 16 | "Iterators", 17 | "are", 18 | "awesome" 19 | }; 20 | foreach (var item in collection) 21 | { 22 | Console.WriteLine(item.ToString()); 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /docs/core/deploying/applications.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Deploying .NET Core applications 3 | description: Deploying .NET Core applications 4 | keywords: .NET, .NET Core 5 | author: dotnet-bot 6 | manager: wpickett 7 | ms.date: 06/20/2016 8 | ms.topic: article 9 | ms.prod: .net-core 10 | ms.technology: .net-core-technologies 11 | ms.devlang: dotnet 12 | ms.assetid: 1db00fb1-d947-480d-8d7d-7152e67b0585 13 | --- 14 | 15 | # 🔧 Deploying .NET Core applications 16 | 17 | > **Note** 18 | > 19 | > This topic hasn’t been written yet! 20 | > 21 | > We welcome your input to help shape the scope and approach. 22 | > 23 | > Learn more about how you can contribute on 24 | > [GitHub](https://github.com/dotnet/core-docs/blob/master/CONTRIBUTING.md). 25 | > -------------------------------------------------------------------------------- /samples/linq/csharp/element/FirstOrDefault-Sample-1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Element 5 | { 6 | public static class FirstOrDefaultSample1 7 | { 8 | //This sample uses FirstOrDefault to try to return the first element of the sequence, 9 | //unless there are no elements, in which case the default value for that type 10 | //is returned. FirstOrDefault is useful for creating outer joins. 11 | // 12 | //Output: 13 | // 0 14 | public static void Example() 15 | { 16 | int[] numbers = { }; 17 | 18 | int firstNumOrDefault = numbers.FirstOrDefault(); 19 | 20 | Console.WriteLine(firstNumOrDefault); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /samples/csharp-language/expression-trees/UnaryVisitor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq.Expressions; 3 | 4 | namespace ExpressionVisitor 5 | { 6 | internal class UnaryVisitor : Visitor 7 | { 8 | private readonly UnaryExpression node; 9 | public UnaryVisitor(UnaryExpression node) : base(node) 10 | { 11 | this.node = node; 12 | } 13 | 14 | public override void Visit(string prefix) 15 | { 16 | Console.WriteLine($"{prefix}This expression is a {NodeType} expression"); 17 | var operandVisitor = Visitor.CreateFromExpression(node.Operand); 18 | Console.WriteLine($"The operand is:"); 19 | operandVisitor.Visit(prefix + "\t"); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /samples/linq/csharp/equality/SequenceEqual-Sample-1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Equality 5 | { 6 | //This sample uses SequenceEqual to see if two sequences match on all elements in the same order. 7 | //Outputs to the console: 8 | // The sequences match: True 9 | public class SequenceEqual1 10 | { 11 | public static void MethodSyntaxExample() 12 | { 13 | var wordsA = new string[] { "cherry", "apple", "blueberry" }; 14 | var wordsB = new string[] { "cherry", "apple", "blueberry" }; 15 | 16 | bool match = wordsA.SequenceEqual(wordsB); 17 | 18 | Console.WriteLine("The sequences match: {0}", match); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /samples/linq/csharp/equality/SequenceEqual-Sample-2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Equality 5 | { 6 | //This sample uses SequenceEqual to see if two sequences match on all elements in the same order. 7 | //Outputs to the console: 8 | // The sequences match: False 9 | public class SequenceEqual2 10 | { 11 | public static void MethodSyntaxExample() 12 | { 13 | var wordsA = new string[] { "cherry", "apple", "blueberry" }; 14 | var wordsB = new string[] { "apple", "blueberry", "cherry" }; 15 | 16 | bool match = wordsA.SequenceEqual(wordsB); 17 | 18 | Console.WriteLine("The sequences match: {0}", match); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /samples/getting-started/golden/test/test-library/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0-*", 3 | "buildOptions": { 4 | "debugType": "portable" 5 | }, 6 | "dependencies": { 7 | "System.Runtime.Serialization.Primitives": "4.1.1", 8 | "xunit": "2.1.0", 9 | "dotnet-test-xunit": "1.0.0-rc2-192208-24", 10 | "library": { 11 | "target": "project" 12 | } 13 | }, 14 | "testRunner": "xunit", 15 | "frameworks": { 16 | "netcoreapp1.0": { 17 | "dependencies": { 18 | "Microsoft.NETCore.App": { 19 | "type": "platform", 20 | "version": "1.0.0" 21 | } 22 | }, 23 | "imports": [ 24 | "dotnet5.4", 25 | "portable-net451+win8" 26 | ] 27 | } 28 | } 29 | } 30 | 31 | 32 | -------------------------------------------------------------------------------- /samples/linq/csharp/aggregate/Aggregate-Sample-1.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System; 3 | 4 | namespace Aggregate 5 | { 6 | public static class AggregateSample1 7 | { 8 | //This sample uses Aggregate to create a running product on the array that calculates the total product of all elements. 9 | //Output: 10 | // Total product of all numbers: 88.33081 11 | public static void MethodSyntaxExample() 12 | { 13 | double[] doubles = { 1.7, 2.3, 1.9, 4.1, 2.9 }; 14 | 15 | double product = doubles.Aggregate((runningProduct, nextFactor) => runningProduct * nextFactor); 16 | 17 | Console.WriteLine($"Total product of all numbers: {product}"); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /docs/core/porting/nuget-packages.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Porting to .NET Core - NuGet packages 3 | description: Porting to .NET Core - NuGet packages 4 | keywords: .NET, .NET Core 5 | author: cartermp 6 | manager: wpickett 7 | ms.date: 06/20/2016 8 | ms.topic: article 9 | ms.prod: .net-core 10 | ms.technology: .net-core-technologies 11 | ms.devlang: dotnet 12 | ms.assetid: 4d823e71-19ac-4419-953e-b47aa58f5538 13 | --- 14 | 15 | # 🔧 Porting to .NET Core - NuGet packages 16 | 17 | > **Note** 18 | > 19 | > This topic hasn’t been written yet! 20 | > 21 | > We welcome your input to help shape the scope and approach. 22 | > 23 | > Learn more about how you can contribute on 24 | > [GitHub](https://github.com/dotnet/core-docs/blob/master/CONTRIBUTING.md). 25 | > 26 | 27 | -------------------------------------------------------------------------------- /samples/csharp-language/expression-trees/ExpressionTreeClassesSampleTwo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq.Expressions; 3 | 4 | namespace ExpressionTreeSamples 5 | { 6 | public class ExpressionTreeClassesSampleTwo : Sample 7 | { 8 | public override string Name { get; } = "Expression Tree Classes, Sample 2"; 9 | 10 | public override void Run() 11 | { 12 | var one = Expression.Constant(1, typeof(int)); 13 | var two = Expression.Constant(2, typeof(int)); 14 | var addition = Expression.Add(one, two); 15 | var lambda = Expression.Lambda(addition); 16 | 17 | var func = (Func)lambda.Compile(); 18 | Console.WriteLine(func()); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /samples/csharp-language/expression-trees/ConstantVisitor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq.Expressions; 3 | 4 | namespace ExpressionVisitor 5 | { 6 | public class ConstantVisitor : Visitor 7 | { 8 | private readonly ConstantExpression node; 9 | 10 | internal ConstantVisitor(ConstantExpression node) : base(node) 11 | { 12 | this.node = node; 13 | } 14 | 15 | public override void Visit(string prefix) 16 | { 17 | Console.WriteLine($"{prefix}This is an {node.NodeType} expression type"); 18 | Console.WriteLine($"{prefix}The type of the constant value is {node.Type}"); 19 | Console.WriteLine($"{prefix}The value of the constant value is {node.Value}"); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /samples/linq/csharp/grouping/Program.cs: -------------------------------------------------------------------------------- 1 | namespace Grouping 2 | { 3 | public class Program 4 | { 5 | //Entry point of application 6 | public void Main(string[] args) 7 | { 8 | //Invoke the linq grouping examples within the project 9 | GroupBy1.QuerySyntaxExample(); 10 | GroupBy1.MethodSyntaxExample(); 11 | 12 | GroupBy2.QuerySyntaxExample(); 13 | GroupBy2.MethodSyntaxExample(); 14 | 15 | GroupBy3.QuerySyntaxExample(); 16 | GroupBy3.MethodSyntaxExample(); 17 | 18 | GroupByNested1.QuerySyntaxExample(); 19 | 20 | GroupByComparer1.MethodSyntaxExample(); 21 | 22 | GroupByComparer2.MethodSyntaxExample(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /samples/linq/csharp/partitioning/Take-Sample-1.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System; 3 | 4 | namespace Partitioning 5 | { 6 | public static class TakeSample1 7 | { 8 | //This sample uses Take to get only the first 3 elements of the array. 9 | // 10 | //Output: 11 | // First 3 numbers: 12 | // 5 13 | // 4 14 | // 1 15 | public static void Example() 16 | { 17 | int[] numbers = {5, 4, 1, 3, 9, 8, 6, 7, 2, 0}; 18 | 19 | var first3Numbers = numbers.Take(3); 20 | 21 | Console.WriteLine("First 3 numbers:"); 22 | foreach (var n in first3Numbers) 23 | { 24 | Console.WriteLine(n); 25 | } 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /samples/linq/csharp/equality/CaseInsensitiveComparer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Equality 5 | { 6 | // This comparer is used to perform case insensitive string comparison 7 | // in the comparer samples. See: 8 | // SequenceEqual-Comparer-Sample-1.cs 9 | public class CaseInsensitiveComparer : IEqualityComparer 10 | { 11 | bool IEqualityComparer.Equals(string x, string y) 12 | { 13 | return string.Equals(x, y, StringComparison.OrdinalIgnoreCase); 14 | } 15 | 16 | int IEqualityComparer.GetHashCode(string obj) 17 | { 18 | if (obj == null) return 0; 19 | return obj.ToLower().GetHashCode(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /samples/linq/csharp/join/Program.cs: -------------------------------------------------------------------------------- 1 | namespace Join 2 | { 3 | public class Program 4 | { 5 | //Entry point of application 6 | public void Main(string[] args) 7 | { 8 | //Invoke the linq join examples within the project 9 | CrossJoinExample1.MethodSyntaxExample(); 10 | CrossJoinExample1.QuerySyntaxExample(); 11 | 12 | GroupJoinExample1.MethodSyntaxExample(); 13 | GroupJoinExample1.QuerySyntaxExample(); 14 | 15 | CrossJoinWithGroupJoinExample1.MethodSyntaxExample(); 16 | CrossJoinWithGroupJoinExample1.QuerySyntaxExample(); 17 | 18 | LeftOuterJoinExample1.MethodSyntaxExample(); 19 | LeftOuterJoinExample1.QuerySyntaxExample(); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /docs/core/tutorials/libraries-with-vs.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Developing .NET Core libraries using Visual Studio 3 | description: Developing .NET Core libraries using Visual Studio 4 | keywords: .NET, .NET Core 5 | author: dotnet-bot 6 | manager: wpickett 7 | ms.date: 06/20/2016 8 | ms.topic: article 9 | ms.prod: .net-core 10 | ms.technology: .net-core-technologies 11 | ms.devlang: dotnet 12 | ms.assetid: 01b988ed-583f-48c8-a016-caeee282e0a6 13 | --- 14 | 15 | # 🔧 Developing .NET Core libraries using Visual Studio 16 | 17 | > **Note** 18 | > 19 | > This topic hasn’t been written yet! 20 | > 21 | > We welcome your input to help shape the scope and approach. 22 | > 23 | > Learn more about how you can contribute on 24 | > [GitHub](https://github.com/dotnet/core-docs/blob/master/CONTRIBUTING.md). 25 | > -------------------------------------------------------------------------------- /samples/linq/csharp/setoperators/Set-Distinct-Sample-1.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System; 3 | namespace SetOperators 4 | { 5 | public class SetDistinct1 6 | { 7 | //This sample uses Distinct to remove duplicate elements in a sequence. 8 | //Outputs the following to Console 9 | // Unique values: 10 | // 2 11 | // 3 12 | // 5 13 | public static void MethodSyntaxExample() 14 | { 15 | int[] values = { 2, 2, 3, 5, 5 }; 16 | 17 | var uniqueValues = values.Distinct(); 18 | 19 | Console.WriteLine("Unique values:"); 20 | foreach (var n in uniqueValues) 21 | { 22 | Console.WriteLine(n); 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /samples/csharp-language/expression-trees/ExpressionTreeInterpretingSampleOne.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq.Expressions; 3 | 4 | namespace ExpressionTreeSamples 5 | { 6 | public class ExpressionTreeInterpretingSampleOne : Sample 7 | { 8 | public override string Name { get; } = "Interpreting Expression Trees, Sample 1: Understanding Constant Nodes"; 9 | 10 | public override void Run() 11 | { 12 | var constant = Expression.Constant(24, typeof(int)); 13 | 14 | Console.WriteLine($"This is an {constant.NodeType} expression type"); 15 | Console.WriteLine($"The type of the constant value is {constant.Type}"); 16 | Console.WriteLine($"The value of the constant value is {constant.Value}"); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /samples/linq/csharp/conversion/OfType-Sample-1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Conversion 5 | { 6 | public static class OfTypeSample1 7 | { 8 | //This sample uses OfType to return only the elements of the array that are of type double. 9 | // 10 | //Output: 11 | // Numbers stored as doubles: 12 | // 1 13 | // 7 14 | public static void Example() 15 | { 16 | object[] numbers = { null, 1.0, "two", 3, "four", 5, "six", 7.0 }; 17 | 18 | var doubles = numbers.OfType(); 19 | 20 | Console.WriteLine("Numbers stored as doubles:"); 21 | foreach (var d in doubles) 22 | { 23 | Console.WriteLine(d); 24 | } 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /.openpublishing.build.ps1: -------------------------------------------------------------------------------- 1 | param( 2 | [string]$buildCorePowershellUrl = "https://opbuildstoragesandbox2.blob.core.windows.net/opps1container/.openpublishing.buildcore.ps1", 3 | [string]$parameters 4 | ) 5 | # Main 6 | $errorActionPreference = 'Stop' 7 | 8 | # Step-1 Download buildcore script to local 9 | echo "download build core script to local with source url: $buildCorePowershellUrl" 10 | $repositoryRoot = Split-Path -Parent $MyInvocation.MyCommand.Definition 11 | $buildCorePowershellDestination = "$repositoryRoot\.openpublishing.buildcore.ps1" 12 | Invoke-WebRequest $buildCorePowershellUrl -OutFile $buildCorePowershellDestination 13 | 14 | # Step-2: Run build core 15 | echo "run build core script with parameters: $parameters" 16 | & "$buildCorePowershellDestination" "$parameters" 17 | exit $LASTEXITCODE 18 | -------------------------------------------------------------------------------- /samples/linq/csharp/element/FirstOrDefault-Sample-2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace Element 6 | { 7 | public static class FirstOrDefaultSample2 8 | { 9 | //This sample uses FirstOrDefault to return the first product whose ProductID is 789 10 | //as a single Product object, unless there is no match, in which case null is returned. 11 | // 12 | //Output: 13 | // Product 789 exists: False 14 | public static void Example() 15 | { 16 | List products = Data.Products; 17 | 18 | Product product789 = products.FirstOrDefault(p => p.ProductId == 789); 19 | 20 | Console.WriteLine("Product 789 exists: {0}", product789 != null); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /samples/csharp-language/WeatherMicroservice/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0-*", 3 | "buildOptions": { 4 | "emitEntryPoint": true 5 | }, 6 | "tooling": { 7 | "defaultNamespace": "WeatherMicroservice" 8 | }, 9 | 10 | "dependencies": { 11 | "Microsoft.NETCore.App": { 12 | "version": "1.0.0-rc2-3002702", 13 | "type": "platform" 14 | }, 15 | "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final", 16 | "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final", 17 | "Newtonsoft.Json": "8.0.4-beta1" 18 | }, 19 | 20 | "frameworks": { 21 | "netcoreapp1.0": { 22 | "imports": ["dotnet", "portable-net40+sl5+win8+wp8+wpa81"] 23 | } 24 | }, 25 | "publishOptions": { 26 | "include": [ 27 | "web.config" 28 | ] 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /samples/csharp-language/events/README.md: -------------------------------------------------------------------------------- 1 | C# Events Sample 2 | ================ 3 | 4 | This sample is created during the [Delegates and Events topic](../../docs/csharp/delegates-and-events.html) 5 | for learning C# features. Please see that topic for detailed steps on the code 6 | for this sample. 7 | 8 | Key Features 9 | ------------ 10 | 11 | This sample demonstrates defining and raising events, subscribing to 12 | events, and release event handlers. 13 | 14 | Build and Run 15 | ------------- 16 | 17 | To build and run the sample, type the following three commands: 18 | 19 | `dotnet restore` 20 | `dotnet build` 21 | `dotnet run` 22 | 23 | `dotnet restore` installs all the dependencies for this sample into the current directory. 24 | `dotnet build` creates the output assembly (or assemblies). 25 | `dotnet run` runs the output assembly. 26 | -------------------------------------------------------------------------------- /samples/linq/csharp/grouping/AnagramEqualityComparer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Grouping 5 | { 6 | //Comparer that matches words that are anagrams of each other. 7 | public class AnagramEqualityComparer : IEqualityComparer 8 | { 9 | public bool Equals(string x, string y) 10 | { 11 | return getCanonicalString(x) == getCanonicalString(y); 12 | } 13 | 14 | public int GetHashCode(string obj) 15 | { 16 | return getCanonicalString(obj).GetHashCode(); 17 | } 18 | 19 | private string getCanonicalString(string word) 20 | { 21 | char[] wordChars = word.ToCharArray(); 22 | Array.Sort(wordChars); 23 | return new string(wordChars); 24 | } 25 | } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /samples/csharp-language/expression-trees/ExpressionTreeInterpretingSampleFour.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Linq.Expressions; 4 | 5 | using ExpressionVisitor; 6 | 7 | namespace ExpressionTreeSamples 8 | { 9 | public class ExpressionTreeInterpretingSampleFour : Sample 10 | { 11 | public override string Name { get; } = "Interpreting Expression Trees, Sample 4: Method Calls and Conditionals"; 12 | 13 | public override void Run() 14 | { 15 | Expression> factorial = (n) => 16 | n == 0 ? 17 | 1 : 18 | Enumerable.Range(1, n).Aggregate((product, factor) => product * factor); 19 | 20 | var visitor = Visitor.CreateFromExpression(factorial); 21 | visitor.Visit(""); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /samples/core-projects/console-apps/Hello/README.md: -------------------------------------------------------------------------------- 1 | Hello Sample 2 | ================ 3 | 4 | This sample is part of the [step-by-step tutorial](https://docs.microsoft.com/dotnet/core/tutorials/using-with-xplat-cli.md) 5 | for creating .NET Core Console Applications. Please see that topic for detailed steps on the code 6 | for this sample. 7 | 8 | Key Features 9 | ------------ 10 | 11 | This is the basic Hello World sample. It demonstrates the basics of the environment. 12 | 13 | Build and Run 14 | ------------- 15 | 16 | To build and run the sample, type the following three commands: 17 | 18 | `dotnet restore` 19 | `dotnet build` 20 | `dotnet run` 21 | 22 | `dotnet restore` installs all the dependencies for this sample into the current directory. 23 | `dotnet build` creates the output assembly (or assemblies). 24 | `dotnet run` runs the output assembly. 25 | -------------------------------------------------------------------------------- /samples/csharp-language/console-teleprompter/config.cs: -------------------------------------------------------------------------------- 1 | using static System.Math; 2 | 3 | namespace TeleprompterConsole 4 | { 5 | internal class TelePrompterConfig 6 | { 7 | private object lockHandle = new object(); 8 | public int DelayInMilliseconds { get; private set; } = 200; 9 | 10 | public void UpdateDelay(int increment) // negative to speed up 11 | { 12 | var newDelay = Min(DelayInMilliseconds + increment, 1000); 13 | newDelay = Max(newDelay, 20); 14 | lock (lockHandle) 15 | { 16 | DelayInMilliseconds = newDelay; 17 | } 18 | } 19 | 20 | public bool Done => done; 21 | 22 | private bool done; 23 | 24 | public void SetDone() 25 | { 26 | done = true; 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /samples/linq/csharp/aggregate/Aggregate-Sample-2.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System; 3 | 4 | namespace Aggregate 5 | { 6 | public static class AggregateSample2 7 | { 8 | //This sample uses Aggregate to create a running account balance that subtracts each 9 | // withdrawal from the initial balance of 100, as long as the balance never drops below 0. 10 | //Output: 11 | // Ending balance: 20 12 | public static void MethodSyntaxExample() 13 | { 14 | double startBalance = 100.0; 15 | 16 | int[] attemptedWithdrawals = { 20, 10, 40, 50, 10, 70, 30 }; 17 | 18 | double endBalance = 19 | attemptedWithdrawals.Aggregate(startBalance, 20 | (balance, nextWithdrawal) => 21 | ((nextWithdrawal <= balance) ? (balance - nextWithdrawal) : balance)); 22 | 23 | Console.WriteLine($"Ending balance: {endBalance}"); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /samples/linq/csharp/partitioning/Skip-Sample-1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Partitioning 5 | { 6 | public static class SkipSample1 7 | { 8 | //This sample uses Skip to get all but the first four elements of the array. 9 | // 10 | //Output: 11 | // All but first 4 numbers: 12 | // 9 13 | // 8 14 | // 6 15 | // 7 16 | // 2 17 | // 0 18 | public static void Example() 19 | { 20 | int[] numbers = {5, 4, 1, 3, 9, 8, 6, 7, 2, 0}; 21 | 22 | var allButFirst4Numbers = numbers.Skip(4); 23 | 24 | Console.WriteLine("All but first 4 numbers:"); 25 | foreach (var n in allButFirst4Numbers) 26 | { 27 | Console.WriteLine(n); 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /samples/linq/csharp/equality/SequenceEqual-Comparer-Sample-3.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Equality 5 | { 6 | //This sample uses SequenceEqual and with a custom comparer to do a 7 | // case-insensitive comparison of the words in an array. 8 | //Outputs to the console: 9 | // The sequences match: True 10 | public class SequenceEqualComparer1 11 | { 12 | public static void MethodSyntaxExample() 13 | { 14 | var wordsA = new string[] { "cherry", "apple", "blueberrY" }; 15 | var wordsB = new string[] { "cherry", "Apple", "Blueberry" }; 16 | 17 | bool match = wordsA.SequenceEqual(wordsB, new CaseInsensitiveComparer()); //See CaseInsensitiveComparer.cs 18 | 19 | Console.WriteLine("The sequences match: {0}", match); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /samples/csharp-language/expression-trees/ExpressionTreeClassesSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Linq.Expressions; 4 | 5 | namespace ExpressionTreeSamples 6 | { 7 | public class ExpressionTreeClassesSampleOne : Sample 8 | { 9 | public override string Name { get; } = "Expression Tree Classes, Sample 1"; 10 | 11 | public override void Run() 12 | { 13 | Expression> addFive = (num) => num + 5; 14 | 15 | if (addFive.NodeType == ExpressionType.Lambda) 16 | { 17 | var lambdaExp = (LambdaExpression)addFive; 18 | 19 | var parameter = lambdaExp.Parameters.First(); 20 | 21 | Console.WriteLine(parameter.Name); 22 | Console.WriteLine(parameter.Type); 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /samples/csharp-language/delegates-and-events/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DelegatesAndEvents 4 | { 5 | public class Program 6 | { 7 | public static void LogToConsole(string message) 8 | { 9 | Console.Error.WriteLine(message); 10 | } 11 | 12 | public static void Main(string[] args) 13 | { 14 | Logger.WriteMessage += LogToConsole; 15 | var file = new FileLogger("log.txt"); 16 | 17 | Logger.LogMessage(Severity.Warning, "Console", "This is a warning message"); 18 | 19 | Logger.LogMessage(Severity.Information, "Console", "Information message one"); 20 | Logger.LogLevel = Severity.Information; 21 | 22 | Logger.LogMessage(Severity.Information, "Console", "Information message two"); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /samples/csharp-language/iterators/README.md: -------------------------------------------------------------------------------- 1 | C# Iterators Sample 2 | ================ 3 | 4 | This sample is created during the [Iterators topic](https://docs.microsoft.com/dotnet/csharp/iterators.html) 5 | for learning C# features. Please see that topic for detailed steps on the code 6 | for this sample. 7 | 8 | Key Features 9 | ------------ 10 | 11 | This sample demonstrates iterating across a data source, and creating 12 | iterator methods to control how a data source is visited (or iterated). 13 | 14 | Build and Run 15 | ------------- 16 | 17 | To build and run the sample, type the following three commands: 18 | 19 | `dotnet restore` 20 | `dotnet build` 21 | `dotnet run` 22 | 23 | `dotnet restore` installs all the dependencies for this sample into the current directory. 24 | `dotnet build` creates the output assembly (or assemblies). 25 | `dotnet run` runs the output assembly. 26 | -------------------------------------------------------------------------------- /samples/linq/csharp/setoperators/Program.cs: -------------------------------------------------------------------------------- 1 | namespace SetOperators 2 | { 3 | public class Program 4 | { 5 | //Entry point of application 6 | public void Main(string[] args) 7 | { 8 | //Invoke the linq set operator examples within the project 9 | SetDistinct1.MethodSyntaxExample(); 10 | 11 | SetDistinct2.QuerySyntaxExample(); 12 | SetDistinct2.MethodSyntaxExample(); 13 | 14 | SetUnion1.MethodSyntaxExample(); 15 | 16 | SetUnion2.MethodSyntaxExample(); 17 | 18 | SetIntersect1.MethodSyntaxExample(); 19 | 20 | SetIntersect2.MethodSyntaxExample(); 21 | 22 | SetExcept1.MethodSyntaxExample(); 23 | 24 | SetExcept2.MethodSyntaxExample(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /samples/csharp-language/indexers/README.md: -------------------------------------------------------------------------------- 1 | C# Indexers Sample 2 | ================ 3 | 4 | This sample is created during the [Indexers](https://docs.microsoft.com/dotnet/csharp/indexers.html) 5 | for learning C# features. Please see that topic for detailed steps on the code 6 | for this sample. 7 | 8 | Key Features 9 | ------------ 10 | 11 | This sample contains for different samples involving 12 | indexers. You'll learn different C# idioms where indexers can be 13 | used to expression your design intent. 14 | 15 | Build and Run 16 | ------------- 17 | 18 | To build and run the sample, type the following three commands: 19 | 20 | `dotnet restore` 21 | `dotnet build` 22 | `dotnet run` 23 | 24 | `dotnet restore` installs all the dependencies for this sample into the current directory. 25 | `dotnet build` creates the output assembly (or assemblies). 26 | `dotnet run` runs the output assembly. 27 | -------------------------------------------------------------------------------- /samples/linq/csharp/conversion/ToDictionary-Sample-1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Conversion 5 | { 6 | public static class ToDictionarySample1 7 | { 8 | //This sample uses ToDictionary to immediately evaluate a sequence and a 9 | //related key expression into a dictionary. 10 | // 11 | //Output: 12 | //Bob's score: 40 13 | public static void Example() 14 | { 15 | var scoreRecords = new[] 16 | { 17 | new {Name = "Alice", Score = 50}, 18 | new {Name = "Bob", Score = 40}, 19 | new {Name = "Cathy", Score = 45} 20 | }; 21 | 22 | var scoreRecordsDict = scoreRecords.ToDictionary(sr => sr.Name); 23 | 24 | Console.WriteLine($"Bob's score: {scoreRecordsDict["Bob"].Score}"); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /docs/core/tools/global-json.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Global.json reference 3 | description: Global.json reference 4 | keywords: .NET, .NET Core 5 | author: aL3891 6 | manager: wpickett 7 | ms.date: 06/20/2016 8 | ms.topic: article 9 | ms.prod: .net-core 10 | ms.technology: .net-core-technologies 11 | ms.devlang: dotnet 12 | ms.assetid: e1ac9659-425f-4486-a376-c12ca942ead8 13 | --- 14 | 15 | # Global.json reference 16 | 17 | * [projects/sources](#projects) 18 | * [packages](#packages) 19 | 20 | 21 | ## projects 22 | Type: String[] 23 | 24 | Specifies what folders the build system should search for projects when resolving dependencies. The build system will only search top level child folders. 25 | 26 | 27 | ## packages 28 | Type: String[] 29 | 30 | The folder to store packages. 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /samples/csharp-language/console-teleprompter/README.md: -------------------------------------------------------------------------------- 1 | C# Console Application Sample 2 | ================ 3 | 4 | This sample is created during the [Console Application Tutorial](https://docs.microsoft.com/dotnet/tutorials/getting-started-with-csharp/console-teleprompter.html) 5 | for learning C# features. Please see that topic for detailed steps on the code 6 | for this sample. 7 | 8 | Key Features 9 | ------------ 10 | 11 | This sample demonstrates File I/O, async features, and terminal input and output. 12 | 13 | Build and Run 14 | ------------- 15 | 16 | To build and run the sample, type the following three commands: 17 | 18 | `dotnet restore` 19 | `dotnet build` 20 | `dotnet run` 21 | 22 | `dotnet restore` installs all the dependencies for this sample into the current directory. 23 | `dotnet build` creates the output assembly (or assemblies). 24 | `dotnet run` runs the output assembly. 25 | -------------------------------------------------------------------------------- /samples/csharp-language/console-linq/README.md: -------------------------------------------------------------------------------- 1 | C# LINQ Sample 2 | ================ 3 | 4 | This sample is created during the [Working with LINQ tutorial](https://docs.microsoft.com/dotnet/tutorials/getting-started-with-csharp/working-with-linq.html) 5 | for learning C# features. Please see that topic for detailed steps on the code 6 | for this sample. 7 | 8 | Key Features 9 | ------------ 10 | 11 | This sample demonstrates querying data sources and processing them using 12 | Language Integrated Query (LINQ) in C#. 13 | 14 | Build and Run 15 | ------------- 16 | 17 | To build and run the sample, type the following three commands: 18 | 19 | `dotnet restore` 20 | `dotnet build` 21 | `dotnet run` 22 | 23 | `dotnet restore` installs all the dependencies for this sample into the current directory. 24 | `dotnet build` creates the output assembly (or assemblies). 25 | `dotnet run` runs the output assembly. 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | .NET Core Documentation 2 | ======================= 3 | 4 | This repo contains work-in-progress documentation for .NET Core. Please see the [Contributing Guide](CONTRIBUTING.md) to get set up and take a look at our [issues list](https://github.com/dotnet/core-docs/issues). 5 | 6 | We very much welcome contributions to help us provide a complete set of .NET Core docs sooner. Feel free to use (copy/paste) documentation from [.NET Framework docs](https://msdn.microsoft.com/library/w0x726c2.aspx) as a starting point for .NET Core docs. We will likely port higher-quality .NET Core content to the .NET Framework docs, such that investments in this repo have a broader impact than .NET Core users. We expect that [Xamarin](http://developer.xamarin.com/api/root/classlib/), [Mono](http://docs.go-mono.com/?link=root%3a%2fclasslib) and [Unity](http://docs.unity3d.com/Manual/index.html) will also use this documentation. 7 | -------------------------------------------------------------------------------- /docs/csharp/syntax.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Syntax 3 | description: Syntax 4 | keywords: .NET, .NET Core 5 | author: dotnet-bot 6 | manager: wpickett 7 | ms.date: 06/20/2016 8 | ms.topic: article 9 | ms.prod: .net-core 10 | ms.technology: .net-core-technologies 11 | ms.devlang: dotnet 12 | ms.assetid: 901184ac-1370-40b0-ad57-1f674890befe 13 | --- 14 | 15 | # 🔧 Syntax 16 | 17 | > **Note** 18 | > 19 | > This topic hasn’t been written yet! 20 | > 21 | > We welcome your input to help shape the scope and approach. You can track the status and provide input on this 22 | > [issue](https://github.com/dotnet/core-docs/issues/485) at GitHub. 23 | > 24 | > If you would like to review early drafts and outlines of this topic, please leave a note with your contact information in the issue. 25 | > 26 | > Learn more about how you can contribute on [GitHub](https://github.com/dotnet/core-docs/blob/master/CONTRIBUTING.md). 27 | > 28 | -------------------------------------------------------------------------------- /docs/csharp/generics.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Generics 3 | description: Generics 4 | keywords: .NET, .NET Core 5 | author: dotnet-bot 6 | manager: wpickett 7 | ms.date: 06/20/2016 8 | ms.topic: article 9 | ms.prod: .net-core 10 | ms.technology: .net-core-technologies 11 | ms.devlang: dotnet 12 | ms.assetid: 63d1fe21-bb1f-46e3-92a0-89efcf0815e8 13 | --- 14 | 15 | # 🔧 Generics 16 | 17 | > **Note** 18 | > 19 | > This topic hasn’t been written yet! 20 | > 21 | > We welcome your input to help shape the scope and approach. You can track the status and provide input on this 22 | > [issue](https://github.com/dotnet/core-docs/issues/489) at GitHub. 23 | > 24 | > If you would like to review early drafts and outlines of this topic, please leave a note with your contact information in the issue. 25 | > 26 | > Learn more about how you can contribute on [GitHub](https://github.com/dotnet/core-docs/blob/master/CONTRIBUTING.md). 27 | > 28 | -------------------------------------------------------------------------------- /docs/csharp/concepts.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: C# Concepts 3 | description: C# Concepts 4 | keywords: .NET, .NET Core 5 | author: dotnet-bot 6 | manager: wpickett 7 | ms.date: 06/24/2016 8 | ms.topic: article 9 | ms.prod: .net-core 10 | ms.technology: .net-core-technologies 11 | ms.devlang: dotnet 12 | ms.assetid: 809148dd-b231-4f2c-bb81-f5bfc426378d 13 | --- 14 | 15 | # 🔧 C# Concepts 16 | 17 | > **Note** 18 | > 19 | > This topic hasn’t been written yet! 20 | > 21 | > We welcome your input to help shape the scope and approach. You can track the status and provide input on this 22 | > [issue](https://github.com/dotnet/core-docs/issues/608) at GitHub. 23 | > 24 | > If you would like to review early drafts and outlines of this topic, please leave a note with your contact information in the issue. 25 | > 26 | > Learn more about how you can contribute on [GitHub](https://github.com/dotnet/core-docs/blob/master/CONTRIBUTING.md). 27 | > -------------------------------------------------------------------------------- /samples/csharp-language/expression-trees/GotoVisitor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq.Expressions; 3 | 4 | namespace ExpressionVisitor 5 | { 6 | public class GoToVisitor : Visitor 7 | { 8 | private readonly GotoExpression node; 9 | public GoToVisitor(GotoExpression node) : base(node) 10 | { 11 | this.node = node; 12 | } 13 | 14 | public override void Visit(string prefix) 15 | { 16 | Console.WriteLine($"{prefix}This expression is a {NodeType} expression"); 17 | Console.WriteLine($"{prefix}THe kind of GoTo is: {node.Kind}"); 18 | 19 | Console.WriteLine($"{prefix}The target is {node.Target.Name}"); 20 | Console.WriteLine($"{prefix}The value of the goto is:"); 21 | var visitor = Visitor.CreateFromExpression(node.Value); 22 | visitor.Visit(prefix + "\t"); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /samples/core-projects/console-apps/Fibonacci/Program.cs: -------------------------------------------------------------------------------- 1 | using static System.Console; 2 | 3 | namespace ConsoleApplication 4 | { 5 | public class Program 6 | { 7 | public static int FibonacciNumber(int n) 8 | { 9 | int a = 0; 10 | int b = 1; 11 | int tmp; 12 | 13 | for (int i = 0; i < n; i++) 14 | { 15 | tmp = a; 16 | a = b; 17 | b += tmp; 18 | } 19 | 20 | return a; 21 | } 22 | 23 | public static void Main(string[] args) 24 | { 25 | WriteLine("Hello World!"); 26 | WriteLine("Fibonacci Numbers 1-15:"); 27 | 28 | for (int i = 0; i < 15; i++) 29 | { 30 | WriteLine($"{i+1}: {FibonacciNumber(i)}"); 31 | } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /samples/core-projects/console-apps/Fibonacci/README.md: -------------------------------------------------------------------------------- 1 | Fibonacci Sample 2 | ================ 3 | 4 | This sample is part of the [step-by-step tutorial](https://docs.microsoft.com/dotnet/core/tutorials/using-with-xplat-cli.html) 5 | for creating .NET Core Console Applications. Please see that topic for detailed steps on the code 6 | for this sample. 7 | 8 | Key Features 9 | ------------ 10 | 11 | This sample demonstrates adding code into an existing project after its been configured for building 12 | a native application on multiple platforms. 13 | 14 | Build and Run 15 | ------------- 16 | 17 | To build and run the sample, type the following three commands: 18 | 19 | `dotnet restore` 20 | `dotnet build` 21 | `dotnet run` 22 | 23 | `dotnet restore` installs all the dependencies for this sample into the current directory. 24 | `dotnet build` creates the output assembly (or assemblies). 25 | `dotnet run` runs the output assembly. 26 | -------------------------------------------------------------------------------- /docs/csharp/type-system.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: C# Type system 3 | description: C# Type system 4 | keywords: .NET, .NET Core 5 | author: dotnet-bot 6 | manager: wpickett 7 | ms.date: 06/20/2016 8 | ms.topic: article 9 | ms.prod: .net-core 10 | ms.technology: .net-core-technologies 11 | ms.devlang: dotnet 12 | ms.assetid: 08589912-2fa0-4636-9aa6-d8b2b83cdf88 13 | --- 14 | 15 | # 🔧 C# Type system 16 | 17 | > **Note** 18 | > 19 | > This topic hasn’t been written yet! 20 | > 21 | > We welcome your input to help shape the scope and approach. You can track the status and provide input on this 22 | > [issue](https://github.com/dotnet/core-docs/issues/487) at GitHub. 23 | > 24 | > If you would like to review early drafts and outlines of this topic, please leave a note with your contact information in the issue. 25 | > 26 | > Learn more about how you can contribute on [GitHub](https://github.com/dotnet/core-docs/blob/master/CONTRIBUTING.md). 27 | > 28 | -------------------------------------------------------------------------------- /samples/core-projects/console-apps/FibonacciBetter/README.md: -------------------------------------------------------------------------------- 1 | Better Fibonacci Sample 2 | ================ 3 | 4 | This sample is part of the [step-by-step tutorial](https://docs.microsoft.com/dotnet/core/tutorials/using-with-xplat-cli.html) 5 | for creating .NET Core Console Applications. Please see that topic for detailed steps on the code 6 | for this sample. 7 | 8 | Key Features 9 | ------------ 10 | 11 | This sample demonstrates a multiple source file project, adding recursion and caching previous 12 | results to the initial Fibonacci sample. 13 | 14 | Build and Run 15 | ------------- 16 | 17 | To build and run the sample, type the following three commands: 18 | 19 | `dotnet restore` 20 | `dotnet build` 21 | `dotnet run` 22 | 23 | `dotnet restore` installs all the dependencies for this sample into the current directory. 24 | `dotnet build` creates the output assembly (or assemblies). 25 | `dotnet run` runs the output assembly. 26 | -------------------------------------------------------------------------------- /samples/csharp-language/delegates-and-events/README.md: -------------------------------------------------------------------------------- 1 | C# Delegates and EVents Sample 2 | ================ 3 | 4 | This sample is created during the [Delegates and Events topic](https://docs.microsoft.com/dotnet/csharp/delegates-and-events.html) 5 | for learning C# features. Please see that topic for detailed steps on the code 6 | for this sample. 7 | 8 | Key Features 9 | ------------ 10 | 11 | This sample demonstrates defining delegate types, creating 12 | lambda expressions that map to delegates, and using single and 13 | using multicast delegates. 14 | 15 | Build and Run 16 | ------------- 17 | 18 | To build and run the sample, type the following three commands: 19 | 20 | `dotnet restore` 21 | `dotnet build` 22 | `dotnet run` 23 | 24 | `dotnet restore` installs all the dependencies for this sample into the current directory. 25 | `dotnet build` creates the output assembly (or assemblies). 26 | `dotnet run` runs the output assembly. 27 | -------------------------------------------------------------------------------- /samples/linq/csharp/partitioning/TakeWhile-Sample-1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Partitioning 5 | { 6 | public static class TakeWhileSample1 7 | { 8 | //This sample uses TakeWhile to return elements starting from the beginning of the array 9 | //until a number is read whose value is not less than 6. 10 | // 11 | //Output: 12 | // First numbers less than 6: 13 | // 5 14 | // 4 15 | // 1 16 | // 3 17 | public static void Example() 18 | { 19 | int[] numbers = {5, 4, 1, 3, 9, 8, 6, 7, 2, 0}; 20 | 21 | var firstNumbersLessThan6 = numbers.TakeWhile(n => n < 6); 22 | 23 | Console.WriteLine("First numbers less than 6:"); 24 | foreach (var num in firstNumbersLessThan6) 25 | { 26 | Console.WriteLine(num); 27 | } 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /samples/linq/csharp/setoperators/Set-Intersect-Sample-1.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System; 3 | 4 | namespace SetOperators 5 | { 6 | public class SetIntersect1 7 | { 8 | //This sample uses Intersect to create one sequence that contains 9 | // the common values shared by both arrays. 10 | //Outputs the following to Console 11 | //Common numbers shared by both arrays: 12 | // 5 13 | // 8 14 | public static void MethodSyntaxExample() 15 | { 16 | int[] numbersA = { 0, 2, 4, 5, 6, 8, 9 }; 17 | int[] numbersB = { 1, 3, 5, 7, 8 }; 18 | 19 | var commonNumbers = numbersA.Intersect(numbersB); 20 | 21 | Console.WriteLine("Common numbers shared by both arrays:"); 22 | foreach (var n in commonNumbers) 23 | { 24 | Console.WriteLine(n); 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /samples/csharp-language/expression-trees/BinaryVisitor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq.Expressions; 3 | 4 | namespace ExpressionVisitor 5 | { 6 | public class BinaryVisitor : Visitor 7 | { 8 | private readonly BinaryExpression node; 9 | public BinaryVisitor(BinaryExpression node) : base(node) 10 | { 11 | this.node = node; 12 | } 13 | 14 | public override void Visit(string prefix) 15 | { 16 | Console.WriteLine($"{prefix}This binary expression is a {NodeType} expression"); 17 | var left = Visitor.CreateFromExpression(node.Left); 18 | Console.WriteLine($"{prefix}The Left argument is:"); 19 | left.Visit(prefix + "\t"); 20 | var right = Visitor.CreateFromExpression(node.Right); 21 | Console.WriteLine($"{prefix}The Right argument is:"); 22 | right.Visit(prefix + "\t"); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /docs/csharp/features.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Features at a glance 3 | description: Features at a glance 4 | keywords: .NET, .NET Core 5 | author: dotnet-bot 6 | manager: wpickett 7 | ms.date: 06/20/2016 8 | ms.topic: article 9 | ms.prod: .net-core 10 | ms.technology: .net-core-technologies 11 | ms.devlang: dotnet 12 | ms.assetid: ebc727cd-8112-42e7-b59c-3c2873ad661c 13 | --- 14 | 15 | # 🔧 Features at a glance 16 | 17 | > **Note** 18 | > 19 | > This topic hasn’t been written yet! 20 | > 21 | > We welcome your input to help shape the scope and approach. You can track the status and provide input on this 22 | > [issue](https://github.com/dotnet/core-docs/issues/486) at GitHub. 23 | > 24 | > If you would like to review early drafts and outlines of this topic, please leave a note with your contact information in the issue. 25 | > 26 | > Learn more about how you can contribute on [GitHub](https://github.com/dotnet/core-docs/blob/master/CONTRIBUTING.md). 27 | > 28 | -------------------------------------------------------------------------------- /docs/csharp/parallel.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Parallel programming 3 | description: Parallel programming 4 | keywords: .NET, .NET Core 5 | author: dotnet-bot 6 | manager: wpickett 7 | ms.date: 06/20/2016 8 | ms.topic: article 9 | ms.prod: .net-core 10 | ms.technology: .net-core-technologies 11 | ms.devlang: dotnet 12 | ms.assetid: 8045b1b8-7835-4a7a-980d-bc9c70d62a0c 13 | --- 14 | 15 | # 🔧 Parallel programming 16 | 17 | > **Note** 18 | > 19 | > This topic hasn’t been written yet! 20 | > 21 | > We welcome your input to help shape the scope and approach. You can track the status and provide input on this 22 | > [issue](https://github.com/dotnet/core-docs/issues/491) at GitHub. 23 | > 24 | > If you would like to review early drafts and outlines of this topic, please leave a note with your contact information in the issue. 25 | > 26 | > Learn more about how you can contribute on [GitHub](https://github.com/dotnet/core-docs/blob/master/CONTRIBUTING.md). 27 | > 28 | -------------------------------------------------------------------------------- /samples/csharp-language/console-webapiclient/README.md: -------------------------------------------------------------------------------- 1 | C# REST Client Sample 2 | ================ 3 | 4 | This sample is created during the [REST client tutorial](https://docs.microsoft.com/dotnet/tutorials/getting-started-with-csharp/console-webapiclient.html) 5 | for learning C# features. Please see that topic for detailed steps on the code 6 | for this sample. 7 | 8 | Key Features 9 | ------------ 10 | 11 | This sample demonstrates making HTTP requests to a web server, using `async` 12 | and `await`, converting JSON objects into C# objects, and terminal output. 13 | 14 | Build and Run 15 | ------------- 16 | 17 | To build and run the sample, type the following three commands: 18 | 19 | `dotnet restore` 20 | `dotnet build` 21 | `dotnet run` 22 | 23 | `dotnet restore` installs all the dependencies for this sample into the current directory. 24 | `dotnet build` creates the output assembly (or assemblies). 25 | `dotnet run` runs the output assembly. 26 | -------------------------------------------------------------------------------- /samples/csharp-language/expression-trees/README.md: -------------------------------------------------------------------------------- 1 | C# Expression Trees Sample 2 | ================ 3 | 4 | This sample is created during the [Expression Trees topic](https://docs.microsoft.com/dotnet/csharp/expression-trees.html) 5 | for learning C# features. Please see that topic for detailed steps on the code 6 | for this sample. 7 | 8 | Key Features 9 | ------------ 10 | 11 | This sample demonstrates creating expression trees, parsing expression 12 | trees, and understanding the relationship between expression trees and 13 | the code you write everyday in C#. 14 | 15 | Build and Run 16 | ------------- 17 | 18 | To build and run the sample, type the following three commands: 19 | 20 | `dotnet restore` 21 | `dotnet build` 22 | `dotnet run` 23 | 24 | `dotnet restore` installs all the dependencies for this sample into the current directory. 25 | `dotnet build` creates the output assembly (or assemblies). 26 | `dotnet run` runs the output assembly. 27 | -------------------------------------------------------------------------------- /docs/csharp/codedoc.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Documenting your code 3 | description: Documenting your code 4 | keywords: .NET, .NET Core 5 | author: dotnet-bot 6 | manager: wpickett 7 | ms.date: 06/20/2016 8 | ms.topic: article 9 | ms.prod: .net-core 10 | ms.technology: .net-core-technologies 11 | ms.devlang: dotnet 12 | ms.assetid: 8e75e317-4a55-45f2-a866-e76124171838 13 | --- 14 | 15 | # 🔧 Documenting your code 16 | 17 | > **Note** 18 | > 19 | > This topic hasn’t been written yet! 20 | > 21 | > We welcome your input to help shape the scope and approach. You can track the status and provide input on this 22 | > [issue](https://github.com/dotnet/core-docs/issues/494) at GitHub. 23 | > 24 | > If you would like to review early drafts and outlines of this topic, please leave a note with your contact information in the issue. 25 | > 26 | > Learn more about how you can contribute on [GitHub](https://github.com/dotnet/core-docs/blob/master/CONTRIBUTING.md). 27 | > 28 | -------------------------------------------------------------------------------- /docs/csharp/lambda-expressions.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Lambda Expressions 3 | description: Lambda Expressions 4 | keywords: .NET, .NET Core 5 | author: dotnet-bot 6 | manager: wpickett 7 | ms.date: 06/20/2016 8 | ms.topic: article 9 | ms.prod: .net-core 10 | ms.technology: .net-core-technologies 11 | ms.devlang: dotnet 12 | ms.assetid: b6a0539a-8ce5-4da7-adcf-44be345a2714 13 | --- 14 | 15 | # 🔧 Lambda Expressions 16 | 17 | > **Note** 18 | > 19 | > This topic hasn’t been written yet! 20 | > 21 | > We welcome your input to help shape the scope and approach. You can track the status and provide input on this 22 | > [issue](https://github.com/dotnet/core-docs/issues/488) at GitHub. 23 | > 24 | > If you would like to review early drafts and outlines of this topic, please leave a note with your contact information in the issue. 25 | > 26 | > Learn more about how you can contribute on [GitHub](https://github.com/dotnet/core-docs/blob/master/CONTRIBUTING.md). 27 | > 28 | -------------------------------------------------------------------------------- /samples/csharp-language/indexers/SampleThree/Mandelbrot.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace IndexersSamples.SampleThree 3 | { 4 | public class Mandelbrot 5 | { 6 | readonly private int maxIterations; 7 | 8 | public Mandelbrot(int maxIterations) 9 | { 10 | this.maxIterations = maxIterations; 11 | } 12 | 13 | public int this [double x, double y] 14 | { 15 | get 16 | { 17 | var iterations = 0; 18 | var x0 = x; 19 | var y0 = y; 20 | 21 | while ((x*x + y * y < 4) && 22 | (iterations < maxIterations)) 23 | { 24 | var newX = x * x - y * y + x0; 25 | y = 2 * x * y + y0; 26 | x = newX; 27 | iterations++; 28 | } 29 | return iterations; 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /samples/linq/csharp/partitioning/TakeWhile-Sample-2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Partitioning 5 | { 6 | public static class TakeWhileSample2 7 | { 8 | //This sample uses TakeWhile to return elements starting from the beginning of the array 9 | //until a number is hit that is less than its position in the array. 10 | // 11 | //Output: 12 | // First numbers not less than their position: 13 | // 5 14 | // 4 15 | public static void Example() 16 | { 17 | int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 }; 18 | 19 | var firstSmallNumbers = numbers.TakeWhile((n, index) => n >= index); 20 | 21 | Console.WriteLine("First numbers not less than their position:"); 22 | foreach (var n in firstSmallNumbers) 23 | { 24 | Console.WriteLine(n); 25 | } 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /docs/csharp/interop.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Native interoperability 3 | description: Native interoperability 4 | keywords: .NET, .NET Core 5 | author: dotnet-bot 6 | manager: wpickett 7 | ms.date: 06/20/2016 8 | ms.topic: article 9 | ms.prod: .net-core 10 | ms.technology: .net-core-technologies 11 | ms.devlang: dotnet 12 | ms.assetid: 54485caa-09e0-466c-86fa-6a9aab6c332b 13 | --- 14 | 15 | # 🔧 Native interoperability 16 | 17 | > **Note** 18 | > 19 | > This topic hasn’t been written yet! 20 | > 21 | > We welcome your input to help shape the scope and approach. You can track the status and provide input on this 22 | > [issue](https://github.com/dotnet/core-docs/issues/492) at GitHub. 23 | > 24 | > If you would like to review early drafts and outlines of this topic, please leave a note with your contact information in the issue. 25 | > 26 | > Learn more about how you can contribute on [GitHub](https://github.com/dotnet/core-docs/blob/master/CONTRIBUTING.md). 27 | > 28 | -------------------------------------------------------------------------------- /samples/csharp-language/expression-trees/LoopVisitor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq.Expressions; 3 | 4 | namespace ExpressionVisitor 5 | { 6 | public class LoopVisitor : Visitor 7 | { 8 | private readonly LoopExpression node; 9 | public LoopVisitor(LoopExpression node) : base(node) 10 | { 11 | this.node = node; 12 | } 13 | 14 | public override void Visit(string prefix) 15 | { 16 | Console.WriteLine($"{prefix}This expression is a {NodeType} expression"); 17 | 18 | Console.WriteLine($"{prefix}Continue Target is: {node.ContinueLabel?.Name ?? ""}"); 19 | Console.WriteLine($"{prefix}Break Target is: {node.BreakLabel.Name ?? ""}"); 20 | 21 | Console.WriteLine($"{prefix}Body is:"); 22 | var bodyVisitor = Visitor.CreateFromExpression(node.Body); 23 | bodyVisitor.Visit(prefix+"\t"); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /samples/linq/csharp/ordering/OrderBy-Comparer-Sample-1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Ordering 5 | { 6 | public class OrderByComparer1 7 | { 8 | //This sample uses an OrderBy clause with a custom comparer to do a case-insensitive sort of the words in an array. 9 | //Outputs to the console: 10 | // AbAcUs 11 | // aPPLE 12 | // BlUeBeRrY 13 | // bRaNcH 14 | // cHeRry 15 | // ClOvEr 16 | public static void MethodSyntaxExample() 17 | { 18 | string[] words = { "aPPLE", "AbAcUs", "bRaNcH", "BlUeBeRrY", "ClOvEr", "cHeRry" }; 19 | 20 | var sortedWords = words.OrderBy(a => a, new CaseInsensitiveComparer()); //See CaseInsensitiveComparer.cs 21 | 22 | foreach (var w in sortedWords) 23 | { 24 | Console.WriteLine(w); 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /docs/csharp/reflection.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Reflection & code generation 3 | description: Reflection & code generation 4 | keywords: .NET, .NET Core 5 | author: dotnet-bot 6 | manager: wpickett 7 | ms.date: 06/20/2016 8 | ms.topic: article 9 | ms.prod: .net-core 10 | ms.technology: .net-core-technologies 11 | ms.devlang: dotnet 12 | ms.assetid: 53339c51-0fbc-4827-9de2-39c805bfc06b 13 | --- 14 | 15 | # 🔧 Reflection & code generation 16 | 17 | > **Note** 18 | > 19 | > This topic hasn’t been written yet! 20 | > 21 | > We welcome your input to help shape the scope and approach. You can track the status and provide input on this 22 | > [issue](https://github.com/dotnet/core-docs/issues/493) at GitHub. 23 | > 24 | > If you would like to review early drafts and outlines of this topic, please leave a note with your contact information in the issue. 25 | > 26 | > Learn more about how you can contribute on [GitHub](https://github.com/dotnet/core-docs/blob/master/CONTRIBUTING.md). 27 | > 28 | -------------------------------------------------------------------------------- /docs/core/versions/servicing.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: .NET Core Servicing 3 | description: .NET Core Servicing 4 | keywords: .NET, .NET Core 5 | author: dotnet-bot 6 | manager: wpickett 7 | ms.date: 06/20/2016 8 | ms.topic: article 9 | ms.prod: .net-core 10 | ms.technology: .net-core-technologies 11 | ms.devlang: dotnet 12 | ms.assetid: 48682290-4fd7-40dc-8a7b-bac528eba361 13 | --- 14 | 15 | # 🔧 .NET Core Servicing 16 | 17 | > **Note** 18 | > 19 | > This topic hasn’t been written yet! 20 | > 21 | > We welcome your input to help shape the scope and approach. You can 22 | > track the status and provide input on this 23 | > [issue](https://github.com/dotnet/core-docs/issues/469) at GitHub. 24 | > 25 | > If you would like to review early drafts and outlines of this 26 | > topic, please leave a note with your contact information in the issue. 27 | > 28 | > Learn more about how you can contribute on 29 | > [GitHub](https://github.com/dotnet/core-docs/blob/master/CONTRIBUTING.md). 30 | > 31 | -------------------------------------------------------------------------------- /docs/csharp/linq.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Language Integrated Query (LINQ) 3 | description: Language Integrated Query (LINQ) 4 | keywords: .NET, .NET Core 5 | author: dotnet-bot 6 | manager: wpickett 7 | ms.date: 06/20/2016 8 | ms.topic: article 9 | ms.prod: .net-core 10 | ms.technology: .net-core-technologies 11 | ms.devlang: dotnet 12 | ms.assetid: 007cc736-f5cf-4919-b99b-0c00ab2814ce 13 | --- 14 | 15 | # 🔧 Language Integrated Query (LINQ) 16 | 17 | > **Note** 18 | > 19 | > This topic hasn’t been written yet! 20 | > 21 | > We welcome your input to help shape the scope and approach. You can track the status and provide input on this 22 | > [issue](https://github.com/dotnet/core-docs/issues/490) at GitHub. 23 | > 24 | > If you would like to review early drafts and outlines of this topic, please leave a note with your contact information in the issue. 25 | > 26 | > Learn more about how you can contribute on [GitHub](https://github.com/dotnet/core-docs/blob/master/CONTRIBUTING.md). 27 | > 28 | -------------------------------------------------------------------------------- /samples/linq/csharp/ordering/OrderByDescending-Comparer-Sample-1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Ordering 5 | { 6 | public class OrderByDescendingComparer1 7 | { 8 | //This sample uses an OrderBy clause with a custom comparer to do a case-insensitive sort of the words in an array. 9 | //Outputs to the console: 10 | // ClOvEr 11 | // cHeRry 12 | // bRaNcH 13 | // BlUeBeRrY 14 | // aPPLE 15 | // AbAcUsr 16 | public static void MethodSyntaxExample() 17 | { 18 | string[] words = { "aPPLE", "AbAcUs", "bRaNcH", "BlUeBeRrY", "ClOvEr", "cHeRry" }; 19 | 20 | var sortedWords = words.OrderByDescending(a => a, new CaseInsensitiveComparer()); //See CaseInsensitiveComparer.cs 21 | 22 | foreach (var w in sortedWords) 23 | { 24 | Console.WriteLine(w); 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /samples/csharp-language/WeatherMicroservice/README.md: -------------------------------------------------------------------------------- 1 | C# Microservices Sample 2 | ================ 3 | 4 | This sample is created during the [Creating Microservices hosted in Docker](https://docs.microsoft.com/dotnet/tutorials/getting-started-with-csharp/microservices.html) 5 | tutorial. Please see that topic for detailed steps on the code 6 | for this sample. 7 | 8 | Key Features 9 | ------------ 10 | 11 | This sample demonstrates creating a web service using asp.net core and C# 12 | and deploying that service in a Docker Container. 13 | 14 | Build and Run 15 | ------------- 16 | 17 | To build and run the sample locally, type the following three commands: 18 | 19 | `dotnet restore` 20 | `dotnet build` 21 | `dotnet run` 22 | 23 | `dotnet restore` installs all the dependencies for this sample into the current directory. 24 | `dotnet build` creates the output assembly (or assemblies). 25 | `dotnet run` runs the output assembly. 26 | 27 | To install and run the sample in Docker, consult the [full tutorial](../microservices.md). 28 | -------------------------------------------------------------------------------- /samples/linq/csharp/ordering/ThenBy-Comparer-Sample-1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Ordering 5 | { 6 | public class ThenByComparer1 7 | { 8 | //This sample uses an OrderBy and a ThenBy clause with a custom comparer to sort 9 | // first by word length and then by a case-insensitive sort of the words in an array. 10 | //Outputs to the console: 11 | // aPPLE 12 | // AbAcUs 13 | // bRaNcH 14 | // cHeRry 15 | // ClOvEr 16 | // BlUeBeRrY 17 | public static void MethodSyntaxExample() 18 | { 19 | string[] words = { "aPPLE", "AbAcUs", "bRaNcH", "BlUeBeRrY", "ClOvEr", "cHeRry" }; 20 | 21 | var sortedWords = words.OrderBy(a => a.Length) 22 | .ThenBy(a => a, new CaseInsensitiveComparer()); 23 | 24 | foreach (var w in sortedWords) 25 | { 26 | Console.WriteLine(w); 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /samples/linq/csharp/partitioning/SkipWhile-Sample-2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Partitioning 5 | { 6 | public static class SkipWhileSample2 7 | { 8 | //This sample uses SkipWhile to get the elements of the array starting from the first element less 9 | //than its position. 10 | // 11 | //Output: 12 | // All elements starting from first element less than its position: 13 | // 1 14 | // 3 15 | // 9 16 | // 8 17 | // 6 18 | // 7 19 | // 2 20 | // 0 21 | public static void Example() 22 | { 23 | int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 }; 24 | 25 | var laterNumbers = numbers.SkipWhile((n, index) => n >= index); 26 | 27 | Console.WriteLine("All elements starting from first element less than its position:"); 28 | foreach (var n in laterNumbers) 29 | { 30 | Console.WriteLine(n); 31 | } 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /samples/csharp-language/expression-trees/ExpressionTreeInterpretingSampleThree.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq.Expressions; 3 | 4 | using ExpressionVisitor; 5 | 6 | namespace ExpressionTreeSamples 7 | { 8 | public class ExpressionTreeInterpretingSampleThree : Sample 9 | { 10 | public override string Name { get; } = "Interpreting Expression Trees, Sample 3: Building a General Visitor"; 11 | 12 | public override void Run() 13 | { 14 | Expression> addition = (a, b) => a + b; 15 | var visitor = Visitor.CreateFromExpression(addition); 16 | 17 | visitor.Visit(""); 18 | 19 | Expression> sum = (a) => 1 + a + 3 + 4; 20 | 21 | visitor = Visitor.CreateFromExpression(sum); 22 | visitor.Visit(""); 23 | 24 | Expression> sum3 = (a, b) => (1 + a) + (3 + b); 25 | 26 | visitor = Visitor.CreateFromExpression(sum3); 27 | visitor.Visit(""); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /samples/linq/csharp/setoperators/Set-Union-Sample-1.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System; 3 | 4 | namespace SetOperators 5 | { 6 | public class SetUnion1 7 | { 8 | //This sample uses Union to create one sequence that contains the unique values from both arrays. 9 | //Outputs the following to Console 10 | // Unique numbers from both arrays: 11 | // 0 12 | // 2 13 | // 4 14 | // 5 15 | // 6 16 | // 8 17 | // 9 18 | // 1 19 | // 3 20 | // 7 21 | public static void MethodSyntaxExample() 22 | { 23 | int[] numbersA = { 0, 2, 4, 5, 6, 8, 9 }; 24 | int[] numbersB = { 1, 3, 5, 7, 8 }; 25 | 26 | var uniqueNumbers = numbersA.Union(numbersB); 27 | 28 | Console.WriteLine("Unique numbers from both arrays:"); 29 | foreach (var n in uniqueNumbers) 30 | { 31 | Console.WriteLine(n); 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /samples/linq/csharp/aggregate/Count-Sample-3.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | 6 | namespace Aggregate 7 | { 8 | public static class CountSample3 9 | { 10 | //This sample uses Count to return a list of customers and how many orders each has. 11 | // 12 | //Output: 13 | // Customer Joe's Pizza has 1 order(s). 14 | // Customer Alfreds Futterkiste has 2 order(s). 15 | // Customer Around the Horn has 3 order(s). 16 | // Customer Bottom-Dollar Markets has 4 order(s). 17 | public static void Example() 18 | { 19 | List customers = Data.Customers; 20 | var orderCounts = 21 | from c in customers 22 | select new {Customer = c.CustomerName, OrderCount = c.Orders.Count()}; 23 | 24 | foreach (var item in orderCounts) 25 | { 26 | Console.WriteLine($"Customer {item.Customer} has {item.OrderCount} order(s)."); 27 | } 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /samples/linq/csharp/concatenation/Concat-Sample-1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Concatenation 5 | { 6 | public class Concat1 7 | { 8 | //This sample uses Concat to create one sequence that contains each array's values, one after the other. 9 | // Outputs to the console: 10 | // All numbers from both arrays: 11 | // 0 12 | // 2 13 | // 4 14 | // 5 15 | // 6 16 | // 8 17 | // 9 18 | // 1 19 | // 3 20 | // 5 21 | // 7 22 | // 8 23 | public static void MethodSyntaxExample() 24 | { 25 | int[] numbersA = { 0, 2, 4, 5, 6, 8, 9 }; 26 | int[] numbersB = { 1, 3, 5, 7, 8 }; 27 | 28 | var allNumbers = numbersA.Concat(numbersB); 29 | 30 | Console.WriteLine("All numbers from both arrays:"); 31 | foreach (var n in allNumbers) 32 | { 33 | Console.WriteLine(n); 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /samples/linq/csharp/setoperators/Set-Except-Sample-1.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | namespace SetOperators 6 | { 7 | public class SetExcept1 8 | { 9 | //This sample uses Except to create a sequence that contains 10 | // the values from numbersAthat are not also in numbersB. 11 | //Outputs the following to Console 12 | // Numbers in first array but not second array: 13 | // 0 14 | // 2 15 | // 4 16 | // 6 17 | // 9 18 | public static void MethodSyntaxExample() 19 | { 20 | int[] numbersA = { 0, 2, 4, 5, 6, 8, 9 }; 21 | int[] numbersB = { 1, 3, 5, 7, 8 }; 22 | 23 | IEnumerable aOnlyNumbers = numbersA.Except(numbersB); 24 | 25 | Console.WriteLine("Numbers in first array but not second array:"); 26 | foreach (var n in aOnlyNumbers) 27 | { 28 | Console.WriteLine(n); 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /samples/linq/csharp/ordering/ThenByDescending-Comparer-Sample-2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Ordering 5 | { 6 | public class ThenByDescendingComparer1 7 | { 8 | //This sample uses an OrderBy and a ThenBy clause with a custom comparer to sort first by 9 | // word length and then by a case-insensitive descending sort of the words in an array. 10 | //Outputs to the console: 11 | // aPPLE 12 | // ClOvEr 13 | // cHeRry 14 | // bRaNcH 15 | // AbAcUs 16 | // BlUeBeRrY 17 | public static void MethodSyntaxExample() 18 | { 19 | string[] words = { "aPPLE", "AbAcUs", "bRaNcH", "BlUeBeRrY", "ClOvEr", "cHeRry" }; 20 | 21 | var sortedWords = 22 | words.OrderBy(a => a.Length) 23 | .ThenByDescending(a => a, new CaseInsensitiveComparer()); //See CaseInsensitiveComparer.cs 24 | 25 | foreach (var w in sortedWords) 26 | { 27 | Console.WriteLine(w); 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /samples/csharp-language/delegates-and-events/Logger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DelegatesAndEvents 4 | { 5 | 6 | // Logger implementation two 7 | public enum Severity 8 | { 9 | Verbose, 10 | Trace, 11 | Information, 12 | Warning, 13 | Error, 14 | Critical 15 | } 16 | 17 | public static class Logger 18 | { 19 | public static Action WriteMessage; 20 | 21 | public static Severity LogLevel {get;set;} = Severity.Warning; 22 | 23 | public static void LogMessage(Severity s, string component, string msg) 24 | { 25 | if (s < LogLevel) 26 | return; 27 | 28 | var outputMsg = $"{DateTime.Now}\t{s}\t{component}\t{msg}"; 29 | // Assumes that the WriteMessage delegate must not be null: 30 | WriteMessage(outputMsg); 31 | // Alternative invoke syntax, for when the delegate 32 | // may not have any methods attached: 33 | WriteMessage?.Invoke(outputMsg); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /samples/linq/csharp/projection/Select-Sample-7.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System; 3 | namespace Projection 4 | { 5 | public class SelectSample7 6 | { 7 | //This sample uses select and query syntax to produce a sequence containing text representations of digits and 8 | //whether their length is even or odd. 9 | // 10 | //Outputs: 11 | // Number: In-place? 12 | // 5: False 13 | // 4: False 14 | // 1: False 15 | // 3: True 16 | // 9: False 17 | // 8: False 18 | // 6: True 19 | // 7: True 20 | // 2: False 21 | // 0: False 22 | public static void Example() 23 | { 24 | int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 }; 25 | 26 | var numsInPlace = numbers.Select((num, index) => new { Num = num, InPlace = (num == index) }); 27 | 28 | Console.WriteLine("Number: In-place?"); 29 | foreach (var n in numsInPlace) 30 | { 31 | Console.WriteLine($"{n.Num}: {n.InPlace}"); 32 | } 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /samples/csharp-language/delegates-and-events/FileLogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | namespace DelegatesAndEvents 5 | { 6 | public class FileLogger 7 | { 8 | private readonly string logPath; 9 | public FileLogger(string path) 10 | { 11 | logPath = path; 12 | Logger.WriteMessage += LogMessage; 13 | } 14 | 15 | public void DetachLog() => Logger.WriteMessage -= LogMessage; 16 | // make sure this can't throw. 17 | private void LogMessage(string msg) 18 | { 19 | try { 20 | using (var log = File.AppendText(logPath)) 21 | { 22 | log.WriteLine(msg); 23 | log.Flush(); 24 | } 25 | } catch (Exception e) 26 | { 27 | // Hmm. We caught an exception while 28 | // logging. We can't really log the 29 | // problem (since it's the log that's failing). 30 | // So, while normally, catching an exception 31 | // and doing nothing isn't wise, it's really the 32 | // only reasonable option here. 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /docs/csharp/tutorials/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: C# Tutorials 3 | description: C# Tutorials 4 | keywords: .NET, .NET Core 5 | author: BillWagner 6 | manager: wpickett 7 | ms.date: 06/20/2016 8 | ms.topic: article 9 | ms.prod: .net-core 10 | ms.technology: .net-core-technologies 11 | ms.devlang: dotnet 12 | ms.assetid: fcc83b5b-fb68-4e48-9132-0882677d8056 13 | --- 14 | 15 | # C# Tutorials 16 | 17 | These exercises enable you to build C# programs using core CLR. 18 | 19 | * [Console Application](console-teleprompter.md). This tutorial 20 | demonstrates Console I/O, the structure of a Console application, and 21 | the basics of the Task based asynchronous programming model. 22 | * [REST Client](console-webapiclient.md). This tutorial 23 | demonstrates web communications, JSON serialization, and Object Oriented 24 | features in the C# language. 25 | * [Working with LINQ](working-with-linq.md) This tutorial demonstrates many of the features of LINQ and the language elements that support it. 26 | 27 | * [Microservices hosted in Docker](microservices.md) This tutorial demonstrates building an asp.net core microservice and hosting it it Docker. 28 | -------------------------------------------------------------------------------- /samples/linq/csharp/restriction/Where-Sample-4.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System; 3 | namespace Restriction 4 | { 5 | //This sample demonstrates an indexed where clause that returns digits whose name is 6 | //shorter than their value. 7 | //Outputs the following to Console 8 | // 9 | // Short digits: 10 | // The word five is shorter than its value. 11 | // The word six is shorter than its value. 12 | // The word seven is shorter than its value. 13 | // The word eight is shorter than its value. 14 | // The word nine is shorter than its value. 15 | public class WhereClause4 16 | { 17 | public static void Example() 18 | { 19 | string[] digits = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }; 20 | 21 | var shortDigits = digits.Where((digit, index) => digit.Length < index); 22 | 23 | Console.WriteLine("Short digits:"); 24 | foreach (var d in shortDigits) 25 | { 26 | Console.WriteLine("The word {0} is shorter than its value.", d); 27 | } 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /docs/core/tutorials/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: .NET Core Tutorials 3 | description: .NET Core Tutorials 4 | keywords: .NET, .NET Core 5 | author: richlander 6 | manager: wpickett 7 | ms.date: 06/24/2016 8 | ms.topic: article 9 | ms.prod: .net-core 10 | ms.technology: .net-core-technologies 11 | ms.devlang: dotnet 12 | ms.assetid: f6f654b1-1d2c-4105-8376-7c1959e23803 13 | --- 14 | 15 | .NET Core Tutorials 16 | =================== 17 | 18 | The following tutorials are available for learning about .NET Core. 19 | 20 | - [Getting started with .NET Core on Windows](using-on-windows.md) 21 | - [Getting started with .NET Core on macOS](using-on-macos.md) 22 | - [Getting started with .NET Core on Windows/Linux/macOS using the command line](using-with-xplat-cli.md) 23 | - [Developing Libraries with Cross Platform Tools](libraries.md) 24 | - [How to Manage Package Dependency Versions for .NET Core 1.0](managing-package-dependency-versions.md) 25 | - [Using MSBuild to build .NET Core projects](target-dotnetcore-with-msbuild.md) 26 | 27 | For tutorials about developing ASP.NET Core web applications, we suggest you head over to [ASP.NET Core documentation](https://docs.asp.net). -------------------------------------------------------------------------------- /samples/csharp-language/console-webapiclient/repo.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.Serialization; 2 | using System; 3 | using System.Globalization; 4 | 5 | namespace WebAPIClient 6 | { 7 | [DataContract(Name="repo")] 8 | public class Repository 9 | { 10 | [DataMember(Name="name")] 11 | public string Name { get; set; } 12 | 13 | [DataMember(Name="description")] 14 | public string Description { get; set; } 15 | 16 | [DataMember(Name="html_url")] 17 | public Uri GitHubHomeUrl { get; set; } 18 | 19 | [DataMember(Name="homepage")] 20 | public Uri Homepage { get; set; } 21 | 22 | [DataMember(Name="watchers")] 23 | public int Watchers { get; set; } 24 | 25 | [DataMember(Name="pushed_at")] 26 | private string JsonDate { get; set; } 27 | 28 | [IgnoreDataMember] 29 | public DateTime LastPush 30 | { 31 | get 32 | { 33 | return DateTime.ParseExact(JsonDate, "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); 34 | } 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /.openpublishing.publish.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "need_generate_pdf": false, 3 | "need_generate_intellisense": false, 4 | "git_repository_branch_open_to_public_contributors": "master", 5 | "git_repository_url_open_to_public_contributors": "https://github.com/dotnet/core-docs", 6 | "docsets_to_publish": [ 7 | { 8 | "docset_name": "core-docs", 9 | "build_source_folder": ".", 10 | "build_output_subfolder": ".", 11 | "locale": "en-us", 12 | "version": 0, 13 | "open_to_public_contributors": true, 14 | "type_mapping": { 15 | "Conceptual": "Content", 16 | "ManagedReference": "Content", 17 | "RestApi": "Content" 18 | }, 19 | "build_entry_point": "docs" 20 | } 21 | ], 22 | "notification_subscribers": [], 23 | "skip_source_output_uploading": false, 24 | "dependent_repositories": [ 25 | { 26 | "path_to_root": "_themes", 27 | "url": "https://github.com/Microsoft/templates.docs.msft", 28 | "branch": "master" 29 | }, 30 | { 31 | "path_to_root": "api_ref", 32 | "url": "https://github.com/docascode/coreapi.git", 33 | "branch": "master" 34 | } 35 | ] 36 | } 37 | -------------------------------------------------------------------------------- /docs/core/tutorials/cli-console-app-tutorial-advanced.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Writing .NET Core console apps using the CLI tools: An advanced step-by-step guide 3 | description: Writing .NET Core console apps using the CLI tools: An advanced step-by-step guide 4 | keywords: .NET, .NET Core 5 | author: dotnet-bot 6 | manager: wpickett 7 | ms.date: 06/20/2016 8 | ms.topic: article 9 | ms.prod: .net-core 10 | ms.technology: .net-core-technologies 11 | ms.devlang: dotnet 12 | ms.assetid: dab9e2f9-9088-4089-b990-fbc3d8dcd611 13 | --- 14 | 15 | # 🔧 Writing .NET Core console apps using the CLI tools: An advanced step-by-step guide 16 | 17 | > **Note** 18 | > 19 | > This topic hasn’t been written yet! 20 | > 21 | > We welcome your input to help shape the scope and approach. You can 22 | > track the status and provide input on this 23 | > [issue](https://github.com/dotnet/core-docs/issues/180) at GitHub. 24 | > 25 | > If you would like to review early drafts and outlines of this 26 | > topic, please leave a note with your contact information in the issue. 27 | > 28 | > Learn more about how you can contribute on 29 | > [GitHub](https://github.com/dotnet/core-docs/blob/master/CONTRIBUTING.md). 30 | > 31 | -------------------------------------------------------------------------------- /samples/csharp-language/console-teleprompter/console-teleprompter.xproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14.0 5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 6 | 7 | 8 | 9 | 1b2825c1-d730-47d3-95c1-0d9d809edea6 10 | console-teleprompter 11 | .\obj 12 | .\bin\ 13 | 14 | 15 | 16 | 2.0 17 | 18 | 19 | -------------------------------------------------------------------------------- /samples/csharp-language/indexers/SampleTwo/ArgsProcessor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace IndexersSamples.SampleTwo 5 | { 6 | public class ArgsProcessor 7 | { 8 | private readonly ArgsActions actions; 9 | 10 | public ArgsProcessor(ArgsActions actions) 11 | { 12 | this.actions = actions; 13 | } 14 | 15 | public void Process(string[] args) 16 | { 17 | foreach(var arg in args) 18 | { 19 | actions[arg]?.Invoke(); 20 | } 21 | } 22 | 23 | } 24 | public class ArgsActions 25 | { 26 | readonly private Dictionary argsActions = new Dictionary(); 27 | 28 | public Action this[string s] 29 | { 30 | get 31 | { 32 | Action action; 33 | Action defaultAction = () => {} ; 34 | return argsActions.TryGetValue(s, out action) ? action : defaultAction; 35 | } 36 | } 37 | 38 | public void SetOption(string s, Action a) 39 | { 40 | argsActions[s] = a; 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /samples/linq/csharp/aggregate/Count-Sample-1.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System; 3 | 4 | namespace Aggregate 5 | { 6 | public static class CountSample1 7 | { 8 | //This sample uses Count to get the number of unique factors of 300 using method syntax. 9 | // 10 | //Output: 11 | // There are 3 unique factors of 300. 12 | public static void MethodSyntaxExample() 13 | { 14 | int[] factorsOf300 = {2, 2, 3, 5, 5}; 15 | 16 | int uniqueFactors = factorsOf300.Distinct().Count(); 17 | 18 | Console.WriteLine($"There are {uniqueFactors} unique factors of 300."); 19 | } 20 | 21 | //This sample uses Count to get the number of unique factors of 300 using query syntax. 22 | // 23 | //Output: 24 | // There are 3 unique factors of 300. 25 | public static void QuerySyntaxExample() 26 | { 27 | int[] factorsOf300 = {2, 2, 3, 5, 5}; 28 | 29 | int uniqueFactors = 30 | (from f in factorsOf300 select f).Distinct().Count(); 31 | 32 | Console.WriteLine($"There are {uniqueFactors} unique factors of 300."); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /samples/csharp-language/events/events.xproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14.0 5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 6 | 7 | 8 | 9 | fd45fa0a-8e95-4daa-aec9-63719b4e3fc9 10 | events 11 | ..\artifacts\obj\$(MSBuildProjectName) 12 | ..\artifacts\bin\$(MSBuildProjectName)\ 13 | 14 | 15 | 16 | 2.0 17 | 18 | 19 | -------------------------------------------------------------------------------- /samples/csharp-language/indexers/indexers.xproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14.0 5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 6 | 7 | 8 | 9 | fc71f48c-e762-4c6e-add9-e84d97e95e4f 10 | indexers 11 | ..\artifacts\obj\$(MSBuildProjectName) 12 | ..\artifacts\bin\$(MSBuildProjectName)\ 13 | 14 | 15 | 16 | 2.0 17 | 18 | 19 | -------------------------------------------------------------------------------- /samples/csharp-language/expression-trees/ConditionalVisitor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq.Expressions; 3 | 4 | namespace ExpressionVisitor 5 | { 6 | public class ConditionalVisitor : Visitor 7 | { 8 | private readonly ConditionalExpression node; 9 | public ConditionalVisitor(ConditionalExpression node) : base(node) 10 | { 11 | this.node = node; 12 | } 13 | 14 | public override void Visit(string prefix) 15 | { 16 | Console.WriteLine($"{prefix}This expression is a {NodeType} expression"); 17 | var testVisitor = Visitor.CreateFromExpression(node.Test); 18 | Console.WriteLine($"{prefix}The Test for this expression is:"); 19 | testVisitor.Visit(prefix + "\t"); 20 | var trueVisitor = Visitor.CreateFromExpression(node.IfTrue); 21 | Console.WriteLine($"{prefix}The True clause for this expression is:"); 22 | trueVisitor.Visit(prefix + "\t"); 23 | var falseVisitor = Visitor.CreateFromExpression(node.IfFalse); 24 | Console.WriteLine($"{prefix}The False clause for this expression is:"); 25 | falseVisitor.Visit(prefix + "\t"); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /samples/linq/csharp/partitioning/SkipWhile-Sample-1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Partitioning 5 | { 6 | public static class SkipWhileSample1 7 | { 8 | //This sample uses SkipWhile to get the elements of the array starting from the first element 9 | //divisible by 3. 10 | // 11 | //Output: 12 | // All elements starting from first element divisible by 3: 13 | // 3 14 | // 9 15 | // 8 16 | // 6 17 | // 7 18 | // 2 19 | // 0 20 | public static void Example() 21 | { 22 | int[] numbers = {5, 4, 1, 3, 9, 8, 6, 7, 2, 0}; 23 | 24 | // In the lambda expression, 'n' is the input parameter that identifies each 25 | // element in the collection in succession. It is is inferred to be 26 | // of type int because numbers is an int array. 27 | var allButFirst3Numbers = numbers.SkipWhile(n => n%3 != 0); 28 | 29 | Console.WriteLine("All elements starting from first element divisible by 3:"); 30 | foreach (var n in allButFirst3Numbers) 31 | { 32 | Console.WriteLine(n); 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /samples/csharp-language/expression-trees/expression-trees.xproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14.0.24720 5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 6 | 7 | 8 | 9 | 74a85a88-89aa-4b22-931c-7a34c737982f 10 | expression-trees 11 | ..\artifacts\obj\$(MSBuildProjectName) 12 | ..\artifacts\bin\$(MSBuildProjectName)\ 13 | 14 | 15 | 16 | 2.0 17 | 18 | 19 | -------------------------------------------------------------------------------- /samples/csharp-language/console-linq/console-linq.xproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14.0.25115 5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 6 | 7 | 8 | 9 | 0d13caeb-8316-4e7c-a3ad-cb83e5da7d90 10 | console-linq 11 | ..\artifacts\obj\$(MSBuildProjectName) 12 | ..\artifacts\bin\$(MSBuildProjectName)\ 13 | 14 | 15 | 16 | 2.0 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /samples/csharp-language/WeatherMicroservice/WeatherMicroservice.xproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14.0 5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 6 | 7 | 8 | 9 | 54b7da3e-2a4f-4722-aef3-c0b97e33d636 10 | WeatherMicroservice 11 | ..\artifacts\obj\$(MSBuildProjectName) 12 | ..\artifacts\bin\$(MSBuildProjectName)\ 13 | 14 | 15 | 16 | 2.0 17 | 18 | 19 | -------------------------------------------------------------------------------- /samples/linq/csharp/setoperators/Set-Intersect-Sample-2.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | namespace SetOperators 6 | { 7 | public class SetIntersect2 8 | { 9 | //This sample uses Intersect to create one sequence that contains 10 | // the common first letter from both product and customer names. 11 | //Outputs the following to Console 12 | // Common first letters from Product names and Customer names: 13 | // A 14 | // B 15 | // J 16 | public static void MethodSyntaxExample() 17 | { 18 | List products = Data.Products; 19 | List customers = Data.Customers; 20 | 21 | var productFirstChars = products.Select(p=> p.ProductName[0]); 22 | var customerFirstChars = customers.Select(c=> c.CustomerName[0]); 23 | var commonFirstChars = productFirstChars.Intersect(customerFirstChars); 24 | 25 | Console.WriteLine("Common first letters from Product names and Customer names:"); 26 | foreach (var ch in commonFirstChars) 27 | { 28 | Console.WriteLine(ch); 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /samples/linq/csharp/grouping/GroupBy-Comparer-Sample-1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Grouping 5 | { 6 | public class GroupByComparer1 7 | { 8 | //This sample uses GroupBy to partition trimmed elements of an array using a 9 | // custom comparer that matches words that are anagrams of each other. 10 | //Outputs the following to Console: 11 | //from 12 | // from 13 | // form 14 | //-------------- 15 | //salt 16 | // salt 17 | // last 18 | //-------------- 19 | //earn 20 | // earn 21 | // near 22 | public static void MethodSyntaxExample() 23 | { 24 | string[] anagrams = { "from ", " salt", " earn ", " last ", " near ", " form " }; 25 | 26 | var orderGroups = anagrams.GroupBy(w => w.Trim(), new AnagramEqualityComparer()); 27 | 28 | foreach (var s in orderGroups) 29 | { 30 | Console.WriteLine("--------------"); 31 | Console.WriteLine(s.Key); 32 | foreach (var i in s.ToList()) 33 | { 34 | Console.WriteLine(i); 35 | } 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /samples/csharp-language/WeatherMicroservice/WeatherReport.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Runtime.Serialization; 6 | 7 | namespace WeatherMicroservice 8 | { 9 | public class WeatherReport 10 | { 11 | private static readonly string[] PossibleConditions = new string[] 12 | { 13 | "Sunny", 14 | "Mostly Sunny", 15 | "Partly Sunny", 16 | "Partly Cloudy", 17 | "Mostly Cloudy", 18 | "Rain" 19 | }; 20 | 21 | 22 | public WeatherReport(double latitude, double longitude, int daysInFuture) 23 | { 24 | var generator = new Random((int)(latitude + longitude) + daysInFuture); 25 | 26 | HiTemperature = generator.Next(40, 100); 27 | LoTemperature = generator.Next(0, HiTemperature); 28 | AverageWindSpeed = generator.Next(0, 45); 29 | Conditions = PossibleConditions[generator.Next(0, PossibleConditions.Length - 1)]; 30 | } 31 | 32 | public int HiTemperature { get; } 33 | 34 | public int LoTemperature { get; } 35 | 36 | public int AverageWindSpeed { get; } 37 | 38 | public string Conditions { get; } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /samples/linq/csharp/ordering/program.cs: -------------------------------------------------------------------------------- 1 | namespace Ordering 2 | { 3 | public class Program 4 | { 5 | public void Main(string[] args) 6 | { 7 | OrderBy1.QuerySyntaxExample(); 8 | OrderBy1.MethodSyntaxExample(); 9 | 10 | OrderBy2.QuerySyntaxExample(); 11 | OrderBy2.MethodSyntaxExample(); 12 | 13 | OrderBy3.QuerySyntaxExample(); 14 | OrderBy3.MethodSyntaxExample(); 15 | 16 | OrderByComparer1.MethodSyntaxExample(); 17 | 18 | OrderByDescending1.QuerySyntaxExample(); 19 | OrderByDescending1.MethodSyntaxExample(); 20 | 21 | OrderByDescending2.QuerySyntaxExample(); 22 | OrderByDescending2.MethodSyntaxExample(); 23 | 24 | OrderByDescendingComparer1.MethodSyntaxExample(); 25 | 26 | ThenBy1.QuerySyntaxExample(); 27 | ThenBy1.MethodSyntaxExample(); 28 | 29 | ThenByComparer1.MethodSyntaxExample(); 30 | 31 | ThenByDescending1.QuerySyntaxExample(); 32 | ThenByDescending1.MethodSyntaxExample(); 33 | 34 | ThenByDescendingComparer1.MethodSyntaxExample(); 35 | 36 | Reverse1.QuerySyntaxExample(); 37 | Reverse1.MethodSyntaxExample(); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /samples/linq/csharp/customsequence/CustomSequence-Sample-1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace CustomSequence 6 | { 7 | public static class CustomSequenceSample1 8 | { 9 | private static IEnumerable Combine(this IEnumerable first, IEnumerable second, Func func) 10 | { 11 | var e1 = first.GetEnumerator(); 12 | var e2 = second.GetEnumerator(); 13 | 14 | while (e1.MoveNext() && e2.MoveNext()) 15 | { 16 | yield return func(e1.Current, e2.Current); 17 | } 18 | } 19 | 20 | //This sample calculates the dot product of two integer vectors. It uses a user-created sequence operator, 21 | //Combine, to calculate the dot product, passing it a lambda function to multiply two arrays, element by element, 22 | //and sum the result. 23 | // 24 | //Output 25 | // Dot product: 109 26 | public static void Example() 27 | { 28 | int[] vectorA = {0, 2, 4, 5, 6}; 29 | int[] vectorB = {1, 3, 5, 7, 8}; 30 | 31 | int dotProduct = vectorA.Combine(vectorB, (a, b) => a * b).Sum(); 32 | 33 | Console.WriteLine("Dot product: {0}", dotProduct); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /samples/csharp-language/expression-trees/LambdaVisitor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq.Expressions; 3 | 4 | namespace ExpressionVisitor 5 | { 6 | public class LambdaVisitor : Visitor 7 | { 8 | private readonly LambdaExpression node; 9 | public LambdaVisitor(LambdaExpression node) : base(node) 10 | { 11 | this.node = node; 12 | } 13 | 14 | public override void Visit(string prefix) 15 | { 16 | Console.WriteLine($"{prefix}This expression is a {NodeType} expression type"); 17 | Console.WriteLine($"{prefix}The name of the lambda is {((node.Name == null) ? "" : node.Name)}"); 18 | Console.WriteLine($"{prefix}The return type is {node.ReturnType.ToString()}"); 19 | Console.WriteLine($"{prefix}The expression has {node.Parameters.Count} arguments. They are:"); 20 | foreach (var argumentExpression in node.Parameters) 21 | { 22 | var argumentVisitor = Visitor.CreateFromExpression(argumentExpression); 23 | argumentVisitor.Visit(prefix + "\t"); 24 | } 25 | Console.WriteLine($"{prefix}The expression body is:"); 26 | var bodyVisitor = Visitor.CreateFromExpression(node.Body); 27 | bodyVisitor.Visit(prefix + "\t"); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /samples/csharp-language/expression-trees/BlockVisitor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq.Expressions; 3 | 4 | namespace ExpressionVisitor 5 | { 6 | public class BlockVisitor : Visitor 7 | { 8 | private readonly BlockExpression node; 9 | public BlockVisitor(BlockExpression node) : base(node) 10 | { 11 | this.node = node; 12 | } 13 | 14 | public override void Visit(string prefix) 15 | { 16 | Console.WriteLine($"{prefix}This expression is a {NodeType} expression"); 17 | 18 | var resultVisitor = Visitor.CreateFromExpression(node.Result); 19 | Console.WriteLine($"{prefix}Result from Block: "); 20 | resultVisitor.Visit(prefix + "\t"); 21 | Console.WriteLine($"{prefix}Variables:"); 22 | foreach (var variable in node.Variables) 23 | { 24 | var variablesVisitor = Visitor.CreateFromExpression(variable); 25 | variablesVisitor.Visit(prefix + "\t"); 26 | } 27 | 28 | Console.WriteLine($"{prefix}Block Statements:"); 29 | foreach(var statement in node.Expressions) 30 | { 31 | var statementVisitor = Visitor.CreateFromExpression(statement); 32 | statementVisitor.Visit(prefix+"\t"); 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /samples/core-projects/console-apps/HelloNative/README.md: -------------------------------------------------------------------------------- 1 | Hello Native Sample 2 | ================ 3 | 4 | This sample is part of the [step-by-step tutorial](https://docs.microsoft.com/dotnet/core/tutorials/using-with-xplat-cli.html) 5 | for creating .NET Core Console Applications. Please see that topic for detailed steps on the code 6 | for this sample. 7 | 8 | Key Features 9 | ------------ 10 | 11 | This is the basic Hello World sample for native output. It demonstrates how you build a native 12 | application using .NET Core on your platform: Linux, Mac, or Windows. 13 | 14 | Note that you can build a native images for any suported platform only from that platform. .NET Core 15 | does not support cross-compiling for supported platform. 16 | 17 | Build and Run 18 | ------------- 19 | 20 | To build and run the sample, type the following three commands: 21 | 22 | `dotnet restore` 23 | `dotnet build` 24 | `.\bin\Debug\netcoreapp1.0\win10-x64\HelloNative.exe` 25 | 26 | `dotnet restore` installs all the dependencies for this sample into the current directory. 27 | `dotnet build` creates the output assembly (or assemblies). 28 | `.\bin\Debug\netcoreapp1.0\win10-x64\HelloNative.exe` runs the output executable. The example 29 | shows the Windows path. Replace `win10-x64` with your platform's RID from the list of 30 | [supported RIDs](../../../docs/core-concepts/rid-catalog.html) 31 | -------------------------------------------------------------------------------- /samples/csharp-language/expression-trees/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace ExpressionTreeSamples 5 | { 6 | public class Program 7 | { 8 | private static List allSamples = new List 9 | { 10 | new ExpressionTreeClassesSampleOne(), 11 | new ExpressionTreeClassesSampleTwo(), 12 | new ExpressionTreeExecutionSampleOne(), 13 | new ExpressionTreeExecutionSampleTwo(), 14 | new ExpressionTreeInterpretingSampleOne(), 15 | new ExpressionTreeInterpretingSampleTwo(), 16 | new ExpressionTreeInterpretingSampleThree(), 17 | new ExpressionTreeInterpretingSampleFour(), 18 | new ExpressionTreeBuildingSampleOne(), 19 | new ExpressionTreeBuildingSampleTwo(), 20 | new ExpressionTreeTranslationSampleOne(), 21 | new ExpressionTreeTranslationSampleTwo(), 22 | new ExpressionTreeTranslationSampleThree() 23 | }; 24 | 25 | public static void Main(string[] args) 26 | { 27 | foreach (var sample in allSamples) 28 | { 29 | Console.WriteLine("========== ========== ========== =========="); 30 | Console.WriteLine($"Running Sample {sample.Name}"); 31 | sample.Run(); 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /samples/linq/csharp/element/ElementAt-Sample1-.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Element 5 | { 6 | public static class ElementAtSample1 7 | { 8 | //This sample uses ElementAt and query syntaxto retrieve the second number greater than 5 from an array. 9 | // 10 | //Output: 11 | // Second number > 5: 8 12 | public static void QuerySyntaxExample() 13 | { 14 | int[] numbers = {5, 4, 1, 3, 9, 8, 6, 7, 2, 0}; 15 | 16 | int fourthLowNum = ( 17 | from num in numbers 18 | where num > 5 19 | select num) 20 | .ElementAt(1); // second number is index 1 because sequences use 0-based indexing 21 | 22 | Console.WriteLine("Second number > 5: {0}", fourthLowNum); 23 | } 24 | 25 | //This sample uses ElementAt and method syntax to retrieve the second number greater than 5 from an array. 26 | // 27 | //Output: 28 | // Second number > 5: 8 29 | public static void MethodSyntaxExample() 30 | { 31 | int[] numbers = {5, 4, 1, 3, 9, 8, 6, 7, 2, 0}; 32 | 33 | // second number is index 1 because sequences use 0-based indexing 34 | int fourthLowNum = (numbers.Where(num => num > 5)).ElementAt(1); 35 | 36 | Console.WriteLine("Second number > 5: {0}", fourthLowNum); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /samples/linq/csharp/grouping/GroupBy-Comparer-Sample-2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Grouping 5 | { 6 | public class GroupByComparer2 7 | { 8 | //This sample uses GroupBy to partition trimmed elements of an array using a 9 | // custom comparer that matches words that are anagrams of each other and 10 | // then converts the results to uppercase. 11 | //Outputs the following to Console: 12 | //from 13 | // FROM 14 | // FORM 15 | //-------------- 16 | //salt 17 | // SALT 18 | // LAST 19 | //-------------- 20 | //earn 21 | // EARN 22 | // NEAR 23 | public static void MethodSyntaxExample() 24 | { 25 | string[] anagrams = { "from ", " salt", " earn ", " last ", " near ", " form " }; 26 | 27 | var orderGroups = anagrams.GroupBy( 28 | w => w.Trim(), 29 | a => a.ToUpper(), 30 | new AnagramEqualityComparer() 31 | ); 32 | 33 | foreach (var s in orderGroups) 34 | { 35 | Console.WriteLine("--------------"); 36 | Console.WriteLine(s.Key); 37 | foreach (var i in s.ToList()) 38 | { 39 | Console.WriteLine(i); 40 | } 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /samples/linq/csharp/setoperators/Set-Except-Sample-2.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | namespace SetOperators 6 | { 7 | public class SetExcept2 8 | { 9 | //This sample uses Except to create one sequence that contains the first letters 10 | // of product names that are not also first letters of customer names. 11 | //Outputs the following to Console 12 | // First letters from Product names, but not from Customer names: 13 | // C 14 | // G 15 | // U 16 | // N 17 | // M 18 | // I 19 | // Q 20 | // K 21 | // T 22 | // P 23 | // S 24 | // R 25 | // Z 26 | public static void MethodSyntaxExample() 27 | { 28 | List products = Data.Products; 29 | List customers = Data.Customers; 30 | 31 | var productFirstChars = products.Select(p=> p.ProductName[0]); 32 | var customerFirstChars = customers.Select(c=> c.CustomerName[0]); 33 | 34 | var productOnlyFirstChars = productFirstChars.Except(customerFirstChars); 35 | 36 | Console.WriteLine("First letters from Product names, but not from Customer names:"); 37 | foreach (var ch in productOnlyFirstChars) 38 | { 39 | Console.WriteLine(ch); 40 | } 41 | 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /samples/core-projects/console-apps/NewTypes/README.md: -------------------------------------------------------------------------------- 1 | NewTypes Pets Sample 2 | ================ 3 | 4 | This sample is part of the [step-by-step tutorial](https://docs.microsoft.com/dotnet/core/tutorials/using-with-xplat-cli.html) 5 | for creating .NET Core Console Applications. Please see that topic for detailed steps on the code 6 | for this sample. 7 | 8 | Key Features 9 | ------------ 10 | 11 | This sample builds a program and an associated unit test assembly. You'll learn how to structure 12 | projects as part of a larger solution, and incorporate unit tests into your projects. 13 | 14 | Build and Run 15 | ------------- 16 | 17 | To build and run the sample, change to the `src/NewTypes` directory and 18 | type the following three commands: 19 | 20 | `dotnet restore` 21 | `dotnet build` 22 | `dotnet run` 23 | 24 | `dotnet restore` installs all the dependencies for this sample into the current directory. 25 | `dotnet build` creates the output assembly (or assemblies). 26 | `dotnet run` runs the output executable. 27 | 28 | To run the tests, change to the `tests/NewTypesTests` directory and 29 | type the following three commands: 30 | 31 | `dotnet restore` 32 | `dotnet build` 33 | `dotnet test` 34 | 35 | `dotnet test` runs all the configure tests 36 | 37 | Note that you must run `dotnet restore` in the `src/NewTypes` directory before you can run 38 | the tests. `dotnet build` will follow the dependency and build both the library and unit 39 | tests projects, but it will not restore NuGet packages. 40 | -------------------------------------------------------------------------------- /samples/linq/csharp/setoperators/Set-Union-Sample-2.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | namespace SetOperators 6 | { 7 | public class SetUnion2 8 | { 9 | //This sample uses Union to create one sequence that contains the 10 | // unique first letter from both product and customer names. 11 | //Outputs the following to Console 12 | // Unique first letters from Product names and Customer names: 13 | // C 14 | // A 15 | // G 16 | // U 17 | // N 18 | // M 19 | // I 20 | // Q 21 | // K 22 | // T 23 | // P 24 | // S 25 | // R 26 | // B 27 | // J 28 | // Z 29 | public static void MethodSyntaxExample() 30 | { 31 | List products = Data.Products; 32 | List customers = Data.Customers; 33 | 34 | var productFirstChars = products.Select(p => p.ProductName[0]); 35 | var customerFirstChars = customers.Select(c => c.CustomerName[0]); 36 | 37 | var uniqueFirstChars = productFirstChars.Union(customerFirstChars); 38 | 39 | Console.WriteLine("Unique first letters from Product names and Customer names:"); 40 | foreach (var ch in uniqueFirstChars) 41 | { 42 | Console.WriteLine(ch); 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /samples/csharp-language/console-linq/extensions.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.IO; 3 | 4 | namespace LinqFaroShuffle 5 | { 6 | public static class Extensions 7 | { 8 | public static IEnumerable InterleaveSequenceWith 9 | (this IEnumerable first, IEnumerable second) 10 | { 11 | var firstIter = first.GetEnumerator(); 12 | var secondIter = second.GetEnumerator(); 13 | while (firstIter.MoveNext() && secondIter.MoveNext()) 14 | { 15 | yield return firstIter.Current; 16 | yield return secondIter.Current; 17 | } 18 | } 19 | 20 | public static bool SequenceEquals(this IEnumerable first, IEnumerable second) 21 | { 22 | var firstIter = first.GetEnumerator(); 23 | var secondIter = second.GetEnumerator(); 24 | while (firstIter.MoveNext() && secondIter.MoveNext()) 25 | { 26 | if (!firstIter.Current.Equals(secondIter.Current)) 27 | return false; 28 | } 29 | return true; 30 | } 31 | 32 | public static IEnumerable LogQuery(this IEnumerable sequence, string tag) 33 | { 34 | using (var writer = File.AppendText("debug.log")) 35 | { 36 | writer.WriteLine($"Executing Query {tag}"); 37 | } 38 | return sequence; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /samples/csharp-language/expression-trees/ExpressionTreeTranslationSampleOne.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq.Expressions; 3 | 4 | namespace ExpressionTreeSamples 5 | { 6 | public class ExpressionTreeTranslationSampleOne : Sample 7 | { 8 | public override string Name { get; } = "Translation Expression Trees, Sample 1: Replacing Constant Nodes"; 9 | 10 | public override void Run() 11 | { 12 | var one = Expression.Constant(1, typeof(int)); 13 | var two = Expression.Constant(2, typeof(int)); 14 | var addition = Expression.Add(one, two); 15 | var sum = ReplaceNodes(addition); 16 | var executableFunc = Expression.Lambda(sum); 17 | 18 | var func = (Func)executableFunc.Compile(); 19 | var answer = func(); 20 | Console.WriteLine(answer); 21 | } 22 | 23 | private static Expression ReplaceNodes(Expression original) 24 | { 25 | if (original.NodeType == ExpressionType.Constant) 26 | { 27 | return Expression.Multiply(original, Expression.Constant(10)); 28 | } 29 | else if (original.NodeType == ExpressionType.Add) 30 | { 31 | var binaryExpression = (BinaryExpression)original; 32 | return Expression.Add( 33 | ReplaceNodes(binaryExpression.Left), 34 | ReplaceNodes(binaryExpression.Right)); 35 | } 36 | return original; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /samples/linq/csharp/projection/SelectMany-Sample-1.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System; 3 | namespace Projection 4 | { 5 | public class SelectManySample1 6 | { 7 | //This sample uses a compound from clause to make a query that returns all pairs of numbers from both arrays 8 | //such that the number from numbersA is less than the number from numbersB. 9 | // 10 | //Output: 11 | // Pairs where a aggregate = null; 23 | // Aggregate, return constants, or the sum of the left and right operand. 24 | // Major simplification: Assume every binary expression is an addition. 25 | aggregate = (exp) => 26 | exp.NodeType == ExpressionType.Constant ? 27 | (int)((ConstantExpression)exp).Value : 28 | aggregate(((BinaryExpression)exp).Left) + aggregate(((BinaryExpression)exp).Right); 29 | 30 | var theSum = aggregate(sum); 31 | Console.WriteLine(theSum); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /samples/unit-testing/using-dotnet-test/test/PrimeService.Tests/PrimeServie_IsPrimeShould.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Prime.Services; 3 | using Xunit; 4 | 5 | namespace Prime.UnitTests.Services 6 | { 7 | public class PrimeService_IsPrimeShould 8 | { 9 | private readonly PrimeService _primeService; 10 | public PrimeService_IsPrimeShould() 11 | { 12 | _primeService = new PrimeService(); 13 | } 14 | 15 | [Theory] 16 | [InlineData(-1)] 17 | [InlineData(0)] 18 | [InlineData(1)] 19 | public void ReturnFalseGivenValuesLessThan2(int value) 20 | { 21 | var result = _primeService.IsPrime(value); 22 | 23 | Assert.False(result, $"{value} should not be prime"); 24 | } 25 | 26 | [Theory] 27 | [InlineData(2)] 28 | [InlineData(3)] 29 | [InlineData(5)] 30 | [InlineData(7)] 31 | public void ReturnTrueGivenPrimesLessThan10(int value) 32 | { 33 | var result = _primeService.IsPrime(value); 34 | 35 | Assert.True(result, $"{value} should be prime"); 36 | } 37 | 38 | [Theory] 39 | [InlineData(4)] 40 | [InlineData(6)] 41 | [InlineData(8)] 42 | [InlineData(9)] 43 | public void ReturnFalseGivenNonPrimesLessThan10(int value) 44 | { 45 | var result = _primeService.IsPrime(value); 46 | 47 | Assert.False(result, $"{value} should not be prime"); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /samples/linq/csharp/aggregate/program.cs: -------------------------------------------------------------------------------- 1 | namespace Aggregate 2 | { 3 | public class Program 4 | { 5 | public void Main(string[] args) 6 | { 7 | AggregateSample1.MethodSyntaxExample(); 8 | AggregateSample2.MethodSyntaxExample(); 9 | 10 | CountSample1.MethodSyntaxExample(); 11 | CountSample1.QuerySyntaxExample(); 12 | 13 | CountSample2.Example(); 14 | 15 | CountSample3.Example(); 16 | 17 | CountSample4.MethodSyntaxExample(); 18 | CountSample4.QuerySyntaxExample(); 19 | 20 | SumSample1.Example(); 21 | 22 | SumSample2.Example(); 23 | 24 | SumSample3.QuerySyntaxExample(); 25 | SumSample3.MethodSyntaxExample(); 26 | 27 | MaxSample1.Example(); 28 | 29 | MaxSample2.Example(); 30 | 31 | MaxSample3.MethodSyntaxExample(); 32 | MaxSample3.QuerySyntaxExample(); 33 | 34 | MaxSample4.MethodSyntaxExample(); 35 | MaxSample4.QuerySyntaxExample(); 36 | 37 | MinSample1.Example(); 38 | 39 | MinSample2.Example(); 40 | 41 | MinSample3.MethodSyntaxExample(); 42 | MinSample3.QuerySyntaxExample(); 43 | 44 | MinSample4.MethodSyntaxExample(); 45 | MinSample4.QuerySyntaxExample(); 46 | 47 | AverageSample1.Example(); 48 | 49 | AverageSample2.Example(); 50 | 51 | AverageSample3.MethodSyntaxExample(); 52 | AverageSample3.QuerySyntaxExample(); 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /samples/linq/csharp/ordering/OrderBy-Sample-1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Ordering 5 | { 6 | public class OrderBy1 7 | { 8 | //This sample uses orderby to sort a list of words alphabetically. 9 | //Outputs to the console: 10 | // The sorted list of words: 11 | // apple 12 | // blueberry 13 | // cherry 14 | public static void QuerySyntaxExample() 15 | { 16 | string[] words = { "cherry", "apple", "blueberry" }; 17 | 18 | var sortedWords = 19 | from w in words 20 | orderby w 21 | select w; 22 | 23 | Console.WriteLine("The sorted list of words:"); 24 | 25 | foreach (var w in sortedWords) 26 | { 27 | Console.WriteLine(w); 28 | } 29 | 30 | } 31 | //This sample uses orderby to sort a list of words alphabetically. 32 | //Outputs to the console: 33 | // The sorted list of words: 34 | // apple 35 | // blueberry 36 | // cherry 37 | public static void MethodSyntaxExample() 38 | { 39 | string[] words = { "cherry", "apple", "blueberry" }; 40 | 41 | var sortedWords = words.OrderBy(w => w); 42 | 43 | Console.WriteLine("The sorted list of words:"); 44 | 45 | foreach (var w in sortedWords) 46 | { 47 | Console.WriteLine(w); 48 | } 49 | 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | os: Visual Studio 2015 2 | 3 | ## .NET Core SDK preview1 is already installed in the build worker image Visual Studio 2015 4 | ## 5 | ## To install a specific version: 6 | ## 7 | ## install: 8 | ## # .NET Core SDK binaries 9 | ## ## 1) from direct url 10 | ## - ps: $url = "https://go.microsoft.com/fwlink/?LinkID=798402" # v1.0.0-preview1 x64 11 | ## ## 2) from url based on version, for example using an env var CLI_VERSION that can be a 12 | ## ## a specific version `1.0.0-preview2-003118` or `Latest` (for latest dev version) 13 | ## - ps: $url = "https://dotnetcli.blob.core.windows.net/dotnet/preview/Binaries/$($env:CLI_VERSION)/dotnet-dev-win-x64.$($env:CLI_VERSION.ToLower()).zip" 14 | ## # Download .NET Core SDK and add to PATH 15 | ## - ps: $env:DOTNET_INSTALL_DIR = "$pwd\.dotnetsdk" 16 | ## - ps: mkdir $env:DOTNET_INSTALL_DIR -Force | Out-Null 17 | ## - ps: $tempFile = [System.IO.Path]::GetTempFileName() 18 | ## - ps: (New-Object System.Net.WebClient).DownloadFile($url, $tempFile) 19 | ## - ps: Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::ExtractToDirectory($tempFile, $env:DOTNET_INSTALL_DIR) 20 | ## - ps: $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path" 21 | 22 | build_script: 23 | # dotnet info 24 | - ps: dotnet --info 25 | # Run dotnet new 26 | - ps: mkdir "test\test-dotnet-new" -Force | Push-Location 27 | - ps: dotnet new --lang fsharp 28 | - ps: dotnet restore 29 | - ps: dotnet --verbose build 30 | - ps: dotnet --verbose run a b 31 | - ps: Pop-Location 32 | 33 | 34 | test: off 35 | version: 0.0.1.{build} 36 | -------------------------------------------------------------------------------- /samples/core-projects/libraries/net40-library/src/Library/Library.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text.RegularExpressions; 3 | 4 | #if NET40 5 | using System.Net; 6 | #else 7 | using System.Net.Http; 8 | using System.Threading.Tasks; 9 | #endif 10 | 11 | namespace Library 12 | { 13 | public class Net40CompatLibrary 14 | { 15 | #if NET40 16 | private readonly WebClient _client = new WebClient(); 17 | private readonly object _locker = new object(); 18 | #else 19 | private readonly HttpClient _client = new HttpClient(); 20 | #endif 21 | 22 | #if NET40 23 | public string GetDotNetCount() 24 | { 25 | string url = "http://www.dotnetfoundation.org/"; 26 | 27 | var uri = new Uri(url); 28 | 29 | string result = ""; 30 | 31 | lock(_locker) 32 | { 33 | result = _client.DownloadString(uri); 34 | } 35 | 36 | int dotNetCount = Regex.Matches(result, ".NET").Count; 37 | 38 | return $"Dotnet Foundation mentions .NET {dotNetCount} times!"; 39 | } 40 | #else 41 | public async Task GetDotNetCountAsync() 42 | { 43 | string url = "http://www.dotnetfoundation.org/"; 44 | 45 | var result = await _client.GetStringAsync(url); 46 | 47 | int dotNetCount = Regex.Matches(result, ".NET").Count; 48 | 49 | return $"dotnetfoundation.org mentions .NET {dotNetCount} times in its HTML!"; 50 | } 51 | #endif 52 | } 53 | } -------------------------------------------------------------------------------- /samples/linq/csharp/ordering/OrderBy-Sample-2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Ordering 5 | { 6 | public class OrderBy2 7 | { 8 | //This sample uses orderby to sort a list of words by length. 9 | //Outputs to the console: 10 | // The sorted list of words (by length): 11 | // apple 12 | // cherry 13 | // blueberry 14 | public static void QuerySyntaxExample() 15 | { 16 | string[] words = { "cherry", "apple", "blueberry" }; 17 | 18 | var sortedWords = 19 | from w in words 20 | orderby w.Length 21 | select w; 22 | 23 | Console.WriteLine("The sorted list of words (by length):"); 24 | foreach (var w in sortedWords) 25 | { 26 | Console.WriteLine(w); 27 | } 28 | } 29 | //This sample uses orderby to sort a list of words by length. 30 | //Outputs to the console: 31 | // The sorted list of words (by length): 32 | // apple 33 | // cherry 34 | // blueberry 35 | public static void MethodSyntaxExample() 36 | { 37 | string[] words = { "cherry", "apple", "blueberry" }; 38 | 39 | var sortedWords = words.OrderBy(w => w.Length); 40 | 41 | Console.WriteLine("The sorted list of words:"); 42 | 43 | foreach (var w in sortedWords) 44 | { 45 | Console.WriteLine(w); 46 | } 47 | 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /samples/csharp-language/expression-trees/ExpressionTreeBuildingSampleOne.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Linq.Expressions; 5 | using System.Reflection; 6 | 7 | using ExpressionVisitor; 8 | 9 | namespace ExpressionTreeSamples 10 | { 11 | public class ExpressionTreeBuildingSampleOne : Sample 12 | { 13 | public override string Name { get; } = "Building Expression Trees, Sample 1: Creating a statement based tree"; 14 | 15 | public override void Run() 16 | { 17 | var lambda = Expression.Lambda( 18 | Expression.Add( 19 | Expression.Constant(1, typeof(int)), 20 | Expression.Constant(2, typeof(int)) 21 | ) 22 | ); 23 | 24 | var xParameter = Expression.Parameter(typeof(double), "x"); 25 | var yParameter = Expression.Parameter(typeof(double), "y"); 26 | 27 | var xSquared = Expression.Multiply(xParameter, xParameter); 28 | var ySquared = Expression.Multiply(yParameter, yParameter); 29 | var sum = Expression.Add(xSquared, ySquared); 30 | 31 | var sqrtMethod = typeof(Math).GetMethod("Sqrt", new[] { typeof(double) }); 32 | var distance = Expression.Call(sqrtMethod, sum); 33 | 34 | var distanceLambda = Expression.Lambda( 35 | distance, 36 | xParameter, 37 | yParameter); 38 | 39 | var visitor = Visitor.CreateFromExpression(distanceLambda); 40 | visitor.Visit(""); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /samples/linq/csharp/conversion/ToList-Sample-1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Conversion 5 | { 6 | public static class ToListSample1 7 | { 8 | //This sample uses ToList and query syntax to immediately evaluate a sequence into a List. 9 | // 10 | //Output: 11 | // The sorted word list: 12 | // apple 13 | // blueberry 14 | // cherry 15 | public static void QuerySyntaxExample() 16 | { 17 | string[] words = { "cherry", "apple", "blueberry" }; 18 | 19 | var sortedWords = 20 | from w in words 21 | orderby w 22 | select w; 23 | var wordList = sortedWords.ToList(); 24 | 25 | Console.WriteLine("The sorted word list:"); 26 | foreach (var w in wordList) 27 | { 28 | Console.WriteLine(w); 29 | } 30 | } 31 | 32 | //This sample uses ToList and method syntax to immediately evaluate a sequence into a List. 33 | // 34 | //Output: 35 | // The sorted word list: 36 | // apple 37 | // blueberry 38 | // cherry 39 | public static void MethodSyntaxExample() 40 | { 41 | string[] words = { "cherry", "apple", "blueberry" }; 42 | 43 | var sortedWords = 44 | words.OrderBy(w => w); 45 | var wordList = sortedWords.ToList(); 46 | 47 | Console.WriteLine("The sorted word list:"); 48 | foreach (var w in wordList) 49 | { 50 | Console.WriteLine(w); 51 | } 52 | } 53 | } 54 | } --------------------------------------------------------------------------------