Temporarily fix VB App Framework Logging.#7590
Temporarily fix VB App Framework Logging.#7590KlausLoeffelmann merged 14 commits intodotnet:mainfrom
Conversation
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| get => GetCachedSwitchValue(ScaleTopLevelFormMinMaxSizeForDpiSwitchName, ref s_scaleTopLevelFormMinMaxSizeForDpi); | ||
| } | ||
| private const string AssumeVbLogClassWasConfiguredByConfigFileName = "System.Windows.Forms.AssumeVbLogClassWasConfiguredByConfigFile"; |
There was a problem hiding this comment.
CS applications don't need this switch, why not put it into the VB assembly?
There was a problem hiding this comment.
I wouldn't say this is language related?
It's not that the Application Framework can only be used by VB. So, for example, take a look at this:
Also, I often saw even C# WPF apps using a few features from the VB App Framework to ease their life. It's a valid approach!
There was a problem hiding this comment.
Application that benefits from this quirk, references AppFramework, right? Why doesn't this quirk belong to Applicationframework then?
| If _listenerAttributes Is Nothing Then | ||
| _listenerAttributes = Attributes | ||
| End If | ||
| Return _hasBeenInitializedFromConfigFile |
There was a problem hiding this comment.
I would had returned false here for the RC and would have worked on the proper fix, i.e. how to get if this was initialized from the config file.
There was a problem hiding this comment.
I thought about this first. But then I thought, there is a good chance it will stay like this, and then we could have it right away.
There was a problem hiding this comment.
there is a good chance it will stay like this,
Maybe runtime can add a protected property for us to look up?
|
I don't quite understand the use cases, developer and user experiences. It would be great if you could provide more details explaining those. E.g., this is how a .NET Framework app worked, now ported to .NET 7 it'd work like this. Would a developer or use need to opt-in or opt-out? |
|
I pretty much explained the breaking change in the runtime which led to this. |
|
I would prefer returning a false unconditionally because: |
|
Squash merge please. Or enable auto-merge (that is squash default) |
| End If | ||
| Return _hasBeenInitializedFromConfigFile | ||
|
|
||
| ' TODO: This is a tempory fix, which will break configuring logging via file for the time being. See: https://github.com/dotnet/winforms/pull/7590 |
There was a problem hiding this comment.
Did you open a follow up bug to get this fixed?
|
@KlausLoeffelmann is this a breaking change that we need to document? |
|
@RussKie yeah, probably. It would be a minute number of customers impacted but it's good to document it of course. |
|
app config was not enabled in the previous versions, so this is a regression from .NET framework but not from the previous release of Core |
The runtime PR dotnet/runtime#73087 broke the Visual Basic Application Framework Logging.
https://source.dot.net/#Microsoft.VisualBasic.Forms/Microsoft/VisualBasic/Logging/Log.vb,170
The original assumption that this would work was, that when
GetSupportedAttributesgets called in a class derived fromTraceSourcethat then would tell that the trace source was configured from a config file. This is not only whatDefaultTraceSourcedoes, it seems to be the only reason for it existence. Now, as far as I understand it, after the change,GetSupportAttributesgets called unconditionally, soHasBeenConfiguredin the VB AppFramework'sDefaultTraceSourcereturns alwaystrue, and so a FileLogTraceListener gets never added, since the Log class assumes, the trace source was configured by a config file. And that's why there will never be a value other thannothingfor theDefaultFileLogWriterproperty.After discussing this with the WinForms Team and the VB PM, we're fixing this temporary in the runtime, by returning
falseunconditionally forLogging.Log.HasBeenConfigured. This assumes, that the trace source has NOT been configured by a config file. Configuring by a config file remains a broken scenario for VB My.Logging, until we will be getting a fix from the Runtime.Microsoft Reviewers: Open in CodeFlow