Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
efd8b644
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
efd8b644
编写于
5月 12, 2017
作者:
F
Fredric Silberberg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactored logic into helpers.
上级
1d11b70f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
28 addition
and
28 deletion
+28
-28
src/VisualStudio/Core/Def/Implementation/Experimentation/AnalyzerVsixSuggestedActionCallback.cs
...on/Experimentation/AnalyzerVsixSuggestedActionCallback.cs
+28
-28
未找到文件。
src/VisualStudio/Core/Def/Implementation/Experimentation/AnalyzerVsixSuggestedActionCallback.cs
浏览文件 @
efd8b644
...
...
@@ -56,13 +56,29 @@ public void OnSuggestedActionExecuted(SuggestedAction action)
return
;
}
EnsureInitialized
();
// Only show if the VSIX is not installed, the info bar hasn't been shown this session,
// and the user is an A/B test candidate
if
(!
IsVsixInstalled
()
&&
!
_infoBarShown
&&
IsCandidate
())
{
ShowInfoBarIfNecessary
();
}
}
private
void
EnsureInitialized
()
{
// Initialize the experimentation service if it hasn't yet been fetched
if
(
_experimentationService
==
null
)
{
_experimentationService
=
_workspace
.
Services
.
GetRequiredService
<
IExperimentationService
>();
}
}
// If we haven't yet checked to see if the VSIX is installed, check now
private
bool
IsVsixInstalled
()
{
if
(
_installStatus
==
LiveCodeAnalysisInstallStatus
.
Unknown
)
{
var
vsShell
=
_serviceProvider
.
GetService
(
typeof
(
SVsShell
))
as
IVsShell
;
...
...
@@ -75,33 +91,25 @@ public void OnSuggestedActionExecuted(SuggestedAction action)
// suggested action is called, and we don't want to continue if the shell
// is busted.
_installStatus
=
LiveCodeAnalysisInstallStatus
.
Installed
;
return
;
}
_installStatus
=
installed
!=
0
?
LiveCodeAnalysisInstallStatus
.
Installed
:
LiveCodeAnalysisInstallStatus
.
NotInstalled
;
}
// Only proceed if the VSIX isn't installed
if
(
_installStatus
==
LiveCodeAnalysisInstallStatus
.
Installed
)
{
return
;
else
{
_installStatus
=
installed
!=
0
?
LiveCodeAnalysisInstallStatus
.
Installed
:
LiveCodeAnalysisInstallStatus
.
NotInstalled
;
}
}
if
(!
_infoBarShown
)
{
SuggestedActionOccurred
();
}
return
_installStatus
==
LiveCodeAnalysisInstallStatus
.
Installed
;
}
private
void
SuggestedActionOccurred
()
private
bool
IsCandidate
()
{
var
options
=
_workspace
.
Options
;
// Filter for valid A/B test candidates. Candidates fill the following critera:
// 1: Are a Dotnet user (as evidenced by the fact that this code is being run)
// 2: Have triggered a lightbulb on 3 separate days
// If the user hasn't met candidacy conditions, then we check them. Otherwise, proceed
// to info bar check
var
options
=
_workspace
.
Options
;
var
isCandidate
=
options
.
GetOption
(
AnalyzerABTestOptions
.
HasMetCandidacyRequirements
);
if
(!
isCandidate
)
{
...
...
@@ -125,14 +133,7 @@ private void SuggestedActionOccurred()
}
}
// If the user still isn't a candidate, then return. Otherwise, we move to checking if
// the infobar should be shown
if
(!
isCandidate
)
{
return
;
}
ShowInfoBarIfNecessary
();
return
isCandidate
;
}
private
void
ShowInfoBarIfNecessary
()
...
...
@@ -142,12 +143,13 @@ private void ShowInfoBarIfNecessary()
// If we got true from the experimentation service, then we're in the treatment
// group, and the experiment is enabled. We determine if the infobar has been
// displayed in the past 24 hours. If it hasn't been displayed, then we do so now.
var
last
Day
InfoBarShown
=
DateTime
.
FromBinary
(
_workspace
.
Options
.
GetOption
(
AnalyzerABTestOptions
.
LastDateTimeInfoBarShown
));
var
last
Time
InfoBarShown
=
DateTime
.
FromBinary
(
_workspace
.
Options
.
GetOption
(
AnalyzerABTestOptions
.
LastDateTimeInfoBarShown
));
var
utcNow
=
DateTime
.
UtcNow
;
var
timeSinceLastShown
=
utcNow
-
last
Day
InfoBarShown
;
var
timeSinceLastShown
=
utcNow
-
last
Time
InfoBarShown
;
if
(
timeSinceLastShown
.
TotalDays
>=
1
)
{
_infoBarShown
=
true
;
_workspace
.
Options
=
_workspace
.
Options
.
WithChangedOption
(
AnalyzerABTestOptions
.
LastDateTimeInfoBarShown
,
utcNow
.
ToBinary
());
var
infoBarService
=
_workspace
.
Services
.
GetRequiredService
<
IInfoBarService
>();
...
...
@@ -161,8 +163,6 @@ private void ShowInfoBarIfNecessary()
new
InfoBarUI
(
title
:
ServicesVSResources
.
Analyzer_vsix_do_not_show_again
,
kind
:
InfoBarUI
.
UIKind
.
Button
,
action
:
DoNotShowAgain
));
_infoBarShown
=
true
;
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录