I create a CSharpCodeProvider
like so:
CSharpCodeProvider codeProvider = new CSharpCodeProvider(new Dictionary<string, string>{{ "CompilerVersion", "v4.0" }});
CompilerParameters compileParameters = new CompilerParameters(refs.ToArray(), newFile, debugBuild) { WarningLevel = 4 };
I have a script that creates the WPF FormattedText
object likes so:
FormattedText volumeText = new FormattedText(volumeString, Core.Globals.GeneralOptions.CurrentCulture, FlowDirection.LeftToRight, typeFace, SuperDom.Font.Size, ForeColor) { MaxLineCount = 1, MaxTextWidth = renderWidth - 6, Trimming = TextTrimming.CharacterEllipsis };
.NET 4.6.2 added a new constructor for specifying DPI scaling and the current method we use is deprecated. However, our application targets .NET 4.5.0, and this is all we support. However, when compiling my code, I still get the following warning:
Warning: 'System.Windows.Media.FormattedText.FormattedText(string, System.Globalization.CultureInfo, System.Windows.FlowDirection, System.Windows.Media.Typeface, double, System.Windows.Media.Brush)' is obsolete: 'Use the PixelsPerDip override'
There is no valid use case (for us) where the new constructor is valid, and in fact what I would expect if someone tried to use it is to get a compile error due to that method signature being incorrect for 4.5.
Is there a way to avoid these warnings? Previously we did not specify the CompilerVersion
for the code provider, but adding it did not help, and based on what I've seen in other questions here, v4.0 is the only valid version to use for my case anyway. Would a different warning level avoid this?