Skip to content

Commit

Permalink
Added snippets, images, notes, clarifying statements, clean up, etc. (d…
Browse files Browse the repository at this point in the history
…otnet#27594)

* Added snippets, images, notes, clarifying statments, clean up, etc.

* A few tweaks and modifications

* Update docs/csharp/roslyn-sdk/source-generators-overview.md

Co-authored-by: Andy (Steve) De George <[email protected]>

Co-authored-by: Andy (Steve) De George <[email protected]>
  • Loading branch information
IEvangelist and adegeo authored Dec 15, 2021
1 parent 9eff22e commit 6bf4df1
Show file tree
Hide file tree
Showing 10 changed files with 262 additions and 162 deletions.
6 changes: 5 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
/docs/core/deploying/ @adegeo
# Diagnostics
/docs/core/diagnostics/ @tommcdon @dotnet/docs
# Extensions
/docs/core/extensions/ @IEvangelist
# Docker
/docs/core/docker/ @IEvangelist
# Install
Expand All @@ -86,6 +88,8 @@
/docs/core/project-sdk/ @gewarren
# Config settings
/docs/core/run-time-config/ @gewarren
# Testing
/docs/core/testing/ @IEvangelist
# Tools
/docs/core/tools/ @tdykstra
# Tutorials
Expand Down Expand Up @@ -195,7 +199,7 @@
# Visual Basic snippets:
/samples/snippets/visualbasic/ @BillWagner
# F# Snippets:
/samples/snippets/fsharp/ @dotnet/docs @cartermp
/samples/snippets/fsharp/ @dotnet/docs

# WPF folders:
/samples/snippets/xaml/wpf/ @adegeo
Expand Down
170 changes: 86 additions & 84 deletions docfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,18 +266,19 @@
"author": {
"docs/azure/**/*.*": "camsoper",
"docs/architecture/**/**.md": "nishanil",
"docs/architecture/grpc-for-wcf-developers/**/**.md": "shirhatti",
"docs/architecture/grpc-for-wcf-developers/**/**.md": "JamesNK",
"docs/architecture/modernize-desktop/**/**.md": "OliaG",
"docs/core/**/**.md": "tdykstra",
"docs/core/compatibility/**/**.md": "gewarren",
"docs/core/deploying/**/**.md": "adegeo",
"docs/core/diagnostics/**/**.md": "tommcdon",
"docs/core/extensions/**/**.md": "IEvangelist",
"docs/core/docker/**/**.md": "IEvangelist",
"docs/core/native-interop/**/**.md": "jkoritzinsky",
"docs/core/porting/**/**.md": "cartermp",
"docs/core/project-sdk/**/**.md": "gewarren",
"docs/core/run-time-config/**/**.md": "gewarren",
"docs/core/testing/**/**.md": "billwagner",
"docs/core/testing/**/**.md": "IEvangelist",
"docs/core/tools/**/**.md": "tdykstra",
"docs/core/tutorials/**/**.md": "tdykstra",
"docs/core/versions/**/**.md": "billwagner",
Expand Down Expand Up @@ -346,88 +347,89 @@
"docs/whats-new/**/**.md": "billwagner"
},
"ms.author": {
"_csharplang/**/*.md": "wiwagn",
"_vblang/spec/*.md": "wiwagn",
"docs/architecture/**/**.md": "nanil",
"docs/architecture/grpc-for-wcf-developers/**/**.md": "soshir",
"docs/architecture/modernize-desktop/**/**.md": "oliag",
"docs/azure/**/*.*": "casoper",
"docs/core/**/**.md": "dotnetcontent",
"docs/core/compatibility/**/**.md": "gewarren",
"docs/core/deploying/**/**.md": "adegeo",
"docs/core/diagnostics/**/**.md": "tommcdon",
"docs/core/docker/**/**.md": "dapine",
"docs/core/native-interop/**/**.md": "jekoritz",
"docs/core/porting/**/**.md": "dotnetcontent",
"docs/core/project-sdk/**/**.md": "gewarren",
"docs/core/run-time-config/**/**.md": "gewarren",
"docs/core/testing/**/**.md": "wiwagn",
"docs/core/tools/**/**.md": "tdykstra",
"docs/core/tutorials/**/**.md": "tdykstra",
"docs/core/versions/**/**.md": "wiwagn",
"docs/core/whats-new/**/**.md": "adegeo",
"docs/csharp/**/*.*": "wiwagn",
"docs/framework/**/**.md": "dotnetcontent",
"docs/framework/app-domains/**/**.md": "gewarren",
"docs/framework/configure-apps/file-schema/network/**/**.md": "ncldev",
"docs/framework/configure-apps/file-schema/wcf/**/**.md": "wcfsrvt",
"docs/framework/configure-apps/file-schema/winforms/**/**.md": "adegeo",
"docs/framework/data/adonet/**/**.md": "dotnetcontent",
"docs/framework/data/wcf/**/**.md": "wcfsrvt",
"docs/framework/deployment/**/**.md": "adegeo",
"docs/framework/get-started/**/**.md": "gewarren",
"docs/framework/install/**/**.md": "adegeo",
"docs/framework/migration-guide/**/**.md": "gewarren",
"docs/framework/misc/**/**.md": "gewarren",
"docs/framework/network-programming/**/**.md": "ncldev",
"docs/framework/performance/**/**.md": "wiwagn",
"docs/framework/reflection-and-codedom/**/**.md": "adegeo",
"docs/framework/resources/**/**.md": "adegeo",
"docs/framework/tools/**/**.md": "tdykstra",
"docs/framework/ui-automation/**/**.md": "adegeo",
"docs/framework/unmanaged-api/alink/**/**.md": "jeffschw",
"docs/framework/unmanaged-api/debugging/**/**.md": "tommcdon",
"docs/framework/unmanaged-api/diagnostics/**/**.md": "tommcdon",
"docs/framework/unmanaged-api/fusion/**/**.md": "jeffschw",
"docs/framework/unmanaged-api/hosting/**/**.md": "jeffschw",
"docs/framework/unmanaged-api/profiling/**/**.md": "tommcdon",
"docs/framework/unmanaged-api/strong-naming/**/**.md": "jeffschw",
"docs/framework/unmanaged-api/tlbexp/**/**.md": "jeffschw",
"docs/framework/whats-new/**/**.md": "gewarren",
"docs/framework/wcf/**/**.md": "wcfsrvt",
"docs/fsharp/**/**.md": "dotnetcontent",
"docs/fundamentals/code-analysis/**/*.md": "gewarren",
"docs/fundamentals/syslib-diagnostics/**/**.md": "gewarren",
"docs/iot/**/*.*": "casoper",
"docs/machine-learning/**/**.md": "luquinta",
"docs/spark/**/**.md": "luquinta",
"docs/standard/**/**.md": "gewarren",
"docs/standard/analyzers/**/**.md": "dapine",
"docs/standard/assembly/**/**.md": "dapine",
"docs/standard/asynchronous-programming-patterns/**/**.md": "wiwagn",
"docs/standard/attributes/**/**.md": "tdykstra",
"docs/standard/base-types/**/**.md": "adegeo",
"docs/standard/collections/**/**.md": "dapine",
"docs/standard/data/**/**.md": "gewarren",
"docs/standard/data/sqlite/**/**.md": "bricelam",
"docs/standard/datetime/**/**.md": "adegeo",
"docs/standard/design-guidelines/**/**.md": "kcwalina",
"docs/standard/events/**/**.md": "dapine",
"docs/standard/exceptions/**/**.md": "tdykstra",
"docs/standard/garbage-collection/**/**.md": "gewarren",
"docs/standard/generics/**/**.md": "adegeo",
"docs/standard/globalization-localization/**/**.md": "dotnetcontent",
"docs/standard/io/**/**.md": "adegeo",
"docs/standard/library-guidance/**/**.md": "jamesnk",
"docs/standard/linq/**/**.md": "dotnetcontent",
"docs/standard/memory-and-spans/**/**.md": "tdykstra",
"docs/standard/native-interop/**/**.md": "jekoritz",
"docs/standard/parallel-programming/**/**.md": "dapine",
"docs/standard/security/**/**.md": "dapine",
"docs/standard/serialization/**/**.md": "tdykstra",
"docs/standard/threading/**/**.md": "wiwagn",
"docs/standard/whats-new/**/**.md": "dotnetcontent",
"docs/visual-basic/**/**.md": "kdollard"
"_csharplang/**/*.md": "wiwagn",
"_vblang/spec/*.md": "wiwagn",
"docs/architecture/**/**.md": "nanil",
"docs/architecture/grpc-for-wcf-developers/**/**.md": "jamesnk",
"docs/architecture/modernize-desktop/**/**.md": "oliag",
"docs/azure/**/*.*": "casoper",
"docs/core/**/**.md": "dotnetcontent",
"docs/core/compatibility/**/**.md": "gewarren",
"docs/core/deploying/**/**.md": "adegeo",
"docs/core/diagnostics/**/**.md": "tommcdon",
"docs/core/extensions/**/**.md": "dapine",
"docs/core/docker/**/**.md": "dapine",
"docs/core/native-interop/**/**.md": "jekoritz",
"docs/core/porting/**/**.md": "dotnetcontent",
"docs/core/project-sdk/**/**.md": "gewarren",
"docs/core/run-time-config/**/**.md": "gewarren",
"docs/core/testing/**/**.md": "dapine",
"docs/core/tools/**/**.md": "tdykstra",
"docs/core/tutorials/**/**.md": "tdykstra",
"docs/core/versions/**/**.md": "wiwagn",
"docs/core/whats-new/**/**.md": "adegeo",
"docs/csharp/**/*.*": "wiwagn",
"docs/framework/**/**.md": "dotnetcontent",
"docs/framework/app-domains/**/**.md": "gewarren",
"docs/framework/configure-apps/file-schema/network/**/**.md": "ncldev",
"docs/framework/configure-apps/file-schema/wcf/**/**.md": "wcfsrvt",
"docs/framework/configure-apps/file-schema/winforms/**/**.md": "adegeo",
"docs/framework/data/adonet/**/**.md": "dotnetcontent",
"docs/framework/data/wcf/**/**.md": "wcfsrvt",
"docs/framework/deployment/**/**.md": "adegeo",
"docs/framework/get-started/**/**.md": "gewarren",
"docs/framework/install/**/**.md": "adegeo",
"docs/framework/migration-guide/**/**.md": "gewarren",
"docs/framework/misc/**/**.md": "gewarren",
"docs/framework/network-programming/**/**.md": "ncldev",
"docs/framework/performance/**/**.md": "wiwagn",
"docs/framework/reflection-and-codedom/**/**.md": "adegeo",
"docs/framework/resources/**/**.md": "adegeo",
"docs/framework/tools/**/**.md": "tdykstra",
"docs/framework/ui-automation/**/**.md": "adegeo",
"docs/framework/unmanaged-api/alink/**/**.md": "jeffschw",
"docs/framework/unmanaged-api/debugging/**/**.md": "tommcdon",
"docs/framework/unmanaged-api/diagnostics/**/**.md": "tommcdon",
"docs/framework/unmanaged-api/fusion/**/**.md": "jeffschw",
"docs/framework/unmanaged-api/hosting/**/**.md": "jeffschw",
"docs/framework/unmanaged-api/profiling/**/**.md": "tommcdon",
"docs/framework/unmanaged-api/strong-naming/**/**.md": "jeffschw",
"docs/framework/unmanaged-api/tlbexp/**/**.md": "jeffschw",
"docs/framework/whats-new/**/**.md": "gewarren",
"docs/framework/wcf/**/**.md": "wcfsrvt",
"docs/fsharp/**/**.md": "dotnetcontent",
"docs/fundamentals/code-analysis/**/*.md": "gewarren",
"docs/fundamentals/syslib-diagnostics/**/**.md": "gewarren",
"docs/iot/**/*.*": "casoper",
"docs/machine-learning/**/**.md": "luquinta",
"docs/spark/**/**.md": "luquinta",
"docs/standard/**/**.md": "gewarren",
"docs/standard/analyzers/**/**.md": "dapine",
"docs/standard/assembly/**/**.md": "dapine",
"docs/standard/asynchronous-programming-patterns/**/**.md": "wiwagn",
"docs/standard/attributes/**/**.md": "tdykstra",
"docs/standard/base-types/**/**.md": "adegeo",
"docs/standard/collections/**/**.md": "dapine",
"docs/standard/data/**/**.md": "gewarren",
"docs/standard/data/sqlite/**/**.md": "bricelam",
"docs/standard/datetime/**/**.md": "adegeo",
"docs/standard/design-guidelines/**/**.md": "kcwalina",
"docs/standard/events/**/**.md": "dapine",
"docs/standard/exceptions/**/**.md": "tdykstra",
"docs/standard/garbage-collection/**/**.md": "gewarren",
"docs/standard/generics/**/**.md": "adegeo",
"docs/standard/globalization-localization/**/**.md": "dotnetcontent",
"docs/standard/io/**/**.md": "adegeo",
"docs/standard/library-guidance/**/**.md": "jamesnk",
"docs/standard/linq/**/**.md": "dotnetcontent",
"docs/standard/memory-and-spans/**/**.md": "tdykstra",
"docs/standard/native-interop/**/**.md": "jekoritz",
"docs/standard/parallel-programming/**/**.md": "dapine",
"docs/standard/security/**/**.md": "dapine",
"docs/standard/serialization/**/**.md": "tdykstra",
"docs/standard/threading/**/**.md": "wiwagn",
"docs/standard/whats-new/**/**.md": "dotnetcontent",
"docs/visual-basic/**/**.md": "kdollard"
},
"ms.date": {
"_csharplang/spec/*.md": "07/01/2017",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\SourceGenerator\SourceGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace ConsoleApp;

partial class Program
{
static void Main(string[] args)
{
HelloFrom("Generated Code");
}

static partial void HelloFrom(string name);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Microsoft.CodeAnalysis;

namespace SourceGenerator
{
[Generator]
public class HelloSourceGenerator : ISourceGenerator
{
public void Execute(GeneratorExecutionContext context)
{
// Find the main method
var mainMethod = context.Compilation.GetEntryPoint(context.CancellationToken);

// Build up the source code
string source = $@" // Auto-generated code
using System;
namespace {mainMethod.ContainingNamespace.ToDisplayString()}
{{
public static partial class {mainMethod.ContainingType.Name}
{{
static partial void HelloFrom(string name) =>
Console.WriteLine($""Generator says: Hi from '{{name}}'"");
}}
}}
";
var typeName = mainMethod.ContainingType.Name;

// Add the source code to the compilation
context.AddSource($"{typeName}.g.cs", source);
}

public void Initialize(GeneratorInitializationContext context)
{
// No initialization required for this one
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.0.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3" PrivateAssets="all" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.32002.185
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleApp", "ConsoleApp\ConsoleApp.csproj", "{B0A361D0-D9D7-4E39-AFC1-189121AAC9CE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SourceGenerator", "SourceGenerator\SourceGenerator.csproj", "{7CB852F5-F320-41AF-B1AC-4CDBD61FEB17}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B0A361D0-D9D7-4E39-AFC1-189121AAC9CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B0A361D0-D9D7-4E39-AFC1-189121AAC9CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B0A361D0-D9D7-4E39-AFC1-189121AAC9CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B0A361D0-D9D7-4E39-AFC1-189121AAC9CE}.Release|Any CPU.Build.0 = Release|Any CPU
{7CB852F5-F320-41AF-B1AC-4CDBD61FEB17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7CB852F5-F320-41AF-B1AC-4CDBD61FEB17}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7CB852F5-F320-41AF-B1AC-4CDBD61FEB17}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7CB852F5-F320-41AF-B1AC-4CDBD61FEB17}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8483CBEE-3CD5-4416-96BF-D457893183B6}
EndGlobalSection
EndGlobal
Loading

0 comments on commit 6bf4df1

Please sign in to comment.