-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Temporarily fix VB App Framework Logging. #7590
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CS applications don't need this switch, why not put it into the VB assembly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Application that benefits from this quirk, references AppFramework, right? Why doesn't this quirk belong to Applicationframework then?
@@ -163,20 +164,10 @@ Namespace Microsoft.VisualBasic.Logging | |||
If _listenerAttributes Is Nothing Then | |||
_listenerAttributes = Attributes | |||
End If | |||
Return _hasBeenInitializedFromConfigFile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is a good chance it will stay like this,
Maybe runtime can add a protected property for us to look up?
...ystem.Windows.Forms.Primitives/src/System/LocalAppContextSwitches/LocalAppContextSwitches.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms.Primitives/src/System.Windows.Forms.Primitives.csproj
Outdated
Show resolved
Hide resolved
...ystem.Windows.Forms.Primitives/src/System/LocalAppContextSwitches/LocalAppContextSwitches.cs
Outdated
Show resolved
Hide resolved
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: |
src/Microsoft.VisualBasic.Forms/src/Microsoft.VisualBasic.Forms.vbproj
Outdated
Show resolved
Hide resolved
Squash merge please. Or enable auto-merge (that is squash default) |
@@ -163,20 +163,12 @@ Namespace Microsoft.VisualBasic.Logging | |||
If _listenerAttributes Is Nothing Then | |||
_listenerAttributes = Attributes | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
GetSupportedAttributes
gets called in a class derived fromTraceSource
that then would tell that the trace source was configured from a config file. This is not only whatDefaultTraceSource
does, it seems to be the only reason for it existence. Now, as far as I understand it, after the change,GetSupportAttributes
gets called unconditionally, soHasBeenConfigured
in the VB AppFramework'sDefaultTraceSource
returns 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 thannothing
for theDefaultFileLogWriter
property.After discussing this with the WinForms Team and the VB PM, we're fixing this temporary in the runtime, by returning
false
unconditionally 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