Skip to content

Conversation

@IEvangelist
Copy link
Member

@IEvangelist IEvangelist commented Oct 9, 2024

Summary

  • Extend config extensions doc with binding source generator info

Fixes #36939, /cc @ericstj


Internal previews

📄 File 🔗 Preview link
docs/core/extensions/configuration-generator.md docs/core/extensions/configuration-generator
docs/core/extensions/configuration.md docs/core/extensions/configuration

@dotnet-policy-service dotnet-policy-service bot added okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings. 🏁 Release: .NET 9 Work items for the .NET 9 release labels Oct 9, 2024
@IEvangelist IEvangelist changed the title Draft of config source gen with interceptors Add content for config source gen with interceptors Oct 9, 2024
@IEvangelist IEvangelist requested a review from adegeo October 9, 2024 15:39
@IEvangelist IEvangelist marked this pull request as ready for review October 9, 2024 15:40
@IEvangelist IEvangelist requested a review from a team as a code owner October 9, 2024 15:40
@ericstj
Copy link
Member

ericstj commented Oct 9, 2024

@dotnet/area-extensions-configuration @tarekgh @eiriktsarpalis cc @eerhardt @steveharter

@ericstj ericstj requested a review from tarekgh October 9, 2024 15:57
Copy link
Member

@tarekgh tarekgh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes LGTM. Thanks @IEvangelist!

I have a suggestion but I'm not sure if it is worth adding. The provided sample is good, we can show a sample of the generated source too with warning the users may not get exact generated code as the source gen is evolving.

Also, using <EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles> in the project will make the build process keep the generated code that allow users to inspect it.

@IEvangelist
Copy link
Member Author

EmitCompilerGeneratedFiles

Hi @tarekgh - thanks for the quick review. I just tried adding the <EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles> but even after multiple forced clean/builds, it is not working.

Here's the error I'm seeing:

Exception details ``` 1>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets(89,5): error : 1>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets(89,5): error : Unhandled Exception: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\david\source\repos\docs\docs\core\extensions\snippets\configuration\console-binder-gen\obj\Debug\net8.0\generated\Microsoft.Extensions.Configuration.Binder.SourceGeneration\Microsoft.Extensions.Configuration.Binder.SourceGeneration.ConfigurationBindingGenerator'. 1>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets(89,5): error : at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 1>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets(89,5): error : at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj, Boolean checkHost) 1>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets(89,5): error : at System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean checkHost) 1>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets(89,5): error : at Microsoft.CodeAnalysis.CommonCompiler.CompileAndEmit(TouchedFileLogger touchedFilesLogger, Compilation& compilation, ImmutableArray`1 analyzers, ImmutableArray`1 generators, ImmutableArray`1 additionalTextFiles, AnalyzerConfigSet analyzerConfigSet, ImmutableArray`1 sourceFileAnalyzerConfigOptions, ImmutableArray`1 embeddedTexts, DiagnosticBag diagnostics, ErrorLogger errorLogger, CancellationToken cancellationToken, CancellationTokenSource& analyzerCts, AnalyzerDriver& analyzerDriver, Nullable`1& generatorTimingInfo) 1>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets(89,5): error : at Microsoft.CodeAnalysis.CommonCompiler.RunCore(TextWriter consoleOutput, ErrorLogger errorLogger, CancellationToken cancellationToken) 1>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets(89,5): error : at Microsoft.CodeAnalysis.CommonCompiler.Run(TextWriter consoleOutput, CancellationToken cancellationToken) 1>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets(89,5): error : at Microsoft.CodeAnalysis.CSharp.CommandLine.Csc.<>c__DisplayClass1_0.b__0(TextWriter tw) 1>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets(89,5): error : at Microsoft.CodeAnalysis.CommandLine.ConsoleUtil.RunWithUtf8Output[T](Func`2 func) 1>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets(89,5): error : at Microsoft.CodeAnalysis.CSharp.CommandLine.Csc.Run(String[] args, BuildPaths buildPaths, TextWriter textWriter, IAnalyzerAssemblyLoader analyzerLoader) 1>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets(89,5): error : at Microsoft.CodeAnalysis.CommandLine.BuildClient.RunLocalCompilation(String[] arguments, BuildPaths buildPaths, TextWriter textWriter) 1>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets(89,5): error : at Microsoft.CodeAnalysis.CommandLine.BuildClient.RunCompilation(IEnumerable`1 originalArguments, BuildPaths buildPaths, TextWriter textWriter, String pipeName) 1>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets(89,5): error : at Microsoft.CodeAnalysis.CommandLine.BuildClient.Run(IEnumerable`1 arguments, RequestLanguage language, CompileFunc compileFunc, CompileOnServerFunc compileOnServerFunc, ICompilerServerLogger logger) 1>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets(89,5): error : at Microsoft.CodeAnalysis.CSharp.CommandLine.Program.MainCore(String[] args) 1>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets(89,5): error : at Microsoft.CodeAnalysis.CSharp.CommandLine.Program.Main(String[] args) ```

@IEvangelist IEvangelist merged commit 2a70c23 into dotnet:main Oct 9, 2024
8 checks passed
@tarekgh
Copy link
Member

tarekgh commented Oct 9, 2024

I just tried adding the true but even after multiple forced clean/builds, it is not working.

EmitCompilerGeneratedFiles is documented here https://learn.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/source-generators-overview and worked all the time for me. Could your machine not be enabled for long paths? https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry#enable-long-paths-in-windows-10-version-1607-and-later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🏁 Release: .NET 9 Work items for the .NET 9 release okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings.

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

Extend config extensions doc with binding source generator info

3 participants