RoslynCodeDomProvider
RoslynCodeDomProvider copied to clipboard
Found resource/memory leak from never disposing of a disposable inside of a linq query.
The code here: https://github.com/aspnet/RoslynCodeDomProvider/blob/main/src/Microsoft.CodeDom.Providers.DotNetCompilerPlatform/Compiler.cs#L52-L56
Contains a resource/memory leak from not disposing of the disposable inside of the .Select when it gets computed at runtime for each item in it.
The best way to fix this is to use the simplified using syntax by setting <LangVersion>8</LangVersion> or newer inside of the csproj.
For .NET Framework projects I have tested that even the absolute latest language version in the latest compiler binaries (even the preview ones in VS2022 Preview) works, even when the language version of preview is used as well. Just got to be aware of what specific features to avoid however.
I only found this when I started to port the code over myself to my own project to improve it as it seems this repository is not maintained much and I needed some much needed fixes ASAP.