-
Notifications
You must be signed in to change notification settings - Fork 327
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
Aggressively seal classes in package:devtools_app_shared
#6235
Conversation
It feels weird using I think we should be very aggressive with marking anything we expose through this package as |
@@ -2,6 +2,8 @@ | |||
// Use of this source code is governed by a BSD-style license that can be | |||
// found in the LICENSE file. | |||
|
|||
import 'dart:async'; | |||
|
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.
this file should be reviewed
@@ -161,6 +161,13 @@ MockVmServiceWrapper createMockVmServiceWrapperWithDefaults() { | |||
return service; | |||
} | |||
|
|||
MockServiceConnectionManager createMockServiceConnectionWithDefaults() { |
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.
new code
@@ -20,35 +20,103 @@ import 'fake_vm_service_wrapper.dart'; | |||
import 'generated.mocks.dart'; | |||
import 'mocks.dart'; | |||
|
|||
class FakeServiceManager extends Fake implements ServiceConnectionManager { | |||
FakeServiceManager({ | |||
class FakeServiceConnectionManager extends Fake |
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.
this file should be reviewed
@@ -7,6 +7,7 @@ import 'dart:core'; | |||
|
|||
import 'package:flutter/foundation.dart'; | |||
import 'package:logging/logging.dart'; | |||
import 'package:meta/meta.dart'; |
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.
this file should be reviewed
@@ -188,3 +193,40 @@ class ConnectedApp { | |||
flutterVersionKey: flutterVersionNow!.version, | |||
}; | |||
} | |||
|
|||
final class OfflineConnectedApp extends ConnectedApp { |
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.
moved from package:devtools_app and marked final
@@ -150,7 +196,8 @@ class ServiceConnectionManager extends ServiceManager<VmServiceWrapper> { | |||
/// | |||
/// Throws an Exception if no 'FlutterView' is present in this isolate. | |||
Future<String> get flutterViewId async { |
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.
superficially extensions like this seem equally useful for devtools extensions as for devtools proper.
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.
Agreed we may want to expose this. For now, I'd like to keep the API small and add more to devtools_app_shared
as it makes sense.
@override | ||
List<IsolateRef> isolatesFromVm(VM? vm) { | ||
return vm?.isolatesForDevToolsMode() ?? <IsolateRef>[]; | ||
Future<String?> rootLibraryForMainIsolate() async { |
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.
this seems like something an extension might want to know. how do you draw the line on whether to include it in the shared code or not?
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.
Agreed we may want to expose this. For now, I'd like to keep the API small and add more to devtools_app_shared
as it makes sense. At this point I am exposing everything needed for the package:provider extension as a customer zero, and will expose more as we get a better idea of what more initial customers need.
Turns out there is an alternative to using |
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.
LGTM, but we should probably get another +1 as I had a hard time reviewing this thoroughly (Chrome + GitHub are thrashing hard when I open the "Files changed" tab).
@@ -33,7 +35,35 @@ const debugLogServiceProtocolEvents = false; | |||
|
|||
const defaultRefreshRate = 60.0; | |||
|
|||
class ServiceConnectionManager extends ServiceManager<VmServiceWrapper> { | |||
class ServiceConnectionManager { | |||
ServiceConnectionManager() { |
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.
Nit: can't this be ServiceConnectionManager() : serviceManager = ServiceManager().. //...
? Then I think you can remove the late
from the declaration of serviceManager
as well.
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.
the callbacks can't be accessed in an initializer.
Also, do we plan on using the solution from dart-lang/language#3106 (comment) or landing with |
In this comment here, I explain why we need to use |
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.
Seems alright to me, but it was definitely a lot to review :P
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.
oops I meant to approve
devtools_app_shared
will be published on pub and will be used by DevTools extension authors to build extensions. In order to limit breaking changes to DevTools extensions, we would like to "seal" as many classes in this shared library as possible.This PR aggressively marks classes as
final
, where possible. In cases where marking classesfinal
would prohibit us from being able to effectively write tests, we use the@sealed
annotation frompackage:meta
.@bkonyi @jacob314