code
stringlengths 2
1.05M
| repo_name
stringlengths 5
101
| path
stringlengths 4
991
| language
stringclasses 3
values | license
stringclasses 5
values | size
int64 2
1.05M
|
|---|---|---|---|---|---|
Imports System
Imports System.Data
Imports System.Collections
Imports System.Web.UI
Imports Telerik.Web.UI
Imports SistFoncreagro.BussinessEntities
Imports SistFoncreagro.BussinesLogic
Public Class ControlCuentaBancaria
Inherits System.Web.UI.UserControl
Private _dataItem As Object = Nothing
Dim PlanContableBl As New PlanContableBL
Dim _PlanContable As PlanContable
Public Property DataItem() As Object
Get
Return Me._dataItem
End Get
Set(ByVal value As Object)
Me._dataItem = value
End Set
End Property
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.RadComboBox1.Filter = 1
Me.RadComboBox2.Filter = 1
End Sub
Protected Sub Page_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.DataBinding
If Not TypeOf DataItem Is GridInsertionObject Then
'para la lista de valores de cuenta contable
_PlanContable = PlanContableBl.GetPLANCONTABLEByIdPlan(DataBinder.Eval(DataItem, "IdPlan"))
If Not _PlanContable Is Nothing Then
Me.RadComboBox1.DataSourceID = "odsPlanContable1"
Me.odsPlanContable1.SelectParameters("Texto").DefaultValue = _PlanContable.Nombre
Me.RadComboBox1.DataBind()
Me.RadComboBox1.SelectedValue = DataBinder.Eval(DataItem, "IdPlan")
End If
Me.TextBox1.Text = DataBinder.Eval(DataItem, "Descripcion")
Me.DropDownList1.SelectedValue = DataBinder.Eval(DataItem, "IdMoneda")
Me.DropDownList2.SelectedValue = DataBinder.Eval(DataItem, "IdBanco")
Me.DropDownList3.SelectedValue = DataBinder.Eval(DataItem, "IdTipoCtaBancaria")
Me.TextBox2.Text = DataBinder.Eval(DataItem, "NroCta")
Me.RadComboBox2.SelectedValue = DataBinder.Eval(DataItem, "IdSubdiario")
End If
End Sub
Protected Sub RadComboBox1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadComboBoxItemEventArgs) Handles RadComboBox1.ItemDataBound
e.Item.Text = (DirectCast(e.Item.DataItem, SistFoncreagro.BussinessEntities.PlanContable)).Cuenta.ToString()
e.Item.Value = (DirectCast(e.Item.DataItem, SistFoncreagro.BussinessEntities.PlanContable)).IdPlan.ToString()
End Sub
Protected Sub RadComboBox1_ItemsRequested(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs) Handles RadComboBox1.ItemsRequested
If e.Text.Length > 2 Then
Me.RadComboBox1.DataSourceID = "odsPlanContable1"
Me.odsPlanContable1.SelectParameters("Texto").DefaultValue = e.Text.ToString
Me.RadComboBox1.DataBind()
End If
End Sub
End Class
|
crackper/SistFoncreagro
|
SistFoncreagro.WebSite/Contabilidad/Controles/ControlCuentaBancaria.ascx.vb
|
Visual Basic
|
mit
| 2,800
|
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated by a tool.
' Runtime Version:4.0.30319.17929
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Namespace My
'NOTE: This file is auto-generated; do not modify it directly. To make changes,
' or if you encounter build errors in this file, go to the Project Designer
' (go to Project Properties or double-click the My Project node in
' Solution Explorer), and make changes on the Application tab.
'
Partial Friend Class MyApplication
<Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
Public Sub New()
MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows)
Me.IsSingleInstance = false
Me.EnableVisualStyles = true
Me.SaveMySettingsOnExit = true
Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses
End Sub
<Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
Protected Overrides Sub OnCreateMainForm()
Me.MainForm = Global.Length_Conversion.frmConversion
End Sub
End Class
End Namespace
|
patkub/visual-basic-intro
|
Length Conversion/Length Conversion/My Project/Application.Designer.vb
|
Visual Basic
|
mit
| 1,491
|
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated by a tool.
' Runtime Version:4.0.30319.42000
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Namespace My.Resources
'This class was auto-generated by the StronglyTypedResourceBuilder
'class via a tool like ResGen or Visual Studio.
'To add or remove a member, edit your .ResX file then rerun ResGen
'with the /str option, or rebuild your VS project.
'''<summary>
''' A strongly-typed resource class, for looking up localized strings, etc.
'''</summary>
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0"), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
Friend Module Resources
Private resourceMan As Global.System.Resources.ResourceManager
Private resourceCulture As Global.System.Globalization.CultureInfo
'''<summary>
''' Returns the cached ResourceManager instance used by this class.
'''</summary>
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
Get
If Object.ReferenceEquals(resourceMan, Nothing) Then
Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("ng2ts.Resources", GetType(Resources).Assembly)
resourceMan = temp
End If
Return resourceMan
End Get
End Property
'''<summary>
''' Overrides the current thread's CurrentUICulture property for all
''' resource lookups using this strongly typed resource class.
'''</summary>
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Friend Property Culture() As Global.System.Globalization.CultureInfo
Get
Return resourceCulture
End Get
Set(ByVal value As Global.System.Globalization.CultureInfo)
resourceCulture = value
End Set
End Property
End Module
End Namespace
|
errisy/ng2ts
|
My Project/Resources.Designer.vb
|
Visual Basic
|
mit
| 2,710
|
Imports System
Imports System.Reflection
Imports System.Runtime.InteropServices
' General Information about an assembly is controlled through the following
' set of attributes. Change these attribute values to modify the information
' associated with an assembly.
' Review the values of the assembly attributes
<Assembly: AssemblyTitle("rapidserverlib")>
<Assembly: AssemblyDescription("")>
<Assembly: AssemblyCompany("")>
<Assembly: AssemblyProduct("rapidserverlib")>
<Assembly: AssemblyCopyright("Copyright © 2014")>
<Assembly: AssemblyTrademark("")>
<Assembly: ComVisible(False)>
'The following GUID is for the ID of the typelib if this project is exposed to COM
<Assembly: Guid("8fd138cd-a347-45d0-99d2-82d8c4372cb4")>
' Version information for an assembly consists of the following four values:
'
' Major Version
' Minor Version
' Build Number
' Revision
'
' You can specify all the values or you can default the Build and Revision Numbers
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.0.0.0")>
<Assembly: AssemblyFileVersion("1.0.0.0")>
|
perrybutler/rapid-server
|
rapidserverlib/My Project/AssemblyInfo.vb
|
Visual Basic
|
mit
| 1,146
|
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class frmShowMessage
Inherits System.Windows.Forms.Form
'Form 重写 Dispose,以清理组件列表。
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改它。
'不要使用代码编辑器修改它。
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmShowMessage))
Me.Label1 = New System.Windows.Forms.Label()
Me.txtUUID = New System.Windows.Forms.TextBox()
Me.Label2 = New System.Windows.Forms.Label()
Me.txtSender = New System.Windows.Forms.TextBox()
Me.Label3 = New System.Windows.Forms.Label()
Me.txtReceiveTime = New System.Windows.Forms.TextBox()
Me.txtMessage = New System.Windows.Forms.TextBox()
Me.Button1 = New System.Windows.Forms.Button()
Me.Button2 = New System.Windows.Forms.Button()
Me.Button3 = New System.Windows.Forms.Button()
Me.Button4 = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(12, 15)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(23, 15)
Me.Label1.TabIndex = 0
Me.Label1.Text = "ID"
'
'txtUUID
'
Me.txtUUID.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.txtUUID.Location = New System.Drawing.Point(95, 12)
Me.txtUUID.Name = "txtUUID"
Me.txtUUID.ReadOnly = True
Me.txtUUID.Size = New System.Drawing.Size(540, 25)
Me.txtUUID.TabIndex = 1
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Location = New System.Drawing.Point(12, 46)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(52, 15)
Me.Label2.TabIndex = 2
Me.Label2.Text = "发送者"
'
'txtSender
'
Me.txtSender.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.txtSender.Location = New System.Drawing.Point(95, 43)
Me.txtSender.Name = "txtSender"
Me.txtSender.ReadOnly = True
Me.txtSender.Size = New System.Drawing.Size(540, 25)
Me.txtSender.TabIndex = 3
'
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.Location = New System.Drawing.Point(12, 77)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(67, 15)
Me.Label3.TabIndex = 4
Me.Label3.Text = "接收时间"
'
'txtReceiveTime
'
Me.txtReceiveTime.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.txtReceiveTime.Location = New System.Drawing.Point(95, 74)
Me.txtReceiveTime.Name = "txtReceiveTime"
Me.txtReceiveTime.ReadOnly = True
Me.txtReceiveTime.Size = New System.Drawing.Size(540, 25)
Me.txtReceiveTime.TabIndex = 5
'
'txtMessage
'
Me.txtMessage.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.txtMessage.Location = New System.Drawing.Point(15, 105)
Me.txtMessage.Multiline = True
Me.txtMessage.Name = "txtMessage"
Me.txtMessage.ReadOnly = True
Me.txtMessage.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
Me.txtMessage.Size = New System.Drawing.Size(620, 361)
Me.txtMessage.TabIndex = 7
'
'Button1
'
Me.Button1.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.Button1.Location = New System.Drawing.Point(560, 472)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(75, 35)
Me.Button1.TabIndex = 8
Me.Button1.Text = "关闭(&C)"
Me.Button1.UseVisualStyleBackColor = True
'
'Button2
'
Me.Button2.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.Button2.Location = New System.Drawing.Point(479, 472)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(75, 35)
Me.Button2.TabIndex = 9
Me.Button2.Text = "删除(&D)"
Me.Button2.UseVisualStyleBackColor = True
'
'Button3
'
Me.Button3.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.Button3.Location = New System.Drawing.Point(383, 472)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(90, 35)
Me.Button3.TabIndex = 10
Me.Button3.Text = "另存为(&S)"
Me.Button3.UseVisualStyleBackColor = True
'
'Button4
'
Me.Button4.Location = New System.Drawing.Point(15, 473)
Me.Button4.Name = "Button4"
Me.Button4.Size = New System.Drawing.Size(75, 34)
Me.Button4.TabIndex = 11
Me.Button4.Text = "回复(&R)"
Me.Button4.UseVisualStyleBackColor = True
'
'frmShowMessage
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 15.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(647, 519)
Me.Controls.Add(Me.Button4)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.txtMessage)
Me.Controls.Add(Me.txtReceiveTime)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.txtSender)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.txtUUID)
Me.Controls.Add(Me.Label1)
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Name = "frmShowMessage"
Me.Text = "查看短消息"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents txtUUID As System.Windows.Forms.TextBox
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents txtSender As System.Windows.Forms.TextBox
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents txtReceiveTime As System.Windows.Forms.TextBox
Friend WithEvents txtMessage As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Button3 As System.Windows.Forms.Button
Friend WithEvents Button4 As System.Windows.Forms.Button
End Class
|
twd2/MyGSM
|
MyGSM/GUI/frmShowMessage.Designer.vb
|
Visual Basic
|
mit
| 8,000
|
Imports ExampleBase
Imports NetOffice
Imports Word = NetOffice.WordApi
Imports NetOffice.WordApi.Enums
Imports NetOffice.WordApi.Tools.Contribution
''' <summary>
''' Example 3 - Using templates
''' </summary>
Public Class Example03
Implements IExample
Dim _hostApplication As ExampleBase.IHost
Public Sub RunExample() Implements ExampleBase.IExample.RunExample
'start word and turn off msg boxes
Dim wordApplication As Word.Application
wordApplication = New Word.Application()
wordApplication.DisplayAlerts = WdAlertLevel.wdAlertsNone
' create a utils instance, not need for but helpful to keep the lines of code low
Dim utils As CommonUtils = New CommonUtils(wordApplication)
'add a new document
Dim newDocument As Word.Document
newDocument = wordApplication.Documents.Add()
'create a new listtemplate
Dim template As Word.ListTemplate
template = newDocument.ListTemplates.Add(True, "NetOfficeListTemplate")
'get the predefined listlevels (9)
Dim levels As Word.ListLevels
levels = template.ListLevels
'customize the first level of the list
levels(1).NumberFormat = "%1."
'tab is used to change the level
levels(1).TrailingCharacter = WdTrailingCharacter.wdTrailingTab
levels(1).NumberStyle = WdListNumberStyle.wdListNumberStyleArabic
levels(1).NumberPosition = 0
levels(1).Alignment = WdListLevelAlignment.wdListLevelAlignLeft
levels(1).TextPosition = wordApplication.CentimetersToPoints(0.63F)
levels(1).TabPosition = wordApplication.CentimetersToPoints(0.63F)
levels(1).ResetOnHigher = 0
levels(1).StartAt = 1
levels(1).LinkedStyle = ""
levels(1).Font.Bold = 1
'customize the second level of the list
levels(2).NumberFormat = "%1.%2."
'tab is used to change the level
levels(2).TrailingCharacter = WdTrailingCharacter.wdTrailingTab
levels(2).NumberStyle = WdListNumberStyle.wdListNumberStyleArabic
'we want the numbers to appear under the first letter of the higher level
levels(2).NumberPosition = wordApplication.CentimetersToPoints(0.63F)
levels(2).Alignment = WdListLevelAlignment.wdListLevelAlignLeft
'and the text should indent a tab more on the right
levels(2).TextPosition = wordApplication.CentimetersToPoints(1.4F)
levels(2).TabPosition = wordApplication.CentimetersToPoints(1.4F)
levels(2).ResetOnHigher = 0
levels(2).StartAt = 1
levels(2).LinkedStyle = ""
levels(2).Font.Italic = 1
'apply the defined listtemplate to the selection
wordApplication.Selection.Range.ListFormat.ApplyListTemplate(template, False, _
WdListApplyTo.wdListApplyToWholeList, WdDefaultListBehavior.wdWord9ListBehavior)
'create a list
wordApplication.Selection.TypeText("Welcoming")
wordApplication.Selection.TypeParagraph()
wordApplication.Selection.TypeText("Introduction")
wordApplication.Selection.TypeParagraph()
wordApplication.Selection.TypeText("Presentation")
wordApplication.Selection.TypeParagraph()
'execute the indent so the second level gets activated
wordApplication.Selection.Range.ListFormat.ListIndent()
wordApplication.Selection.TypeText("Top 1")
wordApplication.Selection.TypeParagraph()
wordApplication.Selection.TypeText("Top 2")
wordApplication.Selection.TypeParagraph()
wordApplication.Selection.TypeText("Top 3")
wordApplication.Selection.TypeParagraph()
' execute the outdent so the first level gets reactivated
wordApplication.Selection.Range.ListFormat.ListOutdent()
wordApplication.Selection.TypeText("Questions & Answers")
'save document
Dim documentFile As String = utils.File.Combine(_hostApplication.RootDirectory, "Example03", DocumentFormat.Normal)
newDocument.SaveAs(documentFile)
' close word and dispose reference
wordApplication.Quit()
wordApplication.Dispose()
' show end dialog
_hostApplication.ShowFinishDialog(Nothing, documentFile)
End Sub
Public ReadOnly Property Caption As String Implements ExampleBase.IExample.Caption
Get
Return "Example03"
End Get
End Property
Public ReadOnly Property Description As String Implements ExampleBase.IExample.Description
Get
Return "Using templates"
End Get
End Property
Public Sub Connect(ByVal hostApplication As ExampleBase.IHost) Implements ExampleBase.IExample.Connect
_hostApplication = hostApplication
End Sub
Public ReadOnly Property Panel As System.Windows.Forms.UserControl Implements ExampleBase.IExample.Panel
Get
Return Nothing
End Get
End Property
End Class
|
NetOfficeFw/NetOffice
|
Examples/Word/VB/Standard Examples/WordExamples/Examples/Example03.vb
|
Visual Basic
|
mit
| 5,010
|
Public Class LoginUI
'Form load
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBoxUsername.Text = My.Settings.RemeUser
CheckBoxReme.Checked = My.Settings.RemeTick
End Sub
' Check DB
Private Function login() As Boolean
Dim result = db.query("SELECT ID FROM Staff WHERE enable = true AND username = '" + TextBoxUsername.Text + "' AND password='" + TextBoxPassword.Text + "'")
Return result.hasRows()
End Function
' Save Setting
Private Sub rememberSettings()
My.Settings.RemeTick = CheckBoxReme.Checked
If CheckBoxReme.Checked Then
My.Settings.RemeUser = TextBoxUsername.Text
Else
My.Settings.RemeUser = ""
End If
My.Settings.Save()
End Sub
' OK
Private Sub ButtonOK_Click() Handles ButtonOK.Click
rememberSettings()
If login() Then
currUser = Staff.getStaff(TextBoxUsername.Text)
'MainMenuUI.Dispose()
MainMenuUI.Show()
Me.Close()
Else
MsgBox("Incorrect Username or Password. Please try again.")
End If
End Sub
' Cancel
Private Sub ButtonCancel_Click() Handles ButtonCancel.Click
End
End Sub
' Keyboard
Private Sub KeyDownHandle(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBoxPassword.KeyDown, TextBoxUsername.KeyDown
If e.KeyValue = Keys.Enter Then
ButtonOK_Click()
End If
End Sub
End Class
|
louislam/summer-course-system
|
Summer Course System/UI/LoginUI.vb
|
Visual Basic
|
mit
| 1,376
|
'-------------------------------------------------------------------------------------------'
' Inicio del codigo
'-------------------------------------------------------------------------------------------'
' Importando librerias
'-------------------------------------------------------------------------------------------'
Imports System.Data
'-------------------------------------------------------------------------------------------'
' Inicio de clase "fFaltantes_Renuncia"
'-------------------------------------------------------------------------------------------'
Partial Class fFaltantes_Renuncia
Inherits vis2formularios.frmReporte
Dim loObjetoReporte As CrystalDecisions.CrystalReports.Engine.ReportDocument
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
Dim loComandoSeleccionar As New StringBuilder()
loComandoSeleccionar.AppendLine(" SELECT Faltantes.Cod_Cli, ")
loComandoSeleccionar.AppendLine(" Clientes.Nom_Cli, ")
loComandoSeleccionar.AppendLine(" Clientes.Rif, ")
loComandoSeleccionar.AppendLine(" Clientes.Nit, ")
loComandoSeleccionar.AppendLine(" Clientes.Dir_Fis, ")
loComandoSeleccionar.AppendLine(" Clientes.Telefonos, ")
loComandoSeleccionar.AppendLine(" Clientes.Fax, ")
loComandoSeleccionar.AppendLine(" Faltantes.Nom_Cli As Nom_Gen, ")
loComandoSeleccionar.AppendLine(" Faltantes.Rif As Rif_Gen, ")
loComandoSeleccionar.AppendLine(" Faltantes.Nit As Nit_Gen, ")
loComandoSeleccionar.AppendLine(" Faltantes.Documento, ")
loComandoSeleccionar.AppendLine(" Faltantes.Fec_Ini, ")
loComandoSeleccionar.AppendLine(" Faltantes.Fec_Fin, ")
loComandoSeleccionar.AppendLine(" Faltantes.Mon_Bru, ")
loComandoSeleccionar.AppendLine(" Faltantes.Mon_Imp1, ")
loComandoSeleccionar.AppendLine(" Faltantes.Dis_Imp, ")
loComandoSeleccionar.AppendLine(" Faltantes.Mon_Net, ")
loComandoSeleccionar.AppendLine(" Faltantes.Cod_For, ")
loComandoSeleccionar.AppendLine(" SUBSTRING(Formas_Pagos.Nom_For,1,35) AS Nom_For, ")
loComandoSeleccionar.AppendLine(" Faltantes.Cod_Ven, ")
loComandoSeleccionar.AppendLine(" Faltantes.Comentario, ")
loComandoSeleccionar.AppendLine(" Vendedores.Nom_Ven, ")
loComandoSeleccionar.AppendLine(" Renglones_Faltantes.Cod_Art, ")
loComandoSeleccionar.AppendLine(" Articulos.Nom_Art, ")
loComandoSeleccionar.AppendLine(" Renglones_Faltantes.Renglon, ")
loComandoSeleccionar.AppendLine(" Renglones_Faltantes.Can_Pen1 AS Can_Art1, ")
loComandoSeleccionar.AppendLine(" Renglones_Faltantes.Cod_Uni, ")
loComandoSeleccionar.AppendLine(" Renglones_Faltantes.Precio1, ")
loComandoSeleccionar.AppendLine(" Renglones_Faltantes.Mon_Net As Neto, ")
loComandoSeleccionar.AppendLine(" Renglones_Faltantes.Por_Imp1 As Por_Imp, ")
loComandoSeleccionar.AppendLine(" Renglones_Faltantes.Cod_Imp, ")
loComandoSeleccionar.AppendLine(" Renglones_Faltantes.Mon_Imp1 As Impuesto, ")
loComandoSeleccionar.AppendLine(" Renglones_Faltantes.Por_Des AS Por_Des_Renglon, ")
loComandoSeleccionar.AppendLine(" Faltantes.Por_Des1,")
loComandoSeleccionar.AppendLine(" Faltantes.Por_Rec1, ")
loComandoSeleccionar.AppendLine(" Faltantes.Mon_Des1,")
loComandoSeleccionar.AppendLine(" Faltantes.Mon_Rec1 ")
loComandoSeleccionar.AppendLine(" FROM Faltantes, ")
loComandoSeleccionar.AppendLine(" Renglones_Faltantes, ")
loComandoSeleccionar.AppendLine(" Clientes, ")
loComandoSeleccionar.AppendLine(" Formas_Pagos, ")
loComandoSeleccionar.AppendLine(" Vendedores, ")
loComandoSeleccionar.AppendLine(" Articulos ")
loComandoSeleccionar.AppendLine(" WHERE Faltantes.Documento = Renglones_Faltantes.Documento AND ")
loComandoSeleccionar.AppendLine(" Faltantes.Cod_Cli = Clientes.Cod_Cli AND ")
loComandoSeleccionar.AppendLine(" Faltantes.Cod_For = Formas_Pagos.Cod_For AND ")
loComandoSeleccionar.AppendLine(" Faltantes.Cod_Ven = Vendedores.Cod_Ven AND ")
loComandoSeleccionar.AppendLine(" Articulos.Cod_Art = Renglones_Faltantes.Cod_Art AND " & cusAplicacion.goFormatos.pcCondicionPrincipal)
Dim loServicios As New cusDatos.goDatos
Dim laDatosReporte As DataSet = loServicios.mObtenerTodosSinEsquema(loComandoSeleccionar.ToString, "curReportes")
Dim lcXml As String = "<impuesto></impuesto>"
Dim lcPorcentajesImpueto As String
Dim loImpuestos As New System.Xml.XmlDocument()
lcPorcentajesImpueto = "("
'Recorre cada renglon de la tabla
For lnNumeroFila As Integer = 0 To laDatosReporte.Tables(0).Rows.Count - 1
lcXml = laDatosReporte.Tables(0).Rows(lnNumeroFila).Item("dis_imp")
If String.IsNullOrEmpty(lcXml.Trim()) Then
Continue For
End If
loImpuestos.LoadXml(lcXml)
'En cada renglón lee el contenido de la distribució de impuestos
For Each loImpuesto As System.Xml.XmlNode In loImpuestos.SelectNodes("impuestos/impuesto")
If lnNumeroFila = laDatosReporte.Tables(0).Rows.Count - 1 Then
lcPorcentajesImpueto = lcPorcentajesImpueto & ", " & CDec(loImpuesto.SelectSingleNode("porcentaje").InnerText) & "%"
End If
Next loImpuesto
Next lnNumeroFila
lcPorcentajesImpueto = lcPorcentajesImpueto & ")"
lcPorcentajesImpueto = lcPorcentajesImpueto.Replace("(,", "(")
'--------------------------------------------------'
' Carga la imagen del logo en cusReportes '
'--------------------------------------------------'
Me.mCargarLogoEmpresa(laDatosReporte.Tables(0), "LogoEmpresa")
'-------------------------------------------------------------------------------------------------------
' Verificando si el select (tabla nº0) trae registros
'-------------------------------------------------------------------------------------------------------
If (laDatosReporte.Tables(0).Rows.Count <= 0) Then
Me.WbcAdministradorMensajeModal.mMostrarMensajeModal("Información", _
"No se Encontraron Registros para los Parámetros Especificados. ", _
vis3Controles.wbcAdministradorMensajeModal.enumTipoMensaje.KN_Informacion, _
"350px", _
"200px")
End If
loObjetoReporte = cusAplicacion.goFormatos.mCargarInforme("fFaltantes_Renuncia", laDatosReporte)
lcPorcentajesImpueto= lcPorcentajesImpueto.Replace(".", ",")
CType(loObjetoReporte.ReportDefinition.ReportObjects("Text29"), CrystalDecisions.CrystalReports.Engine.TextObject).Text = lcPorcentajesImpueto.ToString
Me.mTraducirReporte(loObjetoReporte)
Me.mFormatearCamposReporte(loObjetoReporte)
Me.crvfFaltantes_Renuncia.ReportSource = loObjetoReporte
Catch loExcepcion As Exception
Me.WbcAdministradorMensajeModal.mMostrarMensajeModal("Error", _
"No se pudo Completar el Proceso: " & loExcepcion.Message, _
vis3Controles.wbcAdministradorMensajeModal.enumTipoMensaje.KN_Error, _
"auto", _
"auto")
End Try
End Sub
Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
Try
loObjetoReporte.Close()
Catch loExcepcion As Exception
End Try
End Sub
End Class
'-------------------------------------------------------------------------------------------'
' Fin del codigo
'-------------------------------------------------------------------------------------------'
' CMS: 24/09/09: Codigo inicial
'-------------------------------------------------------------------------------------------'
' CMS: 18/03/10: Se aplicaron los metodos carga de imagen y validacion de registro cero
'-------------------------------------------------------------------------------------------'
' CMS: 18/05/10: Se cambio el origen de datos de la columna Can_Art1: (Renglones_Faltantes.Can_Art1 - Renglones_Faltantes.Can_Pen1)
' a solo Renglones_Faltantes.Can_Pen1
'-------------------------------------------------------------------------------------------'
|
kodeitsolutions/ef-reports
|
fFaltantes_Renuncia.aspx.vb
|
Visual Basic
|
mit
| 9,576
|
Imports System
Imports System.Reflection
Imports System.Runtime.InteropServices
' General Information about an assembly is controlled through the following
' set of attributes. Change these attribute values to modify the information
' associated with an assembly.
' Review the values of the assembly attributes
<Assembly: AssemblyTitle("EmbUI")>
<Assembly: AssemblyDescription("Configurator for Embrionix 2022-6 SFPs")>
<Assembly: AssemblyCompany("NBCUniversal")>
<Assembly: AssemblyProduct("EmbUI")>
<Assembly: AssemblyCopyright("Copyright © 2016")>
<Assembly: AssemblyTrademark("")>
<Assembly: ComVisible(False)>
'The following GUID is for the ID of the typelib if this project is exposed to COM
<Assembly: Guid("626e91d6-9b33-46f0-85ab-6a9934773b6b")>
' Version information for an assembly consists of the following four values:
'
' Major Version
' Minor Version
' Build Number
' Revision
'
' You can specify all the values or you can default the Build and Revision Numbers
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.3.0.0")>
<Assembly: AssemblyFileVersion("1.3.0.0")>
|
andrewburnheimer/EmbUI
|
EmbUI/My Project/AssemblyInfo.vb
|
Visual Basic
|
apache-2.0
| 1,169
|
'*******************************************************************************************'
' '
' Download Free Evaluation Version From: https://bytescout.com/download/web-installer '
' '
' Also available as Web API! Get free API Key https://app.pdf.co/signup '
' '
' Copyright © 2017-2020 ByteScout, Inc. All rights reserved. '
' https://www.bytescout.com '
' https://www.pdf.co '
'*******************************************************************************************'
Imports System.IO
Imports System.Net
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq
Module Module1
' The authentication key (API Key).
' Get your own by registering at https://app.pdf.co
Const API_KEY As String = "***********************************"
' Direct URL of source PDF file.
' You can also upload your own file into PDF.co and use it as url. Check "Upload File" samples for code snippets: https://github.com/bytescout/pdf-co-api-samples/tree/master/File%20Upload/
Const SourceFileUrl As String = "https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-split/sample.pdf"
' PDF document password. Leave empty for unprotected documents.
const Password As string = ""
' Destination PDF file name
const DestinationFile as string = ".\result.pdf"
Sub Main()
' Create standard .NET web client instance
Dim webClient As WebClient = New WebClient()
' Set API Key
webClient.Headers.Add("x-api-key", API_KEY)
' Set JSON content type
webClient.Headers.Add("Content-Type", "application/json")
' Prepare URL for `Delete Text from PDF` API call
Dim url As String = "https://api.pdf.co/v1/pdf/edit/delete-text"
' Prepare requests params as JSON
' See documentation: https : //apidocs.pdf.co
Dim parameters As New Dictionary(Of String, Object)
parameters.Add("name", Path.GetFileName(DestinationFile))
parameters.Add("password", Password)
parameters.Add("url", SourceFileUrl)
parameters.Add("searchString", "conspicuous")
' Convert dictionary of params to JSON
Dim jsonPayload As String = JsonConvert.SerializeObject(parameters)
Try
' Execute POST request with JSON payload
Dim response As String = webClient.UploadString(url, jsonPayload)
' Parse JSON response
Dim json As JObject = JObject.Parse(response)
If json("error").ToObject(Of Boolean) = False Then
' Get URL of generated PDF file
Dim resultFileUrl As String = json("url").ToString()
' Download PDF file
webClient.DownloadFile(resultFileUrl, DestinationFile)
Console.WriteLine("Generated PDF file saved as ""{0}"" file.", DestinationFile)
Else
Console.WriteLine(json("message").ToString())
End If
Catch ex As WebException
Console.WriteLine(ex.ToString())
End Try
webClient.Dispose()
Console.WriteLine()
Console.WriteLine("Press any key...")
Console.ReadKey()
End Sub
End Module
|
bytescout/ByteScout-SDK-SourceCode
|
PDF.co Web API/Delete Text From PDF/VB.NET/Delete PDF Text From URL/Module1.vb
|
Visual Basic
|
apache-2.0
| 3,453
|
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated by a tool.
' Runtime Version:2.0.50727.3082
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Namespace My
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0"), _
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Partial Friend NotInheritable Class MySettings
Inherits Global.System.Configuration.ApplicationSettingsBase
Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings)
#Region "My.Settings Auto-Save Functionality"
#If _MyType = "WindowsForms" Then
Private Shared addedHandler As Boolean
Private Shared addedHandlerLockObject As New Object
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
If My.Application.SaveMySettingsOnExit Then
My.Settings.Save()
End If
End Sub
#End If
#End Region
Public Shared ReadOnly Property [Default]() As MySettings
Get
#If _MyType = "WindowsForms" Then
If Not addedHandler Then
SyncLock addedHandlerLockObject
If Not addedHandler Then
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
addedHandler = True
End If
End SyncLock
End If
#End If
Return defaultInstance
End Get
End Property
End Class
End Namespace
Namespace My
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
Friend Module MySettingsProperty
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
Friend ReadOnly Property Settings() As Global.Kron____Mynt.My.MySettings
Get
Return Global.Kron____Mynt.My.MySettings.Default
End Get
End Property
End Module
End Namespace
|
niikoo/NProj
|
Windows/Skole/Kron - Mynt/Kron - Mynt/My Project/Settings.Designer.vb
|
Visual Basic
|
apache-2.0
| 2,971
|
' Copyright (c) Microsoft Corporation. All rights reserved.
Imports Microsoft.VisualBasic
Imports System.Reflection
Imports System.Runtime.CompilerServices
Imports System.Runtime.InteropServices
' General Information about an assembly is controlled through the following
' set of attributes. Change these attribute values to modify the information
' associated with an assembly.
<Assembly: AssemblyTitle("AppRestartRecoveryDemo")>
<Assembly: AssemblyDescription("Application Restart Recovery Demo")>
<Assembly: AssemblyConfiguration("")>
<Assembly: AssemblyCompany("Microsoft")>
<Assembly: AssemblyProduct("Microsoft Windows API Code Pack for .NET Framework")>
<Assembly: AssemblyCopyright("Copyright © Microsoft 2009")>
<Assembly: AssemblyTrademark("")>
<Assembly: AssemblyCulture("")>
' Setting ComVisible to false makes the types in this assembly not visible
' to COM components. If you need to access a type in this assembly from
' COM, set the ComVisible attribute to true on that type.
<Assembly: ComVisible(False)>
' The following GUID is for the ID of the typelib if this project is exposed to COM
<Assembly: Guid("5b55c1fe-4e02-4ffd-9c19-7f39d900ad8f")>
' Version information for an assembly consists of the following four values:
'
' Major Version
' Minor Version
' Build Number
' Revision
'
' You can specify all the values or you can default the Build and Revision Numbers
' by using the '*' as shown below:
' [assembly: AssemblyVersion("1.0.*")]
<Assembly: AssemblyVersion("1.0.0.0")>
<Assembly: AssemblyFileVersion("1.0.0.0")>
|
devkimchi/Windows-API-Code-Pack-1.1
|
source/Samples/AppRestartRecoveryDemo/VB/My Project/AssemblyInfo.vb
|
Visual Basic
|
mit
| 1,578
|
'*******************************************************************************************'
' '
' Download Free Evaluation Version From: https://bytescout.com/download/web-installer '
' '
' Also available as Web API! Get free API Key https://app.pdf.co/signup '
' '
' Copyright © 2017-2020 ByteScout, Inc. All rights reserved. '
' https://www.bytescout.com '
' https://www.pdf.co '
'*******************************************************************************************'
Imports Bytescout.PDFRenderer
Class Program
Friend Shared Sub Main(args As String())
' Create an instance of Bytescout.PDFRenderer.RasterRenderer object and register it.
Dim renderer As New RasterRenderer()
renderer.RegistrationName = "demo"
renderer.RegistrationKey = "demo"
' Load PDF document.
renderer.LoadDocumentFromFile("multipage.pdf")
' define page to start from
Dim startPage As Integer = 0
' define page to end on
Dim endPage As Integer = renderer.GetPageCount() - 1
' Save PDF document to black-and-white multi-page TIFF
Dim renderingOptions As New RenderingOptions()
renderingOptions.TIFFCompression = TIFFCompression.CCITT4
renderingOptions.ResolutionOverride = 300
' Generate 800x600 px multipage TIFF
renderer.SaveMultipageTiff("multipage.tiff", startPage, endPage, 600, 800, renderingOptions)
' Cleanup
renderer.Dispose()
' Open the first output file in default image viewer.
System.Diagnostics.Process.Start("multipage.tiff")
End Sub
End Class
|
bytescout/ByteScout-SDK-SourceCode
|
Premium Suite/VB.NET/Override resolution in multipage tiff with pdf renderer sdk/Program.vb
|
Visual Basic
|
apache-2.0
| 2,119
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports Roslyn.Test.Utilities
Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests
Public Class ScriptSemanticsTests
Inherits BasicTestBase
<WorkItem(530404, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530404")>
<Fact>
Public Sub DiagnosticsPass()
Dim source0 = "
Function F(e As System.Linq.Expressions.Expression(Of System.Func(Of Object))) As Object
Return e.Compile()()
End Function"
Dim c0 = CreateSubmission(source0, {SystemCoreRef})
Dim source1 = "
F(Function()
Return Nothing
End Function)
"
Dim c1 = CreateSubmission(source1, {SystemCoreRef}, previous:=c0)
AssertTheseDiagnostics(c1,
<errors>
BC36675: Statement lambdas cannot be converted to expression trees.
F(Function()
~~~~~~~~~~~
</errors>)
End Sub
<Fact>
<WorkItem(10023, "https://github.com/dotnet/roslyn/issues/10023")>
Public Sub Errors_01()
Dim code = "System.Console.WriteLine(1)"
Dim compilationUnit = VisualBasic.SyntaxFactory.ParseCompilationUnit(code, options:=New VisualBasicParseOptions(kind:=SourceCodeKind.Script))
Dim syntaxTree = compilationUnit.SyntaxTree
Dim compilation = CreateCompilationWithMscorlib45({syntaxTree}, assemblyName:="Errors_01")
Dim semanticModel = compilation.GetSemanticModel(syntaxTree, True)
Dim node5 As MemberAccessExpressionSyntax = ErrorTestsGetNode(syntaxTree)
Assert.Equal("WriteLine", node5.Name.ToString())
Assert.Null(semanticModel.GetSymbolInfo(node5.Name).Symbol)
compilation.AssertTheseDiagnostics(
<expected>
BC30420: 'Sub Main' was not found in 'Errors_01'.
BC30001: Statement is not valid in a namespace.
System.Console.WriteLine(1)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
</expected>
)
compilation = CreateCompilationWithMscorlib45({syntaxTree}, options:=TestOptions.ReleaseExe.WithScriptClassName("Script"), assemblyName:="Errors_01")
semanticModel = compilation.GetSemanticModel(syntaxTree, True)
node5 = ErrorTestsGetNode(syntaxTree)
Assert.Equal("WriteLine", node5.Name.ToString())
Assert.Null(semanticModel.GetSymbolInfo(node5.Name).Symbol)
compilation.AssertTheseDiagnostics(
<expected>
BC30420: 'Sub Main' was not found in 'Errors_01'.
BC30001: Statement is not valid in a namespace.
System.Console.WriteLine(1)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
</expected>
)
syntaxTree = SyntaxFactory.ParseSyntaxTree(code, options:=New VisualBasicParseOptions(kind:=SourceCodeKind.Script))
compilation = CreateCompilationWithMscorlib45AndVBRuntime({syntaxTree})
semanticModel = compilation.GetSemanticModel(syntaxTree, True)
node5 = ErrorTestsGetNode(syntaxTree)
Assert.Equal("WriteLine", node5.Name.ToString())
Assert.Equal("Sub System.Console.WriteLine(value As System.Int32)", semanticModel.GetSymbolInfo(node5.Name).Symbol.ToTestDisplayString())
CompileAndVerify(compilation, expectedOutput:="1").VerifyDiagnostics()
syntaxTree = SyntaxFactory.ParseSyntaxTree(code, options:=New VisualBasicParseOptions(kind:=SourceCodeKind.Script))
compilation = CreateCompilationWithMscorlib45AndVBRuntime({syntaxTree}, options:=TestOptions.ReleaseExe.WithScriptClassName("Script"))
semanticModel = compilation.GetSemanticModel(syntaxTree, True)
node5 = ErrorTestsGetNode(syntaxTree)
Assert.Equal("WriteLine", node5.Name.ToString())
Assert.Equal("Sub System.Console.WriteLine(value As System.Int32)", semanticModel.GetSymbolInfo(node5.Name).Symbol.ToTestDisplayString())
CompileAndVerify(compilation, expectedOutput:="1").VerifyDiagnostics()
syntaxTree = SyntaxFactory.ParseSyntaxTree(code, options:=New VisualBasicParseOptions(kind:=SourceCodeKind.Script))
compilation = CreateCompilationWithMscorlib45AndVBRuntime({syntaxTree}, options:=TestOptions.ReleaseExe.WithScriptClassName(""))
semanticModel = compilation.GetSemanticModel(syntaxTree, True)
node5 = ErrorTestsGetNode(syntaxTree)
Assert.Equal("WriteLine", node5.Name.ToString())
Assert.Equal("Sub System.Console.WriteLine(value As System.Int32)", semanticModel.GetSymbolInfo(node5.Name).Symbol.ToTestDisplayString())
compilation.AssertTheseDiagnostics(
<expected>
BC2014: the value '' is invalid for option 'ScriptClassName'
</expected>
)
syntaxTree = SyntaxFactory.ParseSyntaxTree(code, options:=New VisualBasicParseOptions(kind:=SourceCodeKind.Script))
compilation = CreateCompilationWithMscorlib45AndVBRuntime({syntaxTree}, options:=TestOptions.ReleaseExe.WithScriptClassName(Nothing))
semanticModel = compilation.GetSemanticModel(syntaxTree, True)
node5 = ErrorTestsGetNode(syntaxTree)
Assert.Equal("WriteLine", node5.Name.ToString())
Assert.Equal("Sub System.Console.WriteLine(value As System.Int32)", semanticModel.GetSymbolInfo(node5.Name).Symbol.ToTestDisplayString())
compilation.AssertTheseDiagnostics(
<expected>
BC2014: the value 'Nothing' is invalid for option 'ScriptClassName'
</expected>
)
syntaxTree = SyntaxFactory.ParseSyntaxTree(code, options:=New VisualBasicParseOptions(kind:=SourceCodeKind.Script))
compilation = CreateCompilationWithMscorlib45AndVBRuntime({syntaxTree}, options:=TestOptions.ReleaseExe.WithScriptClassName("a" + ChrW(0) + "b"))
semanticModel = compilation.GetSemanticModel(syntaxTree, True)
node5 = ErrorTestsGetNode(syntaxTree)
Assert.Equal("WriteLine", node5.Name.ToString())
Assert.Equal("Sub System.Console.WriteLine(value As System.Int32)", semanticModel.GetSymbolInfo(node5.Name).Symbol.ToTestDisplayString())
compilation.VerifyDiagnostics(
Diagnostic(ERRID.ERR_InvalidSwitchValue).WithArguments("ScriptClassName", "a" + ChrW(0) + "b").WithLocation(1, 1)
)
End Sub
<Fact>
<WorkItem(10023, "https://github.com/dotnet/roslyn/issues/10023")>
Public Sub Errors_02()
Dim compilationUnit = VisualBasic.SyntaxFactory.ParseCompilationUnit("System.Console.WriteLine(1)", options:=New VisualBasicParseOptions(kind:=SourceCodeKind.Script))
Dim syntaxTree1 = compilationUnit.SyntaxTree
Dim syntaxTree2 = SyntaxFactory.ParseSyntaxTree("System.Console.WriteLine(2)", options:=New VisualBasicParseOptions(kind:=SourceCodeKind.Script))
Dim node1 As MemberAccessExpressionSyntax = ErrorTestsGetNode(syntaxTree1)
Assert.Equal("WriteLine", node1.Name.ToString())
Dim node2 As MemberAccessExpressionSyntax = ErrorTestsGetNode(syntaxTree2)
Assert.Equal("WriteLine", node2.Name.ToString())
Dim compilation = CreateCompilationWithMscorlib45({syntaxTree1, syntaxTree2})
Dim semanticModel1 = compilation.GetSemanticModel(syntaxTree1, True)
Dim semanticModel2 = compilation.GetSemanticModel(syntaxTree2, True)
Assert.Null(semanticModel1.GetSymbolInfo(node1.Name).Symbol)
Assert.Equal("Sub System.Console.WriteLine(value As System.Int32)", semanticModel2.GetSymbolInfo(node2.Name).Symbol.ToTestDisplayString())
compilation.AssertTheseDiagnostics(
<expected>
BC30001: Statement is not valid in a namespace.
System.Console.WriteLine(1)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
</expected>
)
compilation = CreateCompilationWithMscorlib45({syntaxTree2, syntaxTree1})
semanticModel1 = compilation.GetSemanticModel(syntaxTree1, True)
semanticModel2 = compilation.GetSemanticModel(syntaxTree2, True)
Assert.Null(semanticModel1.GetSymbolInfo(node1.Name).Symbol)
Assert.Equal("Sub System.Console.WriteLine(value As System.Int32)", semanticModel2.GetSymbolInfo(node2.Name).Symbol.ToTestDisplayString())
compilation.AssertTheseDiagnostics(
<expected>
BC30001: Statement is not valid in a namespace.
System.Console.WriteLine(1)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
</expected>
)
End Sub
Private Shared Function ErrorTestsGetNode(syntaxTree As SyntaxTree) As MemberAccessExpressionSyntax
Dim node1 = DirectCast(syntaxTree.GetRoot(), CompilationUnitSyntax)
Dim node3 = DirectCast(node1.Members.First(), ExpressionStatementSyntax)
Dim node4 = DirectCast(node3.Expression, InvocationExpressionSyntax)
Dim node5 = DirectCast(node4.Expression, MemberAccessExpressionSyntax)
Return node5
End Function
End Class
End Namespace
|
mmitche/roslyn
|
src/Compilers/VisualBasic/Test/Semantic/Semantics/ScriptSemanticsTests.vb
|
Visual Basic
|
apache-2.0
| 9,091
|
Imports System.Drawing
Imports Grasshopper.Kernel
Imports Owl.Core.Tensors
Imports Owl.GH.Common
Public Class WebcamFrameComponent
Inherits GH_Component
Sub New()
MyBase.New("WebCamCapture",
"Capture",
"Capture a single frame from a webcam",
"Owl.Accord",
OwlComponentBase.SubCategoryDisplay)
End Sub
Public Overrides ReadOnly Property ComponentGuid As Guid
Get
Return New Guid("bf279f15-f375-4936-bcd5-c7780c5d94c6")
End Get
End Property
Protected Overrides ReadOnly Property Icon As Bitmap
Get
Return My.Resources.Icons_new_08
End Get
End Property
Public Overrides ReadOnly Property Exposure As GH_Exposure
Get
Return GH_Exposure.tertiary
End Get
End Property
Protected Overrides Sub RegisterInputParams(pManager As GH_InputParamManager)
pManager.AddBooleanParameter("On", "O", "Turn On/Off the webcam.", GH_ParamAccess.item, False)
pManager.AddBooleanParameter("Capture", "C", "Capture", GH_ParamAccess.item, False)
pManager.AddIntegerParameter("Device", "D", "Device index", GH_ParamAccess.item, 0)
pManager.AddIntegerParameter("Resolution", "R", "Resolution index, -1=highest found", GH_ParamAccess.item, -1)
End Sub
Protected Overrides Sub RegisterOutputParams(pManager As GH_OutputParamManager)
pManager.AddParameter(New Param_OwlTensor)
End Sub
Private cap As New Extensions.Video.RunningCapture()
Private tens As Tensor = Nothing
Public Overrides Sub RemovedFromDocument(document As GH_Document)
MyBase.RemovedFromDocument(document)
If cap IsNot Nothing Then cap.CameraTurnOff()
End Sub
Protected Overrides Sub SolveInstance(DA As IGH_DataAccess)
Dim run = False
Dim doit = False
Dim dev As Integer = 0
Dim res As Integer = -1
If Not DA.GetData(0, run) Then Return
DA.GetData(1, doit)
DA.GetData(2, dev)
DA.GetData(3, res)
If run Then
cap.ListDevices()
cap.CameraTurnOn(cap.Devices(dev), res)
If doit Then cap.TakePicture()
Else
cap.CameraTurnOff()
End If
If cap.LastCapture IsNot Nothing Then tens = Owl.Core.Images.FromGrayscale(cap.LastCapture)
If tens IsNot Nothing Then DA.SetData(0, tens)
End Sub
End Class
|
mateuszzwierzycki/Owl
|
Owl.Accord.GH/Components/Display/CameraView.vb
|
Visual Basic
|
mit
| 2,161
|
Imports System.Windows.Input
Namespace Common
''' <summary>
'''
''' </summary>
''' <remarks></remarks>
Public Class RelayCommand
Implements ICommand
Private ReadOnly _execute As Action
Private ReadOnly _canExecute As Func(Of Boolean)
Public Sub New(execute As Action)
Me.New(execute, Nothing)
End Sub
Public Sub New(execute As Action, canExecute As Func(Of Boolean))
If execute Is Nothing Then
Throw New ArgumentNullException("execute")
End If
_execute = execute
_canExecute = canExecute
End Sub
Public Event CanExecuteChanged As EventHandler Implements ICommand.CanExecuteChanged
Public Sub RaiseCanExecuteChanged()
RaiseEvent CanExecuteChanged(Me, EventArgs.Empty)
End Sub
Public Function CanExecute(parameter As Object) As Boolean Implements ICommand.CanExecute
Return If(_canExecute Is Nothing, True, _canExecute())
End Function
Public Sub Execute(parameter As Object) Implements ICommand.Execute
_execute()
End Sub
End Class
End Namespace
|
jaksg82/XtfViewer
|
XtfViewerAppCommons/RelayCommand.vb
|
Visual Basic
|
mit
| 1,200
|
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class AddaCommand
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.CancelBtn1 = New System.Windows.Forms.Button()
Me.SaveBtn1 = New System.Windows.Forms.Button()
Me.Label3 = New System.Windows.Forms.Label()
Me.ValueTxt1 = New System.Windows.Forms.TextBox()
Me.Label2 = New System.Windows.Forms.Label()
Me.CommandTxt1 = New System.Windows.Forms.TextBox()
Me.Label1 = New System.Windows.Forms.Label()
Me.SuspendLayout()
'
'CancelBtn1
'
Me.CancelBtn1.Location = New System.Drawing.Point(114, 93)
Me.CancelBtn1.Name = "CancelBtn1"
Me.CancelBtn1.Size = New System.Drawing.Size(75, 23)
Me.CancelBtn1.TabIndex = 13
Me.CancelBtn1.Text = "Cancel"
Me.CancelBtn1.UseVisualStyleBackColor = True
'
'SaveBtn1
'
Me.SaveBtn1.Location = New System.Drawing.Point(195, 93)
Me.SaveBtn1.Name = "SaveBtn1"
Me.SaveBtn1.Size = New System.Drawing.Size(75, 23)
Me.SaveBtn1.TabIndex = 12
Me.SaveBtn1.Text = "Save"
Me.SaveBtn1.UseVisualStyleBackColor = True
'
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.Location = New System.Drawing.Point(15, 70)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(37, 13)
Me.Label3.TabIndex = 11
Me.Label3.Text = "Value:"
'
'ValueTxt1
'
Me.ValueTxt1.Location = New System.Drawing.Point(78, 67)
Me.ValueTxt1.Name = "ValueTxt1"
Me.ValueTxt1.Size = New System.Drawing.Size(192, 20)
Me.ValueTxt1.TabIndex = 10
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Location = New System.Drawing.Point(15, 37)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(57, 13)
Me.Label2.TabIndex = 9
Me.Label2.Text = "Command:"
'
'CommandTxt1
'
Me.CommandTxt1.Location = New System.Drawing.Point(78, 34)
Me.CommandTxt1.Name = "CommandTxt1"
Me.CommandTxt1.Size = New System.Drawing.Size(192, 20)
Me.CommandTxt1.TabIndex = 8
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(15, 8)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(135, 13)
Me.Label1.TabIndex = 7
Me.Label1.Text = "Add a command to the bot."
'
'AddaCommand
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(285, 124)
Me.Controls.Add(Me.CancelBtn1)
Me.Controls.Add(Me.SaveBtn1)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.ValueTxt1)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.CommandTxt1)
Me.Controls.Add(Me.Label1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "AddaCommand"
Me.ShowInTaskbar = False
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
Me.Text = "Add a Command"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents CancelBtn1 As Button
Friend WithEvents SaveBtn1 As Button
Friend WithEvents Label3 As Label
Friend WithEvents ValueTxt1 As TextBox
Friend WithEvents Label2 As Label
Friend WithEvents CommandTxt1 As TextBox
Friend WithEvents Label1 As Label
End Class
|
MechaGS/TwitchBot
|
TwitchBot/Forms/AddaCommand.Designer.vb
|
Visual Basic
|
mit
| 4,529
|
Namespace Security
Public Class SecurityForm
Private Sub SecurityManager_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
End Namespace
|
okyereadugyamfi/softlogik
|
SPCode/Security/SecurityForm.vb
|
Visual Basic
|
mit
| 220
|
Option Strict Off
Option Explicit On
Friend Class frmDiagPtArtn
Inherits System.Windows.Forms.Form
'**************************************************
'* frmDiagPtArtn version info:
'* See basGlobals (Globals.bas).
'**************************************************
Private Const TBarButtons As String = "Exit;"
Public Sub IPAHelpPrint(ByRef bToPrinter As Boolean, ByRef bDummyArgument As Boolean)
On Error Resume Next
'UPGRADE_NOTE: Capture was upgraded to Capture_Renamed. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
Dim Capture_Renamed As clsCapture
If (bToPrinter) Then
Capture_Renamed = New clsCapture
Capture_Renamed.PrintChart((Picture1.Image), "Chart:" & vbTab & vbTab & "Points of Articulation")
'UPGRADE_NOTE: Object Capture_Renamed may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
Capture_Renamed = Nothing
Else
My.Computer.Clipboard.Clear()
My.Computer.Clipboard.SetImage(Picture1.Image)
End If
End Sub
'UPGRADE_WARNING: Form event frmDiagPtArtn.Activate has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"'
Private Sub frmDiagPtArtn_Activated(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Activated
On Error Resume Next
With mdiHelpCharts
.ShowTBarButtons(TBarButtons)
CType(.Controls("panStatus"), Object).Visible = True
CType(.Controls("mnuTest"), Object).Enabled = False
CType(.Controls("mnuExportBitmap"), Object).Visible = True
CType(.Controls("mnuBkgrdColor"), Object)(1).Enabled = False
CType(.Controls("mnuPrint"), Object)(0).Visible = True
CType(.Controls("mnuPrint"), Object)(1).Visible = True
End With
gStatLine.Text = ""
'UPGRADE_ISSUE: Unable to determine which constant to upgrade vbNormal to. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="B3B44E51-B5F1-4FD7-AA29-CAD31B71F487"'
If WindowState = vbNormal Then
Top = VB6.TwipsToPixelsY(-VB6.PixelsToTwipsY(Height))
Show()
WindowState = System.Windows.Forms.FormWindowState.Maximized
End If
End Sub
'UPGRADE_WARNING: Form event frmDiagPtArtn.Deactivate has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"'
Private Sub frmDiagPtArtn_Deactivate(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Deactivate
On Error Resume Next
gStatLine.Text = ""
CType(mdiHelpCharts.Controls("mnuExportBitmap"), Object).Visible = False
CType(mdiHelpCharts.Controls("mnuBkgrdColor"), Object)(1).Enabled = True
CType(mdiHelpCharts.Controls("mnuPrint"), Object)(0).Visible = False
CType(mdiHelpCharts.Controls("mnuPrint"), Object)(1).Visible = False
End Sub
Private Sub frmDiagPtArtn_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
mdiHelpCharts.panStatus.Visible = True
Top = VB6.TwipsToPixelsY(-VB6.PixelsToTwipsY(Height))
Show()
WindowState = System.Windows.Forms.FormWindowState.Maximized
End Sub
Private Sub frmDiagPtArtn_MouseMove(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
Dim Button As Short = eventArgs.Button \ &H100000
Dim Shift As Short = System.Windows.Forms.Control.ModifierKeys \ &H10000
Dim X As Single = VB6.PixelsToTwipsX(eventArgs.X)
Dim y As Single = VB6.PixelsToTwipsY(eventArgs.Y)
On Error Resume Next
gStatLine.Text = ""
End Sub
Private Sub frmDiagPtArtn_FormClosing(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Dim Cancel As Boolean = eventArgs.Cancel
Dim UnloadMode As System.Windows.Forms.CloseReason = eventArgs.CloseReason
On Error Resume Next
'UPGRADE_WARNING: Form event frmDiagPtArtn.Deactivate has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"'
frmDiagPtArtn_Deactivate(Me, New System.EventArgs())
'UPGRADE_NOTE: Object frmDiagPtArtn may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
Me.Dispose()
eventArgs.Cancel = Cancel
End Sub
End Class
|
sillsdev/ipa-help
|
Src/DIAGPTAR.vb
|
Visual Basic
|
mit
| 4,725
|
Imports CefSharp
Imports CefSharp.WinForms
Public Class frmBrowser
Private WithEvents _browser As ChromiumWebBrowser
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
_browser = New ChromiumWebBrowser("http://google.com")
pnlBrowser.Controls.Add(_browser)
End Sub
Private Sub btnMSDN_Click(sender As Object, e As EventArgs) Handles btnMSDN.Click
_browser.Load("https://msdn.com")
End Sub
Private Sub Form1_Disposed(sender As Object, e As EventArgs) Handles Me.Disposed
_browser.Dispose()
CefSharp.Cef.Shutdown()
End Sub
Private Sub _browser_LoadingStateChanged(sender As Object, e As LoadingStateChangedEventArgs) Handles _browser.LoadingStateChanged
Dim xtn = Sub()
pnlActions.Enabled = Not e.IsLoading
End Sub
If InvokeRequired Then
Invoke(Sub()
xtn()
End Sub
)
Else
xtn.Invoke
End If
End Sub
End Class
|
VBDev2Dev/CefSharpSample
|
Cef Sample/frmBrowser.vb
|
Visual Basic
|
mit
| 1,166
|
Public Class BankaKrvi_Form
'Dugme za dodavanje u bazu svih polja koja su unesena.
Private Sub Banka_krviBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles Banka_krviBindingNavigatorSaveItem.Click
Me.Validate()
Me.Banka_krviBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.IbolnicaDataSet)
End Sub
'Konekcija sa SQL bazom podataka.
Private Sub BankaKrvi_Form_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'IbolnicaDataSet.banka_krvi' table. You can move, or remove it, as needed.
Me.Banka_krviTableAdapter.Fill(Me.IbolnicaDataSet.banka_krvi)
End Sub
'Dugme za uredjivanje i dodavanje modifikacija u tabeli.
Private Sub BtnUredi_Click(sender As Object, e As EventArgs) Handles BtnUredi.Click
Me.Validate()
Me.Banka_krviBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.IbolnicaDataSet)
End Sub
'Dugme za zatvaranje forme.
Private Sub BtnZatvori_Click(sender As Object, e As EventArgs) Handles BtnZatvori.Click
Me.Close()
End Sub
End Class
|
error505/iHospital
|
iBolnica/BankaKrvi_Form.vb
|
Visual Basic
|
mit
| 1,164
|
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated by a tool.
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Namespace My.Resources
'This class was auto-generated by the StronglyTypedResourceBuilder
'class via a tool like ResGen or Visual Studio.
'To add or remove a member, edit your .ResX file then rerun ResGen
'with the /str option, or rebuild your VS project.
'<summary>
' A strongly-typed resource class, for looking up localized strings, etc.
'</summary>
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0"), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
Friend Module Resources
Private resourceMan As Global.System.Resources.ResourceManager
Private resourceCulture As Global.System.Globalization.CultureInfo
'<summary>
' Returns the cached ResourceManager instance used by this class.
'</summary>
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
Get
If Object.ReferenceEquals(resourceMan, Nothing) Then
Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("HTML_fundamentals.Resources", GetType(Resources).Assembly)
resourceMan = temp
End If
Return resourceMan
End Get
End Property
'<summary>
' Overrides the current thread's CurrentUICulture property for all
' resource lookups using this strongly typed resource class.
'</summary>
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Friend Property Culture() As Global.System.Globalization.CultureInfo
Get
Return resourceCulture
End Get
Set(ByVal value As Global.System.Globalization.CultureInfo)
resourceCulture = value
End Set
End Property
End Module
End Namespace
|
todorm85/TelerikAcademy
|
Courses/Web Design and UI/HTML/notes/HTML fundamentals/My Project/Resources.Designer.vb
|
Visual Basic
|
mit
| 2,706
|
Imports SistFoncreagro.BussinessEntities
Public Interface IDetalleEjecucionBL
Function GetDETALLEEJECUCIONByIdProyecto(ByVal IdProyecto As Int32) As List(Of DetalleEjecucion)
Function SaveDETALLEEJECUCION(ByVal _DetalleEjecucion As DetalleEjecucion) As Int32
Function GetDETALLEEJECUCIONByIdDetalleEje(ByVal IdDetalleEje As Int32) As DetalleEjecucion
Sub DeletetDETALLEEJECUCION(ByVal IdDetalleEje As Int32)
Sub UpdateEstadoDetalleejecucion(ByVal IdDetalleEje As Int32)
End Interface
|
crackper/SistFoncreagro
|
SistFoncreagro.BussinesLogic/IDetalleEjecucionBL.vb
|
Visual Basic
|
mit
| 507
|
' The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkID=391641
''' <summary>
''' Provides application-specific behavior to supplement the default Application class.
''' </summary>
NotInheritable Class App
Inherits Application
Private _transitions As TransitionCollection
''' <summary>
''' Initializes the singleton application object. This is the first line of authored code
''' executed, and as such is the logical equivalent of main() or WinMain().
''' </summary>
Public Sub New()
InitializeComponent()
End Sub
''' <summary>
''' Invoked when the application is launched normally by the end user. Other entry points
''' will be used when the application is launched to open a specific file, to display
''' search results, and so forth.
''' </summary>
''' <param name="e">Details about the launch request and process.</param>
Protected Overrides Sub OnLaunched(e As LaunchActivatedEventArgs)
Dim rootFrame As Frame = TryCast(Window.Current.Content, Frame)
' Do not repeat app initialization when the Window already has content,
' just ensure that the window is active
If rootFrame Is Nothing Then
' Create a Frame to act as the navigation context and navigate to the first page
rootFrame = New Frame()
' TODO: change this value to a cache size that is appropriate for your application
rootFrame.CacheSize = 1
If e.PreviousExecutionState = ApplicationExecutionState.Terminated Then
' TODO: Load state from previously suspended application
End If
' Place the frame in the current Window
Window.Current.Content = rootFrame
End If
If rootFrame.Content Is Nothing Then
' Removes the turnstile navigation for startup.
If rootFrame.ContentTransitions IsNot Nothing Then
_transitions = New TransitionCollection()
For Each transition As Transition In rootFrame.ContentTransitions
_transitions.Add(transition)
Next
End If
rootFrame.ContentTransitions = Nothing
AddHandler rootFrame.Navigated, AddressOf RootFrame_FirstNavigated
' When the navigation stack isn't restored navigate to the first page,
' configuring the new page by passing required information as a navigation
' parameter
If Not rootFrame.Navigate(GetType(MainPage), e.Arguments) Then
Throw New Exception("Failed to create initial page")
End If
End If
' Ensure the current window is active
Window.Current.Activate()
End Sub
''' <summary>
''' Restores the content transitions after the app has launched.
''' </summary>
Private Sub RootFrame_FirstNavigated(sender As Object, e As NavigationEventArgs)
Dim newTransitions As TransitionCollection
If _transitions Is Nothing Then
newTransitions = New TransitionCollection()
newTransitions.Add(New NavigationThemeTransition())
Else
newTransitions = _transitions
End If
Dim rootFrame As Frame = DirectCast(sender, Frame)
rootFrame.ContentTransitions = newTransitions
RemoveHandler rootFrame.Navigated, AddressOf RootFrame_FirstNavigated
End Sub
''' <summary>
''' Invoked when application execution is being suspended.Application state is saved
''' without knowing whether the application will be terminated or resumed with the contents
''' of memory still intact.
''' </summary>
Private Sub OnSuspending(sender As Object, e As SuspendingEventArgs) Handles Me.Suspending
Dim deferral As SuspendingDeferral = e.SuspendingOperation.GetDeferral()
' TODO: Save application state and stop any background activity
deferral.Complete()
End Sub
End Class
|
ljw1004/async-mr-flakey
|
AsyncMrFlakey/Demo_Phone_VB/App.xaml.vb
|
Visual Basic
|
mit
| 4,018
|
Option Explicit On
Option Infer On
Option Strict On
#Region " --------------->> Imports/ usings "
Imports System.Text
#End Region
Namespace vCardBuilder
''' <summary>Specify the organizational name and units associated with the vCard.</summary>
Public Class vCardOrganization
#Region " ---------------------- Class Description "
'Url: http://tools.ietf.org/html/rfc2426#section-3.5.5
'
'3.5.5 ORG Type Definition
'
'Subject: Registration of text/directory MIME type ORG
'
'Type name: ORG
'
'Type purpose: To specify the organizational name and units associated
'with the vCard.
'
'Type encoding: 8bit
'
'Type value: A single structured text value consisting of components
'separated the SEMI-COLON character (ASCII decimal 59).
'
'Type special notes: The type is based on the X.520 Organization Name
'and Organization Unit attributes. The type value is a structured type
'consisting of the organization name, followed by one or more levels
'of organizational unit names.
'
'Type example: A type value consisting of an organizational name,
'organizational unit #1 name and organizational unit #2 name.
' ORG:ABC\, Inc.;North American Division;Marketing
#End Region
#Region " --------------->> Enumerationen der Klasse "
#End Region
#Region " --------------->> Eigenschaften der Klasse "
#End Region
#Region " --------------->> Konstruktor und Destruktor der Klasse "
Public Sub New()
End Sub
Public Sub New(ByVal organizationalName As String, ByVal organizationalUnitNames As IEnumerable(Of String))
_OrganizationalName = organizationalName
If organizationalUnitNames Is Nothing Then Return
_OrganizationalUnitNames.AddRange(organizationalUnitNames)
End Sub
#End Region
#Region " --------------->> Zugriffsmethoden der Klasse "
Public Property OrganizationalName() As String
Public ReadOnly Property OrganizationalUnitNames() As New List(Of String)
#End Region
#Region " --------------->> Ereignismethoden der Klasse "
#End Region
#Region " --------------->> Private Methoden der Klasse "
#End Region
#Region " --------------->> Öffentliche Methoden der Klasse "
Public Overrides Function ToString() As String
Dim sb = New StringBuilder
sb.Append($"ORG:{_OrganizationalName}")
_OrganizationalUnitNames.ForEach(Sub(s) sb.Append($";{s}"))
Return sb.ToString
End Function
#End Region
End Class
End Namespace
|
vanitas-mundi/Base
|
Base/vCardBuilder/vCardOrganization.vb
|
Visual Basic
|
mit
| 2,584
|
Imports System
Imports System.Threading
Imports System.IO
Imports System.Net
Imports System.Net.Sockets
Imports System.Configuration
Imports System.Runtime.Serialization.Formatters.Binary
Module Main
Private SerialPort As System.IO.Ports.SerialPort
Private listener As TcpListener
Private publisher As UdpClient
Private threads(4) As Thread
Private NuvoZones As New Collections.Generic.List(Of NuvoZone)
Private NuvoSources As New Collections.Generic.List(Of NuvoSource)
Private NeedToWakeUp As Boolean = True
Public Sub Main()
Try
InitializeSerialPort()
AddHandler SerialPort.DataReceived, AddressOf SerialDataReceived
InitializeNuvoSources()
InitializeNuvoZones()
listener = New System.Net.Sockets.TcpListener(IPAddress.Any, 2055)
listener.Start()
LogInformation("Server listening to Port: {0}", listener.LocalEndpoint)
For i As Integer = 0 To threads.Length - 1
threads(i) = New Thread(New ThreadStart(AddressOf Service))
threads(i).Start()
Next
Catch ex As Exception
LogInformation(ex.Message)
For Each t As Thread In threads
If IsNothing(t) = False Then
t.Abort()
End If
Next
If IsNothing(listener) = False Then
listener.Stop()
End If
End Try
End Sub
Public Sub Service()
Dim client As TcpClient
Try
client = New TcpClient
Do While True
LogInformation("Service Thread: {0} Waiting...", CStr(System.Threading.Thread.CurrentThread.ManagedThreadId))
client = listener.AcceptTcpClient()
LogInformation("Service Thread: {0} Connected: {1}", CStr(System.Threading.Thread.CurrentThread.ManagedThreadId), client.Client.RemoteEndPoint)
Call LoopOnMessage(client)
'if Service Pause/Stop exit Loop
Loop
Catch ex As System.Threading.ThreadAbortException
' thread is being shut down
LogInformation("Service Thread {0} Aborted", System.Threading.Thread.CurrentThread.ManagedThreadId)
Catch ex2 As Exception
LogInformation("Service Thread {0} Exception {1}", CStr(System.Threading.Thread.CurrentThread.ManagedThreadId), ex2.Message)
End Try
End Sub
Private Sub LoopOnMessage(ByVal client As TcpClient)
Dim rsp As String
Dim msg As String
Dim b As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
Try
Using s As Stream = client.GetStream,
sr As New StreamReader(s),
sw As New StreamWriter(s)
sw.AutoFlush = True
Do While True
Try
msg = sr.ReadLine
If IsNothing(msg) Then
LogInformation("Service Thread: {0} msg Is Nothing", System.Threading.Thread.CurrentThread.ManagedThreadId)
Throw New Exception("exit")
End If
LogInformation("Received {0}", msg)
Select Case msg.ToUpper.Trim
Case "CLOSE"
Throw New Exception("exit")
Case "NUVOZONES"
b.Serialize(s, NuvoZones)
Case "NUVOSOURCES"
b.Serialize(s, NuvoSources)
Case ""
'do nothing
Case Else
' this is a command
rsp = AskSerialPort(msg)
LogInformation("Response {0} ", rsp)
End Select
Catch ex As Exception
If ex.Message = "exit" Then
LogInformation("Service Thread {0} Exiting", System.Threading.Thread.CurrentThread.ManagedThreadId)
Else
LogInformation("Service Thread {0} Exception {1}", System.Threading.Thread.CurrentThread.ManagedThreadId, ex.Message)
End If
Exit Do
End Try
Loop
sr.Close()
sw.Close()
s.Close()
End Using
Catch ex As Exception
LogInformation("Service Thread {0} Exception {1}", System.Threading.Thread.CurrentThread.ManagedThreadId, ex.Message)
End Try
End Sub
Private Sub SerialDataReceived(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs)
Dim s As String
Try
s = ""
Do While SerialPort.BytesToRead > 0
s = s & SerialPort.ReadLine
Loop
LogInformation("Serial Data Received {0} {1}", CStr(Now), s)
If System.Text.RegularExpressions.Regex.IsMatch(s, "#ALLOFF") Then
NeedToWakeUp = True
End If
HandleUnsolicitedMessages(s)
Catch ex As Exception
LogInformation("SerialDataReceived Error: " & ex.Message)
End Try
End Sub
Public Sub InitializeSerialPort()
Try
SerialPort = New System.IO.Ports.SerialPort
SerialPort.PortName = "COM3"
SerialPort.Handshake = IO.Ports.Handshake.None
SerialPort.DtrEnable = True
SerialPort.DiscardNull = False
SerialPort.NewLine = vbCrLf
SerialPort.ReceivedBytesThreshold = 1
SerialPort.BaudRate = 57600
SerialPort.Parity = IO.Ports.Parity.None
SerialPort.StopBits = IO.Ports.StopBits.One
SerialPort.DataBits = 8
SerialPort.Open()
Call WakeUpSerialPort()
Catch ex As Exception
Throw New Exception("InitializeSerialPort Failed: " & ex.Message)
End Try
End Sub
Public Sub WakeUpSerialPort()
Try
SerialPort.Write(vbCrLf)
System.Threading.Thread.Sleep(20)
NeedToWakeUp = False
Catch ex As Exception
Throw New Exception("WakeUpSerialPort Failed: " & ex.Message)
End Try
End Sub
Public Sub SendMessage(ByVal msg As String)
Try
If NeedToWakeUp = True Then
WakeUpSerialPort()
End If
SerialPort.WriteLine(msg)
Catch ex As Exception
Throw New Exception("SendMessage Failed: " & ex.Message)
End Try
End Sub
Public Function AskSerialPort(ByVal msg As String) As String
Dim rsp As String = ""
Try
SerialPort.WriteLine(msg)
System.Threading.Thread.Sleep(50)
LogInformation("Bytes to Read {0}", CStr(SerialPort.BytesToRead))
Do While SerialPort.BytesToRead > 0
rsp = rsp & SerialPort.ReadLine
Loop
HandleUnsolicitedMessages(rsp)
Catch ex As Exception
LogInformation("AskSerialPort Error: {0}", ex.Message)
rsp = ""
End Try
Return rsp
End Function
Public Sub InitializeNuvoZones()
Dim i As Integer
Dim z As NuvoZone
Dim request As String = ""
Try
'create all the classes first because we might have a gap in the
'zone sequence if there are slave zones
For i = 1 To 12
z = New NuvoZone(i)
NuvoZones.Add(z)
Next i
For i = 1 To 12
z = NuvoZones(i - 1)
'*ZCFGzSTATUS?
request = "*ZCFG" & CStr(z.Number) & "STATUS?" & vbCrLf
LogInformation(request)
SendMessage(request)
System.Threading.Thread.Sleep(50)
''*ZCFGzEQ?
request = "*ZCFG" & CStr(z.Number) & "EQ?" & vbCrLf
SendMessage(request)
System.Threading.Thread.Sleep(50)
''*ZCFGzVOL?
request = "*ZCFG" & CStr(z.Number) & "VOL?" & vbCrLf
SendMessage(request)
System.Threading.Thread.Sleep(50)
''*ZCFGzDISP?
request = "*ZCFG" & CStr(z.Number) & "DISP?" & vbCrLf
SendMessage(request)
System.Threading.Thread.Sleep(50)
''*ZzSTATUS?
request = "*Z" & CStr(z.Number) & "STATUS?" & vbCrLf
SendMessage(request)
System.Threading.Thread.Sleep(50)
Next
Catch ex As Exception
Throw New Exception("InitializeNuvoZones Failed: " & ex.Message)
End Try
End Sub
Public Function InitializeNuvoSources() As Boolean
Dim i As Integer
Dim s As NuvoSource
Dim request As String = ""
Try
For i = 1 To 6
s = New NuvoSource(i)
NuvoSources.Add(s)
Next i
For i = 1 To 6
s = NuvoSources(i - 1)
'*SCFGsSTATUS?
request = "*SCFG" & CStr(s.Number) & "STATUS?" & vbCrLf
SendMessage(request)
System.Threading.Thread.Sleep(50)
''#SsDISPLINEx,"y"
''*SsDISPLINE?
request = "*S" & CStr(s.Number) & "DISPLINE?" & vbCrLf
SendMessage(request)
System.Threading.Thread.Sleep(50)
'*SsDISPINFO?
''#SsDISPINFO,DURATIONx,POSITIONy,STATUSz
request = "*S" & CStr(s.Number) & "DISPINFO?" & vbCrLf
SendMessage(request)
System.Threading.Thread.Sleep(50)
Next i
Catch ex As Exception
Throw New Exception("InitializeNuvoSources Failed: " & ex.Message)
End Try
End Function
Public Function HandleUnsolicitedMessages(ByVal pdata As String) As Boolean
'Dim pdata As Byte()
Dim ep As System.Net.IPEndPoint = Nothing
Dim msg As String = ""
Dim r() As String 'array of strings
Dim idx As Integer 'index
Dim pattern As String = "S\dDISPLINE\d,"".*"""
Dim foundstring As System.Text.RegularExpressions.Match
Try
For Each msg In pdata.Split("#")
'LogInformation("** message received: " & msg)
'#ZCFG5,ENABLE1,NAME"Master Bath",SLAVETO4,GROUP0,SOURCES3, XSRC0, IR1, DND0, LOCKED0, SLAVEEQ0
'#ZCFG1,ENABLE1,NAME"M3 A",SLAVETO0,GROUP0,SOURCES0,XSRC0,IR0,DND0,LOCKED0
'#ZCFG1,ENABLE0
If System.Text.RegularExpressions.Regex.IsMatch(msg, "ZCFG\d,ENABLE\d") Then
r = msg.Split(",")
idx = CInt(Mid(r(0), 5, 1)) - 1
Call NuvoZone.LoadZoneConfiguration(NuvoZones(idx), r)
End If
If System.Text.RegularExpressions.Regex.IsMatch(msg, "ZCFG\d\d,ENABLE\d") Then
r = msg.Split(",")
idx = CInt(Mid(r(0), 5, 2)) - 1
Call NuvoZone.LoadZoneConfiguration(NuvoZones(idx), r)
End If
'#ZCFG1,BASS0,TREB0,BALC,LOUDCMP0
If System.Text.RegularExpressions.Regex.IsMatch(msg, "ZCFG\d,BASS\d,TREB\d") Then
r = msg.Split(",")
idx = CInt(Mid(r(0), 5, 1)) - 1
Call NuvoZone.LoadZoneEQConfiguration(NuvoZones(idx), r)
End If
If System.Text.RegularExpressions.Regex.IsMatch(msg, "ZCFG\d\d,BASS\d,TREB\d") Then
r = msg.Split(",")
idx = CInt(Mid(r(0), 5, 2)) - 1
Call NuvoZone.LoadZoneEQConfiguration(NuvoZones(idx), r)
End If
'#ZCFG1,MAXVOL0,INIVOL0,PAGEVOL0,PARTYVOL0,VOLRST0
If System.Text.RegularExpressions.Regex.IsMatch(msg, "ZCFG\d,MAXVOL") Then
r = msg.Split(",")
idx = CInt(Mid(r(0), 5, 1)) - 1
Call NuvoZone.LoadZoneVolumeConfiguration(NuvoZones(idx), r)
End If
If System.Text.RegularExpressions.Regex.IsMatch(msg, "ZCFG\d\d,MAXVOL") Then
r = msg.Split(",")
idx = CInt(Mid(r(0), 5, 2)) - 1
Call NuvoZone.LoadZoneVolumeConfiguration(NuvoZones(idx), r)
End If
'#ZCFG1,BRIGHT0,AUTODIM0,DIM0,DISPMODE0,TIME1
If System.Text.RegularExpressions.Regex.IsMatch(msg, "ZCFG\d,BRIGHT") Then
r = msg.Split(",")
idx = CInt(Mid(r(0), 5, 1)) - 1
Call NuvoZone.LoadZoneDisplayConfiguration(NuvoZones(idx), r)
End If
If System.Text.RegularExpressions.Regex.IsMatch(msg, "ZCFG\d\d,BRIGHT") Then
r = msg.Split(",")
idx = CInt(Mid(r(0), 5, 2)) - 1
Call NuvoZone.LoadZoneDisplayConfiguration(NuvoZones(idx), r)
End If
'#Z1,ON,SRC4,VOL60,DND0,LOCK0 - POWER ON
'#Z1,OFF - POWER OFF
If System.Text.RegularExpressions.Regex.IsMatch(msg, "Z\d,ON") Or _
System.Text.RegularExpressions.Regex.IsMatch(msg, "Z\d,OFF") Then
r = msg.Split(",")
idx = CInt(Mid(r(0), 2, 1)) - 1
Call NuvoZone.LoadZoneStatus(NuvoZones(idx), r)
'RaiseEvent PowerStateChanged(NuvoZones(idx))
End If
'#ALLOFF
If System.Text.RegularExpressions.Regex.IsMatch(msg, "ALLOFF") Then
NuvoZones.Clear()
Call InitializeNuvoZones()
End If
'#Z11,ON,SRC4,VOL60,DND0,LOCK0 - POWER ON
'#Z11,OFF - POWER OFF
If System.Text.RegularExpressions.Regex.IsMatch(msg, "Z\d\d,ON") Or _
System.Text.RegularExpressions.Regex.IsMatch(msg, "Z\d\d,OFF") Then
r = msg.Split(",")
idx = CInt(Mid(r(0), 2, 2)) - 1
Call NuvoZone.LoadZoneStatus(NuvoZones(idx), r)
'RaiseEvent PowerStateChanged(NuvoZones(idx))
End If
'#SCFGx,ENABLE1,NAME"M3 A",GAIN0,NUVONET1,SHORTNAMEM3A
'#SCFG1,ENABLE0
If System.Text.RegularExpressions.Regex.IsMatch(msg, "SCFG\d,ENABLE\d") Then
r = msg.Split(",")
idx = CInt(Mid(r(0), 5, 1)) - 1
Call NuvoSource.LoadSourceConfiguration(NuvoSources(idx), r)
End If
'#SxDISPLINE1,""#SxDISPLINE2,""#SxDISPLINE3,"SOURCE x"#SxDISPLINE4,""
'#Z0S1IRCTL9#S1DISPLINE1,"98.1"#S1DISPLINE2,"KING"
foundstring = System.Text.RegularExpressions.Regex.Match(msg, pattern)
If foundstring.Success = True Then
'Debug.Print(foundstring.ToString)
r = foundstring.ToString.Split(",")
idx = CInt(Mid(r(0), 2, 1)) - 1
Call NuvoSource.LoadSourceDisplayLine(NuvoSources(idx), r)
End If
'#SsDISPINFO,DURx,POSy,STATUSz
If System.Text.RegularExpressions.Regex.IsMatch(msg, "S\dDISPINFO") Then
r = msg.Split(",")
idx = CInt(Mid(r(0), 2, 1)) - 1
Call NuvoSource.LoadSourceTrackStatus(NuvoSources(idx), r)
End If
' Debug.Print("Unknown Message: " & msg)
Next
Catch ex As Exception
LogInformation("HandleUnsolicitedMessages Error: {0} {1}", ex.Message, pdata)
End Try
End Function
End Module
|
chrisdias/NuvoServiceVB
|
NuvoService/Main.vb
|
Visual Basic
|
mit
| 16,765
|
Imports Owl.Learning.Initializers
Imports Owl.Learning.NeuronFunctions
Namespace Networks
Public Class Network
Inherits NetworkBase
Private _weights As New TensorSet
Private _biases As New TensorSet
Private _neur As New List(Of NeuronFunctionBase)
''' <summary>
''' The hardcore way.
''' </summary>
Public Sub New()
End Sub
''' <summary>
''' The direct way.
''' </summary>
Public Sub New(Weights As TensorSet, Biases As TensorSet, NeuronFunctions As IEnumerable(Of NeuronFunctionBase))
Me.Weights = Weights
Me.Biases = Biases
Dim funcs As New List(Of NeuronFunctionBase)(NeuronFunctions)
If NeuronFunctions.Count = 1 Then
For i As Integer = 1 To Weights.Count - 1 Step 1
funcs.Add(funcs(0).Duplicate)
Next
End If
Me.NeuronFunctions = funcs
End Sub
''' <summary>
''' The usual way.
''' </summary>
''' <param name="NFunction"></param>
''' <param name="Inputs"></param>
''' <param name="Neurons"></param>
''' <param name="NetworkInitializer"></param>
Sub New(NFunction As NeuronFunctionBase, Inputs As Integer, Neurons As IEnumerable(Of Integer), Optional NetworkInitializer As InitializerBase = Nothing)
For i As Integer = 0 To Neurons.Count - 1 Step 1
_neur.Add(NFunction.Duplicate)
Next
Dim nl As New List(Of Integer) From {Inputs}
nl.AddRange(Neurons)
For i As Integer = 1 To nl.Count - 1 Step 1
Dim prev As Integer = nl(i - 1)
Dim this As Integer = nl(i)
_weights.Add(New Tensor(New List(Of Integer) From {prev, this}))
_biases.Add(New Tensor(New List(Of Integer) From {this}))
Next
If NetworkInitializer IsNot Nothing Then NetworkInitializer.InitializeNetwork(Me)
End Sub
''' <summary>
''' The usual way.
''' </summary>
''' <param name="NFunctions"></param>
''' <param name="Inputs"></param>
''' <param name="Neurons"></param>
''' <param name="NetworkInitializer"></param>
Sub New(NFunctions As IEnumerable(Of NeuronFunctionBase), Inputs As Integer, Neurons As IEnumerable(Of Integer), Optional NetworkInitializer As InitializerBase = Nothing)
_neur.AddRange(NFunctions)
If _neur.Count = 1 Then
For i As Integer = 1 To Neurons.Count - 1 Step 1
_neur.Add(_neur(0).Duplicate)
Next
End If
Dim nl As New List(Of Integer) From {Inputs}
nl.AddRange(Neurons)
For i As Integer = 1 To nl.Count - 1 Step 1
Dim prev As Integer = nl(i - 1)
Dim this As Integer = nl(i)
_weights.Add(New Tensor(New List(Of Integer) From {prev, this}))
_biases.Add(New Tensor(New List(Of Integer) From {this}))
Next
If NetworkInitializer IsNot Nothing Then NetworkInitializer.InitializeNetwork(Me)
End Sub
Public Function Duplicate() As Network
Dim nl As New List(Of NeuronFunctionBase)
For Each f As NeuronFunctionBase In Me.NeuronFunctions
nl.Add(f.Duplicate)
Next
Return New Network(Weights.Duplicate, Biases.Duplicate, nl)
End Function
Public Function NeuronCounts() As List(Of Integer)
Dim nl As New List(Of Integer)
For i = 0 To Me.LayerCount - 1
nl.Add(Me.NeuronCount(i))
Next
Return nl
End Function
Public ReadOnly Property LayerCount As Integer
Get
Return _weights.Count
End Get
End Property
Public ReadOnly Property InputCount(LayerIndex As Integer) As Integer
Get
Return _weights(LayerIndex).ShapeAt(0)
End Get
End Property
Public ReadOnly Property NeuronCount(LayerIndex As Integer) As Integer
Get
Return _weights(LayerIndex).ShapeAt(1)
End Get
End Property
Public Property LayerWeights(layerIndex As Integer) As Tensor
Get
Return _weights(layerIndex)
End Get
Set(value As Tensor)
_weights(layerIndex) = value
End Set
End Property
Public Property LayerBiases(layerIndex As Integer) As Tensor
Get
Return _biases(layerIndex)
End Get
Set(value As Tensor)
_biases(layerIndex) = value
End Set
End Property
''' <summary>
''' Direct access to the underlying arrays. Weights are stored in Tensors of form [Input, Neuron].
''' This implies the input Tensor for Compute has to be of shape [1, Input].
''' The ComputeLayer performs this reshaping before feeding the Tensor.
''' </summary>
''' <returns></returns>
Public Property Weights As TensorSet
Get
Return _weights
End Get
Set(value As TensorSet)
_weights = value
End Set
End Property
''' <summary>
''' Direct access to the underlying arrays
''' </summary>
''' <returns></returns>
Public Property Biases As TensorSet
Get
Return _biases
End Get
Set(value As TensorSet)
_biases = value
End Set
End Property
''' <summary>
''' Direct access to the underlying function per layer.
''' </summary>
''' <returns></returns>
Public Property NeuronFunctions As List(Of NeuronFunctionBase)
Get
Return _neur
End Get
Set(value As List(Of NeuronFunctionBase))
_neur = value
End Set
End Property
Public Function ComputeOptimized(Inputs As TensorSet) As TensorSet
Dim outputs As New TensorSet
Dim wtrans As TensorSet = Me.Weights.Duplicate
For i As Integer = 0 To wtrans.Count - 1 Step 1
wtrans(i) = Owl.Core.Images.Transpose(wtrans(i))
Next
For i As Integer = 0 To Inputs.Count - 1 Step 1
Dim thisinput As Tensor = Inputs(i).Duplicate
thisinput.TryReshape({1, thisinput.Length})
For j As Integer = 0 To Me.LayerCount - 1 Step 1
thisinput = OptimizedMatMul(thisinput, wtrans(j))
thisinput.Add(Biases(j))
NeuronFunctions(j).Evaluate(thisinput)
Next
outputs.Add(thisinput)
Next
Return outputs
End Function
''' <summary>
''' Memory-optimizied MatMul...
''' </summary>
''' <param name="TransposedMatrix"></param>
''' <returns></returns>
Public Function OptimizedMatMul(InputTensor As Tensor, TransposedMatrix As Tensor) As Tensor
Dim AB As New Tensor(TransposedMatrix.Height, InputTensor.Height)
Dim da() As Double = InputTensor.TensorData
Dim db() As Double = TransposedMatrix.TensorData
Dim posa As Integer = 0
Dim posb As Integer = 0
Dim posc As Integer = 0
For i As Integer = 0 To InputTensor.Height - 1 Step 1
posa = i * InputTensor.Width
posb = 0
For j As Integer = 0 To TransposedMatrix.Height - 1 Step 1
Dim sum As Double = 0
For k As Integer = 0 To InputTensor.Width - 1 Step 1
sum += da(posa + k) * db(posb + k)
Next
AB.TensorData(posc) = sum
posb += InputTensor.Width
posc += 1
Next
Next
Return AB
End Function
Public Overrides Function Compute(InputTensor As Tensor) As Tensor
Dim thistens As Tensor = InputTensor
For i As Integer = 0 To Me.LayerCount - 1 Step 1
thistens = ComputeLayer(thistens, i)
Next
Return thistens
End Function
''' <summary>
''' Input tensor gets always reshaped into a [1, length] matrix.
''' </summary>
''' <param name="InputTensor"></param>
''' <param name="LayerIndex"></param>
''' <returns></returns>
Public Function ComputeLayer(InputTensor As Tensor, LayerIndex As Integer) As Tensor
InputTensor.TryReshape({1, InputTensor.Length})
Dim tsum As Tensor = Tensor.MatMul(InputTensor, Me.Weights(LayerIndex))
tsum.Add(Biases(LayerIndex))
NeuronFunctions(LayerIndex).Evaluate(tsum)
Return tsum
End Function
End Class
End Namespace
|
mateuszzwierzycki/Owl
|
Owl.Learning/Networks/Network.vb
|
Visual Basic
|
mit
| 9,245
|
Imports System.Resources
Imports System
Imports System.Reflection
Imports System.Runtime.InteropServices
' General Information about an assembly is controlled through the following
' set of attributes. Change these attribute values to modify the information
' associated with an assembly.
' Review the values of the assembly attributes
<Assembly: AssemblyTitle("Room Painter")>
<Assembly: AssemblyDescription("Use the Room Painter app to calculate the floor area; work out how much paint you need to paint a wall; and to work out the room volume.")>
<Assembly: AssemblyCompany("")>
<Assembly: AssemblyProduct("Room Painter")>
<Assembly: AssemblyCopyright("©2016 Hassy.")>
<Assembly: AssemblyTrademark("")>
<Assembly: ComVisible(False)>
'The following GUID is for the ID of the typelib if this project is exposed to COM
<Assembly: Guid("f92b6482-6cf5-48f9-96af-5a99cf2a52e4")>
' Version information for an assembly consists of the following four values:
'
' Major Version
' Minor Version
' Build Number
' Revision
'
' You can specify all the values or you can default the Build and Revision Numbers
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.0.0.0")>
<Assembly: AssemblyFileVersion("1.0.0.0")>
<Assembly: NeutralResourcesLanguage("en-GB")>
|
Hassy16/Room-Painter
|
Room Painter/My Project/AssemblyInfo.vb
|
Visual Basic
|
apache-2.0
| 1,335
|
Public Class CleanTool
Public Shared Sub GitClean(dir As String)
Dim prc As New Process
prc.StartInfo.CreateNoWindow = False
prc.StartInfo.RedirectStandardOutput = False
prc.StartInfo.RedirectStandardError = False
prc.StartInfo.FileName = "git"
prc.StartInfo.Arguments = "clean -X -d -f"
prc.StartInfo.WorkingDirectory = dir
prc.StartInfo.UseShellExecute = False
Try
prc.Start()
Console.WriteLine("Git clean ok")
Catch ex As Exception
Console.WriteLine("Git clean error: " + ex.Message)
End Try
End Sub
End Class
|
Lifemotion/Bwl.VsTools
|
Bwl.VsTools/tools/CleanTool.vb
|
Visual Basic
|
apache-2.0
| 648
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Collections.Immutable
Imports System.Diagnostics
Imports System.Linq
Imports System.Runtime.InteropServices
Imports Microsoft.CodeAnalysis.Collections
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports TypeKind = Microsoft.CodeAnalysis.TypeKind
Namespace Microsoft.CodeAnalysis.VisualBasic
Partial Friend Class OverloadResolution
''' <summary>
''' A map from Operator name to number of parameters and kind.
''' </summary>
Private Shared ReadOnly OperatorNames As Dictionary(Of String, OperatorInfo)
''' <summary>
''' Operator kind and expected number of parameters.
''' </summary>
Friend Structure OperatorInfo
Private ReadOnly m_Id As Integer
Public Sub New(op As UnaryOperatorKind)
m_Id = (1 Or (op << 2))
End Sub
Public Sub New(op As BinaryOperatorKind)
m_Id = (2 Or (op << 2))
End Sub
Public ReadOnly Property ParamCount As Integer
Get
Return (m_Id And 3)
End Get
End Property
Public ReadOnly Property IsBinary As Boolean
Get
Return ParamCount = 2
End Get
End Property
Public ReadOnly Property IsUnary As Boolean
Get
Return ParamCount = 1
End Get
End Property
Public ReadOnly Property UnaryOperatorKind As UnaryOperatorKind
Get
If Not IsUnary Then
Return UnaryOperatorKind.Error
End If
Return CType(m_Id >> 2, UnaryOperatorKind)
End Get
End Property
Public ReadOnly Property BinaryOperatorKind As BinaryOperatorKind
Get
If Not IsBinary Then
Return BinaryOperatorKind.Error
End If
Return CType(m_Id >> 2, BinaryOperatorKind)
End Get
End Property
End Structure
Friend Shared Function GetOperatorInfo(name As String) As OperatorInfo
Dim result As OperatorInfo = Nothing
If name.Length > 3 AndAlso IdentifierComparison.Equals("op_", name.Substring(0, 3)) AndAlso OperatorNames.TryGetValue(name, result) Then
Return result
End If
Return Nothing
End Function
Shared Sub New()
Dim operators As New Dictionary(Of String, OperatorInfo)(IdentifierComparison.Comparer)
operators.Add(WellKnownMemberNames.OnesComplementOperatorName, New OperatorInfo(UnaryOperatorKind.Not))
operators.Add(WellKnownMemberNames.TrueOperatorName, New OperatorInfo(UnaryOperatorKind.IsTrue))
operators.Add(WellKnownMemberNames.FalseOperatorName, New OperatorInfo(UnaryOperatorKind.IsFalse))
operators.Add(WellKnownMemberNames.UnaryPlusOperatorName, New OperatorInfo(UnaryOperatorKind.Plus))
operators.Add(WellKnownMemberNames.AdditionOperatorName, New OperatorInfo(BinaryOperatorKind.Add))
operators.Add(WellKnownMemberNames.UnaryNegationOperatorName, New OperatorInfo(UnaryOperatorKind.Minus))
operators.Add(WellKnownMemberNames.SubtractionOperatorName, New OperatorInfo(BinaryOperatorKind.Subtract))
operators.Add(WellKnownMemberNames.MultiplyOperatorName, New OperatorInfo(BinaryOperatorKind.Multiply))
operators.Add(WellKnownMemberNames.DivisionOperatorName, New OperatorInfo(BinaryOperatorKind.Divide))
operators.Add(WellKnownMemberNames.IntegerDivisionOperatorName, New OperatorInfo(BinaryOperatorKind.IntegerDivide))
operators.Add(WellKnownMemberNames.ModulusOperatorName, New OperatorInfo(BinaryOperatorKind.Modulo))
operators.Add(WellKnownMemberNames.ExponentOperatorName, New OperatorInfo(BinaryOperatorKind.Power))
operators.Add(WellKnownMemberNames.EqualityOperatorName, New OperatorInfo(BinaryOperatorKind.Equals))
operators.Add(WellKnownMemberNames.InequalityOperatorName, New OperatorInfo(BinaryOperatorKind.NotEquals))
operators.Add(WellKnownMemberNames.LessThanOperatorName, New OperatorInfo(BinaryOperatorKind.LessThan))
operators.Add(WellKnownMemberNames.GreaterThanOperatorName, New OperatorInfo(BinaryOperatorKind.GreaterThan))
operators.Add(WellKnownMemberNames.LessThanOrEqualOperatorName, New OperatorInfo(BinaryOperatorKind.LessThanOrEqual))
operators.Add(WellKnownMemberNames.GreaterThanOrEqualOperatorName, New OperatorInfo(BinaryOperatorKind.GreaterThanOrEqual))
operators.Add(WellKnownMemberNames.LikeOperatorName, New OperatorInfo(BinaryOperatorKind.Like))
operators.Add(WellKnownMemberNames.ConcatenateOperatorName, New OperatorInfo(BinaryOperatorKind.Concatenate))
operators.Add(WellKnownMemberNames.BitwiseAndOperatorName, New OperatorInfo(BinaryOperatorKind.And))
operators.Add(WellKnownMemberNames.BitwiseOrOperatorName, New OperatorInfo(BinaryOperatorKind.Or))
operators.Add(WellKnownMemberNames.ExclusiveOrOperatorName, New OperatorInfo(BinaryOperatorKind.Xor))
operators.Add(WellKnownMemberNames.LeftShiftOperatorName, New OperatorInfo(BinaryOperatorKind.LeftShift))
operators.Add(WellKnownMemberNames.RightShiftOperatorName, New OperatorInfo(BinaryOperatorKind.RightShift))
operators.Add(WellKnownMemberNames.ImplicitConversionName, New OperatorInfo(UnaryOperatorKind.Implicit))
operators.Add(WellKnownMemberNames.ExplicitConversionName, New OperatorInfo(UnaryOperatorKind.Explicit))
' These cannot be declared in source, but can be imported.
operators.Add(WellKnownMemberNames.LogicalNotOperatorName, New OperatorInfo(UnaryOperatorKind.Not))
operators.Add(WellKnownMemberNames.LogicalAndOperatorName, New OperatorInfo(BinaryOperatorKind.And))
operators.Add(WellKnownMemberNames.LogicalOrOperatorName, New OperatorInfo(BinaryOperatorKind.Or))
operators.Add(WellKnownMemberNames.UnsignedLeftShiftOperatorName, New OperatorInfo(BinaryOperatorKind.LeftShift))
operators.Add(WellKnownMemberNames.UnsignedRightShiftOperatorName, New OperatorInfo(BinaryOperatorKind.RightShift))
OperatorNames = operators
End Sub
Friend Shared Function GetOperatorTokenKind(name As String) As SyntaxKind
Dim opInfo As OperatorInfo = GetOperatorInfo(name)
Return GetOperatorTokenKind(opInfo)
End Function
Friend Shared Function GetOperatorTokenKind(opInfo As OperatorInfo) As SyntaxKind
If opInfo.IsUnary Then
Return GetOperatorTokenKind(opInfo.UnaryOperatorKind)
Else
Return GetOperatorTokenKind(opInfo.BinaryOperatorKind)
End If
End Function
Friend Shared Function GetOperatorTokenKind(op As UnaryOperatorKind) As SyntaxKind
Select Case op
Case UnaryOperatorKind.IsFalse
Return SyntaxKind.IsFalseKeyword
Case UnaryOperatorKind.IsTrue
Return SyntaxKind.IsTrueKeyword
Case UnaryOperatorKind.Minus
Return SyntaxKind.MinusToken
Case UnaryOperatorKind.Not
Return SyntaxKind.NotKeyword
Case UnaryOperatorKind.Plus
Return SyntaxKind.PlusToken
Case UnaryOperatorKind.Implicit, UnaryOperatorKind.Explicit
Return SyntaxKind.CTypeKeyword
Case Else
Throw ExceptionUtilities.UnexpectedValue(op)
End Select
End Function
Friend Shared Function GetOperatorTokenKind(op As BinaryOperatorKind) As SyntaxKind
Select Case op
Case BinaryOperatorKind.Add
Return SyntaxKind.PlusToken
Case BinaryOperatorKind.Subtract
Return SyntaxKind.MinusToken
Case BinaryOperatorKind.Multiply
Return SyntaxKind.AsteriskToken
Case BinaryOperatorKind.Divide
Return SyntaxKind.SlashToken
Case BinaryOperatorKind.IntegerDivide
Return SyntaxKind.BackslashToken
Case BinaryOperatorKind.Modulo
Return SyntaxKind.ModKeyword
Case BinaryOperatorKind.Power
Return SyntaxKind.CaretToken
Case BinaryOperatorKind.Equals
Return SyntaxKind.EqualsToken
Case BinaryOperatorKind.NotEquals
Return SyntaxKind.LessThanGreaterThanToken
Case BinaryOperatorKind.LessThan
Return SyntaxKind.LessThanToken
Case BinaryOperatorKind.GreaterThan
Return SyntaxKind.GreaterThanToken
Case BinaryOperatorKind.LessThanOrEqual
Return SyntaxKind.LessThanEqualsToken
Case BinaryOperatorKind.GreaterThanOrEqual
Return SyntaxKind.GreaterThanEqualsToken
Case BinaryOperatorKind.Like
Return SyntaxKind.LikeKeyword
Case BinaryOperatorKind.Concatenate
Return SyntaxKind.AmpersandToken
Case BinaryOperatorKind.And
Return SyntaxKind.AndKeyword
Case BinaryOperatorKind.Or
Return SyntaxKind.OrKeyword
Case BinaryOperatorKind.Xor
Return SyntaxKind.XorKeyword
Case BinaryOperatorKind.LeftShift
Return SyntaxKind.LessThanLessThanToken
Case BinaryOperatorKind.RightShift
Return SyntaxKind.GreaterThanGreaterThanToken
Case BinaryOperatorKind.AndAlso
Return SyntaxKind.AndAlsoKeyword
Case BinaryOperatorKind.OrElse
Return SyntaxKind.OrElseKeyword
Case BinaryOperatorKind.Is
Return SyntaxKind.IsKeyword
Case BinaryOperatorKind.IsNot
Return SyntaxKind.IsNotKeyword
Case Else
Throw ExceptionUtilities.UnexpectedValue(op)
End Select
End Function
Friend Shared Function TryGetOperatorName(op As BinaryOperatorKind) As String
Select Case (op And BinaryOperatorKind.OpMask)
Case BinaryOperatorKind.Add
Return WellKnownMemberNames.AdditionOperatorName
Case BinaryOperatorKind.Concatenate
Return WellKnownMemberNames.ConcatenateOperatorName
Case BinaryOperatorKind.Like
Return WellKnownMemberNames.LikeOperatorName
Case BinaryOperatorKind.Equals
Return WellKnownMemberNames.EqualityOperatorName
Case BinaryOperatorKind.NotEquals
Return WellKnownMemberNames.InequalityOperatorName
Case BinaryOperatorKind.LessThanOrEqual
Return WellKnownMemberNames.LessThanOrEqualOperatorName
Case BinaryOperatorKind.GreaterThanOrEqual
Return WellKnownMemberNames.GreaterThanOrEqualOperatorName
Case BinaryOperatorKind.LessThan
Return WellKnownMemberNames.LessThanOperatorName
Case BinaryOperatorKind.GreaterThan
Return WellKnownMemberNames.GreaterThanOperatorName
Case BinaryOperatorKind.Subtract
Return WellKnownMemberNames.SubtractionOperatorName
Case BinaryOperatorKind.Multiply
Return WellKnownMemberNames.MultiplyOperatorName
Case BinaryOperatorKind.Power
Return WellKnownMemberNames.ExponentOperatorName
Case BinaryOperatorKind.Divide
Return WellKnownMemberNames.DivisionOperatorName
Case BinaryOperatorKind.Modulo
Return WellKnownMemberNames.ModulusOperatorName
Case BinaryOperatorKind.IntegerDivide
Return WellKnownMemberNames.IntegerDivisionOperatorName
Case BinaryOperatorKind.LeftShift
Return WellKnownMemberNames.LeftShiftOperatorName
Case BinaryOperatorKind.RightShift
Return WellKnownMemberNames.RightShiftOperatorName
Case BinaryOperatorKind.Xor
Return WellKnownMemberNames.ExclusiveOrOperatorName
Case BinaryOperatorKind.Or
Return WellKnownMemberNames.BitwiseOrOperatorName
Case BinaryOperatorKind.And
Return WellKnownMemberNames.BitwiseAndOperatorName
Case Else
Return Nothing
'Case BinaryOperatorKind.OrElse
'Case BinaryOperatorKind.AndAlso
'Case BinaryOperatorKind.Is
'Case BinaryOperatorKind.IsNot
End Select
End Function
Friend Shared Function TryGetOperatorName(op As UnaryOperatorKind) As String
Select Case (op And UnaryOperatorKind.OpMask)
Case UnaryOperatorKind.Plus
Return WellKnownMemberNames.UnaryPlusOperatorName
Case UnaryOperatorKind.Minus
Return WellKnownMemberNames.UnaryNegationOperatorName
Case UnaryOperatorKind.Not
Return WellKnownMemberNames.OnesComplementOperatorName
Case UnaryOperatorKind.Implicit
Return WellKnownMemberNames.ImplicitConversionName
Case UnaryOperatorKind.Explicit
Return WellKnownMemberNames.ExplicitConversionName
Case UnaryOperatorKind.IsTrue
Return WellKnownMemberNames.TrueOperatorName
Case UnaryOperatorKind.IsFalse
Return WellKnownMemberNames.FalseOperatorName
Case Else
Return Nothing
End Select
End Function
Friend Shared Function ValidateOverloadedOperator(
method As MethodSymbol,
opInfo As OperatorInfo,
Optional diagnosticsOpt As DiagnosticBag = Nothing
) As Boolean
Debug.Assert(method.IsMethodKindBasedOnSyntax OrElse diagnosticsOpt Is Nothing)
Debug.Assert(opInfo.ParamCount <> 0)
If method.ParameterCount <> opInfo.ParamCount Then
Return False
End If
Dim result As Boolean = True
Dim containingType As NamedTypeSymbol = method.ContainingType
Dim targetsContainingType As Boolean = False
Dim targetMismatchError As ERRID
Dim isConversion As Boolean = False
If opInfo.IsUnary Then
Select Case opInfo.UnaryOperatorKind
Case UnaryOperatorKind.Implicit, UnaryOperatorKind.Explicit
isConversion = True
targetMismatchError = ERRID.ERR_ConvParamMustBeContainingType1
If OverloadedOperatorTargetsContainingType(containingType, method.ReturnType) Then
targetsContainingType = True
End If
Case Else
targetMismatchError = ERRID.ERR_UnaryParamMustBeContainingType1
If Not method.ReturnType.IsBooleanType() Then
Select Case opInfo.UnaryOperatorKind
Case UnaryOperatorKind.IsTrue
If diagnosticsOpt IsNot Nothing Then
diagnosticsOpt.Add(ErrorFactory.ErrorInfo(ERRID.ERR_OperatorRequiresBoolReturnType1, SyntaxFacts.GetText(SyntaxKind.IsTrueKeyword)), method.Locations(0))
result = False
Else
Return False
End If
Case UnaryOperatorKind.IsFalse
If diagnosticsOpt IsNot Nothing Then
diagnosticsOpt.Add(ErrorFactory.ErrorInfo(ERRID.ERR_OperatorRequiresBoolReturnType1, SyntaxFacts.GetText(SyntaxKind.IsFalseKeyword)), method.Locations(0))
result = False
Else
Return False
End If
End Select
End If
End Select
Else
Debug.Assert(opInfo.IsBinary)
targetMismatchError = ERRID.ERR_BinaryParamMustBeContainingType1
Select Case opInfo.BinaryOperatorKind
Case BinaryOperatorKind.LeftShift, BinaryOperatorKind.RightShift
If method.Parameters(1).Type.GetNullableUnderlyingTypeOrSelf().SpecialType <> Microsoft.CodeAnalysis.SpecialType.System_Int32 Then
If diagnosticsOpt IsNot Nothing Then
diagnosticsOpt.Add(ErrorFactory.ErrorInfo(ERRID.ERR_OperatorRequiresIntegerParameter1,
SyntaxFacts.GetText(If(opInfo.BinaryOperatorKind = BinaryOperatorKind.LeftShift,
SyntaxKind.LessThanLessThanToken,
SyntaxKind.GreaterThanGreaterThanToken))), method.Locations(0))
result = False
Else
Return False
End If
End If
End Select
End If
For Each param In method.Parameters
If OverloadedOperatorTargetsContainingType(containingType, param.Type) Then
targetsContainingType = True
End If
If param.IsByRef Then
If diagnosticsOpt IsNot Nothing Then
' Diagnostic has been reported when we were interpreting parameter's modifiers.
Debug.Assert(Not method.IsMethodKindBasedOnSyntax)
result = False
Else
Return False
End If
End If
Next
If Not targetsContainingType Then
If diagnosticsOpt IsNot Nothing Then
diagnosticsOpt.Add(ErrorFactory.ErrorInfo(targetMismatchError, method.ContainingSymbol), method.Locations(0))
result = False
Else
Return False
End If
ElseIf isConversion Then
' Conversion operators specific checks
Dim sourceType As TypeSymbol = method.Parameters(0).Type
Dim targetType As TypeSymbol = method.ReturnType
If sourceType.IsObjectType() Then
If diagnosticsOpt IsNot Nothing Then
diagnosticsOpt.Add(ErrorFactory.ErrorInfo(ERRID.ERR_ConversionFromObject), method.Locations(0))
result = False
Else
Return False
End If
ElseIf targetType.IsObjectType() Then
If diagnosticsOpt IsNot Nothing Then
diagnosticsOpt.Add(ErrorFactory.ErrorInfo(ERRID.ERR_ConversionToObject), method.Locations(0))
result = False
Else
Return False
End If
ElseIf sourceType.IsInterfaceType() Then
If diagnosticsOpt IsNot Nothing Then
diagnosticsOpt.Add(ErrorFactory.ErrorInfo(ERRID.ERR_ConversionFromInterfaceType), method.Locations(0))
result = False
Else
Return False
End If
ElseIf targetType.IsInterfaceType() Then
If diagnosticsOpt IsNot Nothing Then
diagnosticsOpt.Add(ErrorFactory.ErrorInfo(ERRID.ERR_ConversionToInterfaceType), method.Locations(0))
result = False
Else
Return False
End If
ElseIf If(containingType.SpecialType = SpecialType.System_Nullable_T,
sourceType Is targetType,
sourceType.GetNullableUnderlyingTypeOrSelf() Is targetType.GetNullableUnderlyingTypeOrSelf()) Then
If diagnosticsOpt IsNot Nothing Then
diagnosticsOpt.Add(ErrorFactory.ErrorInfo(ERRID.ERR_ConversionToSameType), method.Locations(0))
result = False
Else
Return False
End If
ElseIf (sourceType.Kind = SymbolKind.NamedType OrElse sourceType.Kind = SymbolKind.TypeParameter) AndAlso
(targetType.Kind = SymbolKind.NamedType OrElse targetType.Kind = SymbolKind.TypeParameter) Then
If Conversions.HasWideningDirectCastConversionButNotEnumTypeConversion(targetType, sourceType, Nothing) Then
If diagnosticsOpt IsNot Nothing Then
diagnosticsOpt.Add(ErrorFactory.ErrorInfo(If(targetType Is method.ContainingSymbol,
ERRID.ERR_ConversionFromBaseType,
ERRID.ERR_ConversionToDerivedType)), method.Locations(0))
result = False
Else
Return False
End If
ElseIf Conversions.HasWideningDirectCastConversionButNotEnumTypeConversion(sourceType, targetType, Nothing) Then
If diagnosticsOpt IsNot Nothing Then
diagnosticsOpt.Add(ErrorFactory.ErrorInfo(If(targetType Is method.ContainingSymbol,
ERRID.ERR_ConversionFromDerivedType,
ERRID.ERR_ConversionToBaseType)), method.Locations(0))
result = False
Else
Return False
End If
End If
End If
End If
Return result
End Function
Private Shared Function OverloadedOperatorTargetsContainingType(containingType As NamedTypeSymbol, typeFromSignature As TypeSymbol) As Boolean
If containingType.SpecialType = SpecialType.System_Nullable_T Then
Return typeFromSignature Is containingType
Else
Return typeFromSignature.GetNullableUnderlyingTypeOrSelf() Is containingType
End If
End Function
Public Shared Function MapUnaryOperatorKind(opCode As SyntaxKind) As UnaryOperatorKind
Dim result As UnaryOperatorKind
Select Case opCode
Case SyntaxKind.UnaryPlusExpression
result = UnaryOperatorKind.Plus
Case SyntaxKind.UnaryMinusExpression
result = UnaryOperatorKind.Minus
Case SyntaxKind.NotExpression
result = UnaryOperatorKind.Not
Case Else
Throw ExceptionUtilities.UnexpectedValue(opCode)
End Select
Return result
End Function
''' <summary>
''' Returns UnaryOperatorKind.Error in case of error, otherwise adjusted operator kind.
''' </summary>
Public Shared Function ResolveUnaryOperator(
opCode As UnaryOperatorKind,
operand As BoundExpression,
binder As Binder,
<Out()> ByRef intrinsicOperatorType As SpecialType,
<Out()> ByRef userDefinedOperator As OverloadResolutionResult,
<[In], Out> ByRef useSiteDiagnostics As HashSet(Of DiagnosticInfo)
) As UnaryOperatorKind
Debug.Assert((opCode And UnaryOperatorKind.IntrinsicOpMask) = opCode AndAlso opCode <> UnaryOperatorKind.Error)
opCode = (opCode And UnaryOperatorKind.IntrinsicOpMask)
intrinsicOperatorType = SpecialType.None
userDefinedOperator = Nothing
Dim operandType = operand.Type
' First, dig through Nullable
Dim nullableUnderlying = operandType.GetNullableUnderlyingTypeOrSelf()
Dim operandIsNullable = (operandType IsNot nullableUnderlying)
' Now dig through Enum
Dim enumUnderlying = nullableUnderlying.GetEnumUnderlyingTypeOrSelf()
Dim operandIsEnum = (enumUnderlying IsNot nullableUnderlying)
' Filter out unexpected underlying types for Nullable and enum types
If (operandIsEnum OrElse operandIsNullable) AndAlso
(enumUnderlying.IsStringType() OrElse enumUnderlying.IsObjectType()) Then
Return UnaryOperatorKind.Error
End If
Dim sourceType = enumUnderlying
If sourceType.SpecialType <> SpecialType.System_Object AndAlso
Not sourceType.IsIntrinsicType() Then
If operandType.CanContainUserDefinedOperators(useSiteDiagnostics) Then
userDefinedOperator = ResolveUserDefinedUnaryOperator(operand, opCode, binder, includeEliminatedCandidates:=False, useSiteDiagnostics:=useSiteDiagnostics)
If Not userDefinedOperator.BestResult.HasValue AndAlso userDefinedOperator.Candidates.Length = 0 Then
userDefinedOperator = ResolveUserDefinedUnaryOperator(operand, opCode, binder, includeEliminatedCandidates:=True, useSiteDiagnostics:=useSiteDiagnostics)
If userDefinedOperator.Candidates.Length = 0 Then
Return UnaryOperatorKind.Error
End If
End If
Return UnaryOperatorKind.UserDefined
End If
Return UnaryOperatorKind.Error
End If
Dim result As UnaryOperatorKind = UnaryOperatorKind.Error
If operandIsEnum AndAlso opCode = UnaryOperatorKind.Not AndAlso sourceType.IsIntegralType() Then
'§11.17 Logical Operators
'The enumerated type operators do the bitwise operation on the underlying type of
'the enumerated type, but the return value is the enumerated type.
result = UnaryOperatorKind.Not
Else
intrinsicOperatorType = ResolveNotLiftedIntrinsicUnaryOperator(opCode, sourceType.SpecialType)
If intrinsicOperatorType <> SpecialType.None Then
result = opCode
End If
End If
If result <> UnaryOperatorKind.Error AndAlso operandIsNullable Then
result = result Or UnaryOperatorKind.Lifted
End If
Return result
End Function
''' <summary>
''' Returns result type of the operator or SpecialType.None if operator is not supported.
''' </summary>
Friend Shared Function ResolveNotLiftedIntrinsicUnaryOperator(
opCode As UnaryOperatorKind,
operandSpecialType As SpecialType
) As SpecialType
Dim intrinsicOperatorType As SpecialType
Select Case opCode
Case UnaryOperatorKind.Not
'§11.17 Logical Operators
'Bo SB By Sh US In UI Lo UL De Si Do Da Ch St Ob
'Bo SB By Sh US In UI Lo UL Lo Lo Lo Err Err Lo Ob
Select Case operandSpecialType
Case SpecialType.System_Boolean,
SpecialType.System_SByte,
SpecialType.System_Byte,
SpecialType.System_Int16,
SpecialType.System_UInt16,
SpecialType.System_Int32,
SpecialType.System_UInt32,
SpecialType.System_Int64,
SpecialType.System_UInt64,
SpecialType.System_Object
intrinsicOperatorType = operandSpecialType
Case SpecialType.System_Decimal,
SpecialType.System_Single,
SpecialType.System_Double,
SpecialType.System_String
intrinsicOperatorType = SpecialType.System_Int64
Case Else
intrinsicOperatorType = SpecialType.None
End Select
Case UnaryOperatorKind.Plus
'§11.13.1 Unary Plus Operator
'Bo SB By Sh US In UI Lo UL De Si Do Da Ch St Ob
'Sh SB By Sh US In UI Lo UL De Si Do Err Err Do Ob
Select Case operandSpecialType
Case SpecialType.System_Boolean
intrinsicOperatorType = SpecialType.System_Int16
Case SpecialType.System_SByte,
SpecialType.System_Byte,
SpecialType.System_Int16,
SpecialType.System_UInt16,
SpecialType.System_Int32,
SpecialType.System_UInt32,
SpecialType.System_Int64,
SpecialType.System_UInt64,
SpecialType.System_Decimal,
SpecialType.System_Single,
SpecialType.System_Double,
SpecialType.System_Object
intrinsicOperatorType = operandSpecialType
Case SpecialType.System_String
intrinsicOperatorType = SpecialType.System_Double
Case Else
intrinsicOperatorType = SpecialType.None
End Select
Case UnaryOperatorKind.Minus
'§11.13.2 Unary Minus Operator
'Bo SB By Sh US In UI Lo UL De Si Do Da Ch St Ob
'Sh SB Sh Sh In In Lo Lo De De Si Do Err Err Do Ob
Select Case operandSpecialType
Case SpecialType.System_Boolean,
SpecialType.System_Byte
intrinsicOperatorType = SpecialType.System_Int16
Case SpecialType.System_SByte,
SpecialType.System_Int16,
SpecialType.System_Int32,
SpecialType.System_Int64,
SpecialType.System_Decimal,
SpecialType.System_Single,
SpecialType.System_Double,
SpecialType.System_Object
intrinsicOperatorType = operandSpecialType
Case SpecialType.System_UInt16
intrinsicOperatorType = SpecialType.System_Int32
Case SpecialType.System_UInt32
intrinsicOperatorType = SpecialType.System_Int64
Case SpecialType.System_UInt64
intrinsicOperatorType = SpecialType.System_Decimal
Case SpecialType.System_String
intrinsicOperatorType = SpecialType.System_Double
Case Else
intrinsicOperatorType = SpecialType.None
End Select
Case Else
Throw ExceptionUtilities.UnexpectedValue(opCode)
End Select
Return intrinsicOperatorType
End Function
''' <summary>
''' Attempts to fold unary operator applied to a constant expression.
'''
''' Returns Nothing if operator cannot be folded.
'''
''' If folding failed due to non-integer overflow, ConstantValue.Bad is returned. Consumer
''' is responsible for reporting appropriate diagnostics.
'''
''' If integer overflow occurs, integerOverflow is set to True and ConstantValue for overflowed result is returned.
''' Consumer is responsible for reporting appropriate diagnostics and potentially discarding the result.
''' </summary>
Public Shared Function TryFoldConstantUnaryOperator(
op As UnaryOperatorKind,
operand As BoundExpression,
resultType As TypeSymbol,
ByRef integerOverflow As Boolean
) As ConstantValue
Debug.Assert(operand IsNot Nothing)
Debug.Assert(resultType IsNot Nothing)
integerOverflow = False
Dim operandValue As ConstantValue = operand.ConstantValueOpt
If operandValue Is Nothing OrElse operandValue.IsBad OrElse resultType.IsErrorType() Then
' Not a constant
Return Nothing
End If
Dim operandType = operand.Type
Dim result As ConstantValue = Nothing
Dim underlyingResultType = resultType.GetEnumUnderlyingTypeOrSelf()
If operandType.AllowsCompileTimeOperations() AndAlso
underlyingResultType.AllowsCompileTimeOperations() Then
Debug.Assert(underlyingResultType.IsValidForConstantValue(operandValue))
' Attempt folding
If underlyingResultType.IsIntegralType() Then
Dim value As Int64 = GetConstantValueAsInt64(operandValue)
Select Case (op And UnaryOperatorKind.IntrinsicOpMask)
Case UnaryOperatorKind.Plus
' Nothing to do
Case UnaryOperatorKind.Minus
Debug.Assert(Not underlyingResultType.IsUnsignedIntegralType())
If value = Int64.MinValue Then
integerOverflow = True
End If
value = -value
Case UnaryOperatorKind.Not
value = Not value
Case Else
Throw ExceptionUtilities.UnexpectedValue(op)
End Select
Dim detectedIntegerOverflow = integerOverflow
Dim discriminator = underlyingResultType.GetConstantValueTypeDiscriminator()
result = GetConstantValue(discriminator, NarrowIntegralResult(value, discriminator, discriminator, integerOverflow))
integerOverflow = (op And UnaryOperatorKind.IntrinsicOpMask) = UnaryOperatorKind.Minus AndAlso (integerOverflow OrElse detectedIntegerOverflow)
ElseIf underlyingResultType.IsFloatingType Then
Dim value As Double = If(underlyingResultType.IsSingleType(), operandValue.SingleValue, operandValue.DoubleValue)
Select Case (op And UnaryOperatorKind.IntrinsicOpMask)
Case UnaryOperatorKind.Plus
' Nothing to do
Case UnaryOperatorKind.Minus
value = -value
Case Else
Throw ExceptionUtilities.UnexpectedValue(op)
End Select
Dim overflow As Boolean = False
value = NarrowFloatingResult(value, underlyingResultType.GetConstantValueTypeDiscriminator(), overflow)
' We have decided to ignore overflows in compile-time evaluation
' of floating expressions.
If underlyingResultType.IsSingleType() Then
result = ConstantValue.Create(CType(value, Single))
Else
result = ConstantValue.Create(value)
End If
ElseIf underlyingResultType.IsDecimalType() Then
Dim value As Decimal = operandValue.DecimalValue
Select Case (op And UnaryOperatorKind.IntrinsicOpMask)
Case UnaryOperatorKind.Plus
' Nothing to do
Case UnaryOperatorKind.Minus
value = Decimal.Negate(value)
Case Else
Throw ExceptionUtilities.UnexpectedValue(op)
End Select
result = ConstantValue.Create(value)
ElseIf underlyingResultType.IsBooleanType() Then
Debug.Assert((op And UnaryOperatorKind.IntrinsicOpMask) = UnaryOperatorKind.Not)
result = ConstantValue.Create(Not operandValue.BooleanValue)
End If
End If
Return result
End Function
Public Shared Function MapBinaryOperatorKind(opCode As SyntaxKind) As BinaryOperatorKind
Dim result As BinaryOperatorKind
Select Case opCode
Case SyntaxKind.AddExpression : result = BinaryOperatorKind.Add
Case SyntaxKind.ConcatenateExpression : result = BinaryOperatorKind.Concatenate
Case SyntaxKind.LikeExpression : result = BinaryOperatorKind.Like
Case SyntaxKind.EqualsExpression : result = BinaryOperatorKind.Equals
Case SyntaxKind.NotEqualsExpression : result = BinaryOperatorKind.NotEquals
Case SyntaxKind.LessThanOrEqualExpression : result = BinaryOperatorKind.LessThanOrEqual
Case SyntaxKind.GreaterThanOrEqualExpression : result = BinaryOperatorKind.GreaterThanOrEqual
Case SyntaxKind.LessThanExpression : result = BinaryOperatorKind.LessThan
Case SyntaxKind.GreaterThanExpression : result = BinaryOperatorKind.GreaterThan
Case SyntaxKind.SubtractExpression : result = BinaryOperatorKind.Subtract
Case SyntaxKind.MultiplyExpression : result = BinaryOperatorKind.Multiply
Case SyntaxKind.ExponentiateExpression : result = BinaryOperatorKind.Power
Case SyntaxKind.DivideExpression : result = BinaryOperatorKind.Divide
Case SyntaxKind.ModuloExpression : result = BinaryOperatorKind.Modulo
Case SyntaxKind.IntegerDivideExpression : result = BinaryOperatorKind.IntegerDivide
Case SyntaxKind.LeftShiftExpression : result = BinaryOperatorKind.LeftShift
Case SyntaxKind.RightShiftExpression : result = BinaryOperatorKind.RightShift
Case SyntaxKind.ExclusiveOrExpression : result = BinaryOperatorKind.Xor
Case SyntaxKind.OrExpression : result = BinaryOperatorKind.Or
Case SyntaxKind.OrElseExpression : result = BinaryOperatorKind.OrElse
Case SyntaxKind.AndExpression : result = BinaryOperatorKind.And
Case SyntaxKind.AndAlsoExpression : result = BinaryOperatorKind.AndAlso
Case Else
Throw ExceptionUtilities.UnexpectedValue(opCode)
End Select
Return result
End Function
''' <summary>
''' Returns UnaryOperatorKind.Error in case of error, otherwise adjusted operator kind.
'''
''' For comparison operators, the operator type computed here is not
''' the result type of the comparison (which is typically boolean),
''' but is the type to which the operands are to be converted. For
''' other operators, the type computed here is both the result type
''' and the common operand type.
''' </summary>
Public Shared Function ResolveBinaryOperator(
opCode As BinaryOperatorKind,
left As BoundExpression,
right As BoundExpression,
binder As Binder,
considerUserDefinedOrLateBound As Boolean,
<Out()> ByRef intrinsicOperatorType As SpecialType,
<Out()> ByRef userDefinedOperator As OverloadResolutionResult,
<[In], Out> ByRef useSiteDiagnostics As HashSet(Of DiagnosticInfo)
) As BinaryOperatorKind
Debug.Assert((opCode And BinaryOperatorKind.OpMask) = opCode AndAlso opCode <> BinaryOperatorKind.Error)
opCode = (opCode And BinaryOperatorKind.OpMask)
intrinsicOperatorType = SpecialType.None
userDefinedOperator = Nothing
Dim leftType As TypeSymbol = left.Type
Dim rightType As TypeSymbol = right.Type
' First, dig through Nullable
Dim leftNullableUnderlying = leftType.GetNullableUnderlyingTypeOrSelf()
Dim leftIsNullable = (leftType IsNot leftNullableUnderlying)
Dim rightNullableUnderlying = rightType.GetNullableUnderlyingTypeOrSelf()
Dim rightIsNullable = (rightType IsNot rightNullableUnderlying)
' Now dig through Enum
Dim leftEnumUnderlying = leftNullableUnderlying.GetEnumUnderlyingTypeOrSelf()
Dim leftIsEnum = (leftEnumUnderlying IsNot leftNullableUnderlying)
Dim rightEnumUnderlying = rightNullableUnderlying.GetEnumUnderlyingTypeOrSelf()
Dim rightIsEnum = (rightEnumUnderlying IsNot rightNullableUnderlying)
' Filter out unexpected underlying types for Nullable and enum types
If ((leftIsEnum OrElse leftIsNullable) AndAlso
(leftEnumUnderlying.IsStringType() OrElse leftEnumUnderlying.IsObjectType() OrElse leftEnumUnderlying.IsCharArrayRankOne())) OrElse
((rightIsEnum OrElse rightIsNullable) AndAlso
(rightEnumUnderlying.IsStringType() OrElse rightEnumUnderlying.IsObjectType() OrElse rightEnumUnderlying.IsCharArrayRankOne())) Then
Return BinaryOperatorKind.Error
End If
If UseUserDefinedBinaryOperators(opCode, leftType, rightType) Then
If considerUserDefinedOrLateBound Then
If leftType.CanContainUserDefinedOperators(useSiteDiagnostics) OrElse rightType.CanContainUserDefinedOperators(useSiteDiagnostics) OrElse
(opCode = BinaryOperatorKind.Subtract AndAlso
leftType.GetNullableUnderlyingTypeOrSelf().IsDateTimeType() AndAlso
rightType.GetNullableUnderlyingTypeOrSelf().IsDateTimeType()) Then ' Let (Date - Date) use operator overloading.
userDefinedOperator = ResolveUserDefinedBinaryOperator(left, right, opCode, binder, includeEliminatedCandidates:=False, useSiteDiagnostics:=useSiteDiagnostics)
If userDefinedOperator.ResolutionIsLateBound Then
intrinsicOperatorType = SpecialType.System_Object
Return opCode
ElseIf Not userDefinedOperator.BestResult.HasValue AndAlso userDefinedOperator.Candidates.Length = 0 Then
userDefinedOperator = ResolveUserDefinedBinaryOperator(left, right, opCode, binder, includeEliminatedCandidates:=True, useSiteDiagnostics:=Nothing)
If userDefinedOperator.Candidates.Length = 0 Then
Return BinaryOperatorKind.Error
End If
End If
Return BinaryOperatorKind.UserDefined
Else
' An operator with an Object operand and a Type Parameter operand
' is latebound if the Type Parameter has no class constraint.
Dim latebound As Boolean = False
If leftType.IsObjectType() Then
If rightType.IsTypeParameter() AndAlso DirectCast(rightType, TypeParameterSymbol).GetNonInterfaceConstraint(useSiteDiagnostics) Is Nothing Then
latebound = True
End If
ElseIf rightType.IsObjectType() Then
If leftType.IsTypeParameter() AndAlso DirectCast(leftType, TypeParameterSymbol).GetNonInterfaceConstraint(useSiteDiagnostics) Is Nothing Then
latebound = True
End If
End If
If latebound Then
intrinsicOperatorType = SpecialType.System_Object
Return opCode
End If
End If
End If
Return BinaryOperatorKind.Error
End If
Dim result As BinaryOperatorKind = BinaryOperatorKind.Error
If leftIsEnum AndAlso rightIsEnum AndAlso
(opCode = BinaryOperatorKind.Xor OrElse opCode = BinaryOperatorKind.And OrElse opCode = BinaryOperatorKind.Or) AndAlso
leftNullableUnderlying.IsSameTypeIgnoringCustomModifiers(rightNullableUnderlying) Then
'§11.17 Logical Operators
'The enumerated type operators do the bitwise operation on the underlying
'type of the enumerated type, but the return value is the enumerated type.
result = opCode
If leftIsNullable OrElse rightIsNullable Then
result = result Or BinaryOperatorKind.Lifted
End If
Else
Dim leftSpecialType = leftEnumUnderlying.SpecialType
Dim rightSpecialType = rightEnumUnderlying.SpecialType
' Operands of type 1-dimensional array of Char are treated as if they
' were of type String.
If leftSpecialType = SpecialType.None AndAlso leftEnumUnderlying.IsCharArrayRankOne() Then
leftSpecialType = SpecialType.System_String
End If
If rightSpecialType = SpecialType.None AndAlso rightEnumUnderlying.IsCharArrayRankOne() Then
rightSpecialType = SpecialType.System_String
End If
intrinsicOperatorType = ResolveNotLiftedIntrinsicBinaryOperator(opCode, leftSpecialType, rightSpecialType)
If intrinsicOperatorType <> SpecialType.None Then
result = opCode
End If
' Like and '&' don't have lifted form.
' Disallow nullable lifting if result is not a value type
If result <> BinaryOperatorKind.Error AndAlso
(leftIsNullable OrElse rightIsNullable) AndAlso
intrinsicOperatorType <> SpecialType.None AndAlso
intrinsicOperatorType <> SpecialType.System_String AndAlso
intrinsicOperatorType <> SpecialType.System_Object AndAlso
opCode <> BinaryOperatorKind.Concatenate AndAlso opCode <> BinaryOperatorKind.Like Then
result = result Or BinaryOperatorKind.Lifted
End If
End If
Return result
End Function
Public Shared Function UseUserDefinedBinaryOperators(opCode As BinaryOperatorKind, leftType As TypeSymbol, rightType As TypeSymbol) As Boolean
Dim leftEnumUnderlying = leftType.GetNullableUnderlyingTypeOrSelf().GetEnumUnderlyingTypeOrSelf()
Dim rightEnumUnderlying = rightType.GetNullableUnderlyingTypeOrSelf().GetEnumUnderlyingTypeOrSelf()
' Operands of type 1-dimensional array of Char are treated as if they
' were of type String.
If (leftEnumUnderlying.SpecialType <> SpecialType.System_Object AndAlso
Not leftEnumUnderlying.IsIntrinsicType() AndAlso
Not leftEnumUnderlying.IsCharArrayRankOne()) OrElse
(rightEnumUnderlying.SpecialType <> SpecialType.System_Object AndAlso
Not rightEnumUnderlying.IsIntrinsicType() AndAlso
Not rightEnumUnderlying.IsCharArrayRankOne()) OrElse
(leftEnumUnderlying.IsDateTimeType() AndAlso rightEnumUnderlying.IsDateTimeType() AndAlso
opCode = BinaryOperatorKind.Subtract) Then ' Let (Date - Date) use operator overloading.
Return True
End If
Return False
End Function
''' <summary>
''' Attempts to fold binary operator applied to constant expressions.
'''
''' Returns Nothing if operator cannot be folded.
'''
''' If folding failed due to non-integer overflow or divide by zero,
''' ConstantValue.Bad is returned. Consumer is responsible for reporting appropriate diagnostics.
'''
''' If divide by zero occurs, divideByZero is set to True.
'''
''' If integer overflow occurs, integerOverflow is set to True and ConstantValue for overflowed result is returned.
''' Consumer is responsible for reporting appropriate diagnostics and potentially discarding the result.
''' </summary>
Public Shared Function TryFoldConstantBinaryOperator(
operatorKind As BinaryOperatorKind,
left As BoundExpression,
right As BoundExpression,
resultType As TypeSymbol,
ByRef integerOverflow As Boolean,
ByRef divideByZero As Boolean,
ByRef compoundLengthOutOfLimit As Boolean,
<[In], Out> Optional ByRef compoundStringLength As Integer = 0
) As ConstantValue
Debug.Assert(left IsNot Nothing)
Debug.Assert(right IsNot Nothing)
Debug.Assert(resultType IsNot Nothing)
integerOverflow = False
divideByZero = False
compoundLengthOutOfLimit = False
Dim leftConstantValue As ConstantValue = left.ConstantValueOpt
Dim rightConstantValue As ConstantValue = right.ConstantValueOpt
If leftConstantValue Is Nothing OrElse leftConstantValue.IsBad OrElse
rightConstantValue Is Nothing OrElse rightConstantValue.IsBad OrElse
resultType.IsErrorType() Then
' Not a constant
Return Nothing
End If
Dim leftType = left.Type
Dim rightType = right.Type
Dim op As BinaryOperatorKind = (operatorKind And BinaryOperatorKind.OpMask)
Dim result As ConstantValue = Nothing
If op <> BinaryOperatorKind.Like AndAlso
(operatorKind And BinaryOperatorKind.CompareText) = 0 AndAlso
leftType.AllowsCompileTimeOperations() AndAlso
rightType.AllowsCompileTimeOperations() AndAlso
resultType.AllowsCompileTimeOperations() Then
Debug.Assert(leftType.IsSameTypeIgnoringCustomModifiers(rightType) OrElse
op = BinaryOperatorKind.LeftShift OrElse op = BinaryOperatorKind.RightShift)
Dim leftUnderlying = leftType.GetEnumUnderlyingTypeOrSelf()
Dim resultUnderlying = resultType.GetEnumUnderlyingTypeOrSelf()
If leftUnderlying.IsIntegralType() OrElse leftUnderlying.IsCharType() OrElse leftUnderlying.IsDateTimeType() Then
result = FoldIntegralCharOrDateTimeBinaryOperator(
op,
leftConstantValue,
rightConstantValue,
leftUnderlying,
resultUnderlying,
integerOverflow,
divideByZero)
ElseIf leftUnderlying.IsFloatingType() Then
result = FoldFloatingBinaryOperator(
op,
leftConstantValue,
rightConstantValue,
leftUnderlying,
resultUnderlying)
ElseIf leftUnderlying.IsDecimalType() Then
result = FoldDecimalBinaryOperator(
op,
leftConstantValue,
rightConstantValue,
resultUnderlying,
divideByZero)
ElseIf leftUnderlying.IsStringType() Then
' During normal compilation we never fold string comparison with
' Option Compare Text in effect. However, it looks like Dev10 goes through
' this code path in EE and folds comparison regardless of Option Compare.
' I am not sure if we need this in Roslyn, will ignore Option Compare Text for now.
Debug.Assert((operatorKind And BinaryOperatorKind.CompareText) = 0)
result = FoldStringBinaryOperator(
op,
leftConstantValue,
rightConstantValue,
compoundStringLength)
If result.IsBad Then
compoundLengthOutOfLimit = True
End If
ElseIf leftUnderlying.IsBooleanType() Then
result = FoldBooleanBinaryOperator(
op,
leftConstantValue,
rightConstantValue)
End If
Debug.Assert(result IsNot Nothing)
End If
Return result
End Function
Private Shared Function FoldIntegralCharOrDateTimeBinaryOperator(
op As BinaryOperatorKind,
left As ConstantValue,
right As ConstantValue,
operandType As TypeSymbol,
resultType As TypeSymbol,
ByRef integerOverflow As Boolean,
ByRef divideByZero As Boolean
) As ConstantValue
Debug.Assert(operandType.IsIntegralType() OrElse operandType.IsCharType() OrElse operandType.IsDateTimeType())
Debug.Assert((op And BinaryOperatorKind.OpMask) = op)
Debug.Assert(Not integerOverflow)
Debug.Assert(Not divideByZero)
Dim result As ConstantValue
Dim leftValue As Long = GetConstantValueAsInt64(left)
Dim rightValue As Long = GetConstantValueAsInt64(right)
If resultType.IsBooleanType() Then
Dim resultValue As Boolean
Select Case op
Case BinaryOperatorKind.Equals
resultValue = If(operandType.IsUnsignedIntegralType(),
UncheckedCULng(leftValue) = UncheckedCULng(rightValue),
leftValue = rightValue)
Case BinaryOperatorKind.NotEquals
resultValue = If(operandType.IsUnsignedIntegralType(),
UncheckedCULng(leftValue) <> UncheckedCULng(rightValue),
leftValue <> rightValue)
Case BinaryOperatorKind.LessThanOrEqual
resultValue = If(operandType.IsUnsignedIntegralType(),
UncheckedCULng(leftValue) <= UncheckedCULng(rightValue),
leftValue <= rightValue)
Case BinaryOperatorKind.GreaterThanOrEqual
resultValue = If(operandType.IsUnsignedIntegralType(),
UncheckedCULng(leftValue) >= UncheckedCULng(rightValue),
leftValue >= rightValue)
Case BinaryOperatorKind.LessThan
resultValue = If(operandType.IsUnsignedIntegralType(),
UncheckedCULng(leftValue) < UncheckedCULng(rightValue),
leftValue < rightValue)
Case BinaryOperatorKind.GreaterThan
resultValue = If(operandType.IsUnsignedIntegralType(),
UncheckedCULng(leftValue) > UncheckedCULng(rightValue),
leftValue > rightValue)
Case Else
Throw ExceptionUtilities.UnexpectedValue(op)
End Select
result = ConstantValue.Create(resultValue)
Else
' Compute the result in 64-bit arithmetic, and determine if the
' operation overflows the result type.
Dim resultValue As Long
Dim leftDiscriminator = operandType.GetConstantValueTypeDiscriminator()
Dim resultDiscriminator = resultType.GetConstantValueTypeDiscriminator()
Select Case op
Case BinaryOperatorKind.Add
resultValue = NarrowIntegralResult(leftValue + rightValue, leftDiscriminator, resultDiscriminator, integerOverflow)
If Not resultType.IsUnsignedIntegralType() Then
If (rightValue > 0 AndAlso resultValue < leftValue) OrElse
(rightValue < 0 AndAlso resultValue > leftValue) Then
integerOverflow = True
End If
ElseIf UncheckedCULng(resultValue) < UncheckedCULng(leftValue) Then
integerOverflow = True
End If
Case BinaryOperatorKind.Subtract
resultValue = NarrowIntegralResult(leftValue - rightValue, leftDiscriminator, resultDiscriminator, integerOverflow)
If Not resultType.IsUnsignedIntegralType() Then
If (rightValue > 0 AndAlso resultValue > leftValue) OrElse
(rightValue < 0 AndAlso resultValue < leftValue) Then
integerOverflow = True
End If
ElseIf UncheckedCULng(resultValue) > UncheckedCULng(leftValue) Then
integerOverflow = True
End If
Case BinaryOperatorKind.Multiply
resultValue = Multiply(leftValue, rightValue, leftDiscriminator, resultDiscriminator, integerOverflow)
Case BinaryOperatorKind.IntegerDivide
If rightValue = 0 Then
divideByZero = True
Else
resultValue = NarrowIntegralResult(
If(resultType.IsUnsignedIntegralType(),
UncheckedCLng(UncheckedCULng(leftValue) \ UncheckedCULng(rightValue)),
UncheckedIntegralDiv(leftValue, rightValue)),
leftDiscriminator, resultDiscriminator, integerOverflow)
If Not resultType.IsUnsignedIntegralType() AndAlso leftValue = Int64.MinValue AndAlso rightValue = -1 Then
integerOverflow = True
End If
End If
Case BinaryOperatorKind.Modulo
If rightValue = 0 Then
divideByZero = True
Else
If resultType.IsUnsignedIntegralType() Then
resultValue = UncheckedCLng(UncheckedCULng(leftValue) Mod UncheckedCULng(rightValue))
' // 64-bit processors crash on 0, -1 (Bug: dd71694)
ElseIf rightValue <> -1L Then
resultValue = leftValue Mod rightValue
Else
resultValue = 0
End If
End If
Case BinaryOperatorKind.Xor
resultValue = leftValue Xor rightValue
Case BinaryOperatorKind.Or
resultValue = leftValue Or rightValue
Case BinaryOperatorKind.And
resultValue = leftValue And rightValue
Case BinaryOperatorKind.LeftShift
resultValue = leftValue << (CType(rightValue, Integer) And CodeGen.CodeGenerator.GetShiftSizeMask(operandType))
' // Round-trip the result through a cast. We do this for two reasons:
' // a) Bits may have shifted off the end and need to be stripped away.
' // b) The sign bit may have changed which requires the result to be sign-extended.
Dim overflowTemp As Boolean = False
resultValue = NarrowIntegralResult(resultValue, leftDiscriminator, resultDiscriminator, overflowTemp)
Case BinaryOperatorKind.RightShift
If resultType.IsUnsignedIntegralType() Then
resultValue = UncheckedCLng((UncheckedCULng(leftValue) >>
(CType(rightValue, Integer) And CodeGen.CodeGenerator.GetShiftSizeMask(operandType))))
Else
resultValue = leftValue >> (CType(rightValue, Integer) And CodeGen.CodeGenerator.GetShiftSizeMask(operandType))
End If
Case Else
Throw ExceptionUtilities.UnexpectedValue(op)
End Select
If divideByZero Then
result = ConstantValue.Bad
Else
result = GetConstantValue(resultDiscriminator, resultValue)
End If
End If
Return result
End Function
Private Shared Function FoldFloatingBinaryOperator(
op As BinaryOperatorKind,
left As ConstantValue,
right As ConstantValue,
operandType As TypeSymbol,
resultType As TypeSymbol
) As ConstantValue
Debug.Assert(operandType.IsFloatingType())
Debug.Assert((op And BinaryOperatorKind.OpMask) = op)
Dim result As ConstantValue
Dim leftValue As Double = If(operandType.IsSingleType, left.SingleValue, left.DoubleValue)
Dim rightValue As Double = If(operandType.IsSingleType, right.SingleValue, right.DoubleValue)
If resultType.IsBooleanType() Then
Dim resultValue As Boolean
Select Case op
Case BinaryOperatorKind.Equals
resultValue = (leftValue = rightValue)
Case BinaryOperatorKind.NotEquals
resultValue = (leftValue <> rightValue)
Case BinaryOperatorKind.LessThanOrEqual
resultValue = (leftValue <= rightValue)
Case BinaryOperatorKind.GreaterThanOrEqual
resultValue = (leftValue >= rightValue)
Case BinaryOperatorKind.LessThan
resultValue = (leftValue < rightValue)
Case BinaryOperatorKind.GreaterThan
resultValue = (leftValue > rightValue)
Case Else
Throw ExceptionUtilities.UnexpectedValue(op)
End Select
result = ConstantValue.Create(resultValue)
Else
' Compute the result in 64-bit arithmetic, and determine if the
' operation overflows the result type.
Dim resultValue As Double = 0
Select Case op
Case BinaryOperatorKind.Add
resultValue = leftValue + rightValue
Case BinaryOperatorKind.Subtract
resultValue = leftValue - rightValue
Case BinaryOperatorKind.Multiply
resultValue = leftValue * rightValue
Case BinaryOperatorKind.Power
' VSW#463059: Special case CRT changes to match CLR behavior.
If Double.IsInfinity(rightValue) Then
If leftValue.Equals(1.0) Then
resultValue = leftValue
Exit Select
End If
If leftValue.Equals(-1.0) Then
resultValue = Double.NaN
Exit Select
End If
ElseIf (
Double.IsNaN(rightValue)
) Then
resultValue = Double.NaN
Exit Select
End If
resultValue = Math.Pow(leftValue, rightValue)
Case BinaryOperatorKind.Divide
' We have decided not to detect zerodivide in compile-time
' evaluation of floating expressions.
resultValue = leftValue / rightValue
Case BinaryOperatorKind.Modulo
' We have decided not to detect zerodivide in compile-time
' evaluation of floating expressions.
' Note, that Math.IEEERemainder(leftValue, rightValue) might give different result.
' Dev10 compiler used fmod function here and it behaves differently. It looks like
' ILOpCode.Rem operation, that we use to emit Mod operator, produces result consistent
' with fmod.
resultValue = leftValue Mod rightValue
Case Else
Throw ExceptionUtilities.UnexpectedValue(op)
End Select
Dim overflow As Boolean = False
resultValue = NarrowFloatingResult(resultValue, resultType.GetConstantValueTypeDiscriminator(), overflow)
' We have decided not to detect overflow in compile-time
' evaluation of floating expressions.
If resultType.IsSingleType() Then
result = ConstantValue.Create(CType(resultValue, Single))
Else
result = ConstantValue.Create(resultValue)
End If
End If
Return result
End Function
Private Shared Function FoldDecimalBinaryOperator(
op As BinaryOperatorKind,
left As ConstantValue,
right As ConstantValue,
resultType As TypeSymbol,
ByRef divideByZero As Boolean
) As ConstantValue
Debug.Assert((op And BinaryOperatorKind.OpMask) = op)
Debug.Assert(Not divideByZero)
Dim result As ConstantValue
Dim leftValue As Decimal = left.DecimalValue
Dim rightValue As Decimal = right.DecimalValue
If resultType.IsBooleanType() Then
Dim resultValue As Boolean = False
Dim comparisonResult As Integer = leftValue.CompareTo(rightValue)
Select Case op
Case BinaryOperatorKind.Equals
resultValue = (comparisonResult = 0)
Case BinaryOperatorKind.NotEquals
resultValue = Not (comparisonResult = 0)
Case BinaryOperatorKind.LessThanOrEqual
resultValue = (comparisonResult <= 0)
Case BinaryOperatorKind.GreaterThanOrEqual
resultValue = (comparisonResult >= 0)
Case BinaryOperatorKind.LessThan
resultValue = (comparisonResult < 0)
Case BinaryOperatorKind.GreaterThan
resultValue = (comparisonResult > 0)
Case Else
Throw ExceptionUtilities.UnexpectedValue(op)
End Select
result = ConstantValue.Create(resultValue)
Else
Dim resultValue As Decimal
Dim overflow As Boolean = False
Try
Select Case op
Case BinaryOperatorKind.Add
resultValue = Decimal.Add(leftValue, rightValue)
Case BinaryOperatorKind.Subtract
resultValue = Decimal.Subtract(leftValue, rightValue)
Case BinaryOperatorKind.Multiply
resultValue = Decimal.Multiply(leftValue, rightValue)
Case BinaryOperatorKind.Divide
resultValue = Decimal.Divide(leftValue, rightValue)
Case BinaryOperatorKind.Modulo
resultValue = Decimal.Remainder(leftValue, rightValue)
Case Else
Throw ExceptionUtilities.UnexpectedValue(op)
End Select
Catch ex As OverflowException
overflow = True
Catch ex As DivideByZeroException
divideByZero = True
End Try
If overflow OrElse divideByZero Then
result = ConstantValue.Bad
Else
result = ConstantValue.Create(resultValue)
End If
End If
Return result
End Function
''' <summary>
''' Returns ConstantValue.Bad if, and only if, compound string length is out of supported limit.
''' The <paramref name="compoundStringLength"/> parameter contains value corresponding to the
''' <paramref name="left"/> node, or zero, which will trigger inference. Upon return, it will
''' be adjusted to correspond future result node.
''' </summary>
Private Shared Function FoldStringBinaryOperator(
op As BinaryOperatorKind,
left As ConstantValue,
right As ConstantValue,
<[In], Out> Optional ByRef compoundStringLength As Integer = 0
) As ConstantValue
Debug.Assert((op And BinaryOperatorKind.OpMask) = op)
Dim result As ConstantValue
Dim leftValue As String = If(left.IsNothing, String.Empty, left.StringValue)
Dim rightValue As String = If(right.IsNothing, String.Empty, right.StringValue)
Select Case op
Case BinaryOperatorKind.Concatenate
If compoundStringLength = 0 Then
' Infer. Keep it simple for now.
compoundStringLength = leftValue.Length
End If
Debug.Assert(compoundStringLength >= leftValue.Length)
Dim newCompoundLength = CLng(compoundStringLength) + CLng(leftValue.Length) + CLng(rightValue.Length)
If newCompoundLength > Integer.MaxValue Then
Return ConstantValue.Bad
End If
Try
result = ConstantValue.Create(String.Concat(leftValue, rightValue))
compoundStringLength = CInt(newCompoundLength)
Catch e As System.OutOfMemoryException
Return ConstantValue.Bad
End Try
Case BinaryOperatorKind.GreaterThan,
BinaryOperatorKind.LessThan,
BinaryOperatorKind.GreaterThanOrEqual,
BinaryOperatorKind.LessThanOrEqual,
BinaryOperatorKind.Equals,
BinaryOperatorKind.NotEquals
Dim stringComparisonSucceeds As Boolean = False
Dim comparisonResult As Integer = String.Compare(leftValue, rightValue, StringComparison.Ordinal)
Select Case op
Case BinaryOperatorKind.Equals
stringComparisonSucceeds = (comparisonResult = 0)
Case BinaryOperatorKind.NotEquals
stringComparisonSucceeds = (comparisonResult <> 0)
Case BinaryOperatorKind.GreaterThan
stringComparisonSucceeds = (comparisonResult > 0)
Case BinaryOperatorKind.GreaterThanOrEqual
stringComparisonSucceeds = (comparisonResult >= 0)
Case BinaryOperatorKind.LessThan
stringComparisonSucceeds = (comparisonResult < 0)
Case BinaryOperatorKind.LessThanOrEqual
stringComparisonSucceeds = (comparisonResult <= 0)
End Select
result = ConstantValue.Create(stringComparisonSucceeds)
Case Else
Throw ExceptionUtilities.UnexpectedValue(op)
End Select
Debug.Assert(Not result.IsBad)
Return result
End Function
Private Shared Function FoldBooleanBinaryOperator(
op As BinaryOperatorKind,
left As ConstantValue,
right As ConstantValue
) As ConstantValue
Debug.Assert((op And BinaryOperatorKind.OpMask) = op)
Dim result As ConstantValue
Dim leftValue As Boolean = left.BooleanValue
Dim rightValue As Boolean = right.BooleanValue
Dim operationSucceeds As Boolean = False
Select Case op
Case BinaryOperatorKind.Equals
operationSucceeds = (leftValue = rightValue)
Case BinaryOperatorKind.NotEquals
operationSucceeds = (leftValue <> rightValue)
Case BinaryOperatorKind.GreaterThan
' Amazingly, False > True.
operationSucceeds = (leftValue = False AndAlso rightValue = True)
Case BinaryOperatorKind.GreaterThanOrEqual
operationSucceeds = (leftValue = False OrElse rightValue = True)
Case BinaryOperatorKind.LessThan
operationSucceeds = (leftValue = True AndAlso rightValue = False)
Case BinaryOperatorKind.LessThanOrEqual
operationSucceeds = (leftValue = True OrElse rightValue = False)
Case BinaryOperatorKind.Xor
operationSucceeds = (leftValue Xor rightValue)
Case BinaryOperatorKind.OrElse,
BinaryOperatorKind.Or
operationSucceeds = (leftValue OrElse rightValue)
Case BinaryOperatorKind.AndAlso,
BinaryOperatorKind.And
operationSucceeds = (leftValue AndAlso rightValue)
Case Else
Throw ExceptionUtilities.UnexpectedValue(op)
End Select
result = ConstantValue.Create(operationSucceeds)
Return result
End Function
''' <summary>
''' Returns result type of the operator or SpecialType.None if operator is not supported.
''' </summary>
Friend Shared Function ResolveNotLiftedIntrinsicBinaryOperator(
opCode As BinaryOperatorKind,
left As SpecialType,
right As SpecialType
) As SpecialType
Dim leftIndex = left.TypeToIndex()
Dim rightIndex = right.TypeToIndex()
If Not (leftIndex.HasValue AndAlso rightIndex.HasValue) Then
Return SpecialType.None
End If
Dim tableKind As BinaryOperatorTables.TableKind
Select Case opCode
Case BinaryOperatorKind.Add
tableKind = BinaryOperatorTables.TableKind.Addition
Case BinaryOperatorKind.Subtract,
BinaryOperatorKind.Multiply,
BinaryOperatorKind.Modulo
tableKind = BinaryOperatorTables.TableKind.SubtractionMultiplicationModulo
Case BinaryOperatorKind.Divide
tableKind = BinaryOperatorTables.TableKind.Division
Case BinaryOperatorKind.IntegerDivide
tableKind = BinaryOperatorTables.TableKind.IntegerDivision
Case BinaryOperatorKind.Power
tableKind = BinaryOperatorTables.TableKind.Power
Case BinaryOperatorKind.LeftShift,
BinaryOperatorKind.RightShift
tableKind = BinaryOperatorTables.TableKind.Shift
Case BinaryOperatorKind.OrElse,
BinaryOperatorKind.AndAlso
tableKind = BinaryOperatorTables.TableKind.Logical
Case BinaryOperatorKind.Concatenate,
BinaryOperatorKind.Like
tableKind = BinaryOperatorTables.TableKind.ConcatenationLike
Case BinaryOperatorKind.Equals,
BinaryOperatorKind.NotEquals,
BinaryOperatorKind.LessThanOrEqual,
BinaryOperatorKind.GreaterThanOrEqual,
BinaryOperatorKind.LessThan,
BinaryOperatorKind.GreaterThan
tableKind = BinaryOperatorTables.TableKind.Relational
Case BinaryOperatorKind.Xor,
BinaryOperatorKind.Or,
BinaryOperatorKind.And
tableKind = BinaryOperatorTables.TableKind.Bitwise
Case Else
Throw ExceptionUtilities.UnexpectedValue(opCode)
End Select
Return CType(BinaryOperatorTables.Table(tableKind, leftIndex.Value, rightIndex.Value), SpecialType)
End Function
Private Class BinaryOperatorTables
Public Enum TableKind
Addition
SubtractionMultiplicationModulo
Division
Power
IntegerDivision
Shift
Logical
Bitwise
Relational
ConcatenationLike
End Enum
' PERF: Using SByte instead of SpecialType because we want the compiler to use array literal initialization.
' The most natural type choice, Enum arrays, are not blittable due to a CLR limitation.
Public Shared ReadOnly Table(,,) As SByte
Shared Sub New()
Const tErr As SByte = SpecialType.None
Const tObj As SByte = SpecialType.System_Object
Const tStr As SByte = SpecialType.System_String
Const tDbl As SByte = SpecialType.System_Double
Const tSBy As SByte = SpecialType.System_SByte
Const tShr As SByte = SpecialType.System_Int16
Const tInt As SByte = SpecialType.System_Int32
Const tLng As SByte = SpecialType.System_Int64
Const tDec As SByte = SpecialType.System_Decimal
Const tSng As SByte = SpecialType.System_Single
Const tByt As SByte = SpecialType.System_Byte
Const tUSh As SByte = SpecialType.System_UInt16
Const tUIn As SByte = SpecialType.System_UInt32
Const tULn As SByte = SpecialType.System_UInt64
Const tBoo As SByte = SpecialType.System_Boolean
Const tChr As SByte = SpecialType.System_Char
Const tDat As SByte = SpecialType.System_DateTime
Table =
{ ' Obj Str Bool Char SByt Shrt Int Long Byte UShr UInt ULng Sngl Dbl Dec Date
{ ' Addition
{tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj}, ' Obj
{tObj, tStr, tDbl, tStr, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tStr}, ' Str
{tObj, tDbl, tShr, tErr, tSBy, tShr, tInt, tLng, tShr, tInt, tLng, tDec, tSng, tDbl, tDec, tErr}, ' Bool
{tObj, tStr, tErr, tStr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr}, ' Char
{tObj, tDbl, tSBy, tErr, tSBy, tShr, tInt, tLng, tShr, tInt, tLng, tDec, tSng, tDbl, tDec, tErr}, ' SByt
{tObj, tDbl, tShr, tErr, tShr, tShr, tInt, tLng, tShr, tInt, tLng, tDec, tSng, tDbl, tDec, tErr}, ' Shrt
{tObj, tDbl, tInt, tErr, tInt, tInt, tInt, tLng, tInt, tInt, tLng, tDec, tSng, tDbl, tDec, tErr}, ' Int
{tObj, tDbl, tLng, tErr, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tDec, tSng, tDbl, tDec, tErr}, ' Long
{tObj, tDbl, tShr, tErr, tShr, tShr, tInt, tLng, tByt, tUSh, tUIn, tULn, tSng, tDbl, tDec, tErr}, ' Byte
{tObj, tDbl, tInt, tErr, tInt, tInt, tInt, tLng, tUSh, tUSh, tUIn, tULn, tSng, tDbl, tDec, tErr}, ' UShr
{tObj, tDbl, tLng, tErr, tLng, tLng, tLng, tLng, tUIn, tUIn, tUIn, tULn, tSng, tDbl, tDec, tErr}, ' UInt
{tObj, tDbl, tDec, tErr, tDec, tDec, tDec, tDec, tULn, tULn, tULn, tULn, tSng, tDbl, tDec, tErr}, ' ULng
{tObj, tDbl, tSng, tErr, tSng, tSng, tSng, tSng, tSng, tSng, tSng, tSng, tSng, tDbl, tSng, tErr}, ' Sngl
{tObj, tDbl, tDbl, tErr, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tErr}, ' Dbl
{tObj, tDbl, tDec, tErr, tDec, tDec, tDec, tDec, tDec, tDec, tDec, tDec, tSng, tDbl, tDec, tErr}, ' Dec
{tObj, tStr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tStr} ' Date
},' Obj Str Bool Char SByt Shrt Int Long Byte UShr UInt ULng Sngl Dbl Dec Date
{ ' Subtraction, Multiplication, and Modulo
{tObj, tObj, tObj, tErr, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tErr}, ' Obj
{tObj, tDbl, tDbl, tErr, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tErr}, ' Str
{tObj, tDbl, tShr, tErr, tSBy, tShr, tInt, tLng, tShr, tInt, tLng, tDec, tSng, tDbl, tDec, tErr}, ' Bool
{tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr}, ' Char
{tObj, tDbl, tSBy, tErr, tSBy, tShr, tInt, tLng, tShr, tInt, tLng, tDec, tSng, tDbl, tDec, tErr}, ' SByt
{tObj, tDbl, tShr, tErr, tShr, tShr, tInt, tLng, tShr, tInt, tLng, tDec, tSng, tDbl, tDec, tErr}, ' Shrt
{tObj, tDbl, tInt, tErr, tInt, tInt, tInt, tLng, tInt, tInt, tLng, tDec, tSng, tDbl, tDec, tErr}, ' Int
{tObj, tDbl, tLng, tErr, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tDec, tSng, tDbl, tDec, tErr}, ' Long
{tObj, tDbl, tShr, tErr, tShr, tShr, tInt, tLng, tByt, tUSh, tUIn, tULn, tSng, tDbl, tDec, tErr}, ' Byte
{tObj, tDbl, tInt, tErr, tInt, tInt, tInt, tLng, tUSh, tUSh, tUIn, tULn, tSng, tDbl, tDec, tErr}, ' UShr
{tObj, tDbl, tLng, tErr, tLng, tLng, tLng, tLng, tUIn, tUIn, tUIn, tULn, tSng, tDbl, tDec, tErr}, ' UInt
{tObj, tDbl, tDec, tErr, tDec, tDec, tDec, tDec, tULn, tULn, tULn, tULn, tSng, tDbl, tDec, tErr}, ' ULng
{tObj, tDbl, tSng, tErr, tSng, tSng, tSng, tSng, tSng, tSng, tSng, tSng, tSng, tDbl, tSng, tErr}, ' Sngl
{tObj, tDbl, tDbl, tErr, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tErr}, ' Dbl
{tObj, tDbl, tDec, tErr, tDec, tDec, tDec, tDec, tDec, tDec, tDec, tDec, tSng, tDbl, tDec, tErr}, ' Dec
{tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr} ' Date
}, ' Special Note: Date - Date is actually TimeSpan, but that cannot be encoded in this table.^^^^
{ ' Division
{tObj, tObj, tObj, tErr, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tErr}, ' Obj
{tObj, tDbl, tDbl, tErr, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tErr}, ' Str
{tObj, tDbl, tDbl, tErr, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tSng, tDbl, tDec, tErr}, ' Bool
{tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr}, ' Char
{tObj, tDbl, tDbl, tErr, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tSng, tDbl, tDec, tErr}, ' SByt
{tObj, tDbl, tDbl, tErr, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tSng, tDbl, tDec, tErr}, ' Shrt
{tObj, tDbl, tDbl, tErr, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tSng, tDbl, tDec, tErr}, ' Int
{tObj, tDbl, tDbl, tErr, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tSng, tDbl, tDec, tErr}, ' Long
{tObj, tDbl, tDbl, tErr, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tSng, tDbl, tDec, tErr}, ' Byte
{tObj, tDbl, tDbl, tErr, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tSng, tDbl, tDec, tErr}, ' UShr
{tObj, tDbl, tDbl, tErr, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tSng, tDbl, tDec, tErr}, ' UInt
{tObj, tDbl, tDbl, tErr, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tSng, tDbl, tDec, tErr}, ' ULng
{tObj, tDbl, tSng, tErr, tSng, tSng, tSng, tSng, tSng, tSng, tSng, tSng, tSng, tDbl, tSng, tErr}, ' Sngl
{tObj, tDbl, tDbl, tErr, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tErr}, ' Dbl
{tObj, tDbl, tDec, tErr, tDec, tDec, tDec, tDec, tDec, tDec, tDec, tDec, tSng, tDbl, tDec, tErr}, ' Dec
{tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr} ' Date
},' Obj Str Bool Char SByt Shrt Int Long Byte UShr UInt ULng Sngl Dbl Dec Date
{ ' Power
{tObj, tObj, tObj, tErr, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tErr}, ' Obj
{tObj, tDbl, tDbl, tErr, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tErr}, ' Str
{tObj, tDbl, tDbl, tErr, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tErr}, ' Bool
{tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr}, ' Char
{tObj, tDbl, tDbl, tErr, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tErr}, ' SByt
{tObj, tDbl, tDbl, tErr, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tErr}, ' Shrt
{tObj, tDbl, tDbl, tErr, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tErr}, ' Int
{tObj, tDbl, tDbl, tErr, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tErr}, ' Long
{tObj, tDbl, tDbl, tErr, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tErr}, ' Byte
{tObj, tDbl, tDbl, tErr, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tErr}, ' UShr
{tObj, tDbl, tDbl, tErr, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tErr}, ' UInt
{tObj, tDbl, tDbl, tErr, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tErr}, ' ULng
{tObj, tDbl, tDbl, tErr, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tErr}, ' Sngl
{tObj, tDbl, tDbl, tErr, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tErr}, ' Dbl
{tObj, tDbl, tDbl, tErr, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tErr}, ' Dec
{tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr} ' Date
},' Obj Str Bool Char SByt Shrt Int Long Byte UShr UInt ULng Sngl Dbl Dec Date
{ ' Integer Division
{tObj, tObj, tObj, tErr, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tErr}, ' Obj
{tObj, tLng, tLng, tErr, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tErr}, ' Str
{tObj, tLng, tShr, tErr, tSBy, tShr, tInt, tLng, tShr, tInt, tLng, tLng, tLng, tLng, tLng, tErr}, ' Bool
{tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr}, ' Char
{tObj, tLng, tSBy, tErr, tSBy, tShr, tInt, tLng, tShr, tInt, tLng, tLng, tLng, tLng, tLng, tErr}, ' SByt
{tObj, tLng, tShr, tErr, tShr, tShr, tInt, tLng, tShr, tInt, tLng, tLng, tLng, tLng, tLng, tErr}, ' Shrt
{tObj, tLng, tInt, tErr, tInt, tInt, tInt, tLng, tInt, tInt, tLng, tLng, tLng, tLng, tLng, tErr}, ' Int
{tObj, tLng, tLng, tErr, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tErr}, ' Long
{tObj, tLng, tShr, tErr, tShr, tShr, tInt, tLng, tByt, tUSh, tUIn, tULn, tLng, tLng, tLng, tErr}, ' Byte
{tObj, tLng, tInt, tErr, tInt, tInt, tInt, tLng, tUSh, tUSh, tUIn, tULn, tLng, tLng, tLng, tErr}, ' UShr
{tObj, tLng, tLng, tErr, tLng, tLng, tLng, tLng, tUIn, tUIn, tUIn, tULn, tLng, tLng, tLng, tErr}, ' UInt
{tObj, tLng, tLng, tErr, tLng, tLng, tLng, tLng, tULn, tULn, tULn, tULn, tLng, tLng, tLng, tErr}, ' ULng
{tObj, tLng, tLng, tErr, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tErr}, ' Sngl
{tObj, tLng, tLng, tErr, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tErr}, ' Dbl
{tObj, tLng, tLng, tErr, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tErr}, ' Dec
{tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr} ' Date
},' Obj Str Bool Char SByt Shrt Int Long Byte UShr UInt ULng Sngl Dbl Dec Date
{ ' Shift. Note: The right operand serves little purpose in this table, however a table is utilized nonetheless to make the most use of already existing code which analyzes binary operators.
{tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj}, ' Obj
{tObj, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng}, ' Str
{tObj, tShr, tShr, tShr, tShr, tShr, tShr, tShr, tShr, tShr, tShr, tShr, tShr, tShr, tShr, tShr}, ' Bool
{tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr}, ' Char
{tObj, tSBy, tSBy, tSBy, tSBy, tSBy, tSBy, tSBy, tSBy, tSBy, tSBy, tSBy, tSBy, tSBy, tSBy, tSBy}, ' SByt
{tObj, tShr, tShr, tShr, tShr, tShr, tShr, tShr, tShr, tShr, tShr, tShr, tShr, tShr, tShr, tShr}, ' Shrt
{tObj, tInt, tInt, tInt, tInt, tInt, tInt, tInt, tInt, tInt, tInt, tInt, tInt, tInt, tInt, tInt}, ' Int
{tObj, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng}, ' Long
{tObj, tByt, tByt, tByt, tByt, tByt, tByt, tByt, tByt, tByt, tByt, tByt, tByt, tByt, tByt, tByt}, ' Byte
{tObj, tUSh, tUSh, tUSh, tUSh, tUSh, tUSh, tUSh, tUSh, tUSh, tUSh, tUSh, tUSh, tUSh, tUSh, tUSh}, ' UShr
{tObj, tUIn, tUIn, tUIn, tUIn, tUIn, tUIn, tUIn, tUIn, tUIn, tUIn, tUIn, tUIn, tUIn, tUIn, tUIn}, ' UInt
{tObj, tULn, tULn, tULn, tULn, tULn, tULn, tULn, tULn, tULn, tULn, tULn, tULn, tULn, tULn, tULn}, ' ULng
{tObj, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng}, ' Sngl
{tObj, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng}, ' Dbl
{tObj, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng}, ' Dec
{tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr} ' Date
},' Obj Str Bool Char SByt Shrt Int Long Byte UShr UInt ULng Sngl Dbl Dec Date
{ ' Logical Operators
{tObj, tObj, tObj, tErr, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tErr}, ' Obj
{tObj, tBoo, tBoo, tErr, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tErr}, ' Str
{tObj, tBoo, tBoo, tErr, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tErr}, ' Bool
{tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr}, ' Char
{tObj, tBoo, tBoo, tErr, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tErr}, ' SByt
{tObj, tBoo, tBoo, tErr, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tErr}, ' Shrt
{tObj, tBoo, tBoo, tErr, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tErr}, ' Int
{tObj, tBoo, tBoo, tErr, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tErr}, ' Long
{tObj, tBoo, tBoo, tErr, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tErr}, ' Byte
{tObj, tBoo, tBoo, tErr, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tErr}, ' UShr
{tObj, tBoo, tBoo, tErr, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tErr}, ' UInt
{tObj, tBoo, tBoo, tErr, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tErr}, ' ULng
{tObj, tBoo, tBoo, tErr, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tErr}, ' Sngl
{tObj, tBoo, tBoo, tErr, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tErr}, ' Dbl
{tObj, tBoo, tBoo, tErr, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tBoo, tErr}, ' Dec
{tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr} ' Date
},' Obj Str Bool Char SByt Shrt Int Long Byte UShr UInt ULng Sngl Dbl Dec Date
{ ' Bitwise Operators
{tObj, tObj, tObj, tErr, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tErr}, ' Obj
{tObj, tLng, tBoo, tErr, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tErr}, ' Str
{tObj, tBoo, tBoo, tErr, tSBy, tShr, tInt, tLng, tShr, tInt, tLng, tLng, tLng, tLng, tLng, tErr}, ' Bool
{tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr}, ' Char
{tObj, tLng, tSBy, tErr, tSBy, tShr, tInt, tLng, tShr, tInt, tLng, tLng, tLng, tLng, tLng, tErr}, ' SByt
{tObj, tLng, tShr, tErr, tShr, tShr, tInt, tLng, tShr, tInt, tLng, tLng, tLng, tLng, tLng, tErr}, ' Shrt
{tObj, tLng, tInt, tErr, tInt, tInt, tInt, tLng, tInt, tInt, tLng, tLng, tLng, tLng, tLng, tErr}, ' Int
{tObj, tLng, tLng, tErr, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tErr}, ' Long
{tObj, tLng, tShr, tErr, tShr, tShr, tInt, tLng, tByt, tUSh, tUIn, tULn, tLng, tLng, tLng, tErr}, ' Byte
{tObj, tLng, tInt, tErr, tInt, tInt, tInt, tLng, tUSh, tUSh, tUIn, tULn, tLng, tLng, tLng, tErr}, ' UShr
{tObj, tLng, tLng, tErr, tLng, tLng, tLng, tLng, tUIn, tUIn, tUIn, tULn, tLng, tLng, tLng, tErr}, ' UInt
{tObj, tLng, tLng, tErr, tLng, tLng, tLng, tLng, tULn, tULn, tULn, tULn, tLng, tLng, tLng, tErr}, ' ULng
{tObj, tLng, tLng, tErr, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tErr}, ' Sngl
{tObj, tLng, tLng, tErr, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tErr}, ' Dbl
{tObj, tLng, tLng, tErr, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tErr}, ' Dec
{tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr} ' Date
},' Obj Str Bool Char SByt Shrt Int Long Byte UShr UInt ULng Sngl Dbl Dec Date
{ ' Relational Operators -- This one is a little unusual because it lists the type of the relational operation, even though the result type is always boolean
{tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj}, ' Obj
{tObj, tStr, tBoo, tStr, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDat}, ' Str
{tObj, tBoo, tBoo, tErr, tSBy, tShr, tInt, tLng, tShr, tInt, tLng, tDec, tSng, tDbl, tDec, tErr}, ' Bool
{tObj, tStr, tErr, tChr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr}, ' Char
{tObj, tDbl, tSBy, tErr, tSBy, tShr, tInt, tLng, tShr, tInt, tLng, tDec, tSng, tDbl, tDec, tErr}, ' SByt
{tObj, tDbl, tShr, tErr, tShr, tShr, tInt, tLng, tShr, tInt, tLng, tDec, tSng, tDbl, tDec, tErr}, ' Shrt
{tObj, tDbl, tInt, tErr, tInt, tInt, tInt, tLng, tInt, tInt, tLng, tDec, tSng, tDbl, tDec, tErr}, ' Int
{tObj, tDbl, tLng, tErr, tLng, tLng, tLng, tLng, tLng, tLng, tLng, tDec, tSng, tDbl, tDec, tErr}, ' Long
{tObj, tDbl, tShr, tErr, tShr, tShr, tInt, tLng, tByt, tUSh, tUIn, tULn, tSng, tDbl, tDec, tErr}, ' Byte
{tObj, tDbl, tInt, tErr, tInt, tInt, tInt, tLng, tUSh, tUSh, tUIn, tULn, tSng, tDbl, tDec, tErr}, ' UShr
{tObj, tDbl, tLng, tErr, tLng, tLng, tLng, tLng, tUIn, tUIn, tUIn, tULn, tSng, tDbl, tDec, tErr}, ' UInt
{tObj, tDbl, tDec, tErr, tDec, tDec, tDec, tDec, tULn, tULn, tULn, tULn, tSng, tDbl, tDec, tErr}, ' ULng
{tObj, tDbl, tSng, tErr, tSng, tSng, tSng, tSng, tSng, tSng, tSng, tSng, tSng, tDbl, tSng, tErr}, ' Sngl
{tObj, tDbl, tDbl, tErr, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tDbl, tErr}, ' Dbl
{tObj, tDbl, tDec, tErr, tDec, tDec, tDec, tDec, tDec, tDec, tDec, tDec, tSng, tDbl, tDec, tErr}, ' Dec
{tObj, tDat, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tErr, tDat} ' Date
},' Obj Str Bool Char SByt Shrt Int Long Byte UShr UInt ULng Sngl Dbl Dec Date
{ ' Concatenation and Like
{tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj, tObj}, ' Obj
{tObj, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr}, ' Str
{tObj, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr}, ' Bool
{tObj, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr}, ' Char
{tObj, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr}, ' SByt
{tObj, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr}, ' Shrt
{tObj, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr}, ' Int
{tObj, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr}, ' Long
{tObj, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr}, ' Byte
{tObj, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr}, ' UShr
{tObj, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr}, ' UInt
{tObj, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr}, ' ULng
{tObj, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr}, ' Sngl
{tObj, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr}, ' Dbl
{tObj, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr}, ' Date
{tObj, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr, tStr} ' Dec
}
}
End Sub
End Class
Public Shared Function ResolveUserDefinedConversion(
source As TypeSymbol,
destination As TypeSymbol,
<[In], Out> ByRef useSiteDiagnostics As HashSet(Of DiagnosticInfo)
) As KeyValuePair(Of ConversionKind, MethodSymbol)
Debug.Assert(Not source.IsErrorType())
Debug.Assert(Not destination.IsErrorType())
Dim result As KeyValuePair(Of ConversionKind, MethodSymbol) = Nothing
Dim opSet = ArrayBuilder(Of MethodSymbol).GetInstance()
' 8.11 User-Defined Conversions
' When determining what user-defined conversion to use, the most specific widening conversion will be used;
' if no widening conversion is most specific, the most specific narrowing conversion will be used. If there
' is no most specific narrowing conversion, then the conversion is undefined and a compile-time error occurs.
' When collecting the candidate user-defined conversions for a type T?, the user-defined conversion operators
' defined by T are used instead. If the type being converted to is also a nullable value type, then any of
' T’s user-defined conversions operators that involve only non-nullable value types are lifted. A conversion
' operator from T to S is lifted to be a conversion from T? to S?
'
' !!! Dev10 implementation doesn't match the spec here (the behavior is duplicated):
' !!! 1) If there were applicable Widening CType operators applicable according to the
' !!! "Most Specific Widening Conversion" section, Narrowing CType opeartors are not considered at all.
' !!! Nullable lifting isn't considered too.
' !!! 2) With "Most Specific Narrowing Conversion" behavior is slightly different. If there is a conversion
' !!! operator that converts from the most specific source type to the most specific target type, then
' !!! nullable lifting isn't considered.
CollectUserDefinedConversionOperators(source, destination, opSet, useSiteDiagnostics)
If opSet.Count = 0 Then
opSet.Free()
Return result
End If
Dim conversionKinds = ArrayBuilder(Of KeyValuePair(Of ConversionKind, ConversionKind)).GetInstance()
conversionKinds.ZeroInit(opSet.Count)
Dim applicable = BitVector.Create(opSet.Count)
Dim bestMatch As MethodSymbol = Nothing
If DetermineMostSpecificWideningConversion(source, destination, opSet, conversionKinds, applicable, bestMatch, suppressViabilityChecks:=False, useSiteDiagnostics:=useSiteDiagnostics) Then
If bestMatch IsNot Nothing Then
result = New KeyValuePair(Of ConversionKind, MethodSymbol)(ConversionKind.Widening Or ConversionKind.UserDefined, bestMatch)
End If
GoTo Done
ElseIf opSet.Count = 0 Then
GoTo Done
End If
If DetermineMostSpecificNarrowingConversion(source, destination, opSet, conversionKinds, applicable, bestMatch, suppressViabilityChecks:=False, useSiteDiagnostics:=useSiteDiagnostics) Then
If bestMatch IsNot Nothing Then
result = New KeyValuePair(Of ConversionKind, MethodSymbol)(ConversionKind.Narrowing Or ConversionKind.UserDefined, bestMatch)
End If
GoTo Done
ElseIf opSet.Count = 0 Then
GoTo Done
End If
' Try nullable lifting.
If source.IsNullableType() AndAlso destination.IsNullableType() Then
applicable.Clear()
conversionKinds.ZeroInit(opSet.Count)
Dim sourceUnderlying As TypeSymbol = source.GetNullableUnderlyingType()
Dim destinationUnderlying As TypeSymbol = destination.GetNullableUnderlyingType()
If Not (sourceUnderlying.IsErrorType() OrElse destinationUnderlying.IsErrorType()) Then
' All candidates applicable to the underlying types should be applicable to the original types, no reason to
' do viability checks for the secont time.
If DetermineMostSpecificWideningConversion(sourceUnderlying, destinationUnderlying, opSet, conversionKinds, applicable, bestMatch, suppressViabilityChecks:=True, useSiteDiagnostics:=useSiteDiagnostics) Then
If bestMatch IsNot Nothing Then
Debug.Assert(Not bestMatch.Parameters(0).Type.IsNullableType())
Debug.Assert(Not bestMatch.ReturnType.IsNullableType())
result = New KeyValuePair(Of ConversionKind, MethodSymbol)(ConversionKind.Widening Or
ConversionKind.UserDefined Or
ConversionKind.Nullable, bestMatch)
End If
ElseIf DetermineMostSpecificNarrowingConversion(sourceUnderlying, destinationUnderlying, opSet, conversionKinds, applicable, bestMatch, suppressViabilityChecks:=True, useSiteDiagnostics:=useSiteDiagnostics) Then
If bestMatch IsNot Nothing Then
Debug.Assert(Not bestMatch.Parameters(0).Type.IsNullableType())
Debug.Assert(Not bestMatch.ReturnType.IsNullableType())
result = New KeyValuePair(Of ConversionKind, MethodSymbol)(ConversionKind.Narrowing Or
ConversionKind.UserDefined Or
ConversionKind.Nullable, bestMatch)
End If
End If
End If
End If
Done:
conversionKinds.Free()
opSet.Free()
Return result
End Function
''' <summary>
''' Returns True if resolution of user defined conversions is complete, i.e. there were operators
''' applicable for the "Most Specific Widening Conversion" purposes.
''' This, however, doesn't mean that resolution is successful.
''' </summary>
Private Shared Function DetermineMostSpecificWideningConversion(
source As TypeSymbol,
destination As TypeSymbol,
opSet As ArrayBuilder(Of MethodSymbol),
conversionKinds As ArrayBuilder(Of KeyValuePair(Of ConversionKind, ConversionKind)),
<[In]()> ByRef applicable As BitVector,
<Out()> ByRef bestMatch As MethodSymbol,
suppressViabilityChecks As Boolean,
<[In], Out> ByRef useSiteDiagnostics As HashSet(Of DiagnosticInfo)
) As Boolean
#If DEBUG Then
Debug.Assert(bestMatch Is Nothing)
For i As Integer = 0 To opSet.Count - 1
Debug.Assert(Not applicable(i))
Next
#End If
bestMatch = Nothing
Dim bestMatchDegreeOfGenericity As Integer = -1 ' (-1) - unknown, 0 - neither type refers to generic type parameters, 1 - one type, 2 - two types
Dim bestMatchIsAmbiguous As Boolean = False
Dim mostSpecificSourceType As TypeSymbol = Nothing
Dim mostSpecificTargetType As TypeSymbol = Nothing
Dim applicableCount As Integer = 0
' 8.11.1 Most Specific Widening Conversion
' - First, all of the candidate conversion operators are collected. The candidate conversion operators are all
' of the user-defined widening conversion operators in the source type and all of the user-defined widening
' conversion operators in the target type.
' - Then, all non-applicable conversion operators are removed from the set. A conversion operator is applicable
' to a source type and target type if there is an intrinsic widening conversion operator from the source type
' to the operand type and there is an intrinsic widening conversion operator from the result of the operator
' to the target type. If there are no applicable conversion operators, then there is no most specific widening
' conversion.
' - Then, the most specific source type of the applicable conversion operators is determined:
' - If any of the conversion operators convert directly from the source type, then the source type is the
' most specific source type.
' - Otherwise, the most specific source type is the most encompassed type in the combined set of source types
' of the conversion operators. If no most encompassed type can be found, then there is no most specific
' widening conversion.
' - Then, the most specific target type of the applicable conversion operators is determined:
' - If any of the conversion operators convert directly to the target type, then the target type is the most
' specific target type.
' - Otherwise, the most specific target type is the most encompassing type in the combined set of target types
' of the conversion operators. If no most encompassing type can be found, then there is no most specific
' widening conversion.
' - Then, if exactly one conversion operator converts from the most specific source type to the most specific target
' type, then this is the most specific conversion operator. If more than one such operator exists, then there is
' no most specific widening conversion.
' 8.11 User-Defined Conversions
' - If an intrinsic widening conversion exists from a type A to a type B,
' and if neither A nor B are interfaces, then A is encompassed by B, and
' B encompasses A.
' - The most encompassing type in a set of types is the one type that encompasses
' all other types in the set. If no single type encompasses all other types, then
' the set has no most encompassing type. In intuitive terms, the most encompassing
' type is the “largest” type in the set—the one type to which each of the other
' types can be converted through a widening conversion.
' - The most encompassed type in a set of types is the one type that is encompassed
' by all other types in the set. If no single type is encompassed by all other types,
' then the set has no most encompassed type. In intuitive terms, the most encompassed
' type is the “smallest” type in the set—the one type that can be converted from each
' of the other types through a narrowing conversion.
Dim viableCandidates As Integer = 0
For i As Integer = 0 To opSet.Count - 1
Dim method As MethodSymbol = opSet(i)
Dim currentIndex As Integer = viableCandidates
viableCandidates += 1
If currentIndex < i Then
Debug.Assert(Not suppressViabilityChecks)
opSet(currentIndex) = method
Else
Debug.Assert(currentIndex = i)
End If
If Not IsWidening(method) Then
Continue For
End If
Dim conversionIn As ConversionKind
Dim conversionOut As ConversionKind
If ClassifyConversionOperatorInOutConversions(source, destination, method, conversionIn, conversionOut, suppressViabilityChecks, useSiteDiagnostics) Then
conversionKinds(currentIndex) = New KeyValuePair(Of ConversionKind, ConversionKind)(conversionIn, conversionOut)
Else
'opSet(currentIndex) = Nothing
Debug.Assert(Not suppressViabilityChecks)
viableCandidates = currentIndex
Continue For
End If
If bestMatch Is Nothing Then
If Not (Conversions.IsWideningConversion(conversionIn) AndAlso Conversions.IsWideningConversion(conversionOut)) Then
Continue For
End If
Else
If Not (Conversions.IsIdentityConversion(conversionIn) AndAlso Conversions.IsIdentityConversion(conversionOut)) Then
Continue For
End If
' Potential ambiguity, let's attempt to resolve based on genericity.
bestMatch = LeastGenericConversionOperator(bestMatch, method, bestMatchDegreeOfGenericity, bestMatchIsAmbiguous)
If bestMatchIsAmbiguous AndAlso bestMatchDegreeOfGenericity = 0 Then
' We will not be able to get rid of this ambiguity.
Exit For
End If
Continue For
End If
If Conversions.IsIdentityConversion(conversionIn) AndAlso Conversions.IsIdentityConversion(conversionOut) Then
Debug.Assert(bestMatch Is Nothing)
bestMatch = method
applicable.Clear()
applicableCount = 0
Else
If Conversions.IsIdentityConversion(conversionIn) Then
mostSpecificSourceType = source
End If
If Conversions.IsIdentityConversion(conversionOut) Then
mostSpecificTargetType = destination
End If
applicable(currentIndex) = True
applicableCount += 1
End If
Next
opSet.Clip(viableCandidates)
conversionKinds.Clip(viableCandidates)
#If DEBUG Then
For i As Integer = 0 To opSet.Count - 1
Debug.Assert(opSet(i) IsNot Nothing)
Next
#End If
If bestMatch IsNot Nothing Then
If bestMatchIsAmbiguous Then
bestMatch = Nothing
End If
Return True
End If
If applicableCount > 0 Then
Debug.Assert(bestMatch Is Nothing)
Debug.Assert(Not bestMatchIsAmbiguous)
If applicableCount > 1 Then
' Try to choose most specific among applicable candidates.
Dim typeSet As ArrayBuilder(Of TypeSymbol) = Nothing
If mostSpecificSourceType Is Nothing Then
typeSet = ArrayBuilder(Of TypeSymbol).GetInstance()
For i As Integer = 0 To opSet.Count - 1
If Not applicable(i) Then
Continue For
End If
typeSet.Add(opSet(i).Parameters(0).Type)
Next
Debug.Assert(typeSet.Count = applicableCount)
mostSpecificSourceType = MostEncompassed(typeSet, useSiteDiagnostics)
End If
If mostSpecificTargetType Is Nothing AndAlso mostSpecificSourceType IsNot Nothing Then
If typeSet Is Nothing Then
typeSet = ArrayBuilder(Of TypeSymbol).GetInstance()
Else
typeSet.Clear()
End If
For i As Integer = 0 To opSet.Count - 1
If Not applicable(i) Then
Continue For
End If
typeSet.Add(opSet(i).ReturnType)
Next
Debug.Assert(typeSet.Count = applicableCount)
mostSpecificTargetType = MostEncompassing(typeSet, useSiteDiagnostics)
End If
If typeSet IsNot Nothing Then
typeSet.Free()
End If
If mostSpecificSourceType IsNot Nothing AndAlso mostSpecificTargetType IsNot Nothing Then
bestMatch = ChooseMostSpecificConversionOperator(opSet, applicable, mostSpecificSourceType, mostSpecificTargetType, bestMatchIsAmbiguous)
End If
If bestMatch IsNot Nothing AndAlso bestMatchIsAmbiguous Then
bestMatch = Nothing
End If
Else
For i As Integer = 0 To opSet.Count - 1
If applicable(i) Then
bestMatch = opSet(i)
Exit For
End If
Next
Debug.Assert(bestMatch IsNot Nothing)
End If
Return True
End If
Debug.Assert(bestMatch Is Nothing)
Return False
End Function
Private Shared Function ChooseMostSpecificConversionOperator(
opSet As ArrayBuilder(Of MethodSymbol),
applicable As BitVector,
mostSpecificSourceType As TypeSymbol,
mostSpecificTargetType As TypeSymbol,
<Out()> ByRef bestMatchIsAmbiguous As Boolean
) As MethodSymbol
Dim bestMatchDegreeOfGenericity As Integer = -1 ' (-1) - unknown, 0 - neither type refers to generic type parameters, 1 - one type, 2 - two types
Dim bestMatch As MethodSymbol = Nothing
bestMatchIsAmbiguous = False
For i As Integer = 0 To opSet.Count - 1
If Not applicable(i) Then
Continue For
End If
Dim method As MethodSymbol = opSet(i)
If Not (mostSpecificSourceType.IsSameTypeIgnoringCustomModifiers(method.Parameters(0).Type) AndAlso
mostSpecificTargetType.IsSameTypeIgnoringCustomModifiers(method.ReturnType)) Then
Continue For
End If
If bestMatch Is Nothing Then
bestMatch = method
Else
' Potential ambiguity, let's attempt to resolve based on genericity.
bestMatch = LeastGenericConversionOperator(bestMatch, method, bestMatchDegreeOfGenericity, bestMatchIsAmbiguous)
If bestMatchIsAmbiguous AndAlso bestMatchDegreeOfGenericity = 0 Then
' We will not be able to get rid of this ambiguity.
Exit For
End If
End If
Next
Return bestMatch
End Function
''' <summary>
''' Returns false if operator should be ignored.
''' </summary>
Private Shared Function ClassifyConversionOperatorInOutConversions(
source As TypeSymbol,
destination As TypeSymbol,
method As MethodSymbol,
<Out()> ByRef conversionIn As ConversionKind,
<Out()> ByRef conversionOut As ConversionKind,
suppressViabilityChecks As Boolean,
<[In], Out> ByRef useSiteDiagnostics As HashSet(Of DiagnosticInfo)
) As Boolean
Dim inputType As TypeSymbol = method.Parameters(0).Type
Dim outputType As TypeSymbol = method.ReturnType
If Not suppressViabilityChecks Then
If Not IsConversionOperatorViableBasedOnTypesInvolved(method, inputType, outputType) Then
conversionIn = Nothing
conversionOut = Nothing
Return False
End If
Else
Debug.Assert(IsConversionOperatorViableBasedOnTypesInvolved(method, inputType, outputType))
End If
' If source is an array literal then use ClassifyArrayLiteralConversion
Dim arrayLiteralType = TryCast(source, ArrayLiteralTypeSymbol)
If arrayLiteralType IsNot Nothing Then
Dim arrayLiteral = arrayLiteralType.ArrayLiteral
conversionIn = Conversions.ClassifyArrayLiteralConversion(arrayLiteral, inputType, arrayLiteral.Binder, useSiteDiagnostics)
If Conversions.IsWideningConversion(conversionIn) AndAlso
IsSameTypeIgnoringCustomModifiers(arrayLiteralType, inputType) Then
conversionIn = ConversionKind.Identity
End If
Else
conversionIn = Conversions.ClassifyPredefinedConversion(source, inputType, useSiteDiagnostics)
End If
conversionOut = Conversions.ClassifyPredefinedConversion(outputType, destination, useSiteDiagnostics)
Return True
End Function
Private Shared Function IsConversionOperatorViableBasedOnTypesInvolved(
method As MethodSymbol,
inputType As TypeSymbol,
outputType As TypeSymbol
) As Boolean
If inputType.IsErrorType() OrElse outputType.IsErrorType() Then
Return False
End If
' Ignore user defined conversions between types that already have intrinsic conversions.
' This could happen for generics after generic param substituion.
If Not method.ContainingType.IsDefinition Then
Dim useSiteDiagnoctics As HashSet(Of DiagnosticInfo) = Nothing
If Conversions.ConversionExists(Conversions.ClassifyPredefinedConversion(inputType, outputType, useSiteDiagnoctics)) OrElse
Not useSiteDiagnoctics.IsNullOrEmpty Then
Return False
End If
End If
Return True
End Function
''' <summary>
''' Returns True if resolution of user defined conversions is complete, i.e. there was an operator
''' that converts from the most specific source type to the most specific target type.
''' This, however, doesn't mean that resolution is successful.
''' </summary>
Private Shared Function DetermineMostSpecificNarrowingConversion(
source As TypeSymbol,
destination As TypeSymbol,
opSet As ArrayBuilder(Of MethodSymbol),
conversionKinds As ArrayBuilder(Of KeyValuePair(Of ConversionKind, ConversionKind)),
<[In]()> ByRef applicable As BitVector,
<Out()> ByRef bestMatch As MethodSymbol,
suppressViabilityChecks As Boolean,
<[In], Out> ByRef useSiteDiagnostics As HashSet(Of DiagnosticInfo)
) As Boolean
#If DEBUG Then
Debug.Assert(bestMatch Is Nothing)
For i As Integer = 0 To opSet.Count - 1
Debug.Assert(Not applicable(i))
Next
#End If
bestMatch = Nothing
Dim bestMatchDegreeOfGenericity As Integer = -1 ' (-1) - unknown, 0 - neither type refers to generic type parameters, 1 - one type, 2 - two types
Dim bestMatchIsAmbiguous As Boolean = False
Dim mostSpecificSourceType As TypeSymbol = Nothing
Dim mostSpecificTargetType As TypeSymbol = Nothing
Dim applicableCount As Integer = 0
' 8.11.2 Most Specific Narrowing Conversion
' Determining the most specific user-defined narrowing conversion operator between two types is accomplished using the following steps:
' - First, all of the candidate conversion operators are collected. The candidate conversion operators are all
' of the user-defined conversion operators in the source type and all of the user-defined conversion operators
' in the target type.
' - Then, all non-applicable conversion operators are removed from the set. A conversion operator is applicable
' to a source type and target type if there is an intrinsic conversion operator from the source type to the
' operand type and there is an intrinsic conversion operator from the result of the operator to the target type.
' If there are no applicable conversion operators, then there is no most specific narrowing conversion.
' - Then, the most specific source type of the applicable conversion operators is determined:
' - If any of the conversion operators convert directly from the source type, then the source type is
' the most specific source type.
' - Otherwise, if any of the conversion operators convert from types that encompass the source type,
' then the most specific source type is the most encompassed type in the combined set of source types
' of those conversion operators. If no most encompassed type can be found, then there is no most
' specific narrowing conversion.
' - Otherwise, the most specific source type is the most encompassing type in the combined set of source
' types of the conversion operators. If no most encompassing type can be found, then there is no most
' specific narrowing conversion.
' - Then, the most specific target type of the applicable conversion operators is determined:
' - If any of the conversion operators convert directly to the target type, then the target type is
' the most specific target type.
' - Otherwise, if any of the conversion operators convert to types that are encompassed by the target type,
' then the most specific target type is the most encompassing type in the combined set of source types of
' those conversion operators. If no most encompassing type can be found, then there is no most specific
' narrowing conversion.
' - Otherwise, the most specific target type is the most encompassed type in the combined set of target
' types of the conversion operators. If no most encompassed type can be found, then there is no most
' specific narrowing conversion.
' - Then, if exactly one conversion operator converts from the most specific source type to the most specific
' target type, then this is the most specific conversion operator. If more than one such operator exists,
' then there is no most specific narrowing conversion.
' 8.11 User-Defined Conversions
' - If an intrinsic widening conversion exists from a type A to a type B,
' and if neither A nor B are interfaces, then A is encompassed by B, and
' B encompasses A.
' - The most encompassing type in a set of types is the one type that encompasses
' all other types in the set. If no single type encompasses all other types, then
' the set has no most encompassing type. In intuitive terms, the most encompassing
' type is the “largest” type in the set—the one type to which each of the other
' types can be converted through a widening conversion.
' - The most encompassed type in a set of types is the one type that is encompassed
' by all other types in the set. If no single type is encompassed by all other types,
' then the set has no most encompassed type. In intuitive terms, the most encompassed
' type is the “smallest” type in the set—the one type that can be converted from each
' of the other types through a narrowing conversion.
Dim haveWideningInConversions As Integer = 0
Dim haveWideningOutConversions As Integer = 0
Dim viableCandidates As Integer = 0
For i As Integer = 0 To opSet.Count - 1
Dim method As MethodSymbol = opSet(i)
Dim currentIndex As Integer = viableCandidates
viableCandidates += 1
If currentIndex < i Then
Debug.Assert(Not suppressViabilityChecks)
opSet(currentIndex) = method
conversionKinds(currentIndex) = conversionKinds(i)
Else
Debug.Assert(currentIndex = i)
End If
Dim conversionIn As ConversionKind
Dim conversionOut As ConversionKind
If IsWidening(method) Then
' When we reach this point, a widening operator is either removed from the opSet (because it was "bad" in one way or another)
' or it was not applicable for the purpose of the "Most Specific Widening Conversion", but conversion information should have been
' captured in conversionKinds for it.
Dim conversion As KeyValuePair(Of ConversionKind, ConversionKind) = conversionKinds(currentIndex)
conversionIn = conversion.Key
conversionOut = conversion.Value
' If the operator would be an acceptable candidate for the "Most Specific Widening Conversion", we shouldn't have
' reached this place.
Debug.Assert(Not (Conversions.IsWideningConversion(conversionIn) AndAlso Conversions.IsWideningConversion(conversionOut)))
ElseIf ClassifyConversionOperatorInOutConversions(source, destination, method, conversionIn, conversionOut, suppressViabilityChecks, useSiteDiagnostics) Then
conversionKinds(currentIndex) = New KeyValuePair(Of ConversionKind, ConversionKind)(conversionIn, conversionOut)
Else
'opSet(currentIndex) = Nothing
Debug.Assert(Not suppressViabilityChecks)
viableCandidates = currentIndex
Continue For
End If
If bestMatch Is Nothing Then
If Not (Conversions.ConversionExists(conversionIn) AndAlso Conversions.ConversionExists(conversionOut)) Then
Continue For
End If
Else
If Not (Conversions.IsIdentityConversion(conversionIn) AndAlso Conversions.IsIdentityConversion(conversionOut)) Then
Continue For
End If
' Potential ambiguity, let's attempt to resolve based on genericity.
bestMatch = LeastGenericConversionOperator(bestMatch, method, bestMatchDegreeOfGenericity, bestMatchIsAmbiguous)
If bestMatchIsAmbiguous AndAlso bestMatchDegreeOfGenericity = 0 Then
' We will not be able to get rid of this ambiguity.
Exit For
End If
Continue For
End If
If Conversions.IsIdentityConversion(conversionIn) AndAlso Conversions.IsIdentityConversion(conversionOut) Then
Debug.Assert(bestMatch Is Nothing)
bestMatch = method
applicable.Clear()
applicableCount = 0
Else
If Conversions.IsWideningConversion(conversionIn) Then
If Conversions.IsIdentityConversion(conversionIn) Then
mostSpecificSourceType = source
Else
haveWideningInConversions += 1
End If
If Conversions.IsWideningConversion(conversionOut) Then
If Conversions.IsIdentityConversion(conversionOut) Then
mostSpecificTargetType = destination
Else
haveWideningOutConversions += 1
End If
Else
Debug.Assert(Conversions.IsNarrowingConversion(conversionOut))
End If
Else
Debug.Assert(Conversions.IsNarrowingConversion(conversionIn))
If Conversions.IsIdentityConversion(conversionOut) Then
mostSpecificTargetType = destination
ElseIf Not Conversions.IsNarrowingConversion(conversionOut) Then
Debug.Assert(Conversions.IsWideningConversion(conversionOut) AndAlso Not Conversions.IsIdentityConversion(conversionOut))
' Note that {Narrowing in, Widening (non-identity) out} operator is not considered as an applicable candidate.
' In fact, an operator like this cannot exist unless nullable in/out conversions are involved.
' Basically we would be dealing with an operator that converts from type derived from source to type derived from destination,
' it would have to be difined in one of those types. When we collect operators we only visit source, destination and their
' bases. So, in order for such an operator to be found, there must be an inheritense relationship between source and
' destination and the operator must be defined in a type that is in between of them in the inheritance hierarchy. Thus,
' there would be an inheritance relationship between parameter type ant return type of the operator, which makes the operator
' inapplicable - there would be a predefined conversion between the types.
' Ignoring an operator like this even when nullable conversions are involved, allows us to consider it as a candidate for a
' lifting, otherwise it would be treated as a not-lifted narrowing.
Continue For
Else
Debug.Assert(Conversions.IsNarrowingConversion(conversionOut))
' When intrinsic types are involved, conversion from intrinsic type T to Nullable(Of S) can be narrowing,
' it is always widening (if exists) for user-defined types. For reasons described above, we might need to ignore
' an operator like this.
If source.IsNullableType() AndAlso destination.IsNullableType() AndAlso
method.ReturnType.IsIntrinsicType() Then
Continue For
End If
End If
End If
applicable(currentIndex) = True
applicableCount += 1
End If
Next
opSet.Clip(viableCandidates)
conversionKinds.Clip(viableCandidates)
#If DEBUG Then
For i As Integer = 0 To opSet.Count - 1
Debug.Assert(opSet(i) IsNot Nothing)
Next
#End If
If bestMatch IsNot Nothing Then
If bestMatchIsAmbiguous Then
bestMatch = Nothing
End If
Return True
End If
If applicableCount > 0 Then
Debug.Assert(bestMatch Is Nothing)
Debug.Assert(Not bestMatchIsAmbiguous)
If applicableCount > 1 Then
' Try to choose most specific among applicable candidates.
Dim typeSet As ArrayBuilder(Of TypeSymbol) = Nothing
If mostSpecificSourceType Is Nothing Then
typeSet = ArrayBuilder(Of TypeSymbol).GetInstance()
For i As Integer = 0 To opSet.Count - 1
If Not applicable(i) Then
Continue For
End If
If haveWideningInConversions <> 0 Then
If Not Conversions.IsWideningConversion(conversionKinds(i).Key) Then
Continue For
End If
Else
Debug.Assert(Conversions.IsNarrowingConversion(conversionKinds(i).Key))
End If
typeSet.Add(opSet(i).Parameters(0).Type)
Next
Debug.Assert(typeSet.Count = applicableCount OrElse (haveWideningInConversions <> 0 AndAlso typeSet.Count = haveWideningInConversions))
If haveWideningInConversions <> 0 Then
mostSpecificSourceType = MostEncompassed(typeSet, useSiteDiagnostics)
Else
mostSpecificSourceType = MostEncompassing(typeSet, useSiteDiagnostics)
End If
End If
If mostSpecificTargetType Is Nothing AndAlso mostSpecificSourceType IsNot Nothing Then
If typeSet Is Nothing Then
typeSet = ArrayBuilder(Of TypeSymbol).GetInstance()
Else
typeSet.Clear()
End If
For i As Integer = 0 To opSet.Count - 1
If Not applicable(i) Then
Continue For
End If
If haveWideningOutConversions <> 0 Then
If Not Conversions.IsWideningConversion(conversionKinds(i).Value) Then
Continue For
End If
Else
Debug.Assert(Conversions.IsNarrowingConversion(conversionKinds(i).Value))
End If
typeSet.Add(opSet(i).ReturnType)
Next
Debug.Assert(typeSet.Count = applicableCount OrElse (haveWideningOutConversions <> 0 AndAlso typeSet.Count = haveWideningOutConversions))
If haveWideningOutConversions <> 0 Then
mostSpecificTargetType = MostEncompassing(typeSet, useSiteDiagnostics)
Else
mostSpecificTargetType = MostEncompassed(typeSet, useSiteDiagnostics)
End If
End If
If typeSet IsNot Nothing Then
typeSet.Free()
End If
If mostSpecificSourceType IsNot Nothing AndAlso mostSpecificTargetType IsNot Nothing Then
bestMatch = ChooseMostSpecificConversionOperator(opSet, applicable, mostSpecificSourceType, mostSpecificTargetType, bestMatchIsAmbiguous)
End If
If bestMatch IsNot Nothing AndAlso bestMatchIsAmbiguous Then
bestMatch = Nothing
Return True
End If
Else
For i As Integer = 0 To opSet.Count - 1
If applicable(i) Then
bestMatch = opSet(i)
Exit For
End If
Next
Debug.Assert(bestMatch IsNot Nothing)
End If
End If
Return bestMatch IsNot Nothing
End Function
''' <summary>
''' The most encompassed type in a set of types is the one type that is encompassed
''' by all other types in the set. If no single type is encompassed by all other types,
''' then the set has no most encompassed type. In intuitive terms, the most encompassed
''' type is the “smallest” type in the set—the one type that can be converted from each
''' of the other types through a narrowing conversion.
''' </summary>
Private Shared Function MostEncompassed(typeSet As ArrayBuilder(Of TypeSymbol), <[In], Out> ByRef useSiteDiagnostics As HashSet(Of DiagnosticInfo)) As TypeSymbol
Dim best As TypeSymbol = Nothing
For i As Integer = 0 To typeSet.Count - 1
Dim type As TypeSymbol = typeSet(i)
If best IsNot Nothing AndAlso best.IsSameTypeIgnoringCustomModifiers(type) Then
Continue For
End If
Debug.Assert(Not type.IsErrorType())
For j As Integer = 0 To typeSet.Count - 1
If i = j Then
Continue For
End If
Dim conv As ConversionKind = Conversions.ClassifyPredefinedConversion(type, typeSet(j), useSiteDiagnostics)
If Not Conversions.IsWideningConversion(conv) Then
' type is not encompassed by the other type
GoTo Next_i
End If
Next
If best Is Nothing Then
best = type
Else
Debug.Assert(Not best.IsSameTypeIgnoringCustomModifiers(type))
best = Nothing ' More than one type
Exit For
End If
Next_i:
Next
Return best
End Function
''' <summary>
''' The most encompassing type in a set of types is the one type that encompasses
''' all other types in the set. If no single type encompasses all other types, then
''' the set has no most encompassing type. In intuitive terms, the most encompassing
''' type is the “largest” type in the set—the one type to which each of the other
''' types can be converted through a widening conversion.
''' </summary>
Private Shared Function MostEncompassing(typeSet As ArrayBuilder(Of TypeSymbol), <[In], Out> ByRef useSiteDiagnostics As HashSet(Of DiagnosticInfo)) As TypeSymbol
Dim best As TypeSymbol = Nothing
For i As Integer = 0 To typeSet.Count - 1
Dim type As TypeSymbol = typeSet(i)
If best IsNot Nothing AndAlso best.IsSameTypeIgnoringCustomModifiers(type) Then
Continue For
End If
Debug.Assert(Not type.IsErrorType())
For j As Integer = 0 To typeSet.Count - 1
If i = j Then
Continue For
End If
Dim conv As ConversionKind = Conversions.ClassifyPredefinedConversion(typeSet(j), type, useSiteDiagnostics)
If Not Conversions.IsWideningConversion(conv) Then
' type is not encompassing the other type
GoTo Next_i
End If
Next
If best Is Nothing Then
best = type
Else
Debug.Assert(Not best.IsSameTypeIgnoringCustomModifiers(type))
best = Nothing ' More than one type
Exit For
End If
Next_i:
Next
Return best
End Function
Private Shared Function LeastGenericConversionOperator(
method1 As MethodSymbol,
method2 As MethodSymbol,
<[In], Out()> ByRef bestDegreeOfGenericity As Integer,
<[In], Out()> ByRef isAmbiguous As Boolean
) As MethodSymbol
If bestDegreeOfGenericity = -1 Then
bestDegreeOfGenericity = DetermineConversionOperatorDegreeOfGenericity(method1)
End If
Dim method2DegreeOfGenericity As Integer = DetermineConversionOperatorDegreeOfGenericity(method2)
' The less degree of genericity, the better.
If bestDegreeOfGenericity < method2DegreeOfGenericity Then
' isAmbiguous state doesn't change.
Return method1
ElseIf method2DegreeOfGenericity < bestDegreeOfGenericity Then
isAmbiguous = False
bestDegreeOfGenericity = method2DegreeOfGenericity
Return method2
End If
isAmbiguous = True
Return method1
End Function
''' <summary>
''' Returns number of types in the list of {input type, output type} that refer to a generic type parameter.
''' </summary>
Private Shared Function DetermineConversionOperatorDegreeOfGenericity(method As MethodSymbol) As Integer
If Not method.ContainingType.IsGenericType Then
Return 0
End If
Dim result As Integer = 0
Dim definition As MethodSymbol = method.OriginalDefinition
If DetectReferencesToGenericParameters(definition.Parameters(0).Type, TypeParameterKind.Type, BitVector.Null) <> TypeParameterKind.None Then
result += 1
End If
If DetectReferencesToGenericParameters(definition.ReturnType, TypeParameterKind.Type, BitVector.Null) <> TypeParameterKind.None Then
result += 1
End If
Debug.Assert(result > 0)
Return result
End Function
''' <summary>
''' A quick check whether given conversion operator is a widening operator.
''' </summary>
Friend Shared Function IsWidening(method As MethodSymbol) As Boolean
Debug.Assert(method.MethodKind = MethodKind.Conversion)
Dim forth As Char = method.Name(3)
If forth = "I"c OrElse forth = "i"c Then
Return True
End If
Debug.Assert(forth = "E"c OrElse forth = "e"c)
Return False
End Function
''' <summary>
''' Collect user-defined conversion operators.
''' Operators declared in the same type are grouped together.
''' Within a group, widening operators are followed by narrowing operators.
''' </summary>
Private Shared Sub CollectUserDefinedConversionOperators(
source As TypeSymbol,
destination As TypeSymbol,
opSet As ArrayBuilder(Of MethodSymbol),
<[In], Out> ByRef useSiteDiagnostics As HashSet(Of DiagnosticInfo)
)
CollectUserDefinedOperators(source, destination, MethodKind.Conversion,
WellKnownMemberNames.ImplicitConversionName, New OperatorInfo(UnaryOperatorKind.Implicit),
WellKnownMemberNames.ExplicitConversionName, New OperatorInfo(UnaryOperatorKind.Explicit),
opSet, useSiteDiagnostics)
End Sub
''' <summary>
''' Collect user-defined operators.
''' Operators declared in the same type are grouped together.
''' Within a group, name1 operators are followed by name2 operators.
''' </summary>
Friend Shared Sub CollectUserDefinedOperators(
type1 As TypeSymbol,
type2 As TypeSymbol,
opKind As MethodKind,
name1 As String,
name1Info As OperatorInfo,
name2Opt As String,
name2InfoOpt As OperatorInfo,
opSet As ArrayBuilder(Of MethodSymbol),
<[In], Out> ByRef useSiteDiagnostics As HashSet(Of DiagnosticInfo)
)
type1 = GetTypeToLookForOperatorsIn(type1, useSiteDiagnostics)
If type2 IsNot Nothing Then
type2 = GetTypeToLookForOperatorsIn(type2, useSiteDiagnostics)
End If
Dim commonAncestor As NamedTypeSymbol = Nothing
If type1 IsNot Nothing AndAlso type1.Kind = SymbolKind.NamedType AndAlso Not type1.IsInterfaceType() Then
Dim current = DirectCast(type1, NamedTypeSymbol)
Do
If type2 IsNot Nothing AndAlso commonAncestor Is Nothing AndAlso
type2.IsOrDerivedFrom(current, useSiteDiagnostics) Then
commonAncestor = current
End If
' Note, intentionally using non-short-circuiting Or operator.
If CollectUserDefinedOperators(current, name1, opKind, name1Info, opSet) Or
(name2Opt IsNot Nothing AndAlso CollectUserDefinedOperators(current, name2Opt, opKind, name2InfoOpt, opSet)) Then
Exit Do
End If
current = current.BaseTypeWithDefinitionUseSiteDiagnostics(useSiteDiagnostics)
Loop While current IsNot Nothing
End If
If type2 IsNot Nothing AndAlso type2.Kind = SymbolKind.NamedType AndAlso Not type2.IsInterfaceType() Then
Dim current = DirectCast(type2, NamedTypeSymbol)
Do
If commonAncestor IsNot Nothing AndAlso commonAncestor.IsSameTypeIgnoringCustomModifiers(current) Then
Exit Do
End If
' Note, intentionally using non-short-circuiting Or operator.
If CollectUserDefinedOperators(current, name1, opKind, name1Info, opSet) Or
(name2Opt IsNot Nothing AndAlso CollectUserDefinedOperators(current, name2Opt, opKind, name2InfoOpt, opSet)) Then
Exit Do
End If
current = current.BaseTypeWithDefinitionUseSiteDiagnostics(useSiteDiagnostics)
Loop While current IsNot Nothing
End If
End Sub
''' <summary>
''' Returns True if we should stop climbing inheritence hierarchy.
''' </summary>
Private Shared Function CollectUserDefinedOperators(
type As TypeSymbol,
opName As String,
opKind As MethodKind,
opInfo As OperatorInfo,
opSet As ArrayBuilder(Of MethodSymbol)
) As Boolean
Dim stopClimbing As Boolean = False
For Each member In type.GetMembers(opName)
If member.Kind = SymbolKind.Method Then
Dim method = DirectCast(member, MethodSymbol)
If method.MethodKind = opKind Then
If method.IsShadows Then
stopClimbing = True
End If
' Operators that were declared in syntax may not satisfy all the constraints on user-defined operators -
' they require extra validation.
If Not method.IsMethodKindBasedOnSyntax OrElse ValidateOverloadedOperator(method.OriginalDefinition, opInfo) Then
opSet.Add(method)
End If
End If
End If
Next
Return stopClimbing
End Function
''' <summary>
''' Given the type of operator's argument, return corresponding type to
''' look for operator in. Can return Nothing.
''' </summary>
Private Shared Function GetTypeToLookForOperatorsIn(type As TypeSymbol, <[In], Out> ByRef useSiteDiagnostics As HashSet(Of DiagnosticInfo)) As TypeSymbol
type = type.GetNullableUnderlyingTypeOrSelf()
If type.Kind = SymbolKind.TypeParameter Then
type = DirectCast(type, TypeParameterSymbol).GetNonInterfaceConstraint(useSiteDiagnostics)
End If
Return type
End Function
Public Shared Function ResolveIsTrueOperator(argument As BoundExpression, binder As Binder, <[In], Out> ByRef useSiteDiagnostics As HashSet(Of DiagnosticInfo)) As OverloadResolutionResult
Dim opSet = ArrayBuilder(Of MethodSymbol).GetInstance()
CollectUserDefinedOperators(argument.Type, Nothing, MethodKind.UserDefinedOperator,
WellKnownMemberNames.TrueOperatorName, New OperatorInfo(UnaryOperatorKind.IsTrue),
Nothing, Nothing,
opSet, useSiteDiagnostics)
Dim result = OperatorInvocationOverloadResolution(opSet, argument, Nothing, binder, lateBindingIsAllowed:=False, includeEliminatedCandidates:=False,
useSiteDiagnostics:=useSiteDiagnostics)
opSet.Free()
Return result
End Function
Public Shared Function ResolveIsFalseOperator(argument As BoundExpression, binder As Binder, <[In], Out> ByRef useSiteDiagnostics As HashSet(Of DiagnosticInfo)) As OverloadResolutionResult
Dim opSet = ArrayBuilder(Of MethodSymbol).GetInstance()
CollectUserDefinedOperators(argument.Type, Nothing, MethodKind.UserDefinedOperator,
WellKnownMemberNames.FalseOperatorName, New OperatorInfo(UnaryOperatorKind.IsFalse),
Nothing, Nothing,
opSet, useSiteDiagnostics)
Dim result = OperatorInvocationOverloadResolution(opSet, argument, Nothing, binder, lateBindingIsAllowed:=False, includeEliminatedCandidates:=False,
useSiteDiagnostics:=useSiteDiagnostics)
opSet.Free()
Return result
End Function
Public Shared Function ResolveUserDefinedUnaryOperator(
argument As BoundExpression,
opKind As UnaryOperatorKind,
binder As Binder,
<[In], Out> ByRef useSiteDiagnostics As HashSet(Of DiagnosticInfo),
Optional includeEliminatedCandidates As Boolean = False
) As OverloadResolutionResult
Dim opSet = ArrayBuilder(Of MethodSymbol).GetInstance()
Select Case opKind
Case UnaryOperatorKind.Not
Dim opInfo As New OperatorInfo(UnaryOperatorKind.Not)
CollectUserDefinedOperators(argument.Type, Nothing, MethodKind.UserDefinedOperator,
WellKnownMemberNames.OnesComplementOperatorName, opInfo,
WellKnownMemberNames.LogicalNotOperatorName, opInfo,
opSet, useSiteDiagnostics)
Case UnaryOperatorKind.Minus
CollectUserDefinedOperators(argument.Type, Nothing, MethodKind.UserDefinedOperator,
WellKnownMemberNames.UnaryNegationOperatorName, New OperatorInfo(UnaryOperatorKind.Minus),
Nothing, Nothing,
opSet, useSiteDiagnostics)
Case UnaryOperatorKind.Plus
CollectUserDefinedOperators(argument.Type, Nothing, MethodKind.UserDefinedOperator,
WellKnownMemberNames.UnaryPlusOperatorName, New OperatorInfo(UnaryOperatorKind.Minus),
Nothing, Nothing,
opSet, useSiteDiagnostics)
Case Else
Throw ExceptionUtilities.UnexpectedValue(opKind)
End Select
Dim result = OperatorInvocationOverloadResolution(opSet, argument, Nothing, binder, lateBindingIsAllowed:=False, includeEliminatedCandidates:=includeEliminatedCandidates,
useSiteDiagnostics:=useSiteDiagnostics)
opSet.Free()
Return result
End Function
Public Shared Function ResolveUserDefinedBinaryOperator(
left As BoundExpression,
right As BoundExpression,
opKind As BinaryOperatorKind,
binder As Binder,
<[In], Out> ByRef useSiteDiagnostics As HashSet(Of DiagnosticInfo),
Optional includeEliminatedCandidates As Boolean = False
) As OverloadResolutionResult
Dim opSet = ArrayBuilder(Of MethodSymbol).GetInstance()
Select Case opKind
Case BinaryOperatorKind.Add
CollectUserDefinedOperators(left.Type, right.Type, MethodKind.UserDefinedOperator,
WellKnownMemberNames.AdditionOperatorName, New OperatorInfo(opKind),
Nothing, Nothing,
opSet, useSiteDiagnostics)
Case BinaryOperatorKind.Subtract
CollectUserDefinedOperators(left.Type, right.Type, MethodKind.UserDefinedOperator,
WellKnownMemberNames.SubtractionOperatorName, New OperatorInfo(opKind),
Nothing, Nothing,
opSet, useSiteDiagnostics)
Case BinaryOperatorKind.Multiply
CollectUserDefinedOperators(left.Type, right.Type, MethodKind.UserDefinedOperator,
WellKnownMemberNames.MultiplyOperatorName, New OperatorInfo(opKind),
Nothing, Nothing,
opSet, useSiteDiagnostics)
Case BinaryOperatorKind.Divide
CollectUserDefinedOperators(left.Type, right.Type, MethodKind.UserDefinedOperator,
WellKnownMemberNames.DivisionOperatorName, New OperatorInfo(opKind),
Nothing, Nothing,
opSet, useSiteDiagnostics)
Case BinaryOperatorKind.IntegerDivide
CollectUserDefinedOperators(left.Type, right.Type, MethodKind.UserDefinedOperator,
WellKnownMemberNames.IntegerDivisionOperatorName, New OperatorInfo(opKind),
Nothing, Nothing,
opSet, useSiteDiagnostics)
Case BinaryOperatorKind.Modulo
CollectUserDefinedOperators(left.Type, right.Type, MethodKind.UserDefinedOperator,
WellKnownMemberNames.ModulusOperatorName, New OperatorInfo(opKind),
Nothing, Nothing,
opSet, useSiteDiagnostics)
Case BinaryOperatorKind.Power
CollectUserDefinedOperators(left.Type, right.Type, MethodKind.UserDefinedOperator,
WellKnownMemberNames.ExponentOperatorName, New OperatorInfo(opKind),
Nothing, Nothing,
opSet, useSiteDiagnostics)
Case BinaryOperatorKind.Equals
CollectUserDefinedOperators(left.Type, right.Type, MethodKind.UserDefinedOperator,
WellKnownMemberNames.EqualityOperatorName, New OperatorInfo(opKind),
Nothing, Nothing,
opSet, useSiteDiagnostics)
Case BinaryOperatorKind.NotEquals
CollectUserDefinedOperators(left.Type, right.Type, MethodKind.UserDefinedOperator,
WellKnownMemberNames.InequalityOperatorName, New OperatorInfo(opKind),
Nothing, Nothing,
opSet, useSiteDiagnostics)
Case BinaryOperatorKind.LessThan
CollectUserDefinedOperators(left.Type, right.Type, MethodKind.UserDefinedOperator,
WellKnownMemberNames.LessThanOperatorName, New OperatorInfo(opKind),
Nothing, Nothing,
opSet, useSiteDiagnostics)
Case BinaryOperatorKind.GreaterThan
CollectUserDefinedOperators(left.Type, right.Type, MethodKind.UserDefinedOperator,
WellKnownMemberNames.GreaterThanOperatorName, New OperatorInfo(opKind),
Nothing, Nothing,
opSet, useSiteDiagnostics)
Case BinaryOperatorKind.LessThanOrEqual
CollectUserDefinedOperators(left.Type, right.Type, MethodKind.UserDefinedOperator,
WellKnownMemberNames.LessThanOrEqualOperatorName, New OperatorInfo(opKind),
Nothing, Nothing,
opSet, useSiteDiagnostics)
Case BinaryOperatorKind.GreaterThanOrEqual
CollectUserDefinedOperators(left.Type, right.Type, MethodKind.UserDefinedOperator,
WellKnownMemberNames.GreaterThanOrEqualOperatorName, New OperatorInfo(opKind),
Nothing, Nothing,
opSet, useSiteDiagnostics)
Case BinaryOperatorKind.Like
CollectUserDefinedOperators(left.Type, right.Type, MethodKind.UserDefinedOperator,
WellKnownMemberNames.LikeOperatorName, New OperatorInfo(opKind),
Nothing, Nothing,
opSet, useSiteDiagnostics)
Case BinaryOperatorKind.Concatenate
CollectUserDefinedOperators(left.Type, right.Type, MethodKind.UserDefinedOperator,
WellKnownMemberNames.ConcatenateOperatorName, New OperatorInfo(opKind),
Nothing, Nothing,
opSet, useSiteDiagnostics)
Case BinaryOperatorKind.And, BinaryOperatorKind.AndAlso
Dim opInfo As New OperatorInfo(opKind)
CollectUserDefinedOperators(left.Type, right.Type, MethodKind.UserDefinedOperator,
WellKnownMemberNames.BitwiseAndOperatorName, opInfo,
WellKnownMemberNames.LogicalAndOperatorName, opInfo,
opSet, useSiteDiagnostics)
Case BinaryOperatorKind.Or, BinaryOperatorKind.OrElse
Dim opInfo As New OperatorInfo(opKind)
CollectUserDefinedOperators(left.Type, right.Type, MethodKind.UserDefinedOperator,
WellKnownMemberNames.BitwiseOrOperatorName, opInfo,
WellKnownMemberNames.LogicalOrOperatorName, opInfo,
opSet, useSiteDiagnostics)
Case BinaryOperatorKind.Xor
CollectUserDefinedOperators(left.Type, right.Type, MethodKind.UserDefinedOperator,
WellKnownMemberNames.ExclusiveOrOperatorName, New OperatorInfo(opKind),
Nothing, Nothing,
opSet, useSiteDiagnostics)
Case BinaryOperatorKind.LeftShift
Dim opInfo As New OperatorInfo(opKind)
CollectUserDefinedOperators(left.Type, right.Type, MethodKind.UserDefinedOperator,
WellKnownMemberNames.LeftShiftOperatorName, opInfo,
WellKnownMemberNames.UnsignedLeftShiftOperatorName, opInfo,
opSet, useSiteDiagnostics)
Case BinaryOperatorKind.RightShift
Dim opInfo As New OperatorInfo(opKind)
CollectUserDefinedOperators(left.Type, right.Type, MethodKind.UserDefinedOperator,
WellKnownMemberNames.RightShiftOperatorName, opInfo,
WellKnownMemberNames.UnsignedRightShiftOperatorName, opInfo,
opSet, useSiteDiagnostics)
Case Else
Throw ExceptionUtilities.UnexpectedValue(opKind)
End Select
Dim result = OperatorInvocationOverloadResolution(opSet, left, right, binder, lateBindingIsAllowed:=True, includeEliminatedCandidates:=includeEliminatedCandidates,
useSiteDiagnostics:=useSiteDiagnostics)
opSet.Free()
Return result
End Function
Private Shared Function OperatorInvocationOverloadResolution(
opSet As ArrayBuilder(Of MethodSymbol),
argument1 As BoundExpression,
argument2 As BoundExpression,
binder As Binder,
lateBindingIsAllowed As Boolean,
includeEliminatedCandidates As Boolean,
<[In], Out> ByRef useSiteDiagnostics As HashSet(Of DiagnosticInfo)
) As OverloadResolutionResult
If opSet.Count = 0 Then
If lateBindingIsAllowed Then
Return New OverloadResolutionResult(ImmutableArray(Of CandidateAnalysisResult).Empty,
argument1.Type.IsObjectType OrElse argument2.Type.IsObjectType,
False,
asyncLambdaSubToFunctionMismatch:=Nothing)
Else
Return New OverloadResolutionResult(ImmutableArray(Of CandidateAnalysisResult).Empty, False, False, asyncLambdaSubToFunctionMismatch:=Nothing)
End If
End If
Dim nullableOfT As NamedTypeSymbol = opSet(0).ContainingAssembly.GetSpecialType(SpecialType.System_Nullable_T)
Dim liftOperators As Boolean = nullableOfT.GetUseSiteErrorInfo() Is Nothing
Dim candidates = ArrayBuilder(Of CandidateAnalysisResult).GetInstance()
For Each method In opSet
Debug.Assert(method.ParameterCount = If(argument2 Is Nothing, 1, 2))
Debug.Assert(method.Arity = 0)
Debug.Assert(Not method.IsSub)
If method.HasUnsupportedMetadata Then
If includeEliminatedCandidates Then
candidates.Add(New CandidateAnalysisResult(New OperatorCandidate(method), CandidateAnalysisResultState.HasUnsupportedMetadata))
End If
Continue For
End If
Dim useSiteErrorInfo As DiagnosticInfo = method.GetUseSiteErrorInfo()
If useSiteErrorInfo IsNot Nothing Then
If useSiteDiagnostics Is Nothing Then
useSiteDiagnostics = New HashSet(Of DiagnosticInfo)()
End If
useSiteDiagnostics.Add(useSiteErrorInfo)
If includeEliminatedCandidates Then
candidates.Add(New CandidateAnalysisResult(New OperatorCandidate(method), CandidateAnalysisResultState.HasUseSiteError))
End If
Continue For
End If
CombineCandidates(candidates, New CandidateAnalysisResult(New OperatorCandidate(method)), method.ParameterCount, Nothing, useSiteDiagnostics)
If liftOperators Then
Dim param1 As ParameterSymbol = method.Parameters(0)
Dim type1 As TypeSymbol = param1.Type
Dim isNullable1 As Boolean = type1.IsNullableType()
Dim canLift1 As Boolean = Not isNullable1 AndAlso type1.IsValueType() AndAlso Not type1.IsRestrictedType()
Dim param2 As ParameterSymbol = Nothing
Dim type2 As TypeSymbol = Nothing
Dim isNullable2 As Boolean = False
Dim canLift2 As Boolean = False
If argument2 IsNot Nothing AndAlso Not isNullable1 Then
param2 = method.Parameters(1)
type2 = param2.Type
isNullable2 = type2.IsNullableType()
canLift2 = Not isNullable2 AndAlso type2.IsValueType() AndAlso Not type2.IsRestrictedType()
End If
If (canLift1 OrElse canLift2) AndAlso Not isNullable1 AndAlso Not isNullable2 Then
' Should lift this operator.
If canLift1 Then
param1 = LiftParameterSymbol(param1, nullableOfT)
End If
If canLift2 Then
param2 = LiftParameterSymbol(param2, nullableOfT)
End If
Dim returnType As TypeSymbol = method.ReturnType
If CanLiftType(returnType) Then
returnType = nullableOfT.Construct(returnType)
End If
CombineCandidates(candidates,
New CandidateAnalysisResult(New LiftedOperatorCandidate(method,
If(argument2 Is Nothing,
ImmutableArray.Create(param1),
ImmutableArray.Create(Of ParameterSymbol)(param1, param2)),
returnType)),
method.ParameterCount, Nothing, useSiteDiagnostics)
End If
End If
Next
' TODO: Need to get rid of dependency on method group. For now create fake one.
Dim methodGroup = New BoundMethodGroup(argument1.Syntax, Nothing, ImmutableArray(Of MethodSymbol).Empty, LookupResultKind.Good, Nothing, QualificationKind.Unqualified)
Dim result As OverloadResolutionResult = ResolveOverloading(methodGroup, candidates,
If(argument2 Is Nothing,
ImmutableArray.Create(argument1),
ImmutableArray.Create(Of BoundExpression)(argument1, argument2)),
Nothing, Nothing, lateBindingIsAllowed, binder:=binder,
asyncLambdaSubToFunctionMismatch:=Nothing,
callerInfoOpt:=Nothing, forceExpandedForm:=False,
useSiteDiagnostics:=useSiteDiagnostics)
candidates.Free()
Return result
End Function
Friend Shared Function CanLiftType(type As TypeSymbol) As Boolean
Return Not type.IsNullableType AndAlso type.IsValueType() AndAlso Not type.IsRestrictedType()
End Function
Friend Shared Function IsValidInLiftedSignature(type As TypeSymbol) As Boolean
Return type.IsNullableType() ' Note, Dev11 has changed implementation of this function, I've taken this into account.
End Function
Private Shared Function LiftParameterSymbol(param As ParameterSymbol, nullableOfT As NamedTypeSymbol) As ParameterSymbol
If param.IsDefinition Then
Return New LiftedParameterSymbol(param, nullableOfT.Construct(param.Type))
Else
Dim definition As ParameterSymbol = param.OriginalDefinition
Return SubstitutedParameterSymbol.CreateMethodParameter(DirectCast(param.ContainingSymbol, SubstitutedMethodSymbol),
New LiftedParameterSymbol(definition, nullableOfT.Construct(definition.Type)))
End If
End Function
Private NotInheritable Class LiftedParameterSymbol
Inherits ParameterSymbol
Private ReadOnly m_ParameterToLift As ParameterSymbol
Private ReadOnly m_Type As TypeSymbol
Public Sub New(parameter As ParameterSymbol, type As TypeSymbol)
Debug.Assert(parameter.IsDefinition)
Debug.Assert(type.IsNullableType())
m_ParameterToLift = parameter
m_Type = type
End Sub
Public Overrides ReadOnly Property Name As String
Get
Return m_ParameterToLift.Name
End Get
End Property
Friend Overrides Function GetUseSiteErrorInfo() As DiagnosticInfo
Return m_ParameterToLift.GetUseSiteErrorInfo()
End Function
Public Overrides ReadOnly Property ContainingSymbol As Symbol
Get
Return m_ParameterToLift.ContainingSymbol
End Get
End Property
Public Overrides ReadOnly Property CustomModifiers As ImmutableArray(Of CustomModifier)
Get
Return m_ParameterToLift.CustomModifiers
End Get
End Property
Public Overrides ReadOnly Property DeclaringSyntaxReferences As ImmutableArray(Of SyntaxReference)
Get
Return ImmutableArray(Of SyntaxReference).Empty
End Get
End Property
Friend Overrides ReadOnly Property ExplicitDefaultConstantValue(inProgress As SymbolsInProgress(Of ParameterSymbol)) As ConstantValue
Get
Return m_ParameterToLift.ExplicitDefaultConstantValue(inProgress)
End Get
End Property
Public Overrides ReadOnly Property HasExplicitDefaultValue As Boolean
Get
Return m_ParameterToLift.HasExplicitDefaultValue
End Get
End Property
Public Overrides ReadOnly Property IsByRef As Boolean
Get
Return m_ParameterToLift.IsByRef
End Get
End Property
Friend Overrides ReadOnly Property IsExplicitByRef As Boolean
Get
Return m_ParameterToLift.IsExplicitByRef
End Get
End Property
Public Overrides ReadOnly Property IsOptional As Boolean
Get
Return m_ParameterToLift.IsOptional
End Get
End Property
Friend Overrides ReadOnly Property IsMetadataOut As Boolean
Get
Return m_ParameterToLift.IsMetadataOut
End Get
End Property
Friend Overrides ReadOnly Property IsMetadataIn As Boolean
Get
Return m_ParameterToLift.IsMetadataIn
End Get
End Property
Friend Overrides ReadOnly Property MarshallingInformation As MarshalPseudoCustomAttributeData
Get
Return m_ParameterToLift.MarshallingInformation
End Get
End Property
Friend Overrides ReadOnly Property HasOptionCompare As Boolean
Get
Return m_ParameterToLift.HasOptionCompare
End Get
End Property
Friend Overrides ReadOnly Property IsIDispatchConstant As Boolean
Get
Return m_ParameterToLift.IsIDispatchConstant
End Get
End Property
Friend Overrides ReadOnly Property IsIUnknownConstant As Boolean
Get
Return m_ParameterToLift.IsIUnknownConstant
End Get
End Property
Friend Overrides ReadOnly Property IsCallerLineNumber As Boolean
Get
Return m_ParameterToLift.IsCallerLineNumber
End Get
End Property
Friend Overrides ReadOnly Property IsCallerMemberName As Boolean
Get
Return m_ParameterToLift.IsCallerMemberName
End Get
End Property
Friend Overrides ReadOnly Property IsCallerFilePath As Boolean
Get
Return m_ParameterToLift.IsCallerFilePath
End Get
End Property
Friend Overrides ReadOnly Property HasByRefBeforeCustomModifiers As Boolean
Get
Return m_ParameterToLift.HasByRefBeforeCustomModifiers
End Get
End Property
Public Overrides ReadOnly Property IsParamArray As Boolean
Get
Return m_ParameterToLift.IsParamArray
End Get
End Property
Public Overrides ReadOnly Property Locations As ImmutableArray(Of Location)
Get
Return ImmutableArray(Of Location).Empty
End Get
End Property
Public Overrides ReadOnly Property Ordinal As Integer
Get
Return m_ParameterToLift.Ordinal
End Get
End Property
Public Overrides ReadOnly Property Type As TypeSymbol
Get
Return m_Type
End Get
End Property
End Class
End Class
End Namespace
|
ManishJayaswal/roslyn
|
src/Compilers/VisualBasic/Portable/Semantics/Operators.vb
|
Visual Basic
|
apache-2.0
| 184,364
|
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.CodeActions
Imports Microsoft.CodeAnalysis.Formatting
Imports Microsoft.CodeAnalysis.Simplification
Imports System.Threading
Namespace TestHelper
' Diagnostic Producer class with extra methods dealing with applying codefixes
' All methods are shared
Partial Public MustInherit Class CodeFixVerifier
Inherits DiagnosticVerifier
''' <summary>
''' Apply the inputted CodeAction to the inputted document.
''' Meant to be used to apply codefixes.
''' </summary>
''' <param name="document">The Document to apply the fix on</param>
''' <param name="codeAction">A CodeAction that will be applied to the Document.</param>
''' <returns>A Document with the changes from the CodeAction</returns>
Private Shared Function ApplyFix(document As Document, codeAction As CodeAction) As Document
Dim operations = codeAction.GetOperationsAsync(CancellationToken.None).Result
Dim solution = operations.OfType(Of ApplyChangesOperation).Single.ChangedSolution
Return solution.GetDocument(document.Id)
End Function
''' <summary>
''' Compare two collections of Diagnostics, and return a list of any New diagnostics that appear only in the second collection.
''' Note: Considers Diagnostics to be the same if they have the same Ids. In the case of mulitple diagnostics With the same Id In a row,
''' this method may not necessarily return the new one.
''' </summary>
''' <param name="diagnostics">The Diagnostics that existed in the code before the CodeFix was applied</param>
''' <param name="newDiagnostics">The Diagnostics that exist in the code after the CodeFix was applied</param>
''' <returns>A list of Diagnostics that only surfaced in the code after the CodeFix was applied</returns>
Private Shared Iterator Function GetNewDiagnostics(diagnostics As IEnumerable(Of Diagnostic), newDiagnostics As IEnumerable(Of Diagnostic)) As IEnumerable(Of Diagnostic)
Dim oldArray = diagnostics.OrderBy(Function(d) d.Location.SourceSpan.Start).ToArray()
Dim newArray = newDiagnostics.OrderBy(Function(d) d.Location.SourceSpan.Start).ToArray()
Dim oldIndex = 0
Dim newIndex = 0
While (newIndex < newArray.Length)
If (oldIndex < oldArray.Length AndAlso oldArray(oldIndex).Id = newArray(newIndex).Id) Then
oldIndex += 1
newIndex += 1
Else
Yield newArray(newIndex)
newIndex += 1
End If
End While
End Function
''' <summary>
''' Get the existing compiler diagnostics on the inputted document.
''' </summary>
''' <param name="document">The Document to run the compiler diagnostic analyzers on</param>
''' <returns>The compiler diagnostics that were found in the code</returns>
Private Shared Function GetCompilerDiagnostics(document As Document) As IEnumerable(Of Diagnostic)
Return document.GetSemanticModelAsync().Result.GetDiagnostics()
End Function
''' <summary>
''' Given a Document, turn it into a string based on the syntax root
''' </summary>
''' <param name="document">The Document to be converted to a string</param>
''' <returns>A string containing the syntax of the Document after formatting</returns>
Private Shared Function GetStringFromDocument(document As Document) As String
Dim simplifiedDoc = Simplifier.ReduceAsync(document, Simplifier.Annotation).Result
Dim root = simplifiedDoc.GetSyntaxRootAsync().Result
root = Formatter.Format(root, Formatter.Annotation, simplifiedDoc.Project.Solution.Workspace)
Return root.GetText().ToString()
End Function
End Class
End Namespace
|
DotNetAnalyzers/DotNetAnalyzers
|
Analyzer_Constructor_Mis-Assignment/Analyzer_VB/Analyzer_VB.Test/Helpers/CodeFixVerifier.Helper.vb
|
Visual Basic
|
mit
| 3,723
|
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Media
Imports ESRI.ArcGIS.Client
Imports ESRI.ArcGIS.Client.Toolkit.DataSources
Imports ESRI.ArcGIS.Client.WebMap
Partial Public Class WebMapKML
Inherits UserControl
Public Sub New()
InitializeComponent()
Dim webMap As New Document()
AddHandler webMap.GetMapCompleted, AddressOf webMap_GetMapCompleted
webMap.ProxyUrl = "http://servicesbeta3.esri.com/SilverlightDemos/ProxyPage/proxy.ashx"
webMap.GetMapAsync("d2cb7cac8b1947c7b57ed8edd6b045bb")
End Sub
Private Sub webMap_GetMapCompleted(ByVal sender As Object, ByVal e As GetMapCompletedEventArgs)
If e.Error Is Nothing Then
For Each layer As Layer In e.Map.Layers
If TypeOf layer Is KmlLayer Then
AddHandler TryCast(layer, KmlLayer).Initialized, AddressOf kmllayer_Initialized
End If
Next layer
e.Map.WrapAround = True
LayoutRoot.Children.Add(e.Map)
End If
End Sub
Private Sub kmllayer_Initialized(ByVal sender As Object, ByVal e As System.EventArgs)
For Each layer As Layer In (TryCast(sender, KmlLayer)).ChildLayers
layer.Visible = True
Dim border As New Border() With {.Background = New SolidColorBrush(Colors.White), .BorderBrush = New SolidColorBrush(Colors.Black), .BorderThickness = New Thickness(1), .CornerRadius = New CornerRadius(5)}
Dim stackPanelChild As New StackPanel() With {.Orientation = Orientation.Horizontal, .Margin = New Thickness(5)}
Dim textValue As New TextBlock()
Dim valueBinding As New Binding(String.Format("[{0}]", "name"))
textValue.SetBinding(TextBlock.TextProperty, valueBinding)
stackPanelChild.Children.Add(textValue)
border.Child = stackPanelChild
TryCast(layer, KmlLayer).MapTip = border
Next layer
End Sub
End Class
|
MrChen2015/arcgis-samples-silverlight
|
src/VBNet/ArcGISSilverlightSDK/WebMaps/WebMapKML.xaml.vb
|
Visual Basic
|
apache-2.0
| 1,881
|
' Licensed to the .NET Foundation under one or more agreements.
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.
Imports Microsoft.CodeAnalysis.Editor.Shared.Options
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Extensions
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Utilities
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Imports Microsoft.CodeAnalysis.Editor.VisualBasic.ImplementInterface
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.VisualStudio.Commanding
Imports Microsoft.VisualStudio.Text
Imports Microsoft.VisualStudio.Text.Editor
Imports Microsoft.VisualStudio.Text.Editor.Commanding.Commands
Imports Microsoft.VisualStudio.Text.Operations
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.ImplementInterface
<[UseExportProvider]>
Public Class ImplementInterfaceCommandHandlerTests
Private Sub Test(code As XElement, expectedText As XElement, nextHandler As Action(Of IWpfTextView, TestWorkspace), assertion As Action(Of String, String, IWpfTextView))
Using workspace = GetWorkspace(code.NormalizedValue)
Dim commandHandler = MoveCaretAndCreateCommandHandler(workspace)
Dim view = workspace.Documents.Single().GetTextView()
commandHandler.ExecuteCommand(New ReturnKeyCommandArgs(view, view.TextBuffer), Sub() nextHandler(view, workspace), TestCommandExecutionContext.Create())
Dim text = view.TextBuffer.CurrentSnapshot.AsText().ToString()
assertion(expectedText.NormalizedValue, text, view)
End Using
End Sub
Private Shared Function MoveCaretAndCreateCommandHandler(workspace As TestWorkspace) As ICommandHandler(Of ReturnKeyCommandArgs)
Dim document = workspace.Documents.Single()
Dim view = document.GetTextView()
Dim cursorPosition = document.CursorPosition.Value
view.Caret.MoveTo(New SnapshotPoint(view.TextBuffer.CurrentSnapshot, cursorPosition))
Return New ImplementInterfaceCommandHandler(workspace.GetService(Of IEditorOperationsFactoryService))
End Function
Private Function GetWorkspace(code As String) As TestWorkspace
Return TestWorkspace.Create(
<Workspace>
<Project Language="Visual Basic" AssemblyName="Assembly" CommonReferences="true">
<Document>
<%= code.Replace(vbCrLf, vbLf) %>
</Document>
</Project>
</Workspace>)
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)>
Public Sub FeatureDoesNothingIfDisabled()
Using workspace = GetWorkspace("
Imports System
Class Goo
Implements IGoo$$
End Class
Interface IGoo
Sub TestSub()
End Interface")
Dim commandHandler = MoveCaretAndCreateCommandHandler(workspace)
workspace.TryApplyChanges(workspace.CurrentSolution.WithOptions(workspace.Options _
.WithChangedOption(FeatureOnOffOptions.AutomaticInsertionOfAbstractOrInterfaceMembers, LanguageNames.VisualBasic, False)))
Dim nextHandlerCalled = False
Dim view = workspace.Documents.Single().GetTextView()
commandHandler.ExecuteCommand(New ReturnKeyCommandArgs(view, view.TextBuffer), Sub() nextHandlerCalled = True, TestCommandExecutionContext.Create())
Assert.True(nextHandlerCalled, "Next handler wasn't called, which means the feature did run")
End Using
End Sub
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)>
Public Sub TestInterfaceWithSingleSub()
Dim code = <text>
Imports System
Class Goo
Implements IGoo$$
End Class
Interface IGoo
Sub TestSub()
End Interface</text>
Dim expectedText = <text>
Public Sub TestSub() Implements IGoo.TestSub
Throw New NotImplementedException()
End Sub</text>
Test(code,
expectedText,
Sub() Throw New Exception("The operation should have been handled."),
Sub(expected, actual, view) AssertEx.AssertContainsToleratingWhitespaceDifferences(expected, actual))
End Sub
<WorkItem(544161, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544161")>
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)>
Public Sub TestInterfacesWithDuplicateMember()
Dim code = <text>
Interface IGoo
Sub Goo()
End Interface
Interface IBar
Sub Goo()
End Interface
Class Zip
Implements IGoo, IBar$$
End Class</text>
Dim expectedText = <text>
Public Sub Goo() Implements IGoo.Goo
Throw New NotImplementedException()
End Sub
Private Sub IBar_Goo() Implements IBar.Goo
Throw New NotImplementedException()
End Sub</text>
Test(code,
expectedText,
Sub() Throw New Exception("The operation should have been handled."),
Sub(expected, actual, view) AssertEx.AssertContainsToleratingWhitespaceDifferences(expected, actual))
End Sub
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)>
Public Sub TestInterfaceWithManyMembers()
Dim code = <text>
Imports System
Class Goo
Implements IGoo$$
End Class
Interface IGoo
Sub TestSub()
Function TestFunc() As Integer
Property TestProperty As String
End Interface</text>
Dim expectedText = <text>
Public Property TestProperty As String Implements IGoo.TestProperty
Get
Throw New NotImplementedException()
End Get
Set(value As String)
Throw New NotImplementedException()
End Set
End Property
Public Sub TestSub() Implements IGoo.TestSub
Throw New NotImplementedException()
End Sub
Public Function TestFunc() As Integer Implements IGoo.TestFunc
Throw New NotImplementedException()
End Function</text>
Test(code,
expectedText,
Sub() Throw New Exception("The operation should have been handled."),
Sub(expected, actual, view) AssertEx.AssertContainsToleratingWhitespaceDifferences(expected, actual))
End Sub
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)>
Public Sub TestMultipleInterfaces()
Dim code = <text>
Imports System
Class Goo
Implements IGoo, IBar$$
End Class
Interface IGoo
Sub TestSub()
End Interface
Interface IBar
Function TestFunc() As Integer
End Interface</text>
Dim expectedText = <text>
Public Sub TestSub() Implements IGoo.TestSub
Throw New NotImplementedException()
End Sub
Public Function TestFunc() As Integer Implements IBar.TestFunc
Throw New NotImplementedException()
End Function</text>
Test(code,
expectedText,
Sub() Throw New Exception("The operation should have been handled."),
Sub(expected, actual, view) AssertEx.AssertContainsToleratingWhitespaceDifferences(expected, actual))
End Sub
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)>
Public Sub TestWrongCursorPlacement()
Dim code = <text>
Imports System
Class Goo
Implements IGoo$$, IBar
End Class
Interface IGoo
Sub TestSub()
End Interface
Interface IBar
Function TestFunc() As Integer
End Interface</text>
Dim expectedText = <text>
Class Goo
Implements IGoo
, IBar
End Class</text>
Test(code,
expectedText,
Sub(view, workspace)
Dim operations = workspace.GetService(Of IEditorOperationsFactoryService)() _
.GetEditorOperations(view)
operations.InsertNewLine()
End Sub,
Sub(expected, actual, view) AssertEx.AssertContainsToleratingWhitespaceDifferences(expected, actual))
End Sub
<WorkItem(530553, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530553")>
<WorkItem(544087, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544087")>
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)>
Public Sub TestInvocationAfterWhitespaceTrivia()
Dim code = <text>
Imports System
Class Goo
Implements IGoo $$
End Class
Interface IGoo
Sub TestSub()
End Interface</text>
Dim expectedText = <text>
Public Sub TestSub() Implements IGoo.TestSub
Throw New NotImplementedException()
End Sub</text>
Test(code,
expectedText,
Sub() Throw New Exception("The operation should have been handled."),
Sub(expected, actual, view) AssertEx.AssertContainsToleratingWhitespaceDifferences(expected, actual))
End Sub
<WorkItem(544089, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544089")>
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)>
Public Sub TestInvocationAfterCommentTrivia()
Dim code = <text>
Imports System
Class Goo
Implements IGoo 'Comment $$
End Class
Interface IGoo
Sub TestSub()
End Interface</text>
Dim expectedText = <text>
Public Sub TestSub() Implements IGoo.TestSub
Throw New NotImplementedException()
End Sub</text>
Test(code,
expectedText,
Sub() Throw New Exception("The operation should have been handled."),
Sub(expected, actual, view) AssertEx.AssertContainsToleratingWhitespaceDifferences(expected, actual))
End Sub
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)>
Public Sub TestNoMembersToImplement()
Dim code = <text>
Class Goo
Implements IGoo$$
End Class
Interface IGoo
End Interface</text>
Dim expectedText = <text>
Class Goo
Implements IGoo
End Class
Interface IGoo
End Interface</text>
Test(code,
expectedText,
Sub(view, workspace)
Dim operations = workspace.GetService(Of IEditorOperationsFactoryService)() _
.GetEditorOperations(view)
operations.InsertNewLine()
End Sub,
Sub(expected, actual, view) Assert.Equal(expected.Trim(), actual.Trim()))
End Sub
<WorkItem(544211, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544211")>
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)>
Public Sub TestWithEndBlockMissing()
Dim code = <text>
Imports System
Class Goo
Implements ICloneable$$
</text>
Dim expectedText = <text>
Imports System
Class Goo
Implements ICloneable
Public Function Clone() As Object Implements ICloneable.Clone
Throw New NotImplementedException()
End Function
End Class</text>
Test(code,
expectedText,
Sub() Throw New Exception("The operation should have been handled."),
Sub(expected, actual, view) AssertEx.AssertEqualToleratingWhitespaceDifferences(expected, actual))
End Sub
<WorkItem(529302, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/529302")>
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)>
Public Sub TestWithEndBlockMissing2()
Dim code = <text>
Imports System
Class Goo
Implements ICloneable$$
Interface IGoo
End Interface</text>
Dim expectedText = <text>
Imports System
Class Goo
Implements ICloneable
Public Function Clone() As Object Implements ICloneable.Clone
Throw New NotImplementedException()
End Function
Interface IGoo
End Interface
End Class</text>
Test(code,
expectedText,
Sub() Throw New Exception("The operation should have been handled."),
Sub(expected, actual, view) AssertEx.AssertEqualToleratingWhitespaceDifferences(expected, actual))
End Sub
<WorkItem(530553, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530553")>
<WorkItem(529337, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/529337")>
<WorkItem(674621, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/674621")>
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)>
Public Sub TestWithStatementSeparator()
Dim code = <text>
Imports System
Interface IGoo
Sub Goo()
End Interface
Class CGoo : Implements IGoo$$ : End Class
</text>
Dim expectedText = <text>
Imports System
Interface IGoo
Sub Goo()
End Interface
Class CGoo : Implements IGoo
Public Sub Goo() Implements IGoo.Goo
Throw New NotImplementedException()
End Sub
End Class
</text>
Test(code,
expectedText,
Sub(view, workspace)
Dim operations = workspace.GetService(Of IEditorOperationsFactoryService)() _
.GetEditorOperations(view)
operations.InsertNewLine()
End Sub,
Sub(expected, actual, view) AssertEx.AssertEqualToleratingWhitespaceDifferences(expected, actual))
End Sub
<WorkItem(529360, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/529360")>
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)>
Public Sub TestCursorNotOnSameLine()
Dim code = <text>
Imports System
Interface IGoo
Sub FogBar()
End Interface
Public Class Bar
Implements IGoo
$$End Class
</text>
Dim expectedText = <text>
Imports System
Interface IGoo
Sub FogBar()
End Interface
Public Class Bar
Implements IGoo
End Class
</text>
Test(code,
expectedText,
Sub(view, workspace)
Dim operations = workspace.GetService(Of IEditorOperationsFactoryService)() _
.GetEditorOperations(view)
operations.InsertNewLine()
End Sub,
Sub(expected, actual, view) AssertEx.AssertEqualToleratingWhitespaceDifferences(expected, actual))
End Sub
<WorkItem(529722, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/529722")>
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)>
Public Sub TestCursorPlacedOnBlankLineAfter()
Dim code = <text>
Imports System
Public Class Bar
Implements ICloneable$$
End Class
</text>
Dim expectedText = <text>
Imports System
Public Class Bar
Implements ICloneable
Public Function Clone() As Object Implements ICloneable.Clone
Throw New NotImplementedException()
End Function
End Class
</text>
Test(code,
expectedText,
Sub(view, workspace)
Dim operations = workspace.GetService(Of IEditorOperationsFactoryService)() _
.GetEditorOperations(view)
operations.InsertNewLine()
End Sub,
Sub(expected, actual, view)
AssertEx.AssertEqualToleratingWhitespaceDifferences(expected, actual)
Assert.Equal(4, view.Caret.Position.BufferPosition.GetContainingLine().LineNumber)
Assert.Equal(4, view.Caret.Position.VirtualSpaces)
End Sub)
End Sub
<WorkItem(545867, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545867")>
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)>
Public Sub TestMultipleImplementationWithCaseDifference()
Dim code = <text>
Interface IA
Sub goo()
End Interface
Interface IB
Sub Goo()
End Interface
Class C
Implements IA, IB$$
End Class</text>
Dim expectedText = <text>
Class C
Implements IA, IB
Public Sub goo() Implements IA.goo
Throw New NotImplementedException()
End Sub
Private Sub IB_Goo() Implements IB.Goo
Throw New NotImplementedException()
End Sub
End Class</text>
Test(code,
expectedText,
Sub() Throw New Exception("The operation should have been handled."),
Sub(expected, actual, view) AssertEx.AssertContainsToleratingWhitespaceDifferences(expected, actual))
End Sub
<WorkItem(927478, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/927478")>
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)>
Public Sub TestFullyQualifiedName()
Dim code = <text>
Namespace N
Interface IA
Sub goo()
End Interface
End Namespace
Class C
Implements N.IA$$
End Class</text>
Dim expectedText = <text>
Class C
Implements N.IA
Public Sub goo() Implements IA.goo
Throw New NotImplementedException()
End Sub
End Class</text>
Test(code,
expectedText,
Sub() Throw New Exception("The operation should have been handled."),
Sub(expected, actual, view) AssertEx.AssertContainsToleratingWhitespaceDifferences(expected, actual))
End Sub
End Class
End Namespace
|
abock/roslyn
|
src/EditorFeatures/VisualBasicTest/ImplementInterface/ImplementInterfaceCommandHandlerTests.vb
|
Visual Basic
|
mit
| 17,839
|
'*******************************************************************************************'
' '
' Download Free Evaluation Version From: https://bytescout.com/download/web-installer '
' '
' Also available as Web API! Get free API Key https://app.pdf.co/signup '
' '
' Copyright © 2017-2020 ByteScout, Inc. All rights reserved. '
' https://www.bytescout.com '
' https://www.pdf.co '
'*******************************************************************************************'
Imports Bytescout.PDFExtractor
Class Program
Friend Shared Sub Main(args As String())
' Create Bytescout.PDFExtractor.XMLExtractor instance
Dim xmlExtractor As New XMLExtractor()
xmlExtractor.RegistrationName = "demo"
xmlExtractor.RegistrationKey = "demo"
' Create Bytescout.PDFExtractor.TableDetector instance
Dim tableDetector As New TableDetector()
tableDetector.RegistrationName = "demo"
tableDetector.RegistrationKey = "demo"
' We should define what kind of tables we should detect.
' So we set min required number of columns to 3 ...
tableDetector.DetectionMinNumberOfColumns = 3
' ... and we set min required number of rows to 3
tableDetector.DetectionMinNumberOfRows = 3
' Load sample PDF document
xmlExtractor.LoadDocumentFromFile(".\sample3.pdf")
tableDetector.LoadDocumentFromFile(".\sample3.pdf")
' Get page count
Dim pageCount As Integer = tableDetector.GetPageCount()
For i As Integer = 0 To pageCount - 1
Dim t As Integer = 1
' Find first table and continue if found
If (tableDetector.FindTable(i)) Then
Do
' Set extraction area for XML extractor to rectangle received from the table detector
xmlExtractor.SetExtractionArea(tableDetector.FoundTableLocation)
' Export the table to XML file
xmlExtractor.SavePageXMLToFile(i, "page-" + i.ToString() + "-table-" + t.ToString() + ".xml")
t = t + 1
Loop While tableDetector.FindNextTable()
End If
Next
' Cleanup
xmlExtractor.Dispose()
tableDetector.Dispose()
' Open first output file in default associated application (for demo purposes)
System.Diagnostics.Process.Start("page-0-table-1.xml")
End Sub
End Class
|
bytescout/ByteScout-SDK-SourceCode
|
Premium Suite/VB.NET/Find table in pdf and extract as xml with pdf extractor sdk/Program.vb
|
Visual Basic
|
apache-2.0
| 2,927
|
' Licensed to the .NET Foundation under one or more agreements.
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.
Imports Microsoft.CodeAnalysis.CodeRefactorings
Imports Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.CodeRefactorings
Imports Microsoft.CodeAnalysis.VisualBasic.InvertIf
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.InvertIf
Public Class InvertMultiLineIfTests
Inherits AbstractVisualBasicCodeActionTest
Protected Overrides Function CreateCodeRefactoringProvider(workspace As Workspace, parameters As TestParameters) As CodeRefactoringProvider
Return New VisualBasicInvertMultiLineIfCodeRefactoringProvider()
End Function
Public Async Function TestFixOneAsync(initial As String, expected As String, Optional parseOptions As ParseOptions = Nothing) As Task
Await TestInRegularAndScriptAsync(CreateTreeText(initial), CreateTreeText(expected), parseOptions:=parseOptions)
End Function
Public Shared Function CreateTreeText(initial As String) As String
Return "
Module Module1
Sub Main()
Dim a As Boolean = True
Dim b As Boolean = True
Dim c As Boolean = True
Dim d As Boolean = True
" + initial + "
End Sub
Private Sub aMethod()
End Sub
Private Sub bMethod()
End Sub
Private Sub cMethod()
End Sub
Private Sub dMethod()
End Sub
End Module
"
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
Public Async Function TestMultiLineIdentifier() As Task
Await TestFixOneAsync(
"
[||]If a Then
aMethod()
Else
bMethod()
End If
",
"
If Not a Then
bMethod()
Else
aMethod()
End If
")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
Public Async Function TestElseIf() As Task
Await TestMissingInRegularAndScriptAsync(
"
Sub Main()
If a Then
aMethod()
[||]ElseIf b Then
bMethod()
Else
cMethod()
End If
End Sub
End Module")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
Public Async Function TestKeepElseIfKeyword() As Task
Await TestMissingInRegularAndScriptAsync(
"Module Program
Sub Main()
If a Then
aMethod()
[||]ElseIf b Then
bMethod()
Else
cMethod()
End If
End Sub
End Module")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
Public Async Function TestMissingOnIfElseIfElse() As Task
Await TestMissingInRegularAndScriptAsync(
"Module Program
Sub Main()
I[||]f a Then
aMethod()
Else If b Then
bMethod()
Else
cMethod()
End If
End Sub
End Module")
End Function
<WorkItem(35525, "https://github.com/dotnet/roslyn/issues/35525")>
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
Public Async Function TestSelection() As Task
Await TestFixOneAsync(
"
[|If a Then
aMethod()
Else
bMethod()
End If|]
",
"
If Not a Then
bMethod()
Else
aMethod()
End If
")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
Public Async Function TestDoesNotOverlapHiddenPosition1() As Task
Await TestInRegularAndScriptAsync(
"Module Program
Sub Main()
#End ExternalSource
goo()
#ExternalSource File.vb 1
[||]If a Then
aMethod()
Else
bMethod()
End If
End Sub
End Module",
"Module Program
Sub Main()
#End ExternalSource
goo()
#ExternalSource File.vb 1
If Not a Then
bMethod()
Else
aMethod()
End If
End Sub
End Module")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
Public Async Function TestDoesNotOverlapHiddenPosition2() As Task
Await TestInRegularAndScriptAsync(
"Module Program
Sub Main()
#ExternalSource File.vb 1
[||]If a Then
aMethod()
Else
bMethod()
End If
#End ExternalSource
End Sub
End Module",
"Module Program
Sub Main()
#ExternalSource File.vb 1
If Not a Then
bMethod()
Else
aMethod()
End If
#End ExternalSource
End Sub
End Module")
End Function
<WorkItem(529624, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/529624")>
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
Public Async Function TestMissingOnOverlapsHiddenPosition1() As Task
Await TestMissingInRegularAndScriptAsync(
"Module Program
Sub Main()
[||]If a Then
#ExternalSource File.vb 1
aMethod()
#End ExternalSource
Else
bMethod()
End If
End Sub
End Module")
End Function
<WorkItem(529624, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/529624")>
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
Public Async Function TestMissingOnOverlapsHiddenPosition2() As Task
Await TestMissingInRegularAndScriptAsync(
"Module Program
Sub Main()
If a Then
aMethod()
[||]Else If b Then
#ExternalSource File.vb 1
bMethod()
#End ExternalSource
Else
cMethod()
End If
End Sub
End Module")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
Public Async Function TestMissingOnOverlapsHiddenPosition3() As Task
Await TestMissingInRegularAndScriptAsync(
"Module Program
Sub Main()
[||]If a Then
aMethod()
#ExternalSource File.vb 1
Else If b Then
bMethod()
#End ExternalSource
Else
cMethod()
End If
End Sub
End Module")
End Function
<WorkItem(529624, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/529624")>
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
Public Async Function TestMissingOnOverlapsHiddenPosition4() As Task
Await TestMissingInRegularAndScriptAsync(
"Module Program
Sub Main()
[||]If a Then
aMethod()
Else
#ExternalSource File.vb 1
bMethod()
#End ExternalSource
End If
End Sub
End Module")
End Function
<WorkItem(529624, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/529624")>
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
Public Async Function TestMissingOnOverlapsHiddenPosition5() As Task
Await TestMissingInRegularAndScriptAsync(
"Module Program
Sub Main()
[||]If a Then
#ExternalSource File.vb 1
aMethod()
Else
bMethod()
#End ExternalSource
End If
End Sub
End Module")
End Function
<WorkItem(529624, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/529624")>
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
Public Async Function TestMissingOnOverlapsHiddenPosition6() As Task
Await TestMissingInRegularAndScriptAsync(
"Module Program
Sub Main()
[||]If a Then
aMethod()
#ExternalSource File.vb 1
Else
#End ExternalSource
bMethod()
End If
End Sub
End Module")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
Public Async Function TestMultipleStatementsMultiLineIfBlock() As Task
Await TestInRegularAndScriptAsync(
"Module Program
Sub Main()
[||]If a Then
goo()
bar()
Else
you()
too()
End If
End Sub
End Module",
"Module Program
Sub Main()
If Not a Then
you()
too()
Else
goo()
bar()
End If
End Sub
End Module")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
Public Async Function TestTriviaAfterMultiLineIfBlock() As Task
Await TestInRegularAndScriptAsync(
"Module Program
Sub Main()
[||]If a Then
aMethod()
Else
bMethod()
End If ' I will stay put
End Sub
End Module",
"Module Program
Sub Main()
If Not a Then
bMethod()
Else
aMethod()
End If ' I will stay put
End Sub
End Module")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
Public Async Function TestKeepExplicitLineContinuationTriviaMethod() As Task
Await TestInRegularAndScriptAsync(
"Module Program
Sub Main()
I[||]f a And b _
Or c Then
aMethod()
Else
bMethod()
End If
End Sub
End Module",
"Module Program
Sub Main()
If (Not a Or Not b) _
And Not c Then
bMethod()
Else
aMethod()
End If
End Sub
End Module")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
Public Async Function TestKeepTriviaInStatementsInMultiLineIfBlock() As Task
Await TestInRegularAndScriptAsync(
"Module Program
Sub Main()
[||]If a Then
aMethod()
Else
bMethod()
End If
End Sub
End Module",
"Module Program
Sub Main()
If Not a Then
bMethod()
Else
aMethod()
End If
End Sub
End Module")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
Public Async Function TestSimplifyToLengthEqualsZero() As Task
Await TestInRegularAndScriptAsync(
"Module Program
Sub Main(args As String())
Dim x As String
[||]If x.Length > 0 Then
GreaterThanZero()
Else
EqualsZero()
End If
End Sub
End Module",
"Module Program
Sub Main(args As String())
Dim x As String
If x.Length = 0 Then
EqualsZero()
Else
GreaterThanZero()
End If
End Sub
End Module")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
Public Async Function TestSimplifyToLengthEqualsZero2() As Task
Await TestInRegularAndScriptAsync(
"Module Program
Sub Main(args As String())
Dim x() As String
[||]If x.Length > 0 Then
GreaterThanZero()
Else
EqualsZero()
End If
End Sub
End Module",
"Module Program
Sub Main(args As String())
Dim x() As String
If x.Length = 0 Then
EqualsZero()
Else
GreaterThanZero()
End If
End Sub
End Module")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
Public Async Function TestSimplifyToLengthEqualsZero4() As Task
Await TestInRegularAndScriptAsync(
"Module Program
Sub Main(args As String())
Dim x() As String
[||]If x.Length > 0x0 Then
GreaterThanZero()
Else
EqualsZero()
End If
End Sub
End Module",
"Module Program
Sub Main(args As String())
Dim x() As String
If x.Length = 0x0 Then
EqualsZero()
Else
GreaterThanZero()
End If
End Sub
End Module")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
Public Async Function TestSimplifyToLengthEqualsZero5() As Task
Await TestInRegularAndScriptAsync(
"Module Program
Sub Main(args As String())
Dim x As String
[||]If 0 < x.Length Then
GreaterThanZero()
Else
EqualsZero()
End If
End Sub
End Module",
"Module Program
Sub Main(args As String())
Dim x As String
If 0 = x.Length Then
EqualsZero()
Else
GreaterThanZero()
End If
End Sub
End Module")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
Public Async Function TestDoesNotSimplifyToLengthEqualsZero() As Task
Await TestInRegularAndScriptAsync(
"Module Program
Sub Main(args As String())
Dim x As String
[||]If x.Length >= 0 Then
aMethod()
Else
bMethod()
End If
End Sub
End Module",
"Module Program
Sub Main(args As String())
Dim x As String
If x.Length < 0 Then
bMethod()
Else
aMethod()
End If
End Sub
End Module")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
Public Async Function TestDoesNotSimplifyToLengthEqualsZero2() As Task
Await TestInRegularAndScriptAsync(
"Module Program
Sub Main(args As String())
Dim x As String
[||]If x.Length > 0.0 Then
aMethod()
Else
bMethod()
End If
End Sub
End Module",
"Module Program
Sub Main(args As String())
Dim x As String
If x.Length <= 0.0 Then
bMethod()
Else
aMethod()
End If
End Sub
End Module")
End Function
<WorkItem(529748, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/529748")>
<WorkItem(530593, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530593")>
<WpfFact(Skip:="Bug 530593"), Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
Public Async Function TestColonAfterSingleLineIfWithEmptyElse() As Task
Await TestInRegularAndScriptAsync(
"Module Program
Sub Main()
' Invert If
I[||]f False Then Return Else : Console.WriteLine(1)
End Sub
End Module",
"Module Program
Sub Main()
' Invert If
If True Then Else Return
Console.WriteLine(1)
End Sub
End Module")
End Function
<WorkItem(529756, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/529756")>
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
Public Async Function TestOnlyOnElseIf() As Task
Await TestMissingInRegularAndScriptAsync(
"Module Program
Sub Main(args As String())
If False Then
Return
ElseIf True [||]Then
Console.WriteLine(""b"")
Else
Console.WriteLine(""a"")
End If
End Sub
End Module")
End Function
<WorkItem(529756, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/529756")>
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
Public Async Function TestOnConditionOfMultiLineIfStatement() As Task
Await TestInRegularAndScriptAsync(
"Module Program
Sub Main(args As String())
If [||]False Then
Return
Else
Console.WriteLine(""a"")
End If
End Sub
End Module",
"Module Program
Sub Main(args As String())
If [||]True Then
Console.WriteLine(""a"")
Else
Return
End If
End Sub
End Module")
End Function
<WorkItem(531474, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/531474")>
<WpfFact(Skip:="531474"), Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
Public Async Function TestDoNotRemoveTypeCharactersDuringComplexification() As Task
Dim markup =
<File>
Imports System
Module Program
Sub Main()
Goo(Function(take)
[||]If True Then Console.WriteLine("true") Else Console.WriteLine("false")
take$.ToString()
Return Function() 1
End Function)
End Sub
Sub Goo(Of T)(x As Func(Of String, T))
End Sub
Sub Goo(Of T)(x As Func(Of Integer, T))
End Sub
End Module
</File>
Dim expected =
<File>
Imports System
Module Program
Sub Main()
Goo(Function(take)
If False Then Console.WriteLine("false") Else Console.WriteLine("true")
take$.ToString()
Return Function() 1
End Function)
End Sub
Sub Goo(Of T)(x As Func(Of String, T))
End Sub
Sub Goo(Of T)(x As Func(Of Integer, T))
End Sub
End Module
</File>
Await TestAsync(markup, expected)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
Public Async Function InvertIfWithoutStatements() As Task
Await TestInRegularAndScriptAsync(
"class C
sub M(x as String)
[||]If x = ""a"" Then
Else
DoSomething()
End If
end sub
sub DoSomething()
end sub
end class",
"class C
sub M(x as String)
If x <> ""a"" Then
DoSomething()
End If
end sub
sub DoSomething()
end sub
end class")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
Public Async Function InvertIfWithOnlyComment() As Task
Await TestInRegularAndScriptAsync(
"class C
sub M(x as String)
[||]If x = ""a"" Then
' A comment in a blank if statement
Else
DoSomething()
End If
end sub
sub DoSomething()
end sub
end class",
"class C
sub M(x as String)
If x <> ""a"" Then
DoSomething()
Else
' A comment in a blank if statement
End If
end sub
sub DoSomething()
end sub
end class")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
Public Async Function InvertIfWithoutElse() As Task
Await TestInRegularAndScriptAsync(
"class C
sub M(x as String)
[||]If x = ""a"" Then
' Comment
x += 1
End If
end sub
end class",
"class C
sub M(x as String)
If x <> ""a"" Then
Return
End If
' Comment
x += 1
end sub
end class")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
<WorkItem(51359, "https://github.com/dotnet/roslyn/issues/51359")>
Public Async Function TestMultiLineTypeOfIs_VB12() As Task
Await TestFixOneAsync(
"
[||]If TypeOf a Is String Then
aMethod()
Else
bMethod()
End If
",
"
If Not (TypeOf a Is String) Then
bMethod()
Else
aMethod()
End If
", VisualBasicParseOptions.Default.WithLanguageVersion(LanguageVersion.VisualBasic12))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
<WorkItem(51359, "https://github.com/dotnet/roslyn/issues/51359")>
Public Async Function TestMultiLineTypeOfIs_VB14() As Task
Await TestFixOneAsync(
"
[||]If TypeOf a Is String Then
aMethod()
Else
bMethod()
End If
",
"
If TypeOf a IsNot String Then
bMethod()
Else
aMethod()
End If
", VisualBasicParseOptions.Default.WithLanguageVersion(LanguageVersion.VisualBasic14))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)>
<WorkItem(51359, "https://github.com/dotnet/roslyn/issues/51359")>
Public Async Function TestMultiLineTypeOfIsNot() As Task
Await TestFixOneAsync(
"
[||]If TypeOf a IsNot String Then
aMethod()
Else
bMethod()
End If
",
"
If TypeOf a Is String Then
bMethod()
Else
aMethod()
End If
")
End Function
End Class
End Namespace
|
bartdesmet/roslyn
|
src/EditorFeatures/VisualBasicTest/InvertIf/InvertMultiLineIfTests.vb
|
Visual Basic
|
mit
| 20,649
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Recommendations.Types
Public Class BuiltInTypesKeywordRecommenderTests
Private ReadOnly _keywordList As String() = {
"Boolean",
"Byte",
"Char",
"Date",
"Decimal",
"Double",
"Integer",
"Long",
"Object",
"SByte",
"Short",
"Single",
"String",
"UInteger",
"ULong",
"UShort"
}
<WpfFact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Sub NumericTypesAfterEnumAs()
VerifyRecommendationsAreExactly(<File>Enum Foo As |</File>, "Byte",
"SByte",
"Short",
"UShort",
"Integer",
"UInteger",
"Long",
"ULong")
End Sub
<WpfFact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Sub AllTypesAfterMethodBody()
VerifyRecommendationsContain(<MethodBody>Dim foo As |</MethodBody>, _keywordList)
End Sub
<WpfFact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Sub NoTypesAreInTypeConstraint()
VerifyRecommendationsMissing(<File>Class Foo(Of String As |</File>, _keywordList)
End Sub
<WpfFact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Sub NoTypesAfterImports()
VerifyRecommendationsMissing(<File>Imports |</File>, _keywordList)
End Sub
<WorkItem(543270)>
<WpfFact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Sub NoTypesInDelegateCreation()
Dim code =
<File>
Module Program
Sub Main(args As String())
Dim f1 As New Foo2( |
End Sub
Delegate Sub Foo2()
Function Bar2() As Object
Return Nothing
End Function
End Module
</File>
VerifyRecommendationsMissing(code, _keywordList)
End Sub
<WpfFact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Sub NoTypesInInheritsStatement()
Dim code =
<File>
Class C
Inherits |
End Class
</File>
VerifyRecommendationsMissing(code, _keywordList)
End Sub
<WpfFact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Sub NoTypesInImplementsStatement()
Dim code =
<File>
Class C
Implements |
End Class
</File>
VerifyRecommendationsMissing(code, _keywordList)
End Sub
End Class
End Namespace
|
VPashkov/roslyn
|
src/EditorFeatures/VisualBasicTest/Recommendations/Types/BuiltInTypesKeywordRecommenderTests.vb
|
Visual Basic
|
apache-2.0
| 3,234
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports Microsoft.CodeAnalysis.Completion
Imports Microsoft.CodeAnalysis.Host.Mef
Imports Microsoft.CodeAnalysis.VisualBasic.Completion
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Completion
Public Class CompletionServiceTests
<Fact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Sub AcquireCompletionService()
Dim workspace = New AdhocWorkspace()
Dim document = workspace _
.AddProject("TestProject", LanguageNames.VisualBasic) _
.AddDocument("TestDocument.vb", String.Empty)
Dim service = CompletionService.GetService(document)
Assert.NotNull(service)
End Sub
End Class
End Namespace
|
mmitche/roslyn
|
src/EditorFeatures/VisualBasicTest/Completion/CompletionServiceTests.vb
|
Visual Basic
|
apache-2.0
| 895
|
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated by a tool.
' Runtime Version:4.0.30319.18326
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Imports System
Namespace TestResources.SymbolsTests
'This class was auto-generated by the StronglyTypedResourceBuilder
'class via a tool like ResGen or Visual Studio.
'To add or remove a member, edit your .ResX file then rerun ResGen
'with the /str option, or rebuild your VS project.
'''<summary>
''' A strongly-typed resource class, for looking up localized strings, etc.
'''</summary>
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0"), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
Public Class CorLibrary
Private Shared resourceMan As Global.System.Resources.ResourceManager
Private Shared resourceCulture As Global.System.Globalization.CultureInfo
<Global.System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")> _
Friend Sub New()
MyBase.New
End Sub
'''<summary>
''' Returns the cached ResourceManager instance used by this class.
'''</summary>
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Public Shared ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
Get
If Object.ReferenceEquals(resourceMan, Nothing) Then
Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("CorLibrary", GetType(CorLibrary).Assembly)
resourceMan = temp
End If
Return resourceMan
End Get
End Property
'''<summary>
''' Overrides the current thread's CurrentUICulture property for all
''' resource lookups using this strongly typed resource class.
'''</summary>
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Public Shared Property Culture() As Global.System.Globalization.CultureInfo
Get
Return resourceCulture
End Get
Set
resourceCulture = value
End Set
End Property
'''<summary>
''' Looks up a localized resource of type System.Byte[].
'''</summary>
Public Shared ReadOnly Property FakeMsCorLib() As Byte()
Get
Dim obj As Object = ResourceManager.GetObject("FakeMsCorLib", resourceCulture)
Return CType(obj,Byte())
End Get
End Property
'''<summary>
''' Looks up a localized resource of type System.Byte[].
'''</summary>
Public Shared ReadOnly Property GuidTest2() As Byte()
Get
Dim obj As Object = ResourceManager.GetObject("GuidTest2", resourceCulture)
Return CType(obj,Byte())
End Get
End Property
'''<summary>
''' Looks up a localized resource of type System.Byte[].
'''</summary>
Public Shared ReadOnly Property NoMsCorLibRef() As Byte()
Get
Dim obj As Object = ResourceManager.GetObject("NoMsCorLibRef", resourceCulture)
Return CType(obj,Byte())
End Get
End Property
End Class
End Namespace
|
paladique/roslyn
|
src/Compilers/Test/Resources/Core/SymbolsTests/CorLibrary/CorLibrary.Designer.vb
|
Visual Basic
|
apache-2.0
| 4,018
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Runtime.CompilerServices
Imports CompilationCreationTestHelpers
Imports ProprietaryTestResources = Microsoft.CodeAnalysis.Test.Resources.Proprietary
Imports Microsoft.CodeAnalysis.Test.Utilities
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports Roslyn.Test.Utilities
Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests.Symbols.Metadata.PE
Public Class TypeKindTests : Inherits BasicTestBase
<Fact>
Public Sub Test1()
Dim assembly = MetadataTestHelpers.LoadFromBytes(ProprietaryTestResources.NetFX.v4_0_21006.mscorlib)
TestTypeKindHelper(assembly)
End Sub
Private Sub TestTypeKindHelper(assembly As AssemblySymbol)
Dim module0 = assembly.Modules(0)
Dim system = (From n In module0.GlobalNamespace.GetMembers()
Where n.Name.Equals("System")).Cast(Of NamespaceSymbol)().Single()
Dim obj = (From t In system.GetTypeMembers()
Where t.Name.Equals("Object")).Single()
Assert.Equal(TypeKind.Class, obj.TypeKind)
Dim [enum] = (From t In system.GetTypeMembers()
Where t.Name.Equals("Enum")).Single()
Assert.Equal(TypeKind.Class, [enum].TypeKind)
Dim int32 = (From t In system.GetTypeMembers()
Where t.Name.Equals("Int32")).Single()
Assert.Equal(TypeKind.Structure, int32.TypeKind)
Dim func = (From t In system.GetTypeMembers()
Where t.Name.Equals("Func") AndAlso t.Arity = 1).Single()
Assert.Equal(TypeKind.Delegate, func.TypeKind)
Dim collections = (From n In system.GetMembers()
Where n.Name.Equals("Collections")).Cast(Of NamespaceSymbol)().Single()
Dim ienumerable = (From t In collections.GetTypeMembers()
Where t.Name.Equals("IEnumerable")).Single()
Assert.Equal(TypeKind.Interface, ienumerable.TypeKind)
Assert.Null(ienumerable.BaseType)
Dim typeCode = (From t In system.GetTypeMembers()
Where t.Name.Equals("TypeCode")).Single()
Assert.Equal(TypeKind.Enum, typeCode.TypeKind)
Assert.False(obj.IsMustInherit)
Assert.False(obj.IsNotInheritable)
Assert.False(obj.IsShared)
Assert.True([enum].IsMustInherit)
Assert.False([enum].IsNotInheritable)
Assert.False([enum].IsShared)
Assert.False(func.IsMustInherit)
Assert.True(func.IsNotInheritable)
Assert.False(func.IsShared)
Dim console = system.GetTypeMembers("Console").Single()
Assert.False(console.IsMustInherit)
Assert.True(console.IsNotInheritable)
Assert.False(console.IsShared)
End Sub
<Fact>
<WorkItem(546314, "DevDiv")>
Public Sub Bug15562()
Dim assembly = MetadataTestHelpers.LoadFromBytes(ProprietaryTestResources.NetFX.v4_0_21006.mscorlib)
Dim module0 = assembly.Modules(0)
Dim system = (From n In module0.GlobalNamespace.GetMembers()
Where n.Name.Equals("System")).Cast(Of NamespaceSymbol)().Single()
Dim multicastDelegate = system.GetTypeMembers("MulticastDelegate").Single()
Assert.Equal(TypeKind.Class, multicastDelegate.TypeKind)
End Sub
End Class
End Namespace
|
paladique/roslyn
|
src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Metadata/PE/TypeKindTests.vb
|
Visual Basic
|
apache-2.0
| 3,822
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Recommendations.Declarations.ModifierKeywordRecommenderTests
Public Class InsideStructureDeclaration
#Region "Scope Keywords"
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function PublicExistsTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>|</StructureDeclaration>, "Public")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function ProtectedMissingTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>|</StructureDeclaration>, "Protected")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function PrivateExistsTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>|</StructureDeclaration>, "Private")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function FriendExistsTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>|</StructureDeclaration>, "Friend")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function ProtectedFriendMissingTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>|</StructureDeclaration>, "Protected Friend")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function PublicNotAfterPublicTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Public |</StructureDeclaration>, "Public")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function ProtectedNotAfterPublicTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Public |</StructureDeclaration>, "Protected")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function PrivateNotAfterPublicTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Public |</StructureDeclaration>, "Private")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function FriendNotAfterPublicTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Public |</StructureDeclaration>, "Friend")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function ProtectedFriendNotAfterPublicTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Public |</StructureDeclaration>, "Protected Friend")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function FriendNotAfterProtectedTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Protected |</StructureDeclaration>, "Friend")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function FriendNotAfterProtectedFriendTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Protected Friend |</StructureDeclaration>, "Friend")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function ProtectedNotAfterFriendTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Friend |</StructureDeclaration>, "Protected")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function ProtectedNotAfterProtectedFriendTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Protected Friend |</StructureDeclaration>, "Protected")
End Function
#End Region
#Region "Narrowing and Widening Keywords"
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function NarrowingExistsTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>|</StructureDeclaration>, "Narrowing")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function WideningExistsTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>|</StructureDeclaration>, "Widening")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function NarrowingNotAfterWideningTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Widening |</StructureDeclaration>, "Narrowing")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function WideningNotAfterNarrowingTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Narrowing |</StructureDeclaration>, "Widening")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function NarrowingNotAfterProtectedTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Protected |</StructureDeclaration>, "Narrowing")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function WideningNotAfterProtectedTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Protected |</StructureDeclaration>, "Widening")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function NarrowingNotAfterPrivateTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Private |</StructureDeclaration>, "Narrowing")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function WideningNotAfterPrivateTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Private |</StructureDeclaration>, "Widening")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function NarrowingNotAfterProtectedFriendTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Protected Friend |</StructureDeclaration>, "Narrowing")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function WideningNotAfterProtectedFriendTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Protected Friend |</StructureDeclaration>, "Widening")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function NarrowingNotAfterMustOverrideTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>MustOverride |</StructureDeclaration>, "Narrowing")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function WideningNotAfterMustOverrideTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>MustOverride |</StructureDeclaration>, "Widening")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function NarrowingNotAfterMustInheritTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>MustInherit |</StructureDeclaration>, "Narrowing")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function WideningNotAfterNotInheritableTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>NotInheritable |</StructureDeclaration>, "Widening")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function NarrowingNotAfterNotInheritableTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>NotInheritable |</StructureDeclaration>, "Narrowing")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function WideningNotAfterMustInheritTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>MustInherit |</StructureDeclaration>, "Widening")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function NarrowingNotAfterNotOverridableTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>NotOverridable |</StructureDeclaration>, "Narrowing")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function WideningNotAfterNotOverridableTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>NotOverridable |</StructureDeclaration>, "Widening")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function NarrowingAfterOverloadsTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>Overloads |</StructureDeclaration>, "Narrowing")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function WideningAfterOverloadsTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>Overloads |</StructureDeclaration>, "Widening")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function NarrowingNotAfterOverridableTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Overridable |</StructureDeclaration>, "Narrowing")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function WideningNotAfterOverridableTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Overridable |</StructureDeclaration>, "Widening")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function NarrowingNotAfterPartialTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Partial |</StructureDeclaration>, "Narrowing")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function WideningNotAfterPartialTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Partial |</StructureDeclaration>, "Widening")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function NarrowingAfterSharedTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>Shared |</StructureDeclaration>, "Narrowing")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function WideningAfterSharedTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>Shared |</StructureDeclaration>, "Widening")
End Function
#End Region
#Region "MustInherit and NotInheritable Keywords"
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function MustInheritExistsTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>|</StructureDeclaration>, "MustInherit")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function NotInheritableExistsTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>|</StructureDeclaration>, "NotInheritable")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function MustInheritNotAfterNotInheritableTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>NotInheritable |</StructureDeclaration>, "MustInherit")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function NotInheritableNotAfterMustInheritTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>MustInherit |</StructureDeclaration>, "NotInheritable")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function MustInheritNotAfterNarrowingTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Narrowing |</StructureDeclaration>, "MustInherit")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function NotInheritableNotAfterNarrowingTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Narrowing |</StructureDeclaration>, "NotInheritable")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function MustInheritNotAfterWideningTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Widening |</StructureDeclaration>, "MustInherit")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function NotInheritableNotAfterWideningTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Widening |</StructureDeclaration>, "NotInheritable")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function MustInheritNotAfterMustOverrideTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>MustOverride |</StructureDeclaration>, "MustInherit")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function NotInheritableNotAfterMustOverrideTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>MustOverride |</StructureDeclaration>, "NotInheritable")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function MustInheritNotAfterNotOverridableTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>NotOverridable |</StructureDeclaration>, "MustInherit")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function NotInheritableNotAfterNotOverridableTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>NotOverridable |</StructureDeclaration>, "NotInheritable")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function MustInheritNotAfterOverridableTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Overridable |</StructureDeclaration>, "MustInherit")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function NotInheritableNotAfterOverridableTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Overridable |</StructureDeclaration>, "NotInheritable")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function MustInheritAfterPartialTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>Partial |</StructureDeclaration>, "MustInherit")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function NotInheritableAfterPartialTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>Partial |</StructureDeclaration>, "NotInheritable")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function MustInheritNotAfterReadOnlyTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>ReadOnly |</StructureDeclaration>, "MustInherit")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function NotInheritableNotAfterReadOnlyTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>ReadOnly |</StructureDeclaration>, "NotInheritable")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function MustInheritNotAfterSharedTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Shared |</StructureDeclaration>, "MustInherit")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function NotInheritableNotAfterSharedTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Shared |</StructureDeclaration>, "NotInheritable")
End Function
#End Region
#Region "Overrides and Overridable Set of Keywords"
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function OverridesExistsTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>|</StructureDeclaration>, "Overrides")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function OverridesNotAfterOverridesTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Overrides |</StructureDeclaration>, "Overrides")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function OverridesNotAfterMustOverrideTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>MustOverride |</StructureDeclaration>, "Overrides")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function OverridesNotAfterOverridableTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Overridable |</StructureDeclaration>, "Overrides")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function OverridesNotAfterNotOverridableTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>NotOverridable |</StructureDeclaration>, "Overrides")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function OverridesNotAfterShadowsTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Shadows |</StructureDeclaration>, "Overrides")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function OverridesAfterOverloadsTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>Overloads |</StructureDeclaration>, "Overrides")
End Function
' ---------
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function MustOverrideMissingTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>|</StructureDeclaration>, "MustOverride")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function MustOverrideNotAfterOverridesTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Overrides |</StructureDeclaration>, "MustOverride")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function MustOverrideNotAfterMustOverrideTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>MustOverride |</StructureDeclaration>, "MustOverride")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function MustOverrideNotAfterOverridableTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Overridable |</StructureDeclaration>, "MustOverride")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function MustOverrideNotAfterNotOverridableTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>NotOverridable |</StructureDeclaration>, "MustOverride")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function MustOverrideNotAfterShadowsTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Shadows |</StructureDeclaration>, "MustOverride")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function MustOverrideNotAfterOverloadsTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Overloads |</StructureDeclaration>, "MustOverride")
End Function
' ---------
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function OverridableMissingTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>|</StructureDeclaration>, "Overridable")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function OverridableNotAfterOverridesTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Overrides |</StructureDeclaration>, "Overridable")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function OverridableNotAfterMustOverrideTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>MustOverride |</StructureDeclaration>, "Overridable")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function OverridableNotAfterOverridableTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Overridable |</StructureDeclaration>, "Overridable")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function OverridableNotAfterNotOverridableTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>NotOverridable |</StructureDeclaration>, "Overridable")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function OverridableNotAfterShadowsTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Shadows |</StructureDeclaration>, "Overridable")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function OverridableNotAfterOverloadsTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Overloads |</StructureDeclaration>, "Overridable")
End Function
' ---------
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function NotOverridableMissingTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>|</StructureDeclaration>, "NotOverridable")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function NotOverridableAfterOverridesTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Overrides |</StructureDeclaration>, "NotOverridable")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function NotOverridableNotAfterMustOverrideTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>MustOverride |</StructureDeclaration>, "NotOverridable")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function NotOverridableNotAfterOverridableTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Overridable |</StructureDeclaration>, "NotOverridable")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function NotOverridableNotAfterNotOverridableTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>NotOverridable |</StructureDeclaration>, "NotOverridable")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function NotOverridableNotAfterShadowsTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Shadows |</StructureDeclaration>, "NotOverridable")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function NotOverridableNotAfterOverloadsTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Overloads |</StructureDeclaration>, "NotOverridable")
End Function
' ---------
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function OverloadsExistsTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>|</StructureDeclaration>, "Overloads")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function OverloadsAfterOverridesTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>Overrides |</StructureDeclaration>, "Overloads")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function OverloadsNotAfterMustOverrideTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>MustOverride |</StructureDeclaration>, "Overloads")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function OverloadsNotAfterOverridableTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Overridable |</StructureDeclaration>, "Overloads")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function OverloadsNotAfterNotOverridableTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>NotOverridable |</StructureDeclaration>, "Overloads")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function OverloadsNotAfterShadowsTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Shadows |</StructureDeclaration>, "Overloads")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function OverloadsNotAfterOverloadsTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Overloads |</StructureDeclaration>, "Overloads")
End Function
#End Region
#Region "ReadOnly and WriteOnly Keywords"
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function ReadOnlyExistsTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>|</StructureDeclaration>, "ReadOnly")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function WriteOnlyExistsTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>|</StructureDeclaration>, "WriteOnly")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function ReadOnlyAfterSharedTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>Shared |</StructureDeclaration>, "ReadOnly")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function WriteOnlyAfterSharedTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>Shared |</StructureDeclaration>, "WriteOnly")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function ReadOnlyAfterDefaultTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>Default |</StructureDeclaration>, "ReadOnly")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function WriteOnlyAfterDefaultTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>Default |</StructureDeclaration>, "WriteOnly")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function ReadOnlyNotAfterMustInheritTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>MustInherit |</StructureDeclaration>, "ReadOnly")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function WriteOnlyNotAfterMustInheritTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>MustInherit |</StructureDeclaration>, "WriteOnly")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function ReadOnlyAfterOverridableTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Overridable |</StructureDeclaration>, "ReadOnly")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function WriteOnlyAfterOverridableTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Overridable |</StructureDeclaration>, "WriteOnly")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function ReadOnlyNotAfterNotOverridableTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>NotOverridable |</StructureDeclaration>, "ReadOnly")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function WriteOnlyAfterNotOverridableTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>NotOverridable |</StructureDeclaration>, "WriteOnly")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function ReadOnlyAfterOverloadsTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>Overloads |</StructureDeclaration>, "ReadOnly")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function WriteOnlyAfterOverloadsTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>Overloads |</StructureDeclaration>, "WriteOnly")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function ReadOnlyNotAfterMustOverrideTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>MustOverride |</StructureDeclaration>, "ReadOnly")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function WriteOnlyNotAfterMustOverrideTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>MustOverride |</StructureDeclaration>, "WriteOnly")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function ReadOnlyNotAfterNarrowingTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Narrowing |</StructureDeclaration>, "ReadOnly")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function WriteOnlyNotAfterNarrowingTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Narrowing |</StructureDeclaration>, "WriteOnly")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function ReadOnlyNotAfterPartialTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Partial |</StructureDeclaration>, "ReadOnly")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function WriteOnlyNotAfterPartialTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Partial |</StructureDeclaration>, "WriteOnly")
End Function
#End Region
#Region "Partial Keyword"
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function PartialExistsTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>|</StructureDeclaration>, "Partial")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function PartialNotAfterMustOverrideTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>MustOverride |</StructureDeclaration>, "Partial")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function PartialNotAfterPartialTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Partial |</StructureDeclaration>, "Partial")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function PartialAfterMustInheritTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>MustInherit |</StructureDeclaration>, "Partial")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function PartialAfterNotInheritableTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>NotInheritable |</StructureDeclaration>, "Partial")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function PartialNotAfterNotOverridableTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>NotOverridable |</StructureDeclaration>, "Partial")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function PartialNotAfterOverloadsTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Overloads |</StructureDeclaration>, "Partial")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function PartialNotAfterOverridesTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Overrides |</StructureDeclaration>, "Partial")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function PartialNotAfterOverridableTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Overridable |</StructureDeclaration>, "Partial")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function PartialNotAfterReadOnlyTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>ReadOnly |</StructureDeclaration>, "Partial")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function PartialNotAfterWriteOnlyTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>WriteOnly |</StructureDeclaration>, "Partial")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function PartialNotAfterNarrowingTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Narrowing |</StructureDeclaration>, "Partial")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function PartialNotAfterWideningTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Widening |</StructureDeclaration>, "Partial")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function PartialNotAfterShadowsTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Shadows |</StructureDeclaration>, "Partial")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function PartialNotAfterDefaultTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Default |</StructureDeclaration>, "Partial")
End Function
#End Region
#Region "Shadows Keyword"
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function ShadowsExistsTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>|</StructureDeclaration>, "Shadows")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function ShadowsNotAfterMustOverrideTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>MustOverride |</StructureDeclaration>, "Shadows")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function ShadowsNotAfterMustInheritTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>MustInherit |</StructureDeclaration>, "Shadows")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function ShadowsNotAfterNotInheritableTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>NotInheritable |</StructureDeclaration>, "Shadows")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function ShadowsAfterNotOverridableTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>NotOverridable |</StructureDeclaration>, "Shadows")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function ShadowsNotAfterOverloadsTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Overloads |</StructureDeclaration>, "Shadows")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function ShadowsNotAfterOverridesTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Overrides |</StructureDeclaration>, "Shadows")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function ShadowsNotAfterOverridableTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Overridable |</StructureDeclaration>, "Shadows")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function ShadowsAfterReadOnlyTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>ReadOnly |</StructureDeclaration>, "Shadows")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function ShadowsAfterWriteOnlyTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>WriteOnly |</StructureDeclaration>, "Shadows")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function ShadowsAfterNarrowingTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>Narrowing |</StructureDeclaration>, "Shadows")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function ShadowsAfterWideningTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>Widening |</StructureDeclaration>, "Shadows")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function ShadowsNotAfterShadowsTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Shadows |</StructureDeclaration>, "Shadows")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function ShadowsAfterDefaultTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>Default |</StructureDeclaration>, "Shadows")
End Function
#End Region
#Region "Shared Keyword"
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function SharedDoesExistTest() As Task
Await VerifyRecommendationsContainAsync(<StructureDeclaration>|</StructureDeclaration>, "Shared")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function SharedDoesNotExistAfterSharedTest() As Task
Await VerifyRecommendationsMissingAsync(<StructureDeclaration>Shared |</StructureDeclaration>, "Shared")
End Function
#End Region
End Class
End Namespace
|
VSadov/roslyn
|
src/EditorFeatures/VisualBasicTest/Recommendations/Declarations/ModifierKeywordRecommenderTests.InsideStructureDeclaration.vb
|
Visual Basic
|
apache-2.0
| 43,172
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Collections.Generic
Imports System.Collections.Immutable
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.Collections
Imports Microsoft.CodeAnalysis.Emit
Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Partial Friend NotInheritable Class AnonymousTypeManager
Private NotInheritable Class AnonymousTypeTemplateSymbol
Inherits AnonymousTypeOrDelegateTemplateSymbol
Private ReadOnly _properties As ImmutableArray(Of AnonymousTypePropertySymbol)
Private ReadOnly _members As ImmutableArray(Of Symbol)
Private ReadOnly _interfaces As ImmutableArray(Of NamedTypeSymbol)
Friend ReadOnly HasAtLeastOneKeyField As Boolean
Public Sub New(manager As AnonymousTypeManager,
typeDescr As AnonymousTypeDescriptor)
MyBase.New(manager, typeDescr)
Dim fieldsCount As Integer = typeDescr.Fields.Length
Dim methodMembersBuilder = ArrayBuilder(Of Symbol).GetInstance()
Dim otherMembersBuilder = ArrayBuilder(Of Symbol).GetInstance()
' The array storing property symbols to be used in
' generation of constructor and other methods
Dim propertiesArray = New AnonymousTypePropertySymbol(fieldsCount - 1) {}
' Anonymous types with at least one Key field are being generated slightly different
HasAtLeastOneKeyField = False
' Process fields
For fieldIndex = 0 To fieldsCount - 1
Dim field As AnonymousTypeField = typeDescr.Fields(fieldIndex)
If field.IsKey Then
HasAtLeastOneKeyField = True
End If
' Add a property
Dim [property] As New AnonymousTypePropertySymbol(Me, field, fieldIndex, Me.TypeParameters(fieldIndex))
propertiesArray(fieldIndex) = [property]
' Property related symbols
otherMembersBuilder.Add([property])
methodMembersBuilder.Add([property].GetMethod)
If [property].SetMethod IsNot Nothing Then
methodMembersBuilder.Add([property].SetMethod)
End If
otherMembersBuilder.Add([property].AssociatedField)
Next
_properties = propertiesArray.AsImmutableOrNull()
' Add a constructor
methodMembersBuilder.Add(New AnonymousTypeConstructorSymbol(Me))
' Add 'ToString'
methodMembersBuilder.Add(New AnonymousTypeToStringMethodSymbol(Me))
' Add optional members
If HasAtLeastOneKeyField AndAlso Me.Manager.System_IEquatable_T_Equals IsNot Nothing Then
' Add 'GetHashCode'
methodMembersBuilder.Add(New AnonymousTypeGetHashCodeMethodSymbol(Me))
' Add optional 'Inherits IEquatable'
Dim equatableInterface As NamedTypeSymbol = Me.Manager.System_IEquatable_T.Construct(ImmutableArray.Create(Of TypeSymbol)(Me))
_interfaces = ImmutableArray.Create(Of NamedTypeSymbol)(equatableInterface)
' Add 'IEquatable.Equals'
Dim method As Symbol = DirectCast(equatableInterface, SubstitutedNamedType).GetMemberForDefinition(Me.Manager.System_IEquatable_T_Equals)
Dim iEquatableEquals As MethodSymbol = New AnonymousType_IEquatable_EqualsMethodSymbol(Me, DirectCast(method, MethodSymbol))
methodMembersBuilder.Add(iEquatableEquals)
' Add 'Equals'
methodMembersBuilder.Add(New AnonymousTypeEqualsMethodSymbol(Me, iEquatableEquals))
Else
_interfaces = ImmutableArray(Of NamedTypeSymbol).Empty
End If
methodMembersBuilder.AddRange(otherMembersBuilder)
otherMembersBuilder.Free()
_members = methodMembersBuilder.ToImmutableAndFree()
End Sub
Friend Overrides Function GetAnonymousTypeKey() As AnonymousTypeKey
Dim properties = _properties.SelectAsArray(Function(p) New AnonymousTypeKeyField(p.Name, isKey:=p.IsReadOnly, ignoreCase:=True))
Return New AnonymousTypeKey(properties)
End Function
Friend Overrides ReadOnly Property GeneratedNamePrefix As String
Get
Return GeneratedNames.AnonymousTypeTemplateNamePrefix
End Get
End Property
Public ReadOnly Property Properties As ImmutableArray(Of AnonymousTypePropertySymbol)
Get
Return Me._properties
End Get
End Property
Public Overrides Function GetMembers() As ImmutableArray(Of Symbol)
Return _members
End Function
Friend Overrides Iterator Function GetFieldsToEmit() As IEnumerable(Of FieldSymbol)
For Each m In GetMembers()
If m.Kind = SymbolKind.Field Then
Yield DirectCast(m, FieldSymbol)
End If
Next
End Function
Friend Overrides Function MakeAcyclicBaseType(diagnostics As DiagnosticBag) As NamedTypeSymbol
Return Me.Manager.System_Object
End Function
Friend Overrides Function MakeAcyclicInterfaces(diagnostics As DiagnosticBag) As ImmutableArray(Of NamedTypeSymbol)
Return _interfaces
End Function
Public Overrides ReadOnly Property TypeKind As TypeKind
Get
Return TypeKind.Class
End Get
End Property
Friend Overrides ReadOnly Property IsInterface As Boolean
Get
Return False
End Get
End Property
Friend Overrides Sub AddSynthesizedAttributes(compilationState As ModuleCompilationState, ByRef attributes As ArrayBuilder(Of SynthesizedAttributeData))
MyBase.AddSynthesizedAttributes(compilationState, attributes)
' Attribute: System.Runtime.CompilerServices.CompilerGeneratedAttribute()
AddSynthesizedAttribute(attributes, Manager.Compilation.TrySynthesizeAttribute(
WellKnownMember.System_Runtime_CompilerServices_CompilerGeneratedAttribute__ctor))
' VB emits this attribute regardless of /debug settings (unlike C#, which only emits it for /debug:full)
' Attribute: System.Diagnostics.DebuggerDisplayAttribute("a={a}, b={b}, c={c}, ...")
AddSynthesizedAttribute(attributes, SynthesizeDebuggerDisplayAttribute())
End Sub
Private Function SynthesizeDebuggerDisplayAttribute() As SynthesizedAttributeData
' VB doesn't allow empty anon types
Debug.Assert(Me.Properties.Length > 0)
Dim builder = PooledStringBuilder.GetInstance()
Dim sb = builder.Builder
Dim displayCount As Integer = Math.Min(Me.Properties.Length, 4)
For fieldIndex = 0 To displayCount - 1
Dim fieldName As String = Me.Properties(fieldIndex).Name
If fieldIndex > 0 Then
sb.Append(", ")
End If
sb.Append(fieldName)
sb.Append("={")
sb.Append(fieldName)
sb.Append("}")
Next
If Me.Properties.Length > displayCount Then
sb.Append(", ...")
End If
Return Manager.Compilation.TrySynthesizeAttribute(
WellKnownMember.System_Diagnostics_DebuggerDisplayAttribute__ctor,
ImmutableArray.Create(New TypedConstant(Manager.System_String, TypedConstantKind.Primitive, builder.ToStringAndFree())))
End Function
End Class
End Class
End Namespace
|
MatthieuMEZIL/roslyn
|
src/Compilers/VisualBasic/Portable/Symbols/AnonymousTypes/SynthesizedSymbols/AnonymousType_TemplateSymbol.vb
|
Visual Basic
|
apache-2.0
| 8,445
|
' Licensed to the .NET Foundation under one or more agreements.
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.
Imports Xunit
|
physhi/roslyn
|
src/Compilers/VisualBasic/Test/Symbol/AssemblyAttributes.vb
|
Visual Basic
|
apache-2.0
| 219
|
Namespace Security.BackStage_Help
Public Class ContactUs
Inherits SecurityItemBase
Public Sub New()
_ConceptItemName = "Contact Us"
_ConceptName = "BackStage_Help"
_Description = "Aprotec Contact Page, via Web Browser"
_IsEnterprise = True
_IsSmallBusiness = True
_IsViewer = False
_IsWeb = True
_IsWebPlus = True
End Sub
End Class
End Namespace
|
nublet/DMS
|
DMS.Forms.Shared/Security/Items/Backstage/Help/ContactUs.vb
|
Visual Basic
|
mit
| 483
|
'------------------------------------------------------------------------------
' <auto-generated>
' 이 코드는 도구를 사용하여 생성되었습니다.
' 런타임 버전:4.0.30319.42000
'
' 파일 내용을 변경하면 잘못된 동작이 발생할 수 있으며, 코드를 다시 생성하면
' 이러한 변경 내용이 손실됩니다.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Namespace My
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0"), _
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Partial Friend NotInheritable Class MySettings
Inherits Global.System.Configuration.ApplicationSettingsBase
Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings)
#Region "My.Settings 자동 저장 기능"
#If _MyType = "WindowsForms" Then
Private Shared addedHandler As Boolean
Private Shared addedHandlerLockObject As New Object
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
If My.Application.SaveMySettingsOnExit Then
My.Settings.Save()
End If
End Sub
#End If
#End Region
Public Shared ReadOnly Property [Default]() As MySettings
Get
#If _MyType = "WindowsForms" Then
If Not addedHandler Then
SyncLock addedHandlerLockObject
If Not addedHandler Then
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
addedHandler = True
End If
End SyncLock
End If
#End If
Return defaultInstance
End Get
End Property
<Global.System.Configuration.UserScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.DefaultSettingValueAttribute("")> _
Public Property ADBpath() As String
Get
Return CType(Me("ADBpath"),String)
End Get
Set
Me("ADBpath") = value
End Set
End Property
<Global.System.Configuration.UserScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.DefaultSettingValueAttribute("")> _
Public Property FBPath() As String
Get
Return CType(Me("FBPath"),String)
End Get
Set
Me("FBPath") = value
End Set
End Property
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.DefaultSettingValueAttribute("AdbWinUsbApi.dll")> _
Public ReadOnly Property ADB_usb() As String
Get
Return CType(Me("ADB_usb"),String)
End Get
End Property
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.DefaultSettingValueAttribute("AdbWinApi.dll")> _
Public ReadOnly Property ADB_win() As String
Get
Return CType(Me("ADB_win"),String)
End Get
End Property
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.DefaultSettingValueAttribute("adb.exe")> _
Public ReadOnly Property ADB_exe() As String
Get
Return CType(Me("ADB_exe"),String)
End Get
End Property
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.DefaultSettingValueAttribute("fastboot.exe")> _
Public ReadOnly Property FB_exe() As String
Get
Return CType(Me("FB_exe"),String)
End Get
End Property
End Class
End Namespace
Namespace My
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
Friend Module MySettingsProperty
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
Friend ReadOnly Property Settings() As Global.MYA.My.MySettings
Get
Return Global.MYA.My.MySettings.Default
End Get
End Property
End Module
End Namespace
|
ssh9930/MYA
|
My Project/Settings.Designer.vb
|
Visual Basic
|
mit
| 5,478
|
Option Strict Off
Option Explicit On
Option Compare Text
Imports VB = Microsoft.VisualBasic
Imports Microsoft.VisualBasic.PowerPacks
Friend Class frmStockTakeLIQCode
Inherits System.Windows.Forms.Form
Dim WithEvents adoPrimaryRS As ADODB.Recordset
Dim mbChangedByCode As Boolean
Dim mvBookMark As Integer
Dim mbEditFlag As Boolean
Dim mbAddNewFlag As Boolean
Dim mbDataChanged As Boolean
Dim gID As Integer
Dim k_posID As Integer
Dim k_posNew As Boolean
Dim flag As Boolean
Dim y As Single
Dim c As Short
Dim YY As Short
Dim x As Short
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hSrcDC As Integer, ByVal xSrc As Integer, ByVal ySrc As Integer, ByVal dwRop As Integer) As Integer
Dim obj As System.Drawing.Image = New System.Drawing.Bitmap(1, 1)
Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA"(ByVal nDrive As String) As Integer
Dim fox(8) As Object
Dim usb_drv As String
Dim yourdrive As String
Dim CDKey As Boolean
Private arData() As Byte
Private arPWord() As Byte
Private m_intCipher As Short
Dim LsSection As String
Private Sub loadLanguage()
' 'frmBlockTestCode = No Code [4MEAT Registration]
' 'rsLang.filter = "LanguageLayoutLnk_LanguageID=" & 0000
' 'If rsLang.RecordCount Then frmBlockTestCode.Caption = rsLang("LanguageLayoutLnk_Description"): frmBlockTestCode.RightToLeft = rsLang("LanguageLayoutLnk_RightTL")
'
' rsLang.filter = "LanguageLayoutLnk_LanguageID=" & 1074 'Undo|Checked
' If rsLang.RecordCount Then cmdCancel.Caption = rsLang("LanguageLayoutLnk_Description"): cmdCancel.RightToLeft = rsLang("LanguageLayoutLnk_RightTL")
'
' rsLang.filter = "LanguageLayoutLnk_LanguageID=" & 1005 'Next|Checked
' If rsLang.RecordCount Then cmdClose.Caption = rsLang("LanguageLayoutLnk_Description"): cmdClose.RightToLeft = rsLang("LanguageLayoutLnk_RightTL")
'
' '_lbl_5 = No Code [Please type in your 4MEAT CD-Key]
' 'rsLang.filter = "LanguageLayoutLnk_LanguageID=" & 0000
' 'If rsLang.RecordCount Then _lbl_5.Caption = rsLang("LanguageLayoutLnk_Description"): _lbl_5.RightToLeft = rsLang("LanguageLayoutLnk_RightTL")
'
' '_lblLabels_1 = No Code [CD Key]
' 'rsLang.filter = "LanguageLayoutLnk_LanguageID=" & 0000
' 'If rsLang.RecordCount Then _lblLabels_1.Caption = rsLang("LanguageLayoutLnk_Description"): _lblLabels_1.RightToLeft = rsLang("LanguageLayoutLnk_RightTL")
'
' rsHelp.filter = "Help_Section=0 AND Help_Form='" & Me.Name & "'"
' If rsHelp.RecordCount Then Me.ToolTip1 = rsHelp("Help_ContextID")
End Sub
Public Sub Reset_frmEncStrings()
Dim strMsg As String
Erase arData
Erase arPWord
End Sub
'UPGRADE_NOTE: Form_Initialize was upgraded to Form_Initialize_Renamed. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
Private Sub Form_Initialize_Renamed()
Initial_settings()
Reset_frmEncStrings()
End Sub
Public Function setupCode() As Boolean
CDKey = False
System.Windows.Forms.Application.DoEvents()
Dim c As Object
Dim i As Byte
'For i = 68 To 75
' c = c + 1
' fox(c) = Chr(i) & ":"
'Next
loadLanguage()
Me.ShowDialog()
setupCode = CDKey
'Exit Function
End Function
Private Sub frmStockTakeLIQCode_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
Select Case KeyAscii
Case System.Windows.Forms.Keys.Escape
KeyAscii = 0
System.Windows.Forms.Application.DoEvents()
' adoPrimaryRS.Move 0
cmdClose_Click(cmdClose, New System.EventArgs())
End Select
eventArgs.KeyChar = Chr(KeyAscii)
If KeyAscii = 0 Then
eventArgs.Handled = True
End If
End Sub
Private Sub cmdCancel_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdCancel.Click
On Error Resume Next
Me.Close()
End Sub
Private Sub cmdClose_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdClose.Click
Dim lCode As String
Dim leCode As String
Dim lPassword As String
Dim rs As ADODB.Recordset
Dim x As Short
CDKey = False
Dim strSerial As String
Dim strTmp As String
Dim intDate As Short
Dim intYear As Short
Dim intMonth As Short
Dim dtDate As String
Dim dtMonth As String
Dim dtYear As String
Dim stPass As String ' clsCryptoAPI
'UPGRADE_ISSUE: clsCryptoAPI object was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6B85A2A7-FE9F-4FBE-AA0C-CF11AC86A305"'
Dim cCrypto As clsCryptoAPI
If openConnection() Then
rs = getRS("SELECT * From Company")
If rs.RecordCount Then
'if old database don't chk secuirty
If rs.Fields.Count <= 55 Then
CDKey = False
MsgBox("You need to download latest 4POS upgrades in order to Register.", MsgBoxStyle.Critical, "4POS")
Exit Sub
End If
txtFields.Text = Trim(Replace(txtFields.Text, "-", ""))
cCrypto = New clsCryptoAPI 'clsCryptoAPI
System.Windows.Forms.Application.DoEvents()
txtFields.Text = LTrim(txtFields.Text)
txtFields.Text = RTrim(txtFields.Text)
txtFields.Text = Trim(txtFields.Text)
'strTmp = cCrypto.ConvertStringFromHex(Left(rs("Company_ResMS"), 6))
strTmp = cCrypto.ConvertStringFromHex(VB.Left(txtFields.Text, Len(txtFields.Text) - 5))
System.Windows.Forms.Application.DoEvents()
arData = cCrypto.StringToByteArray(strTmp)
System.Windows.Forms.Application.DoEvents()
arPWord = cCrypto.StringToByteArray(Val(VB.Right(txtFields.Text, 5)))
System.Windows.Forms.Application.DoEvents()
cCrypto.PassWord = arPWord
System.Windows.Forms.Application.DoEvents()
cCrypto.InputData = System.Text.UnicodeEncoding.Unicode.GetString(arData)
System.Windows.Forms.Application.DoEvents()
' Decrypt the data input from the encrypted text box
'If cCrypto.Decrypt(g_intHashType, m_intCipher) Then
If cCrypto.Decrypt(2, 1) Then
System.Windows.Forms.Application.DoEvents()
arData = cCrypto.OutputData.Clone()
strSerial = cCrypto.ByteArrayToString(arData)
End If
If VB.Left(strSerial, 3) = "liq" Then
'Create date password
If IsNumeric(Mid(strSerial, 4, Len(strSerial))) Then
strSerial = Mid(strSerial, 4, Len(strSerial))
intYear = CShort(Mid(strSerial, 5, 2))
intMonth = CShort(Mid(strSerial, 3, 2))
intDate = CShort(VB.Left(strSerial, 2))
If (intDate / 2) = System.Math.Round(intDate / 2) Then
intDate = intDate / 2
Else
GoTo jumpOut
End If
If (intMonth / 3) = System.Math.Round(intMonth / 3) Then
intMonth = intMonth / 3
Else
GoTo jumpOut
End If
If (intYear / 4) = System.Math.Round(intYear / 4) Then
intYear = intYear / 4
Else
GoTo jumpOut
End If
stPass = "20"
If Len(CStr(intYear)) = 1 Then stPass = stPass & "0" & intYear & "/" Else stPass = stPass & intYear & "/"
If Len(CStr(intMonth)) = 1 Then stPass = stPass & "0" & intMonth & "/" Else stPass = stPass & intMonth & "/"
If Len(CStr(intDate)) = 1 Then stPass = stPass & "0" & intDate Else stPass = stPass & intDate
If IsDate(stPass) Then
If CDate(stPass) >= (System.Date.FromOADate(Today.ToOADate - 31)) Then
cnnDB.Execute("UPDATE Company SET Company_ResMS = '" & txtFields.Text & "';")
CDKey = True
End If
End If
Else
MsgBox("Not a Valid 4LIQUOR Key!", MsgBoxStyle.Critical)
End If
Else
MsgBox("Not a Valid 4LIQUOR Key!", MsgBoxStyle.Critical)
End If
jumpOut:
cCrypto = Nothing ' Free the Crypto class from memory
strTmp = New String(Chr(0), 250) ' overwrite data in temp variable
'Exit Sub
Else
MsgBox("Unable to locate the '4POS Application Suite' database.", MsgBoxStyle.Critical, "4POS")
'End
End If
Else
MsgBox("Unable to locate the '4POS Application Suite' database.", MsgBoxStyle.Critical, "4POS")
'End
End If
cmdClose.Focus()
System.Windows.Forms.Application.DoEvents()
Me.Close()
End Sub
End Class
|
nodoid/PointOfSale
|
VB/4PosBackOffice.NET/frmStockTakeLIQCode.vb
|
Visual Basic
|
mit
| 8,690
|
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated by a tool.
' Runtime Version:4.0.30319.42000
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Namespace My
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0"), _
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Partial Friend NotInheritable Class MySettings
Inherits Global.System.Configuration.ApplicationSettingsBase
Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings)
#Region "My.Settings Auto-Save Functionality"
#If _MyType = "WindowsForms" Then
Private Shared addedHandler As Boolean
Private Shared addedHandlerLockObject As New Object
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
If My.Application.SaveMySettingsOnExit Then
My.Settings.Save()
End If
End Sub
#End If
#End Region
Public Shared ReadOnly Property [Default]() As MySettings
Get
#If _MyType = "WindowsForms" Then
If Not addedHandler Then
SyncLock addedHandlerLockObject
If Not addedHandler Then
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
addedHandler = True
End If
End SyncLock
End If
#End If
Return defaultInstance
End Get
End Property
End Class
End Namespace
Namespace My
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
Friend Module MySettingsProperty
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
Friend ReadOnly Property Settings() As Global.Solicitud.My.MySettings
Get
Return Global.Solicitud.My.MySettings.Default
End Get
End Property
End Module
End Namespace
|
jdmg94/SL-Contabilidad
|
ClinicaSL/Solicitud/My Project/Settings.Designer.vb
|
Visual Basic
|
mit
| 2,908
|
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class IconSlot
Inherits System.Windows.Forms.UserControl
'UserControl overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.PictureBox1 = New System.Windows.Forms.PictureBox()
CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'PictureBox1
'
Me.PictureBox1.Dock = System.Windows.Forms.DockStyle.Fill
Me.PictureBox1.Image = Global.MuntuGUI.My.Resources.Resources.ic_picture
Me.PictureBox1.Location = New System.Drawing.Point(0, 0)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(69, 69)
Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.PictureBox1.TabIndex = 0
Me.PictureBox1.TabStop = False
'
'MaterialIconSlot
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.BackColor = System.Drawing.Color.Transparent
Me.Controls.Add(Me.PictureBox1)
Me.Name = "MaterialIconSlot"
Me.Size = New System.Drawing.Size(69, 69)
CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
End Class
|
RaisyClutch/Beautiful-GUI-Controls-vb.net-c-Muntu
|
Controls/IconSlot.Designer.vb
|
Visual Basic
|
mit
| 2,229
|
#Region "License"
' The MIT License (MIT)
'
' Copyright (c) 2018 Richard L King (TradeWright Software Systems)
'
' Permission is hereby granted, free of charge, to any person obtaining a copy
' of this software and associated documentation files (the "Software"), to deal
' in the Software without restriction, including without limitation the rights
' to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
' copies of the Software, and to permit persons to whom the Software is
' furnished to do so, subject to the following conditions:
'
' The above copyright notice and this permission notice shall be included in all
' copies or substantial portions of the Software.
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
' IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
' FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
' AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
' LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
' OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
' SOFTWARE.
#End Region
Public Class TickSizeEventArgs
Inherits AbstractEventArgsWithTimestamp
Public Property Field As TickType
Public Property Size As Integer
Public Property TickerId As Integer
Public Sub New(timestamp As DateTime, tickerId As Integer, field As TickType, size As Integer)
MyBase.New()
Me._Timestamp = timestamp
Me.TickerId = tickerId
Me.Field = field
Me.Size = size
End Sub
End Class
|
tradewright/tradewright-twsapi
|
src/IBApi/EventArgs/TickSizeEventArgs.vb
|
Visual Basic
|
mit
| 1,635
|
Imports System.Runtime.Serialization
<Serializable>
Public Class OpenType
Public Property Internal As Boolean
Public Property ProgramPath As String
Sub New(internal As Boolean, programPath As String)
Me.Internal = internal
Me.ProgramPath = programPath
End Sub
Public Sub New()
End Sub
End Class
|
KameQuazi/Software-Major-Assignment-2k18
|
LampCommon/user/DesignerOpenType.vb
|
Visual Basic
|
mit
| 341
|
Imports System
Imports System.IO
Imports System.Collections
Module Module1
Sub Main()
Console.Clear()
Console.WriteLine("아무말 v2.00")
Console.WriteLine("Build by null, at 20170622. Twitter @ThisIsMoneLTAN")
Console.WriteLine(" ")
Console.WriteLine("특정 명령어에 대한 자세한 내용이 필요하면 help를 입력하세요.")
Do
Dim txtxt As String
Console.WriteLine("현재 타임스탬프는 " & Format(Now, "yyyy-MM-dd hh:mm:ss") & " 입니다.")
Console.Write("아무말 입력:")
txtxt = Console.ReadLine()
Select Case txtxt
Case "help"
Console.WriteLine(" ")
Console.WriteLine("lf 여러 줄로 메모를 작성합니다.")
Console.WriteLine("cls 화면이 청소됩니다.")
Console.WriteLine("open 데이터베이스 파일을 엽니다.")
Console.WriteLine("copy 데이터베이스가 자동 백업됩니다.")
Console.WriteLine("bye 프로그램이 종료됩니다.")
Console.WriteLine(" ")
Console.WriteLine("자세한 정보는 해당 프로그램에 대한 GitHub 레포지토리 (https://github.com/NewMoneL/AmuMal2)를 참조해주세요.")
Console.WriteLine(" ")
Case "lf"
lf()
Case "cls"
Console.Clear()
Case "open"
If System.IO.File.Exists(System.IO.Directory.GetCurrentDirectory & "\amumal.txt") = True Then
Process.Start(System.IO.Directory.GetCurrentDirectory & "\amumal.txt")
Else
Console.WriteLine("데이터베이스가 없거나 아무 내용도 없습니다. 먼저 메모를 추가하세요.")
End If
Case "copy"
Copy()
Case "bye"
End
Case Else
Write(txtxt)
End Select
Loop
End Sub
Sub Write(txt As String)
Dim FileNum As Integer
Dim FileName As String
FileNum = FreeFile()
FileName = System.IO.Directory.GetCurrentDirectory & "\amumal.txt"
FileOpen(FileNum, FileName, OpenMode.Append)
Print(FileNum, vbCrLf & txt)
Print(FileNum, vbCrLf & Format(Now, "yyyy-MM-dd hh:mm:ss"))
Print(FileNum, vbCrLf & "----------")
FileClose(FileNum)
End Sub
Sub lf()
Dim FileNum As Integer
Dim FileName As String
Dim txt2 As String
Dim ExitMe As Boolean = False
FileNum = FreeFile()
FileName = System.IO.Directory.GetCurrentDirectory & "\amumal.txt"
Console.WriteLine("여러 줄로 메모를 작성합니다. 끝내려면 end를 입력하세요.")
Do While ExitMe = False
txt2 = Console.ReadLine()
If txt2 = "end" Then
ExitMe = True
Else
FileOpen(FileNum, FileName, OpenMode.Append)
Print(FileNum, vbCrLf & txt2)
FileClose(FileNum)
End If
Loop
FileOpen(FileNum, FileName, OpenMode.Append)
Print(FileNum, vbCrLf & Format(Now, "yyyy-MM-dd hh:mm:ss"))
Print(FileNum, vbCrLf & "----------")
FileClose(FileNum)
End Sub
Sub Copy()
Dim FileToCopy As String = System.IO.Directory.GetCurrentDirectory & "\amumal.txt"
Dim NewCopy As String = System.IO.Directory.GetCurrentDirectory & "\amumal_" & System.Guid.NewGuid.ToString & ".txt"
If System.IO.File.Exists(FileToCopy) = True Then
System.IO.File.Copy(FileToCopy, NewCopy)
Console.WriteLine("복사되었습니다.")
Console.WriteLine("파일 이름은 " & NewCopy & " 입니다.")
Else
Console.WriteLine("데이터베이스가 없거나 아무 내용도 없습니다. 먼저 메모를 추가하세요.")
End If
End Sub
End Module
|
NewMoneL/AmuMal2
|
AmuMal2/AmuMal2/AmuMal2/Module1.vb
|
Visual Basic
|
apache-2.0
| 4,306
|
Partial Public MustInherit Class Base
''' <summary>会话数据</summary>
Protected m_Session As ZS.RouterOS.Session = Nothing
Public Sub New(ByVal session As ZS.RouterOS.Session)
If (CheckSession(session)) Then
m_Session = session
End If
End Sub
Private Function CheckSession(ByVal session As ZS.RouterOS.Session)
If (session Is Nothing) Then
Throw New ApplicationException("未指定Session对象!")
End If
Return True
End Function
End Class
|
sugartomato/AllProjects
|
ZS.RouterOS/ZS.RouterOS/Base.vb
|
Visual Basic
|
apache-2.0
| 543
|
Imports System
Imports System.Reflection
Imports System.Runtime.InteropServices
' General Information about an assembly is controlled through the following
' set of attributes. Change these attribute values to modify the information
' associated with an assembly.
' Review the values of the assembly attributes
<Assembly: AssemblyTitle("PhoneDragDropVb")>
<Assembly: AssemblyDescription("")>
<Assembly: AssemblyConfiguration("")>
<Assembly: AssemblyCompany("Microsoft Corp.")>
<Assembly: AssemblyProduct("PhoneDragDropVb")>
<Assembly: AssemblyCopyright("Copyright © Microsoft Corp. 2010")>
<Assembly: AssemblyTrademark("")>
<Assembly: AssemblyCulture("")>
' Setting ComVisible to false makes the types in this assembly not visible
' to COM components. If you need to access a type in this assembly from
' COM, set the ComVisible attribute to true on that type.
<assembly: ComVisible(false)>
' The following GUID is for the ID of the typelib if this project is exposed to COM
<assembly: Guid("AAB3C7FA-CB78-4734-BBDD-A4C1C9E4D7B3")>
' Version information for an assembly consists of the following four values:
'
' Major Version
' Minor Version
' Build Number
' Revision
'
' You can specify all the values or you can default the Revision and Build Numbers
' by using the '*' as shown below:
<assembly: AssemblyVersion("1.0.0.0")>
<assembly: AssemblyFileVersion("1.0.0.0")>
|
jwooley/RxSamples
|
WP7RxSamplesVB/PhoneDragDropVb/PhoneDragDropVb/My Project/AssemblyInfo.vb
|
Visual Basic
|
mit
| 1,414
|
Imports System.Collections.Generic
Imports Aspose.Email.Imap
Imports Aspose.Email.Mail
Namespace Aspose.Email.Examples.VisualBasic.Email.IMAP
Class ListingMessagesWithPagingSupport
Private Shared Sub Run()
' ExStart: ListingMessagesWithPagingSupport
Using client As New ImapClient("host.domain.com", 993, "username", "password")
Try
Dim messagesNum As Integer = 12
Dim itemsPerPage As Integer = 5
Dim message As MailMessage = Nothing
' Create some test messages and append these to server's inbox
For i As Integer = 0 To messagesNum - 1
message = New MailMessage("from@domain.com", "to@domain.com", "EMAILNET-35157 - " + Guid.NewGuid().ToString(), "EMAILNET-35157 Move paging parameters to separate class")
client.AppendMessage(ImapFolderInfo.InBox, message)
Next
' List messages from inbox
client.SelectFolder(ImapFolderInfo.InBox)
Dim totalMessageInfoCol As ImapMessageInfoCollection = client.ListMessages()
' Verify the number of messages added
Console.WriteLine(totalMessageInfoCol.Count)
' RETREIVE THE MESSAGES USING PAGING SUPPORT
Dim pages As New List(Of ImapPageInfo)()
Dim pageInfo As ImapPageInfo = client.ListMessagesByPage(itemsPerPage)
Console.WriteLine(pageInfo.TotalCount)
pages.Add(pageInfo)
While Not pageInfo.LastPage
pageInfo = client.ListMessagesByPage(pageInfo.NextPage)
pages.Add(pageInfo)
End While
Dim retrievedItems As Integer = 0
For Each folderCol As ImapPageInfo In pages
retrievedItems += folderCol.Items.Count
Next
Console.WriteLine(retrievedItems)
Finally
End Try
End Using
' ExEnd: ListingMessagesWithPagingSupport
End Sub
End Class
End Namespace
|
maria-shahid-aspose/Aspose.Email-for-.NET
|
Examples/VisualBasic/IMAP/ListingMessagesWithPagingSupport.vb
|
Visual Basic
|
mit
| 2,266
|
' Licensed to the .NET Foundation under one or more agreements.
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.
Imports Microsoft.CodeAnalysis.Test.Utilities
Imports Roslyn.Test.Utilities
Imports Xunit
Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests.Semantics
Public Class AttributeTests_ObsoleteAttribute
Inherits BasicTestBase
<Fact()>
Public Sub TestObsoleteAttributeOnTypes()
Dim source =
<compilation>
<file name="test.vb"><![CDATA[
Imports System
Module Module1
Dim field1 As Class1
Property Prop1 As Class1
Sub Method1(c As Class1)
End Sub
Sub Main()
Dim c As Class1 = Nothing
field1 = c
Prop1 = c
Method1(New Class1())
Dim x As Mydeleg = Function(i) i
End Sub
End Module
<Obsolete("Do not use this type", True)>
Class Class1
End Class
<Obsolete("Do not use A1", False)>
<A2>
Class A1
Inherits Attribute
End Class
<Obsolete>
<A1>
Class A2
Inherits Attribute
End Class
<A1>
Class A3
Inherits Attribute
End Class
Class AttrWithType
Inherits Attribute
Sub New(t As Type)
End Sub
End Class
<Obsolete>
<Another>
Class G(Of T, U)
End Class
<Obsolete>
<AttrWithType(GetType(G(Of Integer, AnotherAttribute)))>
Class AnotherAttribute
Inherits Attribute
End Class
<AttrWithType(GetType(G(Of Integer, AnotherAttribute)))>
Class AnotherAttribute1
Inherits Attribute
End Class
<System.Obsolete("This message" & " should be concat'ed", Not (False))>
<SelfRecursive1>
Class SelfRecursive1Attribute
Inherits Attribute
End Class
<Obsolete>
Public Delegate Function Mydeleg(x As Integer) As Integer
<GooAttribute.BarAttribute.Baz>
<Obsolete("Blah")>
Class GooAttribute
Inherits Attribute
Class BazAttribute
Inherits Attribute
End Class
Class BarAttribute
Inherits GooAttribute
End Class
End Class
Interface IGoo(Of T)
End Interface
<Obsolete>
Class SelfReferenceInBase
Implements IGoo(Of SelfReferenceInBase)
End Class
Class SelfReferenceInBase1
Implements IGoo(Of SelfReferenceInBase)
End Class
]]>
</file>
</compilation>
CreateCompilationWithMscorlib40AndVBRuntime(source).VerifyDiagnostics(
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "AnotherAttribute").WithArguments("AnotherAttribute"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbol2, "A1").WithArguments("A1", "Do not use A1"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "G(Of Integer, AnotherAttribute)").WithArguments("G(Of Integer, AnotherAttribute)"),
Diagnostic(ERRID.ERR_UseOfObsoleteSymbol2, "Class1").WithArguments("Class1", "Do not use this type"),
Diagnostic(ERRID.ERR_UseOfObsoleteSymbol2, "Class1").WithArguments("Class1", "Do not use this type"),
Diagnostic(ERRID.ERR_UseOfObsoleteSymbol2, "Class1").WithArguments("Class1", "Do not use this type"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "SelfReferenceInBase").WithArguments("SelfReferenceInBase"),
Diagnostic(ERRID.ERR_UseOfObsoleteSymbol2, "Class1").WithArguments("Class1", "Do not use this type"),
Diagnostic(ERRID.ERR_UseOfObsoleteSymbol2, "Class1").WithArguments("Class1", "Do not use this type"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "Mydeleg").WithArguments("Mydeleg"))
End Sub
<Fact()>
Public Sub TestObsoleteAttributeOnMembers()
Dim source =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
Imports System.Runtime.CompilerServices
Public Class Test
Public Shared Sub Main()
ObsoleteMethod1()
ObsoleteMethod2()
ObsoleteMethod3()
ObsoleteMethod5()
Dim t As Test = New Test()
t.ObsoleteMethod4()
Dim f = t.field1
Dim p1 = t.Property1
Dim p2 = t.Property2
AddHandler t.event1, Sub() Return
t.ObsoleteExtensionMethod1()
Dim func As Action(Of Integer) = AddressOf t.ObsoleteMethod4
func(1)
Dim func1 As Action = AddressOf t.ObsoleteMethod4
func1()
Dim t1 As Test = New Test With {.Property1 = 10, .Property2 = 20}
Dim i1 = t1(10)
Dim gt As GenericTest(Of Integer) = New GenericTest(Of Integer)()
gt.ObsoleteMethod1(Of Double)()
Dim gf = gt.field1
Dim gp1 = gt.Property1
AddHandler gt.event1, Sub(i) Return
End Sub
<Obsolete>
Public Shared Sub ObsoleteMethod1()
End Sub
<Obsolete("Do not call this method")>
Public Shared Sub ObsoleteMethod2()
End Sub
<Obsolete("Do not call this method", True)>
Public Shared Sub ObsoleteMethod3()
End Sub
<Obsolete("Do not call this method")>
Public Sub ObsoleteMethod4()
End Sub
<Obsolete("Do not call this method")>
Public Sub ObsoleteMethod4(x As Integer)
End Sub
<Obsolete(Nothing, True)>
Public Shared Sub ObsoleteMethod5()
End Sub
<Obsolete>
Public Sub New()
End Sub
<Obsolete("Do not use this field")>
Public field1 As Integer = 0
<Obsolete("Do not use this property")>
Public Property Property1 As Integer
<Obsolete("Do not use this property")>
Public Property Property2 As Integer
Get
Return 11
End Get
Set(value As Integer)
End Set
End Property
<Obsolete("Do not use this event")>
Public Event event1 As Action
Public ReadOnly Property Prop2 As Integer
<Obsolete>
Get
Return 10
End Get
End Property
Public Property Prop3 As Integer
Get
Return 10
End Get
<Obsolete>
Set(value As Integer)
End Set
End Property
Public Custom Event event2 As Action
<Obsolete>
AddHandler(value As Action)
End AddHandler
<Obsolete>
RemoveHandler(value As Action)
End RemoveHandler
<Obsolete>
RaiseEvent()
End RaiseEvent
End Event
<Obsolete>
Default Public ReadOnly Property Item(x As Integer)
Get
Return 10
End Get
End Property
End Class
Public Class GenericTest(Of T)
<Obsolete>
Public Sub ObsoleteMethod1(Of U)()
End Sub
<Obsolete("Do not use this field")>
Public field1 As T = Nothing
<Obsolete("Do not use this property")>
Public Property Property1 As T
<Obsolete("Do not use this event")>
Public Event event1 As Action(Of T)
End Class
Public Module TestExtension
<Obsolete("Do not call this extension method")>
<Extension>
Public Sub ObsoleteExtensionMethod1(t As Test)
End Sub
End Module
]]>
</file>
</compilation>
CreateCompilationWithMscorlib40AndVBRuntimeAndReferences(source, {SystemCoreRef}).AssertTheseDiagnostics(
<![CDATA[
BC40008: 'Public Shared Sub ObsoleteMethod1()' is obsolete.
ObsoleteMethod1()
~~~~~~~~~~~~~~~~~
BC40000: 'Public Shared Sub ObsoleteMethod2()' is obsolete: 'Do not call this method'.
ObsoleteMethod2()
~~~~~~~~~~~~~~~~~
BC30668: 'Public Shared Sub ObsoleteMethod3()' is obsolete: 'Do not call this method'.
ObsoleteMethod3()
~~~~~~~~~~~~~~~~~
BC31075: 'Public Shared Sub ObsoleteMethod5()' is obsolete.
ObsoleteMethod5()
~~~~~~~~~~~~~~~~~
BC40008: 'Public Sub New()' is obsolete.
Dim t As Test = New Test()
~~~~~~~~~~
BC40000: 'Public Sub ObsoleteMethod4()' is obsolete: 'Do not call this method'.
t.ObsoleteMethod4()
~~~~~~~~~~~~~~~~~~~
BC40000: 'Public field1 As Integer' is obsolete: 'Do not use this field'.
Dim f = t.field1
~~~~~~~~
BC40000: 'Public Property Property1 As Integer' is obsolete: 'Do not use this property'.
Dim p1 = t.Property1
~~~~~~~~~~~
BC40000: 'Public Property Property2 As Integer' is obsolete: 'Do not use this property'.
Dim p2 = t.Property2
~~~~~~~~~~~
BC40000: 'Public Event event1 As Action' is obsolete: 'Do not use this event'.
AddHandler t.event1, Sub() Return
~~~~~~~~
BC40000: 'Public Sub ObsoleteExtensionMethod1()' is obsolete: 'Do not call this extension method'.
t.ObsoleteExtensionMethod1()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BC40000: 'Public Sub ObsoleteMethod4(x As Integer)' is obsolete: 'Do not call this method'.
Dim func As Action(Of Integer) = AddressOf t.ObsoleteMethod4
~~~~~~~~~~~~~~~~~
BC40000: 'Public Sub ObsoleteMethod4()' is obsolete: 'Do not call this method'.
Dim func1 As Action = AddressOf t.ObsoleteMethod4
~~~~~~~~~~~~~~~~~
BC40008: 'Public Sub New()' is obsolete.
Dim t1 As Test = New Test With {.Property1 = 10, .Property2 = 20}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BC40000: 'Public Property Property1 As Integer' is obsolete: 'Do not use this property'.
Dim t1 As Test = New Test With {.Property1 = 10, .Property2 = 20}
~~~~~~~~~
BC40000: 'Public Property Property2 As Integer' is obsolete: 'Do not use this property'.
Dim t1 As Test = New Test With {.Property1 = 10, .Property2 = 20}
~~~~~~~~~
BC40008: 'Public ReadOnly Default Property Item(x As Integer) As Object' is obsolete.
Dim i1 = t1(10)
~~~~~~
BC40008: 'Public Sub ObsoleteMethod1(Of Double)()' is obsolete.
gt.ObsoleteMethod1(Of Double)()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BC40000: 'Public field1 As Integer' is obsolete: 'Do not use this field'.
Dim gf = gt.field1
~~~~~~~~~
BC40000: 'Public Property Property1 As Integer' is obsolete: 'Do not use this property'.
Dim gp1 = gt.Property1
~~~~~~~~~~~~
BC40000: 'Public Event event1 As Action(Of Integer)' is obsolete: 'Do not use this event'.
AddHandler gt.event1, Sub(i) Return
~~~~~~~~~
BC31142: 'System.ObsoleteAttribute' cannot be applied to the 'AddHandler', 'RemoveHandler', or 'RaiseEvent' definitions. If required, apply the attribute directly to the event.
<Obsolete>
~~~~~~~~~~~
BC31142: 'System.ObsoleteAttribute' cannot be applied to the 'AddHandler', 'RemoveHandler', or 'RaiseEvent' definitions. If required, apply the attribute directly to the event.
<Obsolete>
~~~~~~~~~~~
BC31142: 'System.ObsoleteAttribute' cannot be applied to the 'AddHandler', 'RemoveHandler', or 'RaiseEvent' definitions. If required, apply the attribute directly to the event.
<Obsolete>
~~~~~~~~~~~
]]>)
End Sub
<Fact>
Public Sub TestObsoleteAttributeOnOperators()
Dim source =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
Public Class Test
Public Shared Sub Main()
Dim t As New Test()
t = 10
t = CType("10", Test)
Dim c As New Test()
Dim c1 As Test = -c
Dim b1 As Boolean = If(c, True, False)
If (c AndAlso c1) Then
c1 += c
End If
End Sub
<Obsolete>
Public Shared Widening Operator CType(x As Integer) As Test
Return New Test()
End Operator
<Obsolete>
Public Shared Narrowing Operator CType(x As String) As Test
Return New Test()
End Operator
<Obsolete>
Public Shared Operator -(x As test) As Test
Return New Test()
End Operator
<Obsolete>
Public Shared Operator IsTrue(x As Test) As Boolean
Return True
End Operator
<Obsolete>
Public Shared Operator IsFalse(x As test) As Boolean
Return False
End Operator
<Obsolete>
Public Shared Operator +(x As Test, y As Test) As Test
Return New Test()
End Operator
<Obsolete>
Public Shared Operator And(x As Test, y As Test) As Test
Return New Test()
End Operator
End Class
]]>
</file>
</compilation>
CreateCompilationWithMscorlib40(source).VerifyDiagnostics(
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "10").WithArguments("Public Shared Widening Operator CType(x As Integer) As Test"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "CType(""10"", Test)").WithArguments("Public Shared Narrowing Operator CType(x As String) As Test"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "-c").WithArguments("Public Shared Operator -(x As Test) As Test"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "c").WithArguments("Public Shared Operator IsTrue(x As Test) As Boolean"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "c AndAlso c1").WithArguments("Public Shared Operator And(x As Test, y As Test) As Test"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "c AndAlso c1").WithArguments("Public Shared Operator IsFalse(x As Test) As Boolean"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "(c AndAlso c1)").WithArguments("Public Shared Operator IsTrue(x As Test) As Boolean"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "c1 += c").WithArguments("Public Shared Operator +(x As Test, y As Test) As Test"))
End Sub
<Fact>
Public Sub TestObsoleteAttributeInMetadata()
Dim peSource =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
<Obsolete>
Public Class TestClass1
End Class
<Obsolete("TestClass2 is obsolete")>
Public Class TestClass2
End Class
<Obsolete("Do not use TestClass3", True)>
Public Class TestClass3
End Class
<Obsolete("TestClass4 is obsolete", False)>
Public Class TestClass4
End Class
<Obsolete(Nothing, True)>
Public Module TestModule
Public Sub TestMethod()
End Sub
End Module
Public Class TestClass
<Obsolete("Do not use TestMethod")>
Public Sub TestMethod()
End Sub
<Obsolete("Do not use Prop1", False)>
Public Property Prop1 As Integer
<Obsolete("Do not use field1", True)>
Public field1 As TestClass
<Obsolete("Do not use event", True)>
Public Event event1 As Action
End Class
]]>
</file>
</compilation>
Dim peReference = MetadataReference.CreateFromImage(CreateCompilationWithMscorlib40AndVBRuntime(peSource).EmitToArray())
Dim source =
<compilation>
<file name="b.vb"><![CDATA[
Public Class Test
Public Shared Sub goo1(c As TestClass1)
End Sub
Public Shared Sub goo2(c As TestClass2)
End Sub
Public Shared Sub goo3(c As TestClass3)
End Sub
Public Shared Sub goo4(c As TestClass4)
End Sub
Public Shared Sub Main()
Dim c As TestClass = New TestClass()
c.TestMethod()
Dim i = c.Prop1
c = c.field1
AddHandler c.event1, Sub() Return
TestModule.TestMethod()
End Sub
End Class
]]>
</file>
</compilation>
CreateCompilationWithMscorlib40AndReferences(source, {peReference}).VerifyDiagnostics(
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "TestClass1").WithArguments("TestClass1"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbol2, "TestClass2").WithArguments("TestClass2", "TestClass2 is obsolete"),
Diagnostic(ERRID.ERR_UseOfObsoleteSymbol2, "TestClass3").WithArguments("TestClass3", "Do not use TestClass3"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbol2, "TestClass4").WithArguments("TestClass4", "TestClass4 is obsolete"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbol2, "c.TestMethod()").WithArguments("Public Sub TestMethod()", "Do not use TestMethod"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbol2, "c.Prop1").WithArguments("Public Property Prop1 As Integer", "Do not use Prop1"),
Diagnostic(ERRID.ERR_UseOfObsoleteSymbol2, "c.field1").WithArguments("Public field1 As TestClass", "Do not use field1"),
Diagnostic(ERRID.ERR_UseOfObsoleteSymbol2, "c.event1").WithArguments("Public Event event1 As System.Action", "Do not use event"),
Diagnostic(ERRID.ERR_UseOfObsoleteSymbolNoMessage1, "TestModule").WithArguments("TestModule"))
End Sub
<Fact>
Public Sub TestObsoleteAttributeCycles()
Dim source =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
Public Class Test
<Obsolete("F1 is obsolete")>
<SomeAttr(F1)>
Public Const F1 As Integer = 10
<Obsolete("F2 is obsolete", True)>
<SomeAttr(F3)>
Public Const F2 As Integer = 10
<Obsolete("F3 is obsolete")>
<SomeAttr(F2)>
Public Const F3 As Integer = 10
<Obsolete(F4, True)>
Public Const F4 As String = "blah"
<Obsolete(F5)>
Public F5 As String = "blah"
<Obsolete(P1, True)>
Public ReadOnly Property P1 As String
Get
Return "blah"
End Get
End Property
<Obsolete>
<SomeAttr(P2, True)>
Public ReadOnly Property P2 As String
Get
Return "blah"
End Get
End Property
<Obsolete(Method1)>
Public Sub Method1()
End Sub
<Obsolete()>
<SomeAttr1(Method2)>
Public Sub Method2()
End Sub
<Obsolete(F6)>
<SomeAttr(F6)>
<SomeAttr(F7)>
Public Const F6 As String = "F6 is obsolete"
<Obsolete(F7, True)>
<SomeAttr(F6)>
<SomeAttr(F7)>
Public Const F7 As String = "F7 is obsolete"
End Class
<AttributeUsage(AttributeTargets.All, AllowMultiple:=True)>
Public Class SomeAttr
Inherits Attribute
Public Sub New(x As Integer)
End Sub
Public Sub New(x As String)
End Sub
End Class
Public Class SomeAttr1
Inherits Attribute
Public Sub New(x As Action)
End Sub
End Class
]]>
</file>
</compilation>
CreateCompilationWithMscorlib40(source).VerifyDiagnostics(
Diagnostic(ERRID.ERR_BadInstanceMemberAccess, "F5"),
Diagnostic(ERRID.ERR_RequiredConstExpr, "F5"),
Diagnostic(ERRID.ERR_BadInstanceMemberAccess, "P1"),
Diagnostic(ERRID.ERR_RequiredConstExpr, "P1"),
Diagnostic(ERRID.ERR_BadInstanceMemberAccess, "P2"),
Diagnostic(ERRID.ERR_NoArgumentCountOverloadCandidates1, "SomeAttr").WithArguments("New"),
Diagnostic(ERRID.ERR_RequiredConstExpr, "P2"),
Diagnostic(ERRID.ERR_BadInstanceMemberAccess, "Method1"),
Diagnostic(ERRID.ERR_BadInstanceMemberAccess, "Method2"))
End Sub
<Fact>
Public Sub TestObsoleteAttributeSuppress()
Dim source =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
<Obsolete>
Public Class SomeType
Public Shared Instance As SomeType
Public Const Message As String = "goo"
End Class
<Obsolete>
Module Mod1
Dim someField As SomeType = SomeType.Instance
Public Property someProp As SomeType
Sub goo(x As SomeType)
End Sub
End Module
Public Class Test
<Obsolete>
Dim someField As SomeType = SomeType.Instance
<Obsolete>
Dim someFuncField As Func(Of SomeType) = Function() New SomeType()
<Obsolete>
Event someEvent As Action(Of SomeType)
<Obsolete>
Function goo(x As SomeType) As SomeType
Dim y As SomeType = New SomeType()
Return x
End Function
End Class
<Obsolete>
Public Class Base(Of T)
End Class
<Obsolete>
Public Class Derived
Inherits Base(Of Base(Of Integer))
End Class
]]>
</file>
</compilation>
CreateCompilationWithMscorlib40AndVBRuntime(source).VerifyDiagnostics()
End Sub
<Fact>
Public Sub TestObsoleteAttributeSuppress_02()
Dim source =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
<Obsolete>
Public Class SomeType
End Class
<Obsolete>
Public Delegate Sub MyDeleg()
Public Class Test
<Obsolete>
Public Shared Property someProp As SomeType
<Obsolete>
Default Public Property Item(x As SomeType) As SomeType
Get
Return Nothing
End Get
<Obsolete>
Set(value As SomeType)
Dim y As SomeType = New SomeType()
End Set
End Property
<Obsolete>
Custom Event goo As MyDeleg
AddHandler(value As MyDeleg)
End AddHandler
RemoveHandler(value As MyDeleg)
End RemoveHandler
RaiseEvent()
End RaiseEvent
End Event
<Obsolete()>
Public Property Prop1 As SomeType
Get
Return New SomeType()
End Get
Set(ByVal Value As SomeType)
Dim p As New SomeType()
End Set
End Property
End Class
]]>
</file>
</compilation>
CreateCompilationWithMscorlib40(source).VerifyDiagnostics()
End Sub
<Fact>
Public Sub TestObsoleteAndPropertyAccessors()
Dim source =
<compilation>
<file><![CDATA[
Imports System
Namespace Windows.Foundation.Metadata
Public NotInheritable Class DeprecatedAttribute
Inherits Attribute
Public Sub New(message As String, type As DeprecationType, version As UInteger)
End Sub
End Class
Public Enum DeprecationType
Deprecate
Remove
End Enum
End Namespace
]]>
</file>
<file><![CDATA[
Imports Windows.Foundation.Metadata
<Deprecated(Nothing, DeprecationType.Deprecate, 0)>Class A
End Class
<Deprecated(Nothing, DeprecationType.Deprecate, 0)>Class B
End Class
<Deprecated(Nothing, DeprecationType.Deprecate, 0)>Class C
End Class
Class D
ReadOnly Property P As Object
Get
Return New A()
End Get
End Property
<Deprecated(Nothing, DeprecationType.Deprecate, 0)>ReadOnly Property Q As Object
Get
Return New B()
End Get
End Property
ReadOnly Property R As Object
<Deprecated(Nothing, DeprecationType.Deprecate, 0)>Get
Return New C()
End Get
End Property
End Class
]]>
</file>
</compilation>
Dim comp = CreateCompilationWithMscorlib40(source)
comp.AssertTheseDiagnostics(<errors><![CDATA[
BC40008: 'A' is obsolete.
Return New A()
~
]]></errors>)
End Sub
<Fact>
Public Sub TestObsoleteAndEventAccessors()
Dim source =
<compilation>
<file><![CDATA[
Imports System
Namespace Windows.Foundation.Metadata
Public NotInheritable Class DeprecatedAttribute
Inherits Attribute
Public Sub New(message As String, type As DeprecationType, version As UInteger)
End Sub
End Class
Public Enum DeprecationType
Deprecate
Remove
End Enum
End Namespace
]]>
</file>
<file><![CDATA[
Imports System
Imports Windows.Foundation.Metadata
<Deprecated(Nothing, DeprecationType.Deprecate, 0)>Class A
End Class
<Deprecated(Nothing, DeprecationType.Deprecate, 0)>Class B
End Class
<Deprecated(Nothing, DeprecationType.Deprecate, 0)>Class C
End Class
Class D
Custom Event E As EventHandler
AddHandler(value As EventHandler)
End AddHandler
RemoveHandler(value As EventHandler)
M(New A())
End RemoveHandler
RaiseEvent
End RaiseEvent
End Event
<Deprecated(Nothing, DeprecationType.Deprecate, 0)>Custom Event F As EventHandler
AddHandler(value As EventHandler)
End AddHandler
RemoveHandler(value As EventHandler)
M(New B())
End RemoveHandler
RaiseEvent
End RaiseEvent
End Event
Custom Event G As EventHandler
AddHandler(value As EventHandler)
End AddHandler
<Deprecated(Nothing, DeprecationType.Deprecate, 0)>RemoveHandler(value As EventHandler)
M(New C())
End RemoveHandler
RaiseEvent
End RaiseEvent
End Event
Shared Sub M(o As Object)
End Sub
End Class
]]>
</file>
</compilation>
Dim comp = CreateCompilationWithMscorlib40(source)
comp.AssertTheseDiagnostics(<errors><![CDATA[
BC40008: 'A' is obsolete.
M(New A())
~
BC31142: 'Windows.Foundation.Metadata.DeprecatedAttribute' cannot be applied to the 'AddHandler', 'RemoveHandler', or 'RaiseEvent' definitions. If required, apply the attribute directly to the event.
<Deprecated(Nothing, DeprecationType.Deprecate, 0)>RemoveHandler(value As EventHandler)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
]]></errors>)
End Sub
<Fact>
Public Sub TestObsoleteAttributeCycles_02()
Dim source =
<compilation>
<file name="a.vb"><![CDATA[
<Goo>
Class Goo
Inherits Base
End Class
<Goo>
class Base
Inherits System.Attribute
Public Class Nested
Inherits Goo
End Class
End Class
]]>
</file>
</compilation>
CompileAndVerify(source)
source =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
<Obsolete>
Public Class SomeType
Public Shared Instance As SomeType
Public Const Message As String = "goo"
End Class
Public Class SomeAttr
Inherits Attribute
Public Sub New(message As String)
End Sub
End Class
<Obsolete(SomeType.Message)>
Public Class Derived
Inherits Base
End Class
Public Class Base
<Obsolete(SomeType.Message)>
Public Property SomeProp As SomeType
End Class
]]>
</file>
</compilation>
CreateCompilationWithMscorlib40(source, options:=TestOptions.ReleaseDll.WithConcurrentBuild(False)).VerifyDiagnostics()
End Sub
<Fact>
Public Sub TestObsoleteAttributeP2PReference()
Dim s =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
<Obsolete>
public Class C
<Obsolete>
public sub Goo()
end sub
end class
]]>
</file>
</compilation>
Dim other = CreateCompilationWithMscorlib40(s)
s =
<compilation>
<file name="b.vb"><![CDATA[
Public Class A
Sub New(o As C)
o.Goo()
end sub
End Class
]]>
</file>
</compilation>
CreateCompilationWithMscorlib40AndReferences(s, {New VisualBasicCompilationReference(other)}).VerifyDiagnostics(
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "C").WithArguments("C"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "o.Goo()").WithArguments("Public Sub Goo()"))
End Sub
<Fact>
Public Sub TestObsoleteAttributeOnMembers2()
Dim source =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
Class C1
Property p As String
<Obsolete("", False)>
Get
Return "hello"
End Get
<Obsolete>
Set(value As String)
End Set
End Property
<Obsolete>
WithEvents p1 As New C2
Sub handler() Handles p1.XEvent
End Sub
<Obsolete>
Sub handler2() Handles p1.XEvent
End Sub
Custom Event goo As MyDeleg
AddHandler(value As MyDeleg)
End AddHandler
RemoveHandler(value As MyDeleg)
End RemoveHandler
RaiseEvent()
End RaiseEvent
End Event
End Class
Class C2
<Obsolete>
Public Event XEvent()
Sub bar(s As String)
End Sub
Sub goo()
Dim s As New C1
s.p += "as"
bar(s.p)
End Sub
End Class
<Obsolete>
Public Delegate Sub MyDeleg()
]]>
</file>
</compilation>
CreateCompilationWithMscorlib40(source).VerifyDiagnostics(
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "XEvent").WithArguments("Public Event XEvent()"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "MyDeleg").WithArguments("MyDeleg"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "MyDeleg").WithArguments("MyDeleg"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "MyDeleg").WithArguments("MyDeleg"),
Diagnostic(ERRID.WRN_UseOfObsoletePropertyAccessor2, "s.p += ""as""").WithArguments("Set", "Public Property p As String"),
Diagnostic(ERRID.WRN_UseOfObsoletePropertyAccessor2, "s.p").WithArguments("Get", "Public Property p As String"),
Diagnostic(ERRID.WRN_UseOfObsoletePropertyAccessor2, "s.p").WithArguments("Get", "Public Property p As String"))
End Sub
<Fact>
<WorkItem(546636, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/546636")>
Public Sub TestObsoleteAttributeOnAttributes()
Dim source =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
<AttributeUsage(AttributeTargets.All, AllowMultiple:=True)>
Public Class Att
Inherits Attribute
<Obsolete("Constructor", True)>
Public Sub New()
End Sub
<Obsolete("Property", True)>
Public Property Prop As Integer
Get
Return 1
End Get
Set(value As Integer)
End Set
End Property
<Obsolete("Field", True)>
Public Field As Integer
End Class
<Att>
<Att(Field:=1)>
<Att(Prop:=1)>
Public Class Test
<Att()>
Public Shared Sub Main()
End Sub
End Class
]]>
</file>
</compilation>
CreateCompilationWithMscorlib40(source).VerifyDiagnostics(
Diagnostic(ERRID.ERR_UseOfObsoleteSymbol2, "Att()").WithArguments("Public Sub New()", "Constructor"),
Diagnostic(ERRID.ERR_UseOfObsoleteSymbol2, "Att").WithArguments("Public Sub New()", "Constructor"),
Diagnostic(ERRID.ERR_UseOfObsoleteSymbol2, "Field:=1").WithArguments("Public Field As Integer", "Field"),
Diagnostic(ERRID.ERR_UseOfObsoleteSymbol2, "Att(Field:=1)").WithArguments("Public Sub New()", "Constructor"),
Diagnostic(ERRID.ERR_UseOfObsoleteSymbol2, "Prop:=1").WithArguments("Public Property Prop As Integer", "Property"),
Diagnostic(ERRID.ERR_UseOfObsoleteSymbol2, "Att(Prop:=1)").WithArguments("Public Sub New()", "Constructor"))
End Sub
<Fact>
Public Sub TestObsoleteAttributeOnMembers3()
Dim source =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
Namespace A.B
<Obsolete>
Public Class C
<Obsolete>
Public Shared Field1 As Integer = 10
<Obsolete>
Public Class D
<Obsolete>
Public Shared Field2 As Integer = 20
End Class
End Class
<Obsolete>
Public Class C1
Public Class D
End Class
End Class
<Obsolete>
Public Class C2(Of T)
<Obsolete>
Public Shared Field1 As Integer = 10
Public Class D
End Class
<Obsolete>
Public Class E(Of U)
End Class
End Class
End Namespace
Class B(Of T)
End Class
Class D
Inherits B(Of A.B.C1.D)
End Class
Class D1
Inherits B(Of A.B.C2(Of Integer).D)
End Class
Class D2
Inherits B(Of A.B.C2(Of Integer).E(Of Integer))
End Class
Class Program
Shared Sub Main()
Dim x = A.B.C.Field1
Dim x1 = A.B.C.D.Field2
Dim y = New A.B.C1.D()
Dim y1 = New A.B.C2(Of Integer).D()
Dim y2 = A.B.C2(Of Integer).Field1
Dim y3 = New a.b.c2(Of Integer).E(Of Integer)
End Sub
End Class
]]>
</file>
</compilation>
CreateCompilationWithMscorlib40(source).VerifyDiagnostics(
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "A.B.C1").WithArguments("A.B.C1"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "A.B.C2(Of Integer)").WithArguments("A.B.C2(Of Integer)"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "A.B.C2(Of Integer)").WithArguments("A.B.C2(Of Integer)"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "A.B.C2(Of Integer).E(Of Integer)").WithArguments("A.B.C2(Of Integer).E(Of Integer)"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "A.B.C").WithArguments("A.B.C"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "A.B.C.Field1").WithArguments("Public Shared Field1 As Integer"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "A.B.C").WithArguments("A.B.C"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "A.B.C.D").WithArguments("A.B.C.D"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "A.B.C.D.Field2").WithArguments("Public Shared Field2 As Integer"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "A.B.C1").WithArguments("A.B.C1"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "A.B.C2(Of Integer)").WithArguments("A.B.C2(Of Integer)"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "A.B.C2(Of Integer)").WithArguments("A.B.C2(Of T)"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "A.B.C2(Of Integer).Field1").WithArguments("Public Shared Field1 As Integer"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "a.b.c2(Of Integer)").WithArguments("A.B.C2(Of Integer)"),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "a.b.c2(Of Integer).E(Of Integer)").WithArguments("A.B.C2(Of Integer).E(Of Integer)"))
End Sub
Private ReadOnly ObsoleteAttributeSource As XElement = <file name="ObsoleteAttribute.vb"><![CDATA[
Namespace System
Public Class ObsoleteAttribute
Inherits Attribute
Public Sub New()
End Sub
Public Sub New(message As String)
End Sub
Public Sub New(message As String, isError As Boolean)
End Sub
Public Property DiagnosticId As String
Public Property UrlFormat As String
End Class
End Namespace
]]></file>
<Fact, WorkItem(42119, "https://github.com/dotnet/roslyn/issues/42119")>
Public Sub Obsolete_CustomDiagnosticId_01()
Dim source =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
Class C1
<Obsolete(DiagnosticId:="TEST1")>
Sub M1()
End Sub
Sub M2()
M1()
End Sub
End Class
]]>
</file>
<%= ObsoleteAttributeSource %>
</compilation>
Dim comp = CreateCompilationWithMscorlib40(source)
Dim diags = comp.GetDiagnostics()
diags.Verify(Diagnostic("TEST1", "M1()").WithArguments("Public Sub M1()").WithLocation(9, 9))
Dim diag = diags.Single()
Assert.Equal("", diag.Descriptor.HelpLinkUri)
End Sub
<Fact, WorkItem(42119, "https://github.com/dotnet/roslyn/issues/42119")>
Public Sub Obsolete_CustomDiagnosticId_02()
Dim source =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
Class C1
<Obsolete(UrlFormat:="https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/compiler-messages/{0}")>
Sub M1()
End Sub
Sub M2()
M1()
End Sub
End Class
]]>
</file>
<%= ObsoleteAttributeSource %>
</compilation>
Dim comp = CreateCompilationWithMscorlib40(source)
Dim diags = comp.GetDiagnostics()
diags.Verify(Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "M1()").WithArguments("Public Sub M1()").WithLocation(9, 9))
Dim diag = diags.Single()
Assert.Equal("https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/compiler-messages/BC40008", diag.Descriptor.HelpLinkUri)
End Sub
<Fact, WorkItem(42119, "https://github.com/dotnet/roslyn/issues/42119")>
Public Sub Obsolete_CustomDiagnosticId_03()
Dim source =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
Class C1
<Obsolete(UrlFormat:="https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/compiler-messages/{0}/{1}")>
Sub M1()
End Sub
Sub M2()
M1()
End Sub
End Class
]]>
</file>
<%= ObsoleteAttributeSource %>
</compilation>
Dim comp = CreateCompilationWithMscorlib40(source)
Dim diags = comp.GetDiagnostics()
diags.Verify(Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "M1()").WithArguments("Public Sub M1()").WithLocation(9, 9))
Dim diag = diags.Single()
Assert.Equal("", diag.Descriptor.HelpLinkUri)
End Sub
<Fact, WorkItem(42119, "https://github.com/dotnet/roslyn/issues/42119")>
Public Sub Obsolete_CustomDiagnosticId_04()
Dim source =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
Class C1
<Obsolete(UrlFormat:="https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/compiler-messages/elementname-is-obsolete-visual-basic-warning")>
Sub M1()
End Sub
Sub M2()
M1()
End Sub
End Class
]]>
</file>
<%= ObsoleteAttributeSource %>
</compilation>
Dim comp = CreateCompilationWithMscorlib40(source)
Dim diags = comp.GetDiagnostics()
diags.Verify(Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "M1()").WithArguments("Public Sub M1()").WithLocation(9, 9))
Dim diag = diags.Single()
Assert.Equal("https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/compiler-messages/elementname-is-obsolete-visual-basic-warning", diag.Descriptor.HelpLinkUri)
End Sub
<Fact, WorkItem(42119, "https://github.com/dotnet/roslyn/issues/42119")>
Public Sub Obsolete_CustomDiagnosticId_BadAttribute_01()
Dim source =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
Class C1
<Obsolete(DiagnosticId:="TEST1")>
Sub M1()
End Sub
Sub M2()
M1()
End Sub
End Class
Namespace System
Public Class ObsoleteAttribute
Inherits Attribute
Public Sub New()
End Sub
Public Sub New(message As String)
End Sub
Public Sub New(message As String, isError As Boolean)
End Sub
Public Dim DiagnosticId As String
Public Property DiagnosticId As String
End Class
End Namespace
]]></file>
</compilation>
Dim comp = CreateCompilationWithMscorlib40(source)
Dim diags = comp.GetDiagnostics()
diags.Verify(
Diagnostic(ERRID.ERR_MetadataMembersAmbiguous3, "DiagnosticId").WithArguments("DiagnosticId", "class", "System.ObsoleteAttribute").WithLocation(4, 15),
Diagnostic(ERRID.ERR_MultiplyDefinedType3, "DiagnosticId").WithArguments("DiagnosticId", "Public DiagnosticId As String", "class").WithLocation(27, 25))
End Sub
<Fact, WorkItem(42119, "https://github.com/dotnet/roslyn/issues/42119")>
Public Sub Obsolete_CustomDiagnosticId_05()
Dim source =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
Class C1
<Obsolete("don't use", false, DiagnosticId:="TEST1", UrlFormat:="https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/compiler-messages/{0}")>
Sub M1()
End Sub
Sub M2()
M1()
End Sub
End Class
]]>
</file>
<%= ObsoleteAttributeSource %>
</compilation>
Dim comp = CreateCompilationWithMscorlib40(source)
Dim diags = comp.GetDiagnostics()
diags.Verify(Diagnostic("TEST1", "M1()").WithArguments("Public Sub M1()", "don't use").WithLocation(9, 9))
Dim diag = diags.Single()
Assert.Equal("TEST1", diag.Id)
Assert.Equal(ERRID.WRN_UseOfObsoleteSymbol2, DirectCast(diag.Code, ERRID))
Assert.Equal("https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/compiler-messages/TEST1", diag.Descriptor.HelpLinkUri)
End Sub
<Fact, WorkItem(42119, "https://github.com/dotnet/roslyn/issues/42119")>
Public Sub Obsolete_CustomDiagnosticId_BadAttribute_02()
Dim source =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
Class C1
<Obsolete(DiagnosticId:="A", DiagnosticId:="B", UrlFormat:="C", UrlFormat:="D")>
Sub M1()
End Sub
Sub M2()
M1()
End Sub
End Class
]]></file>
<%= ObsoleteAttributeSource %>
</compilation>
Dim comp = CreateCompilationWithMscorlib40(source)
Dim diags = comp.GetDiagnostics()
diags.Verify(Diagnostic("A", "M1()").WithArguments("Public Sub M1()").WithLocation(9, 9))
Dim diag = diags.Single()
Assert.Equal("C", diag.Descriptor.HelpLinkUri)
End Sub
<Fact, WorkItem(42119, "https://github.com/dotnet/roslyn/issues/42119")>
Public Sub Obsolete_CustomDiagnosticId_Suppression_01()
Dim source =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
Class C1
<Obsolete("don't use", false, DiagnosticId:="TEST1")>
Sub M1()
End Sub
<Obsolete>
Sub M2()
End Sub
Sub M3()
M1()
M2()
#Disable Warning TEST1
M1()
M2()
#Enable Warning TEST1
#Disable Warning BC40008
M1()
M2()
End Sub
End Class
]]></file>
<%= ObsoleteAttributeSource %>
</compilation>
Dim comp = CreateCompilationWithMscorlib40(source)
comp.VerifyDiagnostics(
Diagnostic("TEST1", "M1()").WithArguments("Public Sub M1()", "don't use").WithLocation(13, 9),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "M2()").WithArguments("Public Sub M2()").WithLocation(14, 9),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "M2()").WithArguments("Public Sub M2()").WithLocation(18, 9),
Diagnostic("TEST1", "M1()").WithArguments("Public Sub M1()", "don't use").WithLocation(22, 9))
End Sub
<Fact, WorkItem(42119, "https://github.com/dotnet/roslyn/issues/42119")>
Public Sub Obsolete_CustomDiagnosticId_FromMetadata_01()
Dim source1 =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
Public Class C1
<Obsolete("don't use", false, DiagnosticId:="TEST1")>
Public Sub M1()
End Sub
<Obsolete>
Public Sub M2()
End Sub
End Class
]]></file>
<%= ObsoleteAttributeSource %>
</compilation>
Dim source2 =
<compilation>
<file name="a.vb"><![CDATA[
Class C2
Inherits C1
Sub M3()
M1()
M2()
#Disable Warning TEST1
M1()
M2()
#Enable Warning TEST1
#Disable Warning BC40008
M1()
M2()
End Sub
End Class
]]></file>
</compilation>
Dim comp1 = CreateCompilationWithMscorlib40(source1)
comp1.VerifyDiagnostics()
Dim expected = {
Diagnostic("TEST1", "M1()").WithArguments("Public Sub M1()", "don't use").WithLocation(5, 9),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "M2()").WithArguments("Public Sub M2()").WithLocation(6, 9),
Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "M2()").WithArguments("Public Sub M2()").WithLocation(10, 9),
Diagnostic("TEST1", "M1()").WithArguments("Public Sub M1()", "don't use").WithLocation(14, 9)
}
Dim comp2 = CreateCompilationWithMscorlib40(source2, references:={comp1.ToMetadataReference()})
comp2.VerifyDiagnostics(expected)
comp2 = CreateCompilationWithMscorlib40(source2, references:={comp1.EmitToImageReference()})
comp2.VerifyDiagnostics(expected)
End Sub
<Fact, WorkItem(42119, "https://github.com/dotnet/roslyn/issues/42119")>
Public Sub Obsolete_CustomDiagnosticId_FromMetadata_02()
Dim source1 =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
Public Class C1
<Obsolete(DiagnosticId:="TEST1")>
Public Sub M1()
End Sub
<Obsolete("don't use", DiagnosticId:="TEST2")>
Public Sub M2()
End Sub
<Obsolete("don't use", false, DiagnosticId:="TEST3")>
Public Sub M3()
End Sub
End Class
]]></file>
<%= ObsoleteAttributeSource %>
</compilation>
Dim source2 =
<compilation>
<file name="a.vb"><![CDATA[
Class C2
Inherits C1
Sub M4()
M1()
M2()
M3()
End Sub
End Class
]]></file>
</compilation>
Dim comp1 = CreateCompilationWithMscorlib40(source1)
comp1.VerifyDiagnostics()
Dim expected = {
Diagnostic("TEST1", "M1()").WithArguments("Public Sub M1()").WithLocation(5, 9),
Diagnostic("TEST2", "M2()").WithArguments("Public Sub M2()", "don't use").WithLocation(6, 9),
Diagnostic("TEST3", "M3()").WithArguments("Public Sub M3()", "don't use").WithLocation(7, 9)
}
Dim comp2 = CreateCompilationWithMscorlib40(source2, references:={comp1.ToMetadataReference()})
comp2.VerifyDiagnostics(expected)
comp2 = CreateCompilationWithMscorlib40(source2, references:={comp1.EmitToImageReference()})
comp2.VerifyDiagnostics(expected)
End Sub
<Fact, WorkItem(42119, "https://github.com/dotnet/roslyn/issues/42119")>
Public Sub Obsolete_CustomDiagnosticId_FromMetadata_03()
Dim source1 =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
Public Class C1
<Obsolete(DiagnosticId:="TEST1", UrlFormat:="https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/compiler-messages/{0}")>
Public Sub M1()
End Sub
End Class
]]></file>
<%= ObsoleteAttributeSource %>
</compilation>
Dim source2 =
<compilation>
<file name="a.vb"><![CDATA[
Class C2
Inherits C1
Sub M2()
M1()
End Sub
End Class
]]></file>
</compilation>
Dim comp1 = CreateCompilationWithMscorlib40(source1)
comp1.VerifyDiagnostics()
Dim comp2 = CreateCompilationWithMscorlib40(source2, references:={comp1.ToMetadataReference()})
Dim diags = comp2.GetDiagnostics()
diags.Verify(Diagnostic("TEST1", "M1()").WithArguments("Public Sub M1()").WithLocation(5, 9))
Dim diag = diags.Single()
Assert.Equal("https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/compiler-messages/TEST1", diag.Descriptor.HelpLinkUri)
comp2 = CreateCompilationWithMscorlib40(source2, references:={comp1.EmitToImageReference()})
diags = comp2.GetDiagnostics()
diags.Verify(Diagnostic("TEST1", "M1()").WithArguments("Public Sub M1()").WithLocation(5, 9))
diag = diags.Single()
Assert.Equal("https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/compiler-messages/TEST1", diag.Descriptor.HelpLinkUri)
End Sub
<Fact, WorkItem(42119, "https://github.com/dotnet/roslyn/issues/42119")>
Public Sub Obsolete_CustomDiagnosticId_FromMetadata_04()
Dim source1 =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
Public Class C1
<Obsolete(DiagnosticId:=Nothing, UrlFormat:=Nothing)>
Public Sub M1()
End Sub
End Class
]]></file>
<%= ObsoleteAttributeSource %>
</compilation>
Dim source2 =
<compilation>
<file name="a.vb"><![CDATA[
Class C2
Inherits C1
Sub M2()
M1()
End Sub
End Class
]]></file>
</compilation>
Dim comp1 = CreateCompilationWithMscorlib40(source1)
comp1.VerifyDiagnostics()
Dim comp2 = CreateCompilationWithMscorlib40(source2, references:={comp1.ToMetadataReference()})
Dim diags = comp2.GetDiagnostics()
diags.Verify(Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "M1()").WithArguments("Public Sub M1()").WithLocation(5, 9))
Dim diag = diags.Single()
Assert.Equal("", diag.Descriptor.HelpLinkUri)
comp2 = CreateCompilationWithMscorlib40(source2, references:={comp1.EmitToImageReference()})
diags = comp2.GetDiagnostics()
diags.Verify(Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "M1()").WithArguments("Public Sub M1()").WithLocation(5, 9))
diag = diags.Single()
Assert.Equal("", diag.Descriptor.HelpLinkUri)
End Sub
<Fact, WorkItem(42119, "https://github.com/dotnet/roslyn/issues/42119")>
Public Sub Obsolete_CustomDiagnosticId_BadMetadata_01()
Dim source1 =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
Public Class C1
<Obsolete(Flag:=False, DiagnosticId:="TEST1")>
Public Sub M1()
End Sub
End Class
]]></file>
<file name="ObsoleteAttribute.vb"><![CDATA[
Namespace System
Public Class ObsoleteAttribute
Inherits Attribute
Public Property Flag As Boolean
Public Property DiagnosticId As String
End Class
End Namespace
]]></file>
</compilation>
Dim source2 =
<compilation>
<file name="a.vb"><![CDATA[
Class C2
Inherits C1
Sub M2()
M1()
End Sub
End Class
]]></file>
</compilation>
Dim comp1 = CreateCompilationWithMscorlib40(source1)
comp1.VerifyDiagnostics()
Dim comp2 = CreateCompilationWithMscorlib40(source2, references:={comp1.ToMetadataReference()})
Dim diags = comp2.GetDiagnostics()
diags.Verify(Diagnostic("TEST1", "M1()").WithArguments("Public Sub M1()").WithLocation(5, 9))
Dim diag = diags.Single()
Assert.Equal("", diag.Descriptor.HelpLinkUri)
comp2 = CreateCompilationWithMscorlib40(source2, references:={comp1.EmitToImageReference()})
diags = comp2.GetDiagnostics()
diags.Verify(Diagnostic("TEST1", "M1()").WithArguments("Public Sub M1()").WithLocation(5, 9))
diag = diags.Single()
Assert.Equal("", diag.Descriptor.HelpLinkUri)
End Sub
<Fact, WorkItem(42119, "https://github.com/dotnet/roslyn/issues/42119")>
Public Sub Obsolete_CustomDiagnosticId_BadMetadata_02()
Dim source1 =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
Public Class C1
<Obsolete(DiagnosticId:="TEST1", UrlFormat:="TEST2")>
Public Sub M1()
End Sub
End Class
]]></file>
<file name="ObsoleteAttribute.vb"><![CDATA[
Namespace System
Public Class ObsoleteAttribute
Inherits Attribute
Public Dim DiagnosticId As String
Public Dim UrlFormat As String
End Class
End Namespace
]]></file>
</compilation>
Dim source2 =
<compilation>
<file name="a.vb"><![CDATA[
Class C2
Inherits C1
Sub M2()
M1()
End Sub
End Class
]]></file>
</compilation>
Dim comp1 = CreateCompilationWithMscorlib40(source1)
comp1.VerifyDiagnostics()
Dim comp2 = CreateCompilationWithMscorlib40(source2, references:={comp1.ToMetadataReference()})
Dim diags = comp2.GetDiagnostics()
diags.Verify(Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "M1()").WithArguments("Public Sub M1()").WithLocation(5, 9))
Dim diag = diags.Single()
Assert.Equal("", diag.Descriptor.HelpLinkUri)
comp2 = CreateCompilationWithMscorlib40(source2, references:={comp1.EmitToImageReference()})
diags = comp2.GetDiagnostics()
diags.Verify(Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "M1()").WithArguments("Public Sub M1()").WithLocation(5, 9))
diag = diags.Single()
Assert.Equal("", diag.Descriptor.HelpLinkUri)
End Sub
<Fact, WorkItem(42119, "https://github.com/dotnet/roslyn/issues/42119")>
Public Sub Obsolete_CustomDiagnosticId_BadMetadata_03()
Dim source1 =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
Public Enum E1
A
B
End Enum
Namespace System
Public Class ObsoleteAttribute
Inherits Attribute
Public Property ByteProp As Byte
Public Property SByteProp As SByte
Public Property BooleanProp As Boolean
Public Property ShortProp As Short
Public Property UshortProp As UShort
Public Property CharProp As Char
Public Property IntProp As Integer
Public Property UintProp As UInteger
Public Property FloatProp As Single
Public Property LongProp As Long
Public Property UlongProp As ULong
Public Property DoubleProp As Double
Public Property EnumProp As E1
Public Property DiagnosticId As String
End Class
End Namespace
Public Class C1
<Obsolete(
ByteProp:=0,
SByteProp:=0,
BooleanProp:=false,
ShortProp:=0,
UShortProp:=0,
CharProp:="\0",
IntProp:=0,
UIntProp:=0,
FloatProp:=0,
LongProp:=0,
ULongProp:=0,
DoubleProp:=0,
EnumProp:=E1.A,
DiagnosticId:="TEST1")>
Public Sub M1()
End Sub
End Class
]]></file>
</compilation>
Dim source2 =
<compilation>
<file name="a.vb"><![CDATA[
Class C2
Inherits C1
Sub M2()
M1()
End Sub
End Class
]]></file>
</compilation>
Dim comp1 = CreateCompilationWithMscorlib40(source1)
comp1.VerifyDiagnostics()
Dim comp2 = CreateCompilationWithMscorlib40(source2, references:={comp1.ToMetadataReference()})
Dim diags = comp2.GetDiagnostics()
diags.Verify(Diagnostic("TEST1", "M1()").WithArguments("Public Sub M1()").WithLocation(5, 9))
Dim diag = diags.Single()
Assert.Equal("", diag.Descriptor.HelpLinkUri)
comp2 = CreateCompilationWithMscorlib40(source2, references:={comp1.EmitToImageReference()})
diags = comp2.GetDiagnostics()
diags.Verify(Diagnostic("TEST1", "M1()").WithArguments("Public Sub M1()").WithLocation(5, 9))
diag = diags.Single()
Assert.Equal("", diag.Descriptor.HelpLinkUri)
End Sub
<Fact, WorkItem(42119, "https://github.com/dotnet/roslyn/issues/42119")>
Public Sub Obsolete_CustomDiagnosticId_BadMetadata_04()
Dim source1 =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
Public Enum E1
A
B
End Enum
Namespace System
Public Class ObsoleteAttribute
Inherits Attribute
Public Property IntProp As Integer()
Public Property EnumProp As E1()
Public Property DiagnosticId As String
End Class
End Namespace
Public Class C1
<Obsolete(
IntProp:={0, 1, 2},
EnumProp:={E1.A, E1.B},
DiagnosticId:="TEST1")>
Public Sub M1()
End Sub
End Class
]]></file>
</compilation>
Dim source2 =
<compilation>
<file name="a.vb"><![CDATA[
Class C2
Inherits C1
Sub M2()
M1()
End Sub
End Class
]]></file>
</compilation>
Dim comp1 = CreateCompilationWithMscorlib40(source1)
comp1.VerifyDiagnostics()
Dim comp2 = CreateCompilationWithMscorlib40(source2, references:={comp1.ToMetadataReference()})
Dim diags = comp2.GetDiagnostics()
diags.Verify(Diagnostic("TEST1", "M1()").WithArguments("Public Sub M1()").WithLocation(5, 9))
Dim diag = diags.Single()
Assert.Equal("", diag.Descriptor.HelpLinkUri)
comp2 = CreateCompilationWithMscorlib40(source2, references:={comp1.EmitToImageReference()})
diags = comp2.GetDiagnostics()
diags.Verify(Diagnostic("TEST1", "M1()").WithArguments("Public Sub M1()").WithLocation(5, 9))
diag = diags.Single()
Assert.Equal("", diag.Descriptor.HelpLinkUri)
End Sub
<Fact, WorkItem(42119, "https://github.com/dotnet/roslyn/issues/42119")>
Public Sub Obsolete_CustomDiagnosticId_BadMetadata_05()
Dim source1 =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
Public Enum E1
A
B
End Enum
Namespace System
Public Class ObsoleteAttribute
Inherits Attribute
Public Property DiagnosticId As Char()
Public Property UrlFormat As Char()
End Class
End Namespace
Public Class C1
<Obsolete(
DiagnosticId:={"A"},
UrlFormat:={"B"})>
Public Sub M1()
End Sub
End Class
]]></file>
</compilation>
Dim source2 =
<compilation>
<file name="a.vb"><![CDATA[
Class C2
Inherits C1
Sub M2()
M1()
End Sub
End Class
]]></file>
</compilation>
Dim comp1 = CreateCompilationWithMscorlib40(source1)
comp1.VerifyDiagnostics()
Dim comp2 = CreateCompilationWithMscorlib40(source2, references:={comp1.ToMetadataReference()})
Dim diags = comp2.GetDiagnostics()
diags.Verify(Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "M1()").WithArguments("Public Sub M1()").WithLocation(5, 9))
Dim diag = diags.Single()
Assert.Equal("", diag.Descriptor.HelpLinkUri)
comp2 = CreateCompilationWithMscorlib40(source2, references:={comp1.EmitToImageReference()})
diags = comp2.GetDiagnostics()
diags.Verify(Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "M1()").WithArguments("Public Sub M1()").WithLocation(5, 9))
diag = diags.Single()
Assert.Equal("", diag.Descriptor.HelpLinkUri)
End Sub
<Fact, WorkItem(42119, "https://github.com/dotnet/roslyn/issues/42119")>
Public Sub Obsolete_CustomDiagnosticId_BadMetadata_06()
Dim source1 =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
Public Enum E1
A
B
End Enum
Namespace System
Public Class ObsoleteAttribute
Inherits Attribute
Public Property DiagnosticId As Char()
Public Property UrlFormat As Char()
End Class
End Namespace
Public Class C1
<Obsolete(
DiagnosticId:=Nothing,
UrlFormat:=Nothing)>
Public Sub M1()
End Sub
End Class
]]></file>
</compilation>
Dim source2 =
<compilation>
<file name="a.vb"><![CDATA[
Class C2
Inherits C1
Sub M2()
M1()
End Sub
End Class
]]></file>
</compilation>
Dim comp1 = CreateCompilationWithMscorlib40(source1)
comp1.VerifyDiagnostics()
Dim comp2 = CreateCompilationWithMscorlib40(source2, references:={comp1.ToMetadataReference()})
Dim diags = comp2.GetDiagnostics()
diags.Verify(Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "M1()").WithArguments("Public Sub M1()").WithLocation(5, 9))
Dim diag = diags.Single()
Assert.Equal("", diag.Descriptor.HelpLinkUri)
comp2 = CreateCompilationWithMscorlib40(source2, references:={comp1.EmitToImageReference()})
diags = comp2.GetDiagnostics()
diags.Verify(Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "M1()").WithArguments("Public Sub M1()").WithLocation(5, 9))
diag = diags.Single()
Assert.Equal("", diag.Descriptor.HelpLinkUri)
End Sub
<Fact, WorkItem(42119, "https://github.com/dotnet/roslyn/issues/42119")>
Public Sub Obsolete_CustomDiagnosticId_BadMetadata_07()
' In this program C1.M1 has an ObsoleteAttribute with multiple values provided for DiagnosticId and UrlFormat
Dim ilSource = "
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.class public auto ansi beforefieldinit C1
extends [mscorlib]System.Object
{
.method public hidebysig instance void
M1() cil managed
{
.custom instance void System.ObsoleteAttribute::.ctor() = ( 01 00 04 00 // ....
54 0E 0C 44 69 61 67 6E 6F 73 74 69 63 49 64 01 41 // T..DiagnosticId.A
54 0E 0C 44 69 61 67 6E 6F 73 74 69 63 49 64 01 42 // T..DiagnosticId.B
54 0E 09 55 72 6C 46 6F 72 6D 61 74 01 43 // T..UrlFormat.C
54 0E 09 55 72 6C 46 6F 72 6D 61 74 01 44 ) // T..UrlFormat.D
// Code size 2 (0x2)
.maxstack 8
IL_0000: nop
IL_0001: ret
} // end of method C1::M1
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: nop
IL_0007: ret
} // end of method C1::.ctor
} // end of class C1
.class public auto ansi beforefieldinit System.ObsoleteAttribute
extends [mscorlib]System.Attribute
{
.field private string '<DiagnosticId>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
.field private string '<UrlFormat>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
.method public hidebysig specialname instance string
get_DiagnosticId() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld string System.ObsoleteAttribute::'<DiagnosticId>k__BackingField'
IL_0006: ret
} // end of method ObsoleteAttribute::get_DiagnosticId
.method public hidebysig specialname instance void
set_DiagnosticId(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld string System.ObsoleteAttribute::'<DiagnosticId>k__BackingField'
IL_0007: ret
} // end of method ObsoleteAttribute::set_DiagnosticId
.method public hidebysig specialname instance string
get_UrlFormat() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld string System.ObsoleteAttribute::'<UrlFormat>k__BackingField'
IL_0006: ret
} // end of method ObsoleteAttribute::get_UrlFormat
.method public hidebysig specialname instance void
set_UrlFormat(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld string System.ObsoleteAttribute::'<UrlFormat>k__BackingField'
IL_0007: ret
} // end of method ObsoleteAttribute::set_UrlFormat
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Attribute::.ctor()
IL_0006: nop
IL_0007: ret
} // end of method ObsoleteAttribute::.ctor
.property instance string DiagnosticId()
{
.get instance string System.ObsoleteAttribute::get_DiagnosticId()
.set instance void System.ObsoleteAttribute::set_DiagnosticId(string)
} // end of property ObsoleteAttribute::DiagnosticId
.property instance string UrlFormat()
{
.get instance string System.ObsoleteAttribute::get_UrlFormat()
.set instance void System.ObsoleteAttribute::set_UrlFormat(string)
} // end of property ObsoleteAttribute::UrlFormat
} // end of class System.ObsoleteAttribute
"
Dim source2 =
<compilation>
<file name="a.vb"><![CDATA[
Class C2
Inherits C1
Sub M2()
M1()
End Sub
End Class
]]></file>
</compilation>
Dim ilComp = CompileIL(ilSource)
Dim comp2 = CreateCompilationWithMscorlib40(source2, references:={ilComp})
Dim diags = comp2.GetDiagnostics()
diags.Verify(Diagnostic("A", "M1()").WithArguments("Public Overloads Sub M1()").WithLocation(5, 9))
Dim diag = diags.Single()
Assert.Equal("C", diag.Descriptor.HelpLinkUri)
End Sub
<Fact, WorkItem(42119, "https://github.com/dotnet/roslyn/issues/42119")>
Public Sub Obsolete_CustomDiagnosticId_BadMetadata_08()
' In this program C1.M1 has an ObsoleteAttribute with multiple values provided for DiagnosticId and UrlFormat
Dim ilSource = "
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.class public auto ansi beforefieldinit C1
extends [mscorlib]System.Object
{
.method public hidebysig instance void
M1() cil managed
{
.custom instance void System.ObsoleteAttribute::.ctor() = ( 01 00 02 00 // ....
54 0E 0C 44 69 61 67 6E 6F 73 74 69 63 49 64 01 41 // T..DiagnosticId.A
0E 09 55 72 6C 46 6F 72 6D 61 74 01 42 ) // ..UrlFormat.B
// Code size 2 (0x2)
.maxstack 8
IL_0000: nop
IL_0001: ret
} // end of method C1::M1
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: nop
IL_0007: ret
} // end of method C1::.ctor
} // end of class C1
.class public auto ansi beforefieldinit System.ObsoleteAttribute
extends [mscorlib]System.Attribute
{
.field private string '<DiagnosticId>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
.field private string '<UrlFormat>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
.method public hidebysig specialname instance string
get_DiagnosticId() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld string System.ObsoleteAttribute::'<DiagnosticId>k__BackingField'
IL_0006: ret
} // end of method ObsoleteAttribute::get_DiagnosticId
.method public hidebysig specialname instance void
set_DiagnosticId(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld string System.ObsoleteAttribute::'<DiagnosticId>k__BackingField'
IL_0007: ret
} // end of method ObsoleteAttribute::set_DiagnosticId
.method public hidebysig specialname instance string
get_UrlFormat() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld string System.ObsoleteAttribute::'<UrlFormat>k__BackingField'
IL_0006: ret
} // end of method ObsoleteAttribute::get_UrlFormat
.method public hidebysig specialname instance void
set_UrlFormat(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld string System.ObsoleteAttribute::'<UrlFormat>k__BackingField'
IL_0007: ret
} // end of method ObsoleteAttribute::set_UrlFormat
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Attribute::.ctor()
IL_0006: nop
IL_0007: ret
} // end of method ObsoleteAttribute::.ctor
.property instance string DiagnosticId()
{
.get instance string System.ObsoleteAttribute::get_DiagnosticId()
.set instance void System.ObsoleteAttribute::set_DiagnosticId(string)
} // end of property ObsoleteAttribute::DiagnosticId
.property instance string UrlFormat()
{
.get instance string System.ObsoleteAttribute::get_UrlFormat()
.set instance void System.ObsoleteAttribute::set_UrlFormat(string)
} // end of property ObsoleteAttribute::UrlFormat
} // end of class System.ObsoleteAttribute
"
Dim source2 =
<compilation>
<file name="a.vb"><![CDATA[
Class C2
Inherits C1
Sub M2()
M1()
End Sub
End Class
]]></file>
</compilation>
Dim ilComp = CompileIL(ilSource)
Dim comp2 = CreateCompilationWithMscorlib40(source2, references:={ilComp})
Dim diags = comp2.GetDiagnostics()
diags.Verify(Diagnostic("A", "M1()").WithArguments("Public Overloads Sub M1()").WithLocation(5, 9))
Dim diag = diags.Single()
Assert.Equal("", diag.Descriptor.HelpLinkUri)
End Sub
<Fact, WorkItem(42119, "https://github.com/dotnet/roslyn/issues/42119")>
Public Sub Obsolete_CustomDiagnosticId_BadMetadata_09()
Dim source1 =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
Public Enum E1
A
B
End Enum
Namespace System
Public Class ObsoleteAttribute
Inherits Attribute
Public Property DiagnosticId As Object
Public Property UrlFormat As Object
End Class
End Namespace
Public Class C1
<Obsolete(
DiagnosticId:="A",
UrlFormat:="B")>
Public Sub M1()
End Sub
End Class
]]></file>
</compilation>
Dim source2 =
<compilation>
<file name="a.vb"><![CDATA[
Class C2
Inherits C1
Sub M2()
M1()
End Sub
End Class
]]></file>
</compilation>
Dim comp1 = CreateCompilationWithMscorlib40(source1)
comp1.VerifyDiagnostics()
Dim comp2 = CreateCompilationWithMscorlib40(source2, references:={comp1.ToMetadataReference()})
Dim diags = comp2.GetDiagnostics()
diags.Verify(Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "M1()").WithArguments("Public Sub M1()").WithLocation(5, 9))
Dim diag = diags.Single()
Assert.Equal("", diag.Descriptor.HelpLinkUri)
comp2 = CreateCompilationWithMscorlib40(source2, references:={comp1.EmitToImageReference()})
diags = comp2.GetDiagnostics()
diags.Verify(Diagnostic(ERRID.WRN_UseOfObsoleteSymbolNoMessage1, "M1()").WithArguments("Public Sub M1()").WithLocation(5, 9))
diag = diags.Single()
Assert.Equal("", diag.Descriptor.HelpLinkUri)
End Sub
<WorkItem(578023, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/578023")>
<Fact>
Public Sub TestObsoleteInAlias()
Dim compilation = CompilationUtils.CreateCompilationWithMscorlib40AndVBRuntime(
<compilation>
<file name="a.vb"><![CDATA[
Imports X = C
Imports Y = A(Of C)
Imports Z = A(Of C()).B
Imports C
Imports A(Of C)
Imports A(Of C()).B
Class A(Of T)
Friend Class B
End Class
End Class
<System.Obsolete>
Class C
End Class
Module M
Private F As X
Private G As Y
Private H As Z
End Module
]]>
</file>
</compilation>)
compilation.AssertTheseDiagnostics(<errors>
BC40008: 'C' is obsolete.
Imports X = C
~
BC40008: 'C' is obsolete.
Imports Y = A(Of C)
~
BC40008: 'C' is obsolete.
Imports Z = A(Of C()).B
~
BC40008: 'C' is obsolete.
Imports C
~
BC40008: 'C' is obsolete.
Imports A(Of C)
~
BC40008: 'C' is obsolete.
Imports A(Of C()).B
~
</errors>)
End Sub
<WorkItem(580832, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/580832")>
<Fact>
Public Sub TestObsoleteOnVirtualMethod()
Dim compilation = CompilationUtils.CreateCompilationWithMscorlib40AndVBRuntime(
<compilation>
<file name="a.vb"><![CDATA[
Imports System
Public Class A
<Obsolete("A")>
Public Overridable Sub M()
End Sub
End Class
Public Class B
Inherits A
<Obsolete("B")>
Public Overrides Sub M()
End Sub
Private Sub Base()
MyBase.M()
End Sub
End Class
Public Class C
Inherits B
<Obsolete("C")>
Public Overrides Sub M()
End Sub
Private Sub Test(pa As A, pb As B, pc As C)
pa.M()
pb.M()
pc.M()
End Sub
Private Sub Base()
MyBase.M()
End Sub
End Class
]]>
</file>
</compilation>)
' Unlike in C#, VB does not walk up to the least-overridden method.
compilation.AssertTheseDiagnostics(<errors>
BC40000: 'Public Overridable Sub M()' is obsolete: 'A'.
MyBase.M()
~~~~~~~~~~
BC40000: 'Public Overridable Sub M()' is obsolete: 'A'.
pa.M()
~~~~~~
BC40000: 'Public Overrides Sub M()' is obsolete: 'B'.
pb.M()
~~~~~~
BC40000: 'Public Overrides Sub M()' is obsolete: 'C'.
pc.M()
~~~~~~
BC40000: 'Public Overrides Sub M()' is obsolete: 'B'.
MyBase.M()
~~~~~~~~~~
</errors>)
End Sub
<Fact()>
Public Sub TestDeprecatedAttribute()
Dim source1 =
<compilation>
<file name="test.vb"><![CDATA[
Imports Windows.Foundation.Metadata
<Deprecated("Class1 is deprecated.", DeprecationType.Deprecate, 0)>
public class Class1
End Class
<Deprecated("Class2 is deprecated.", DeprecationType.Deprecate, 0, Platform.Windows)>
public class Class2
End Class
<Deprecated("Class3 is deprecated.", DeprecationType.Remove, 1)>
public class Class3
End Class
<Deprecated("Class4 is deprecated.", DeprecationType.Remove, 0, Platform.WindowsPhone)>
public class Class4
End Class
]]>
</file>
</compilation>
Dim compilation1 = CreateEmptyCompilationWithReferences(source1, WinRtRefs)
compilation1.VerifyDiagnostics()
Dim source2 =
<compilation>
<file name="test.vb"><![CDATA[
Imports Windows.Foundation.Metadata
class Class5
Sub Test()
Dim x1 As Class1 = Nothing
Dim x2 As Class2 = Nothing
Dim x3 As Class3 = Nothing
Dim x4 As Class4 = Nothing
Dim x5 As Object
x5=x1
x5 = x2
x5 = x3
x5 = x4
End Sub
End Class
class Class6
Readonly Property P1 As Integer
<Deprecated("P1.get is deprecated.", DeprecationType.Remove, 1)>
get
return 1
End Get
End Property
Custom Event E1 As System.Action
<Deprecated("E1.add is deprecated.", DeprecationType.Remove, 1)>
AddHandler(value As System.Action)
End AddHandler
RemoveHandler(value As System.Action)
End RemoveHandler
RaiseEvent()
End RaiseEvent
End Event
End Class
]]>
</file>
</compilation>
Dim compilation2 = CreateEmptyCompilationWithReferences(source2, WinRtRefs.Concat(New VisualBasicCompilationReference(compilation1)))
Dim expected = <![CDATA[
BC40000: 'Class1' is obsolete: 'Class1 is deprecated.'.
Dim x1 As Class1 = Nothing
~~~~~~
BC40000: 'Class2' is obsolete: 'Class2 is deprecated.'.
Dim x2 As Class2 = Nothing
~~~~~~
BC30668: 'Class3' is obsolete: 'Class3 is deprecated.'.
Dim x3 As Class3 = Nothing
~~~~~~
BC30668: 'Class4' is obsolete: 'Class4 is deprecated.'.
Dim x4 As Class4 = Nothing
~~~~~~
BC31142: 'Windows.Foundation.Metadata.DeprecatedAttribute' cannot be applied to the 'AddHandler', 'RemoveHandler', or 'RaiseEvent' definitions. If required, apply the attribute directly to the event.
<Deprecated("E1.add is deprecated.", DeprecationType.Remove, 1)>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
]]>
compilation2.AssertTheseDiagnostics(expected)
compilation2 = CreateEmptyCompilationWithReferences(source2, WinRtRefs.Concat(compilation1.EmitToImageReference()))
compilation2.AssertTheseDiagnostics(expected)
End Sub
<Fact()>
Public Sub TestDeprecatedAttribute001()
Dim source1 =
<![CDATA[
using System;
using Windows.Foundation.Metadata;
namespace Windows.Foundation.Metadata
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = true)]
public sealed class DeprecatedAttribute : Attribute
{
public DeprecatedAttribute(System.String message, DeprecationType type, System.UInt32 version)
{
}
public DeprecatedAttribute(System.String message, DeprecationType type, System.UInt32 version, Type contract)
{
}
}
public enum DeprecationType
{
Deprecate = 0,
Remove = 1
}
}
public class Test
{
[Deprecated("hello", DeprecationType.Deprecate, 1, typeof(int))]
public static void Goo()
{
}
[Deprecated("hi", DeprecationType.Deprecate, 1)]
public static void Bar()
{
}
}
]]>
Dim compilation1 = CreateCSharpCompilation("Dll1", source1.Value)
Dim ref = compilation1.EmitToImageReference()
Dim source2 =
<compilation>
<file name="test.vb"><![CDATA[
Module Program
Sub Main()
Test.Goo()
Test.Bar()
end Sub
end module
]]>
</file>
</compilation>
Dim compilation2 = CreateCompilationWithMscorlib40AndVBRuntimeAndReferences(source2, {ref})
Dim expected = <![CDATA[
BC40000: 'Public Shared Overloads Sub Goo()' is obsolete: 'hello'.
Test.Goo()
~~~~~~~~~~
BC40000: 'Public Shared Overloads Sub Bar()' is obsolete: 'hi'.
Test.Bar()
~~~~~~~~~~
]]>
compilation2.AssertTheseDiagnostics(expected)
Dim source3 =
<compilation>
<file name="test.vb"><![CDATA[
Imports Windows.Foundation.Metadata
Module Program
<Deprecated("hello", DeprecationType.Deprecate, 1, gettype(integer))>
sub Goo()
end sub
<Deprecated("hi", DeprecationType.Deprecate, 1)>
Sub Bar()
End sub
Sub Main()
Goo()
Bar()
end Sub
end module
]]>
</file>
</compilation>
Dim compilation3 = CreateCompilationWithMscorlib40AndVBRuntimeAndReferences(source3, {ref})
Dim expected2 = <![CDATA[
BC40000: 'Public Sub Goo()' is obsolete: 'hello'.
Goo()
~~~~~
BC40000: 'Public Sub Bar()' is obsolete: 'hi'.
Bar()
~~~~~
]]>
compilation3.AssertTheseDiagnostics(expected2)
End Sub
<Fact>
<WorkItem(22447, "https://github.com/dotnet/roslyn/issues/22447")>
Public Sub TestRefLikeType()
Dim csSource = <![CDATA[
public ref struct S { }
]]>
Dim csCompilation = CreateCSharpCompilation("Dll1", csSource.Value, parseOptions:=New CSharp.CSharpParseOptions(CSharp.LanguageVersion.CSharp7_2))
Dim ref = csCompilation.EmitToImageReference()
Dim vbSource =
<compilation>
<file name="test.vb"><![CDATA[
Module Program
Sub M(s As S)
End Sub
End Module
]]>
</file>
</compilation>
Dim vbCompilation = CreateCompilationWithMscorlib40AndVBRuntimeAndReferences(vbSource, {ref})
vbCompilation.AssertTheseDiagnostics((<![CDATA[
BC30668: 'S' is obsolete: 'Types with embedded references are not supported in this version of your compiler.'.
Sub M(s As S)
~
]]>))
vbCompilation.VerifyDiagnostics(
Diagnostic(ERRID.ERR_UseOfObsoleteSymbol2, "S").WithArguments("S", "Types with embedded references are not supported in this version of your compiler.").WithLocation(2, 16)
)
End Sub
<Fact(), WorkItem(858839, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/858839")>
Public Sub Bug858839_1()
Dim source1 =
<compilation>
<file name="test.vb"><![CDATA[
Imports Windows.Foundation.Metadata
Public Class MainPage
Public Shared Sub Main(args As String())
End Sub
Private Shared Sub TestGoo1(a As IGoo1, b As ConcreteGoo1)
a.Goo() ' IGoo1
b.Goo() ' ConcreteGoo1
End Sub
Private Shared Sub TestGoo2(a As IGoo2, b As ConcreteGoo2)
a.Goo() ' IGoo2
b.Goo() ' ConcreteGoo2
End Sub
Private Shared Sub TestGoo3(a As IGoo3, b As ConcreteGoo3)
a.Goo() ' IGoo3
b.Goo() ' ConcreteGoo3
End Sub
End Class
Public Interface IGoo1
<Deprecated("IGoo1.Goo has been deprecated", DeprecationType.Deprecate, 0, Platform.Windows)>
Sub Goo()
End Interface
Public NotInheritable Class ConcreteGoo1
Implements IGoo1
Public Sub Goo() Implements IGoo1.Goo
End Sub
End Class
Public Interface IGoo2
Sub Goo()
End Interface
Public NotInheritable Class ConcreteGoo2
Implements IGoo2
<Deprecated("ConcreteGoo2.Goo has been deprecated", DeprecationType.Deprecate, 0, Platform.Windows)>
Public Sub Goo() Implements IGoo2.Goo
End Sub
End Class
Public Interface IGoo3
<Deprecated("IGoo3.Goo has been deprecated", DeprecationType.Deprecate, 0, Platform.Windows)>
Sub Goo()
End Interface
Public NotInheritable Class ConcreteGoo3
Implements IGoo3
<Deprecated("ConcreteGoo3.Goo has been deprecated", DeprecationType.Deprecate, 0, Platform.Windows)>
Public Sub Goo() Implements IGoo3.Goo
End Sub
End Class
]]>
</file>
</compilation>
Dim compilation1 = CreateEmptyCompilationWithReferences(source1, WinRtRefs)
Dim expected = <![CDATA[
BC40000: 'Sub Goo()' is obsolete: 'IGoo1.Goo has been deprecated'.
a.Goo() ' IGoo1
~~~~~~~
BC40000: 'Public Sub Goo()' is obsolete: 'ConcreteGoo2.Goo has been deprecated'.
b.Goo() ' ConcreteGoo2
~~~~~~~
BC40000: 'Sub Goo()' is obsolete: 'IGoo3.Goo has been deprecated'.
a.Goo() ' IGoo3
~~~~~~~
BC40000: 'Public Sub Goo()' is obsolete: 'ConcreteGoo3.Goo has been deprecated'.
b.Goo() ' ConcreteGoo3
~~~~~~~
BC40000: 'Sub Goo()' is obsolete: 'IGoo1.Goo has been deprecated'.
Public Sub Goo() Implements IGoo1.Goo
~~~~~~~~~~~~~~~~~~~~
]]>
compilation1.AssertTheseDiagnostics(expected)
End Sub
<Fact(), WorkItem(858839, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/858839")>
Public Sub Bug858839_2()
Dim source0 =
<compilation>
<file name="test.vb"><![CDATA[
Imports Windows.Foundation.Metadata
public Class IExceptionalInterface
Property ExceptionalProp As String
<Deprecated("Actually, don't even use the prop at all.", DeprecationType.Remove, 50331648UI)>
Get
Return String.Empty
End Get
<Deprecated("Changed my mind; don't put this prop.", DeprecationType.Remove, 33554432UI)>
Set(value As String)
End Set
End Property
End Class
]]>
</file>
</compilation>
Dim compilation0 = CreateEmptyCompilationWithReferences(source0, WinRtRefs, TestOptions.ReleaseDll)
compilation0.VerifyDiagnostics()
Dim source1 =
<compilation>
<file name="test.vb"><![CDATA[
Imports System
Class Test
Public Sub F(i As IExceptionalInterface)
i.ExceptionalProp = "goo"
Console.WriteLine(i.ExceptionalProp)
End Sub
End Class]]>
</file>
</compilation>
Dim compilation1 = CreateEmptyCompilationWithReferences(source1, WinRtRefs.Append(New VisualBasicCompilationReference(compilation0)))
Dim expected = <![CDATA[
BC30911: 'Set' accessor of 'Public Property ExceptionalProp As String' is obsolete: 'Changed my mind; don't put this prop.'.
i.ExceptionalProp = "goo"
~~~~~~~~~~~~~~~~~~~~~~~~~
BC30911: 'Get' accessor of 'Public Property ExceptionalProp As String' is obsolete: 'Actually, don't even use the prop at all.'.
Console.WriteLine(i.ExceptionalProp)
~~~~~~~~~~~~~~~~~
]]>
compilation1.AssertTheseDiagnostics(expected)
Dim compilation2 = CreateEmptyCompilationWithReferences(source1, WinRtRefs.Append(compilation0.EmitToImageReference()))
compilation2.AssertTheseDiagnostics(expected)
End Sub
End Class
End Namespace
|
davkean/roslyn
|
src/Compilers/VisualBasic/Test/Emit/Attributes/AttributeTests_ObsoleteAttribute.vb
|
Visual Basic
|
apache-2.0
| 86,718
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Collections.Immutable
Imports System.Composition
Imports System.Threading
Imports Microsoft.CodeAnalysis.CodeActions
Imports Microsoft.CodeAnalysis.CodeFixes
Imports Microsoft.CodeAnalysis.Diagnostics
Imports Microsoft.CodeAnalysis.Formatting
Imports Microsoft.CodeAnalysis.Simplification
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic.CodeFixes.RemoveUnnecessaryCast
<ExportCodeFixProviderAttribute(LanguageNames.VisualBasic, Name:=PredefinedCodeFixProviderNames.RemoveUnnecessaryCast), [Shared]>
<ExtensionOrder(After:=PredefinedCodeFixProviderNames.GenerateEndConstruct)>
Partial Friend Class RemoveUnnecessaryCastCodeFixProvider
Inherits CodeFixProvider
Public NotOverridable Overrides ReadOnly Property FixableDiagnosticIds As ImmutableArray(Of String)
Get
Return ImmutableArray.Create(IDEDiagnosticIds.RemoveUnnecessaryCastDiagnosticId)
End Get
End Property
Public NotOverridable Overrides Async Function RegisterCodeFixesAsync(context As CodeFixContext) As Task
Dim document = context.Document
Dim span = context.Span
Dim cancellationToken = context.CancellationToken
Dim root = Await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(False)
Dim model = DirectCast(Await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(False), SemanticModel)
Dim node = GetCastNode(root, model, span, cancellationToken)
If node Is Nothing Then
Return
End If
context.RegisterCodeFix(
New MyCodeAction(
VBFeaturesResources.RemoveUnnecessaryCast,
Function(c) RemoveUnnecessaryCastAsync(document, node, c)),
context.Diagnostics)
End Function
Private Shared Function GetCastNode(root As SyntaxNode, model As SemanticModel, span As TextSpan, cancellationToken As CancellationToken) As ExpressionSyntax
Dim token = root.FindToken(span.Start)
If Not token.Span.IntersectsWith(span) Then
Return Nothing
End If
Dim node = token.GetAncestors(Of ExpressionSyntax)() _
.Where(Function(c) TypeOf c Is CastExpressionSyntax OrElse TypeOf c Is PredefinedCastExpressionSyntax) _
.FirstOrDefault(Function(c) c.Span.IntersectsWith(span) AndAlso IsUnnecessaryCast(c, model, cancellationToken))
Return node
End Function
Private Shared Function IsUnnecessaryCast(node As ExpressionSyntax, model As SemanticModel, cancellationToken As CancellationToken) As Boolean
Dim castExpression = TryCast(node, CastExpressionSyntax)
If castExpression IsNot Nothing Then
Return castExpression.IsUnnecessaryCast(model, assumeCallKeyword:=True, cancellationToken:=cancellationToken)
End If
Dim predefinedCastExpression = TryCast(node, PredefinedCastExpressionSyntax)
If predefinedCastExpression IsNot Nothing Then
Return predefinedCastExpression.IsUnnecessaryCast(model, assumeCallKeyword:=True, cancellationToken:=cancellationToken)
End If
Return False
End Function
Private Shared Async Function RemoveUnnecessaryCastAsync(document As Document, node As ExpressionSyntax, cancellationToken As CancellationToken) As Task(Of Document)
' First, annotate our expression so that we can get back to it.
Dim updatedDocument = Await document.ReplaceNodeAsync(node, node.WithAdditionalAnnotations(_expressionAnnotation), cancellationToken).ConfigureAwait(False)
Dim expression = Await FindNodeWithAnnotationAsync(Of ExpressionSyntax)(_expressionAnnotation, updatedDocument, cancellationToken).ConfigureAwait(False)
' Next, make the parenting statement of the expression semantically explicit
Dim parentStatement = expression.FirstAncestorOrSelf(Of StatementSyntax)()
Dim explicitParentStatement = Await Simplifier.ExpandAsync(parentStatement, updatedDocument, cancellationToken:=cancellationToken).ConfigureAwait(False)
explicitParentStatement = explicitParentStatement.WithAdditionalAnnotations(Formatter.Annotation, _statementAnnotation)
updatedDocument = Await updatedDocument.ReplaceNodeAsync(parentStatement, explicitParentStatement, cancellationToken).ConfigureAwait(False)
' Next, make the statement after the parenting statement of the expression semantically explicit.
parentStatement = Await FindNodeWithAnnotationAsync(Of StatementSyntax)(_statementAnnotation, updatedDocument, cancellationToken).ConfigureAwait(False)
Dim nextStatement = parentStatement.GetNextStatement()
If nextStatement IsNot Nothing Then
Dim explicitNextStatement = Await Simplifier.ExpandAsync(nextStatement, updatedDocument, cancellationToken:=cancellationToken).ConfigureAwait(False)
updatedDocument = Await updatedDocument.ReplaceNodeAsync(nextStatement, explicitNextStatement, cancellationToken).ConfigureAwait(False)
End If
Return Await RewriteCoreAsync(updatedDocument, expression, cancellationToken).ConfigureAwait(False)
End Function
Private Shared Async Function RewriteCoreAsync(document As Document, originalExpr As ExpressionSyntax, cancellationToken As CancellationToken) As Task(Of Document)
' Finally, rewrite the cast expression
Dim exprToRewrite As ExpressionSyntax = Nothing
Dim annotatedNodes = Await FindNodesWithAnnotationAsync(_expressionAnnotation, document, cancellationToken).ConfigureAwait(False)
For Each annotatedNode In annotatedNodes
exprToRewrite = TryCast(annotatedNode.AsNode, ExpressionSyntax)
If exprToRewrite IsNot Nothing AndAlso exprToRewrite.IsKind(originalExpr.Kind) Then
If annotatedNodes.Count > 1 Then
' Ensure cast is unnecessary
Dim model = Await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(False)
If IsUnnecessaryCast(exprToRewrite, model, cancellationToken) Then
Exit For
End If
Else
Exit For
End If
End If
exprToRewrite = Nothing
Next
If exprToRewrite Is Nothing Then
Return document
End If
Dim rewriter = New Rewriter(exprToRewrite)
Dim newExpression = rewriter.Visit(exprToRewrite).WithoutAnnotations(_expressionAnnotation)
document = Await document.ReplaceNodeAsync(exprToRewrite, newExpression, cancellationToken).ConfigureAwait(False)
If annotatedNodes.Count > 1 Then
Return Await RewriteCoreAsync(document, originalExpr, cancellationToken).ConfigureAwait(False)
End If
Return document
End Function
Private Shared ReadOnly _expressionAnnotation As New SyntaxAnnotation
Private Shared ReadOnly _statementAnnotation As New SyntaxAnnotation
Private Shared Async Function FindNodeWithAnnotationAsync(Of T As SyntaxNode)(annotation As SyntaxAnnotation, document As Document, cancellationToken As CancellationToken) As Task(Of T)
Dim annotatedNodes = Await FindNodesWithAnnotationAsync(annotation, document, cancellationToken).ConfigureAwait(False)
Dim result = annotatedNodes.Single().AsNode()
Return DirectCast(result, T)
End Function
Private Shared Async Function FindNodesWithAnnotationAsync(annotation As SyntaxAnnotation, document As Document, cancellationToken As CancellationToken) As Task(Of IEnumerable(Of SyntaxNodeOrToken))
Dim root = Await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(False)
Return root.GetAnnotatedNodesAndTokens(annotation)
End Function
Public NotOverridable Overrides Function GetFixAllProvider() As FixAllProvider
Return RemoveUnnecessaryCastFixAllProvider.Instance
End Function
Private Class MyCodeAction
Inherits CodeAction.DocumentChangeAction
Public Sub New(title As String, createChangedDocument As Func(Of CancellationToken, Task(Of Document)))
MyBase.New(title, createChangedDocument)
End Sub
End Class
End Class
End Namespace
|
DavidKarlas/roslyn
|
src/Features/VisualBasic/CodeFixes/RemoveUnnecessaryCast/RemoveUnnecessaryCastCodeFixProvider.vb
|
Visual Basic
|
apache-2.0
| 8,966
|
' Licensed to the .NET Foundation under one or more agreements.
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports Microsoft.CodeAnalysis.Test.Utilities
Imports Roslyn.Test.Utilities
Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests.Semantics
Public Class MethodCalls
Inherits BasicTestBase
<Fact>
Public Sub NamedArguments()
Dim compilationDef =
<compilation name="VBNamedArguments1">
<file name="a.vb">
Option Strict Off
Imports System
Module Module1
Sub Main()
TestOrder2(b:=TestOrder1(1), a:=TestOrder1(2))
TestOrder2(a:=TestOrder1(3), b:=TestOrder1(4))
TestOrder2(b:=TestOrder3("5"), a:=TestOrder1(6))
TestOrder2(b:=TestOrder1(7), a:=TestOrder3("8"))
TestOrder2(b:=TestOrder3("9"), a:=TestOrder3("10"))
TestOrder2(a:=TestOrder3("11"), b:=TestOrder3("12"))
End Sub
Sub TestOrder2(a As Integer, b As Integer)
System.Console.WriteLine("TestOrder2: {0}, {1}", a, b)
End Sub
Function TestOrder1(a As Integer) As Integer
System.Console.WriteLine("TestOrder1: {0}", a)
Return a
End Function
Function TestOrder3(a As String) As String
System.Console.WriteLine("TestOrder3: {0}", a)
Return a
End Function
End Module
</file>
</compilation>
CompileAndVerify(compilationDef,
expectedOutput:=
<![CDATA[
TestOrder1: 2
TestOrder1: 1
TestOrder2: 2, 1
TestOrder1: 3
TestOrder1: 4
TestOrder2: 3, 4
TestOrder1: 6
TestOrder3: 5
TestOrder2: 6, 5
TestOrder3: 8
TestOrder1: 7
TestOrder2: 8, 7
TestOrder3: 10
TestOrder3: 9
TestOrder2: 10, 9
TestOrder3: 11
TestOrder3: 12
TestOrder2: 11, 12
]]>)
End Sub
<Fact>
Public Sub TrueByRefArguments1()
Dim compilationDef =
<compilation name="VBTrueByRefArguments1">
<file name="a.vb">
Option Strict Off
Imports System
Module Module1
Sub Main()
Dim x As Integer = 1
Dim z As Integer() = New Integer() {0, 3}
System.Console.WriteLine("---")
TestByRef(x)
System.Console.WriteLine("Test1: {0}", x)
System.Console.WriteLine("---")
TestByRef(z(Return1()))
System.Console.WriteLine("Test3: {0}", z(1))
System.Console.WriteLine("---")
TestByRef(ReturnArray(z)(Return1()))
System.Console.WriteLine("Test4: {0}", z(1))
End Sub
Sub TestByRef(ByRef a As Integer)
a = a + 1
End Sub
Function ReturnArray(z As Integer()) As Integer()
System.Console.WriteLine("ReturnArray")
Return z
End Function
Function Return1() As Integer
System.Console.WriteLine("Return1")
Return 1
End Function
End Module
</file>
</compilation>
CompileAndVerify(compilationDef,
expectedOutput:=
<![CDATA[
---
Test1: 2
---
Return1
Test3: 4
---
ReturnArray
Return1
Test4: 5
]]>)
End Sub
<Fact>
Public Sub ParamArray1()
Dim compilationDef =
<compilation name="VBParamArray1">
<file name="a.vb">
Imports System
Module Module1
Sub Main()
ParamArray1()
ParamArray1("a"c)
ParamArray1("a"c, "b"c)
ParamArray2(1)
ParamArray2(2, "a"c)
ParamArray2(3, "a"c, "b"c)
ParamArray2(a:=4)
End Sub
Sub ParamArray1(ParamArray a As Char())
System.Console.WriteLine("ParamArray1: [{0}]", CStr(a))
End Sub
Sub ParamArray2(a As Integer, ParamArray b As Char())
System.Console.WriteLine("ParamArray1: {0}, [{1}]", a, CStr(b))
End Sub
End Module
</file>
</compilation>
CompileAndVerify(compilationDef,
expectedOutput:=
<![CDATA[
ParamArray1: []
ParamArray1: [a]
ParamArray1: [ab]
ParamArray1: 1, []
ParamArray1: 2, [a]
ParamArray1: 3, [ab]
ParamArray1: 4, []
]]>)
End Sub
<Fact>
Public Sub ByRefArguments2()
Dim compilationDef =
<compilation name="VBByRefArguments2">
<file name="a.vb">
Option Strict Off
Imports System
Module Module1
Dim staticFld As Byte
ReadOnly staticReadonlyFld As Integer
Sub Main()
Dim z As Byte() = New Byte() {0, 81}
System.Console.WriteLine("---")
Test1()
System.Console.WriteLine("---")
System.Console.WriteLine(Test2())
System.Console.WriteLine("---")
Test2_1()
System.Console.WriteLine("---")
System.Console.WriteLine(Test3())
System.Console.WriteLine("---")
System.Console.WriteLine(Test3_1())
System.Console.WriteLine("---")
System.Console.WriteLine(Test3_2())
System.Console.WriteLine("---")
System.Console.WriteLine(Test4(51))
Dim By As Byte = 53
System.Console.WriteLine("---")
Test4_1(By)
System.Console.WriteLine(By)
System.Console.WriteLine("---")
staticFld = 61
Test5()
System.Console.WriteLine(staticFld)
Dim tc As TestClass = New TestClass()
System.Console.WriteLine("---")
tc.instanceFld = 63
Test5_1(tc)
System.Console.WriteLine(tc.instanceFld)
System.Console.WriteLine("---")
Test5_2()
System.Console.WriteLine("---")
Test5_3(tc)
Dim ts As TestStruct = New TestStruct()
ts.instanceFld = 65
System.Console.WriteLine("---")
Test5_4(ts)
System.Console.WriteLine(ts.instanceFld)
System.Console.WriteLine("---")
System.Console.WriteLine(Test5_5(ts))
System.Console.WriteLine("---")
Test5_6(ts)
System.Console.WriteLine("---")
Test5_7()
System.Console.WriteLine("---")
Test5_8()
System.Console.WriteLine("---")
Test5_9(tc)
System.Console.WriteLine(tc.instanceFld)
System.Console.WriteLine("---")
Test5_10()
System.Console.WriteLine("---")
Test6(z)
System.Console.WriteLine(z(1))
System.Console.WriteLine("---")
Test6_1(z)
System.Console.WriteLine(z(1))
ts.instanceFld = 91
Dim z1 As TestStruct() = New TestStruct() {Nothing, ts}
System.Console.WriteLine("---")
Test6_2(z1)
System.Console.WriteLine(z1(1).instanceFld)
System.Console.WriteLine("---")
Test6_3(z1)
System.Console.WriteLine(z1(1).instanceFld)
End Sub
Sub Test6(z As Byte())
TestByRef(z(1))
End Sub
Sub Test6_1(z As Byte())
TestByRef(ReturnArray(z)(1))
End Sub
Sub Test6_2(z As TestStruct())
TestByRef(z(Return1()).instanceFld)
End Sub
Sub Test6_3(z As TestStruct())
TestByRef(z(1).instanceFld)
End Sub
Sub Test1()
TestByRef(20)
End Sub
Function Test2() As Long
Dim x As Byte = 30
Return TestByRef2(CInt(x))
End Function
Sub Test2_1()
Dim x As Byte = 32
TestByRef2(CInt(x))
End Sub
Function Test3() As Byte
Dim x As Byte = 40
TestByRef(x)
Return x
End Function
Function Test3_1() As Long
Dim x As Byte = 42
Return TestByRef2(x) + x
End Function
Function Test3_2() As Byte
Dim x As Byte = 44
TestByRef2(x)
Return x
End Function
Function Test4(x As Byte) As Byte
TestByRef(x)
Return x
End Function
Sub Test4_1(ByRef x As Byte)
TestByRef(x)
End Sub
Sub Test5()
TestByRef(staticFld)
End Sub
Sub Test5_1(x As TestClass)
TestByRef(x.instanceFld)
End Sub
Sub Test5_2()
TestByRef(staticReadonlyFld)
End Sub
Sub Test5_3(x As TestClass)
TestByRef(x.instanceReadonlyFld)
End Sub
Sub Test5_4(ByRef x As TestStruct)
TestByRef(x.instanceFld)
End Sub
Function Test5_5(x As TestStruct) As Byte
TestByRef(x.instanceFld)
Return x.instanceFld
End Function
Sub Test5_6(x As TestStruct)
TestByRef(x.instanceReadonlyFld)
End Sub
Sub Test5_7()
TestByRef(ReturnInteger())
End Sub
Sub Test5_8()
TestByRef(ReturnTestStruct().instanceFld2)
End Sub
Sub Test5_9(x As TestClass)
TestByRef(ReturnTestClass(x).instanceFld)
End Sub
Sub Test5_10()
TestByRef(1)
End Sub
Function ReturnInteger() As Integer
Return 71
End Function
Function ReturnTestStruct() As TestStruct
Dim x As TestStruct = New TestStruct()
x.instanceFld2 = 73
Return x
End Function
Function ReturnTestClass(x As TestClass) As TestClass
Return x
End Function
Sub TestByRef(ByRef a As Integer)
System.Console.WriteLine("TestByRef: {0}", a)
a = a + 1
End Sub
Function TestByRef2(ByRef a As Integer) As Long
System.Console.WriteLine("TestByRef2: {0}", a)
a = a + 1
Return a
End Function
Function ReturnArray(z As Byte()) As Byte()
System.Console.WriteLine("ReturnArray")
Return z
End Function
Function Return1() As Integer
System.Console.WriteLine("Return1")
Return 1
End Function
End Module
Class TestClass
Public instanceFld As Byte
Public ReadOnly instanceReadonlyFld As Integer
End Class
Structure TestStruct
Public instanceFld As Byte
Public ReadOnly instanceReadonlyFld As Integer
Public instanceFld2 As Integer
Sub Test1()
TestByRef(Me.instanceFld)
End Sub
Sub Test2()
TestByRef(instanceFld)
End Sub
Sub Test3()
TestByRef(Me.instanceReadonlyFld)
End Sub
End Structure
</file>
</compilation>
Dim verifier = CompileAndVerify(compilationDef,
expectedOutput:=
<![CDATA[
---
TestByRef: 20
---
TestByRef2: 30
31
---
TestByRef2: 32
---
TestByRef: 40
41
---
TestByRef2: 42
86
---
TestByRef2: 44
45
---
TestByRef: 51
52
---
TestByRef: 53
54
---
TestByRef: 61
62
---
TestByRef: 63
64
---
TestByRef: 0
---
TestByRef: 0
---
TestByRef: 65
66
---
TestByRef: 66
67
---
TestByRef: 0
---
TestByRef: 71
---
TestByRef: 73
---
TestByRef: 64
65
---
TestByRef: 1
---
TestByRef: 81
82
---
ReturnArray
TestByRef: 82
83
---
Return1
TestByRef: 91
92
---
TestByRef: 92
93
]]>)
verifier.VerifyIL("Module1.Test1",
<![CDATA[
{
// Code size 11 (0xb)
.maxstack 1
.locals init (Integer V_0)
IL_0000: ldc.i4.s 20
IL_0002: stloc.0
IL_0003: ldloca.s V_0
IL_0005: call "Sub Module1.TestByRef(ByRef Integer)"
IL_000a: ret
}
]]>)
verifier.VerifyIL("Module1.Test2",
<![CDATA[
{
// Code size 11 (0xb)
.maxstack 1
.locals init (Integer V_0)
IL_0000: ldc.i4.s 30
IL_0002: stloc.0
IL_0003: ldloca.s V_0
IL_0005: call "Function Module1.TestByRef2(ByRef Integer) As Long"
IL_000a: ret
}
]]>)
verifier.VerifyIL("Module1.Test2_1",
<![CDATA[
{
// Code size 12 (0xc)
.maxstack 1
.locals init (Integer V_0)
IL_0000: ldc.i4.s 32
IL_0002: stloc.0
IL_0003: ldloca.s V_0
IL_0005: call "Function Module1.TestByRef2(ByRef Integer) As Long"
IL_000a: pop
IL_000b: ret
}
]]>)
verifier.VerifyIL("Module1.Test3",
<![CDATA[
{
// Code size 13 (0xd)
.maxstack 1
.locals init (Integer V_0)
IL_0000: ldc.i4.s 40
IL_0002: stloc.0
IL_0003: ldloca.s V_0
IL_0005: call "Sub Module1.TestByRef(ByRef Integer)"
IL_000a: ldloc.0
IL_000b: conv.ovf.u1
IL_000c: ret
}
]]>)
verifier.VerifyIL("Module1.Test3_1",
<![CDATA[
{
// Code size 19 (0x13)
.maxstack 2
.locals init (Byte V_0, //x
Integer V_1)
IL_0000: ldc.i4.s 42
IL_0002: stloc.0
IL_0003: ldloc.0
IL_0004: stloc.1
IL_0005: ldloca.s V_1
IL_0007: call "Function Module1.TestByRef2(ByRef Integer) As Long"
IL_000c: ldloc.1
IL_000d: conv.ovf.u1
IL_000e: stloc.0
IL_000f: ldloc.0
IL_0010: conv.u8
IL_0011: add.ovf
IL_0012: ret
}
]]>)
verifier.VerifyIL("Module1.Test3_2",
<![CDATA[
{
// Code size 14 (0xe)
.maxstack 1
.locals init (Integer V_0)
IL_0000: ldc.i4.s 44
IL_0002: stloc.0
IL_0003: ldloca.s V_0
IL_0005: call "Function Module1.TestByRef2(ByRef Integer) As Long"
IL_000a: pop
IL_000b: ldloc.0
IL_000c: conv.ovf.u1
IL_000d: ret
}
]]>)
verifier.VerifyIL("Module1.Test4",
<![CDATA[
{
// Code size 15 (0xf)
.maxstack 1
.locals init (Integer V_0)
IL_0000: ldarg.0
IL_0001: stloc.0
IL_0002: ldloca.s V_0
IL_0004: call "Sub Module1.TestByRef(ByRef Integer)"
IL_0009: ldloc.0
IL_000a: conv.ovf.u1
IL_000b: starg.s V_0
IL_000d: ldarg.0
IL_000e: ret
}
]]>)
verifier.VerifyIL("Module1.Test4_1",
<![CDATA[
{
// Code size 15 (0xf)
.maxstack 2
.locals init (Integer V_0)
IL_0000: ldarg.0
IL_0001: ldind.u1
IL_0002: stloc.0
IL_0003: ldloca.s V_0
IL_0005: call "Sub Module1.TestByRef(ByRef Integer)"
IL_000a: ldarg.0
IL_000b: ldloc.0
IL_000c: conv.ovf.u1
IL_000d: stind.i1
IL_000e: ret
}
]]>)
verifier.VerifyIL("Module1.Test5",
<![CDATA[
{
// Code size 21 (0x15)
.maxstack 1
.locals init (Integer V_0)
IL_0000: ldsfld "Module1.staticFld As Byte"
IL_0005: stloc.0
IL_0006: ldloca.s V_0
IL_0008: call "Sub Module1.TestByRef(ByRef Integer)"
IL_000d: ldloc.0
IL_000e: conv.ovf.u1
IL_000f: stsfld "Module1.staticFld As Byte"
IL_0014: ret
}
]]>)
#If DONT_USE_BYREF_LOCALS_FOR_USE_TWICE Then
verifier.VerifyIL("Module1.Test5_1",
<![CDATA[
{
// Code size 25 (0x19)
.maxstack 2
.locals init (TestClass V_0,
Integer V_1)
IL_0000: ldarg.0
IL_0001: dup
IL_0002: stloc.0
IL_0003: ldfld "TestClass.instanceFld As Byte"
IL_0008: stloc.1
IL_0009: ldloca.s V_1
IL_000b: call "Sub Module1.TestByRef(ByRef Integer)"
IL_0010: ldloc.0
IL_0011: ldloc.1
IL_0012: conv.ovf.u1
IL_0013: stfld "TestClass.instanceFld As Byte"
IL_0018: ret
}
]]>)
#Else
verifier.VerifyIL("Module1.Test5_1",
<![CDATA[
{
// Code size 20 (0x14)
.maxstack 2
.locals init (Integer V_0)
IL_0000: ldarg.0
IL_0001: ldflda "TestClass.instanceFld As Byte"
IL_0006: dup
IL_0007: ldind.u1
IL_0008: stloc.0
IL_0009: ldloca.s V_0
IL_000b: call "Sub Module1.TestByRef(ByRef Integer)"
IL_0010: ldloc.0
IL_0011: conv.ovf.u1
IL_0012: stind.i1
IL_0013: ret
}
]]>)
#End If
verifier.VerifyIL("Module1.Test5_2",
<![CDATA[
{
// Code size 14 (0xe)
.maxstack 1
.locals init (Integer V_0)
IL_0000: ldsfld "Module1.staticReadonlyFld As Integer"
IL_0005: stloc.0
IL_0006: ldloca.s V_0
IL_0008: call "Sub Module1.TestByRef(ByRef Integer)"
IL_000d: ret
}
]]>)
verifier.VerifyIL("Module1.Test5_3",
<![CDATA[
{
// Code size 15 (0xf)
.maxstack 1
.locals init (Integer V_0)
IL_0000: ldarg.0
IL_0001: ldfld "TestClass.instanceReadonlyFld As Integer"
IL_0006: stloc.0
IL_0007: ldloca.s V_0
IL_0009: call "Sub Module1.TestByRef(ByRef Integer)"
IL_000e: ret
}
]]>)
#If DONT_USE_BYREF_LOCALS_FOR_USE_TWICE Then
verifier.VerifyIL("Module1.Test5_4",
<![CDATA[
{
// Code size 23 (0x17)
.maxstack 2
.locals init (Integer V_0)
IL_0000: ldarg.0
IL_0001: ldfld "TestStruct.instanceFld As Byte"
IL_0006: stloc.0
IL_0007: ldloca.s V_0
IL_0009: call "Sub Module1.TestByRef(ByRef Integer)"
IL_000e: ldarg.0
IL_000f: ldloc.0
IL_0010: conv.ovf.u1
IL_0011: stfld "TestStruct.instanceFld As Byte"
IL_0016: ret
}
]]>)
#Else
verifier.VerifyIL("Module1.Test5_4",
<![CDATA[
{
// Code size 20 (0x14)
.maxstack 2
.locals init (Integer V_0)
IL_0000: ldarg.0
IL_0001: ldflda "TestStruct.instanceFld As Byte"
IL_0006: dup
IL_0007: ldind.u1
IL_0008: stloc.0
IL_0009: ldloca.s V_0
IL_000b: call "Sub Module1.TestByRef(ByRef Integer)"
IL_0010: ldloc.0
IL_0011: conv.ovf.u1
IL_0012: stind.i1
IL_0013: ret
}
]]>)
#End If
#If DONT_USE_BYREF_LOCALS_FOR_USE_TWICE Then
verifier.VerifyIL("Module1.Test5_5",
<![CDATA[
{
// Code size 34 (0x22)
.maxstack 2
.locals init (Byte V_0, //Test5_5
Integer V_1)
IL_0000: ldarga.s V_0
IL_0002: ldfld "TestStruct.instanceFld As Byte"
IL_0007: stloc.1
IL_0008: ldloca.s V_1
IL_000a: call "Sub Module1.TestByRef(ByRef Integer)"
IL_000f: ldarga.s V_0
IL_0011: ldloc.1
IL_0012: conv.ovf.u1
IL_0013: stfld "TestStruct.instanceFld As Byte"
IL_0018: ldarga.s V_0
IL_001a: ldfld "TestStruct.instanceFld As Byte"
IL_001f: stloc.0
IL_0020: ldloc.0
IL_0021: ret
}
]]>)
#Else
verifier.VerifyIL("Module1.Test5_5",
<![CDATA[
{
// Code size 27 (0x1b)
.maxstack 2
.locals init (Integer V_0)
IL_0000: ldarga.s V_0
IL_0002: ldflda "TestStruct.instanceFld As Byte"
IL_0007: dup
IL_0008: ldind.u1
IL_0009: stloc.0
IL_000a: ldloca.s V_0
IL_000c: call "Sub Module1.TestByRef(ByRef Integer)"
IL_0011: ldloc.0
IL_0012: conv.ovf.u1
IL_0013: stind.i1
IL_0014: ldarg.0
IL_0015: ldfld "TestStruct.instanceFld As Byte"
IL_001a: ret
}
]]>)
#End If
verifier.VerifyIL("Module1.Test5_6",
<![CDATA[
{
// Code size 15 (0xf)
.maxstack 1
.locals init (Integer V_0)
IL_0000: ldarg.0
IL_0001: ldfld "TestStruct.instanceReadonlyFld As Integer"
IL_0006: stloc.0
IL_0007: ldloca.s V_0
IL_0009: call "Sub Module1.TestByRef(ByRef Integer)"
IL_000e: ret
}
]]>)
verifier.VerifyIL("Module1.Test5_7",
<![CDATA[
{
// Code size 14 (0xe)
.maxstack 1
.locals init (Integer V_0)
IL_0000: call "Function Module1.ReturnInteger() As Integer"
IL_0005: stloc.0
IL_0006: ldloca.s V_0
IL_0008: call "Sub Module1.TestByRef(ByRef Integer)"
IL_000d: ret
}
]]>)
verifier.VerifyIL("Module1.Test5_8",
<![CDATA[
{
// Code size 19 (0x13)
.maxstack 1
.locals init (Integer V_0)
IL_0000: call "Function Module1.ReturnTestStruct() As TestStruct"
IL_0005: ldfld "TestStruct.instanceFld2 As Integer"
IL_000a: stloc.0
IL_000b: ldloca.s V_0
IL_000d: call "Sub Module1.TestByRef(ByRef Integer)"
IL_0012: ret
}
]]>)
#If DONT_USE_BYREF_LOCALS_FOR_USE_TWICE Then
verifier.VerifyIL("Module1.Test5_9",
<![CDATA[
{
// Code size 30 (0x1e)
.maxstack 2
.locals init (TestClass V_0,
Integer V_1)
IL_0000: ldarg.0
IL_0001: call "Function Module1.ReturnTestClass(TestClass) As TestClass"
IL_0006: dup
IL_0007: stloc.0
IL_0008: ldfld "TestClass.instanceFld As Byte"
IL_000d: stloc.1
IL_000e: ldloca.s V_1
IL_0010: call "Sub Module1.TestByRef(ByRef Integer)"
IL_0015: ldloc.0
IL_0016: ldloc.1
IL_0017: conv.ovf.u1
IL_0018: stfld "TestClass.instanceFld As Byte"
IL_001d: ret
}
]]>)
#Else
verifier.VerifyIL("Module1.Test5_9",
<![CDATA[
{
// Code size 25 (0x19)
.maxstack 2
.locals init (Integer V_0)
IL_0000: ldarg.0
IL_0001: call "Function Module1.ReturnTestClass(TestClass) As TestClass"
IL_0006: ldflda "TestClass.instanceFld As Byte"
IL_000b: dup
IL_000c: ldind.u1
IL_000d: stloc.0
IL_000e: ldloca.s V_0
IL_0010: call "Sub Module1.TestByRef(ByRef Integer)"
IL_0015: ldloc.0
IL_0016: conv.ovf.u1
IL_0017: stind.i1
IL_0018: ret
}
]]>)
#End If
verifier.VerifyIL("Module1.Test5_10",
<![CDATA[
{
// Code size 10 (0xa)
.maxstack 1
.locals init (Integer V_0)
IL_0000: ldc.i4.1
IL_0001: stloc.0
IL_0002: ldloca.s V_0
IL_0004: call "Sub Module1.TestByRef(ByRef Integer)"
IL_0009: ret
}
]]>)
#If DONT_USE_BYREF_LOCALS_FOR_USE_TWICE Then
verifier.VerifyIL("TestStruct.Test1",
<![CDATA[
{
// Code size 23 (0x17)
.maxstack 2
.locals init (Integer V_0)
IL_0000: ldarg.0
IL_0001: ldfld "TestStruct.instanceFld As Byte"
IL_0006: stloc.0
IL_0007: ldloca.s V_0
IL_0009: call "Sub Module1.TestByRef(ByRef Integer)"
IL_000e: ldarg.0
IL_000f: ldloc.0
IL_0010: conv.ovf.u1
IL_0011: stfld "TestStruct.instanceFld As Byte"
IL_0016: ret
}
]]>)
#Else
verifier.VerifyIL("TestStruct.Test1",
<![CDATA[
{
// Code size 20 (0x14)
.maxstack 2
.locals init (Integer V_0)
IL_0000: ldarg.0
IL_0001: ldflda "TestStruct.instanceFld As Byte"
IL_0006: dup
IL_0007: ldind.u1
IL_0008: stloc.0
IL_0009: ldloca.s V_0
IL_000b: call "Sub Module1.TestByRef(ByRef Integer)"
IL_0010: ldloc.0
IL_0011: conv.ovf.u1
IL_0012: stind.i1
IL_0013: ret
}
]]>)
#End If
#If DONT_USE_BYREF_LOCALS_FOR_USE_TWICE Then
verifier.VerifyIL("TestStruct.Test2",
<![CDATA[
{
// Code size 23 (0x17)
.maxstack 2
.locals init (Integer V_0)
IL_0000: ldarg.0
IL_0001: ldfld "TestStruct.instanceFld As Byte"
IL_0006: stloc.0
IL_0007: ldloca.s V_0
IL_0009: call "Sub Module1.TestByRef(ByRef Integer)"
IL_000e: ldarg.0
IL_000f: ldloc.0
IL_0010: conv.ovf.u1
IL_0011: stfld "TestStruct.instanceFld As Byte"
IL_0016: ret
}
]]>)
#Else
verifier.VerifyIL("TestStruct.Test2",
<![CDATA[
{
// Code size 20 (0x14)
.maxstack 2
.locals init (Integer V_0)
IL_0000: ldarg.0
IL_0001: ldflda "TestStruct.instanceFld As Byte"
IL_0006: dup
IL_0007: ldind.u1
IL_0008: stloc.0
IL_0009: ldloca.s V_0
IL_000b: call "Sub Module1.TestByRef(ByRef Integer)"
IL_0010: ldloc.0
IL_0011: conv.ovf.u1
IL_0012: stind.i1
IL_0013: ret
}
]]>)
#End If
verifier.VerifyIL("TestStruct.Test3",
<![CDATA[
{
// Code size 15 (0xf)
.maxstack 1
.locals init (Integer V_0)
IL_0000: ldarg.0
IL_0001: ldfld "TestStruct.instanceReadonlyFld As Integer"
IL_0006: stloc.0
IL_0007: ldloca.s V_0
IL_0009: call "Sub Module1.TestByRef(ByRef Integer)"
IL_000e: ret
}
]]>)
#If DONT_USE_BYREF_LOCALS_FOR_USE_TWICE Then
verifier.VerifyIL("Module1.Test6",
<![CDATA[
{
// Code size 19 (0x13)
.maxstack 3
.locals init (Byte() V_0,
Integer V_1)
IL_0000: ldarg.0
IL_0001: dup
IL_0002: stloc.0
IL_0003: ldc.i4.1
IL_0004: ldelem.u1
IL_0005: stloc.1
IL_0006: ldloca.s V_1
IL_0008: call "Sub Module1.TestByRef(ByRef Integer)"
IL_000d: ldloc.0
IL_000e: ldc.i4.1
IL_000f: ldloc.1
IL_0010: conv.ovf.u1
IL_0011: stelem.i1
IL_0012: ret
}
]]>)
#Else
verifier.VerifyIL("Module1.Test6",
<![CDATA[
{
// Code size 21 (0x15)
.maxstack 2
.locals init (Integer V_0)
IL_0000: ldarg.0
IL_0001: ldc.i4.1
IL_0002: ldelema "Byte"
IL_0007: dup
IL_0008: ldind.u1
IL_0009: stloc.0
IL_000a: ldloca.s V_0
IL_000c: call "Sub Module1.TestByRef(ByRef Integer)"
IL_0011: ldloc.0
IL_0012: conv.ovf.u1
IL_0013: stind.i1
IL_0014: ret
}
]]>)
#End If
#If DONT_USE_BYREF_LOCALS_FOR_USE_TWICE Then
verifier.VerifyIL("Module1.Test6_1",
<![CDATA[
{
// Code size 24 (0x18)
.maxstack 3
.locals init (Byte() V_0,
Integer V_1)
IL_0000: ldarg.0
IL_0001: call "Function Module1.ReturnArray(Byte()) As Byte()"
IL_0006: dup
IL_0007: stloc.0
IL_0008: ldc.i4.1
IL_0009: ldelem.u1
IL_000a: stloc.1
IL_000b: ldloca.s V_1
IL_000d: call "Sub Module1.TestByRef(ByRef Integer)"
IL_0012: ldloc.0
IL_0013: ldc.i4.1
IL_0014: ldloc.1
IL_0015: conv.ovf.u1
IL_0016: stelem.i1
IL_0017: ret
}
]]>)
#Else
verifier.VerifyIL("Module1.Test6_1",
<![CDATA[
{
// Code size 26 (0x1a)
.maxstack 2
.locals init (Integer V_0)
IL_0000: ldarg.0
IL_0001: call "Function Module1.ReturnArray(Byte()) As Byte()"
IL_0006: ldc.i4.1
IL_0007: ldelema "Byte"
IL_000c: dup
IL_000d: ldind.u1
IL_000e: stloc.0
IL_000f: ldloca.s V_0
IL_0011: call "Sub Module1.TestByRef(ByRef Integer)"
IL_0016: ldloc.0
IL_0017: conv.ovf.u1
IL_0018: stind.i1
IL_0019: ret
}
]]>)
#End If
#If DONT_USE_BYREF_LOCALS_FOR_USE_TWICE Then
verifier.VerifyIL("Module1.Test6_2",
<![CDATA[
{
// Code size 43 (0x2b)
.maxstack 3
.locals init (TestStruct() V_0,
Integer V_1,
Integer V_2)
IL_0000: ldarg.0
IL_0001: dup
IL_0002: stloc.0
IL_0003: call "Function Module1.Return1() As Integer"
IL_0008: dup
IL_0009: stloc.1
IL_000a: ldelema "TestStruct"
IL_000f: ldfld "TestStruct.instanceFld As Byte"
IL_0014: stloc.2
IL_0015: ldloca.s V_2
IL_0017: call "Sub Module1.TestByRef(ByRef Integer)"
IL_001c: ldloc.0
IL_001d: ldloc.1
IL_001e: ldelema "TestStruct"
IL_0023: ldloc.2
IL_0024: conv.ovf.u1
IL_0025: stfld "TestStruct.instanceFld As Byte"
IL_002a: ret
}
]]>)
#Else
verifier.VerifyIL("Module1.Test6_2",
<![CDATA[
{
// Code size 30 (0x1e)
.maxstack 2
.locals init (Integer V_0)
IL_0000: ldarg.0
IL_0001: call "Function Module1.Return1() As Integer"
IL_0006: ldelema "TestStruct"
IL_000b: ldflda "TestStruct.instanceFld As Byte"
IL_0010: dup
IL_0011: ldind.u1
IL_0012: stloc.0
IL_0013: ldloca.s V_0
IL_0015: call "Sub Module1.TestByRef(ByRef Integer)"
IL_001a: ldloc.0
IL_001b: conv.ovf.u1
IL_001c: stind.i1
IL_001d: ret
}
]]>)
#End If
#If DONT_USE_BYREF_LOCALS_FOR_USE_TWICE Then
verifier.VerifyIL("Module1.Test6_3",
<![CDATA[
{
// Code size 37 (0x25)
.maxstack 2
.locals init (TestStruct() V_0,
Integer V_1)
IL_0000: ldarg.0
IL_0001: dup
IL_0002: stloc.0
IL_0003: ldc.i4.1
IL_0004: ldelema "TestStruct"
IL_0009: ldfld "TestStruct.instanceFld As Byte"
IL_000e: stloc.1
IL_000f: ldloca.s V_1
IL_0011: call "Sub Module1.TestByRef(ByRef Integer)"
IL_0016: ldloc.0
IL_0017: ldc.i4.1
IL_0018: ldelema "TestStruct"
IL_001d: ldloc.1
IL_001e: conv.ovf.u1
IL_001f: stfld "TestStruct.instanceFld As Byte"
IL_0024: ret
}
]]>)
#Else
verifier.VerifyIL("Module1.Test6_3",
<![CDATA[
{
// Code size 26 (0x1a)
.maxstack 2
.locals init (Integer V_0)
IL_0000: ldarg.0
IL_0001: ldc.i4.1
IL_0002: ldelema "TestStruct"
IL_0007: ldflda "TestStruct.instanceFld As Byte"
IL_000c: dup
IL_000d: ldind.u1
IL_000e: stloc.0
IL_000f: ldloca.s V_0
IL_0011: call "Sub Module1.TestByRef(ByRef Integer)"
IL_0016: ldloc.0
IL_0017: conv.ovf.u1
IL_0018: stind.i1
IL_0019: ret
}
]]>)
#End If
End Sub
' Same as ByRefArguments2 but with properties not fields.
<Fact>
Public Sub ByRefArguments2A()
Dim compilationDef =
<compilation name="VBByRefArguments2A">
<file name="a.vb">
Option Strict Off
Imports System
Module Module1
Property staticFld As Byte
ReadOnly _staticReadonlyFld As Integer
ReadOnly Property staticReadonlyFld As Integer
Get
Return _staticReadonlyFld
End Get
End Property
Sub Main()
Dim z As Byte() = New Byte() {0, 81}
System.Console.WriteLine("---")
Test1()
System.Console.WriteLine("---")
System.Console.WriteLine(Test2())
System.Console.WriteLine("---")
Test2_1()
System.Console.WriteLine("---")
System.Console.WriteLine(Test3())
System.Console.WriteLine("---")
System.Console.WriteLine(Test3_1())
System.Console.WriteLine("---")
System.Console.WriteLine(Test3_2())
System.Console.WriteLine("---")
System.Console.WriteLine(Test4(51))
System.Console.WriteLine("---")
staticFld = 61
Test5()
System.Console.WriteLine(staticFld)
Dim tc As TestClass = New TestClass()
System.Console.WriteLine("---")
tc.instanceFld = 63
Test5_1(tc)
System.Console.WriteLine(tc.instanceFld)
System.Console.WriteLine("---")
Test5_2()
System.Console.WriteLine("---")
Test5_3(tc)
Dim ts As TestStruct = New TestStruct()
ts.instanceFld = 65
System.Console.WriteLine("---")
Test5_4(ts)
System.Console.WriteLine(ts.instanceFld)
System.Console.WriteLine("---")
System.Console.WriteLine(Test5_5(ts))
System.Console.WriteLine("---")
Test5_6(ts)
System.Console.WriteLine("---")
Test5_7()
System.Console.WriteLine("---")
Test5_8()
System.Console.WriteLine("---")
Test5_9(tc)
System.Console.WriteLine(tc.instanceFld)
System.Console.WriteLine("---")
Test5_10()
System.Console.WriteLine("---")
Test6(z)
System.Console.WriteLine(z(1))
System.Console.WriteLine("---")
Test6_1(z)
System.Console.WriteLine(z(1))
ts.instanceFld = 91
Dim z1 As TestStruct() = New TestStruct() {Nothing, ts}
System.Console.WriteLine("---")
Test6_2(z1)
System.Console.WriteLine(z1(1).instanceFld)
System.Console.WriteLine("---")
Test6_3(z1)
System.Console.WriteLine(z1(1).instanceFld)
End Sub
Sub Test6(z As Byte())
TestByRef(z(1))
End Sub
Sub Test6_1(z As Byte())
TestByRef(ReturnArray(z)(1))
End Sub
Sub Test6_2(z As TestStruct())
TestByRef(z(Return1()).instanceFld)
End Sub
Sub Test6_3(z As TestStruct())
TestByRef(z(1).instanceFld)
End Sub
Sub Test1()
TestByRef(20)
End Sub
Function Test2() As Long
Dim x As Byte = 30
Return TestByRef2(CInt(x))
End Function
Sub Test2_1()
Dim x As Byte = 32
TestByRef2(CInt(x))
End Sub
Function Test3() As Byte
Dim x As Byte = 40
TestByRef(x)
Return x
End Function
Function Test3_1() As Long
Dim x As Byte = 42
Return TestByRef2(x) + x
End Function
Function Test3_2() As Byte
Dim x As Byte = 44
TestByRef2(x)
Return x
End Function
Function Test4(x As Byte) As Byte
TestByRef(x)
Return x
End Function
Sub Test5()
TestByRef(staticFld)
End Sub
Sub Test5_1(x As TestClass)
TestByRef(x.instanceFld)
End Sub
Sub Test5_2()
TestByRef(staticReadonlyFld)
End Sub
Sub Test5_3(x As TestClass)
TestByRef(x.instanceReadonlyFld)
End Sub
Sub Test5_4(ByRef x As TestStruct)
TestByRef(x.instanceFld)
End Sub
Function Test5_5(x As TestStruct) As Byte
TestByRef(x.instanceFld)
Return x.instanceFld
End Function
Sub Test5_6(x As TestStruct)
TestByRef(x.instanceReadonlyFld)
End Sub
Sub Test5_7()
TestByRef(ReturnInteger())
End Sub
Sub Test5_8()
TestByRef(ReturnTestStruct().instanceFld2)
End Sub
Sub Test5_9(x As TestClass)
TestByRef(ReturnTestClass(x).instanceFld)
End Sub
Sub Test5_10()
TestByRef(1)
End Sub
Function ReturnInteger() As Integer
Return 71
End Function
Function ReturnTestStruct() As TestStruct
Dim x As TestStruct = New TestStruct()
x.instanceFld2 = 73
Return x
End Function
Function ReturnTestClass(x As TestClass) As TestClass
Return x
End Function
Sub TestByRef(ByRef a As Integer)
System.Console.WriteLine("TestByRef: {0}", a)
a = a + 1
End Sub
Function TestByRef2(ByRef a As Integer) As Long
System.Console.WriteLine("TestByRef2: {0}", a)
a = a + 1
Return a
End Function
Function ReturnArray(z As Byte()) As Byte()
System.Console.WriteLine("ReturnArray")
Return z
End Function
Function Return1() As Integer
System.Console.WriteLine("Return1")
Return 1
End Function
End Module
Class TestClass
Public Property instanceFld As Byte
Private ReadOnly _instanceReadonlyFld As Integer
Public ReadOnly Property instanceReadonlyFld As Integer
Get
Return _instanceReadonlyFld
End Get
End Property
End Class
Structure TestStruct
Public Property instanceFld As Byte
Private ReadOnly _instanceReadonlyFld As Integer
Public ReadOnly Property instanceReadonlyFld As Integer
Get
Return _instanceReadonlyFld
End Get
End Property
Public Property instanceFld2 As Integer
Sub Test1()
TestByRef(Me.instanceFld)
End Sub
Sub Test2()
TestByRef(instanceFld)
End Sub
Sub Test3()
TestByRef(Me.instanceReadonlyFld)
End Sub
End Structure
</file>
</compilation>
CompileAndVerify(compilationDef,
expectedOutput:=
<![CDATA[
---
TestByRef: 20
---
TestByRef2: 30
31
---
TestByRef2: 32
---
TestByRef: 40
41
---
TestByRef2: 42
86
---
TestByRef2: 44
45
---
TestByRef: 51
52
---
TestByRef: 61
62
---
TestByRef: 63
64
---
TestByRef: 0
---
TestByRef: 0
---
TestByRef: 65
66
---
TestByRef: 66
67
---
TestByRef: 0
---
TestByRef: 71
---
TestByRef: 73
---
TestByRef: 64
65
---
TestByRef: 1
---
TestByRef: 81
82
---
ReturnArray
TestByRef: 82
83
---
Return1
TestByRef: 91
92
---
TestByRef: 92
93
]]>)
End Sub
<Fact>
Public Sub ByRefArguments3()
Dim compilationDef =
<compilation name="VBByRefArguments3">
<file name="a.vb">
Option Strict Off
Imports System
Module Module1
Sub Main()
Dim By As Byte = 53
Dim Ob As Object
Ob = New TestClass(By)
System.Console.WriteLine(By)
Ob = New TestStructure(By)
System.Console.WriteLine(By)
End Sub
End Module
Class TestClass
Public Sub New(ByRef x As Integer)
x = x + 1
End Sub
End Class
Structure TestStructure
Public Sub New(ByRef x As Integer)
x = x + 1
End Sub
End Structure
</file>
</compilation>
CompileAndVerify(compilationDef,
expectedOutput:=
<![CDATA[
54
55
]]>)
End Sub
<Fact>
Public Sub ByRefArguments4()
Dim compilationDef =
<compilation name="VBByRefArguments4">
<file name="a.vb">
Option Strict Off
Imports System
Module Module1
Sub Main()
System.Console.WriteLine("---")
Test1()
System.Console.WriteLine("---")
System.Console.WriteLine(TestClass.baseStaticReadonlyFld)
System.Console.WriteLine(TestClass.staticReadonlyFld)
System.Console.WriteLine(TestClass.output)
System.Console.WriteLine("---")
Dim tc1 As TestClass = New TestClass()
System.Console.WriteLine(tc1.instanceReadonlyFld)
System.Console.WriteLine("---")
Dim tc2 As TestClass = New TestClass(tc1)
System.Console.WriteLine(tc1.instanceReadonlyFld)
System.Console.WriteLine(tc2.instanceReadonlyFld)
System.Console.WriteLine("---")
Dim tc3 As TestClass = New TestClass(tc1, tc2)
System.Console.WriteLine(TestClass.staticReadonlyFld)
System.Console.WriteLine("---")
Dim tc4 As TestClass = New TestClass(tc1, tc2, tc3)
System.Console.WriteLine(tc4.baseInstanceReadonlyFld)
System.Console.WriteLine("---")
Test2(tc1)
System.Console.WriteLine(TestClass.staticField)
System.Console.WriteLine("---")
Dim z As Byte() = New Byte() {0, 3}
'Dim z As Byte() = New Byte() {0, 1, 2, 3, 4}
Test3(z)
System.Console.WriteLine(z((1 + 1 * 2)/3))
End Sub
Sub Test1()
TestByRef(System.Int32.MinValue)
End Sub
Sub Test2(tc As TestClass)
TestByRef(tc.staticField)
End Sub
Sub Test3(z As Byte())
TestByRef(z((1 + 1 * 2)/3))
End Sub
Sub TestByRef(ByRef a As Integer)
System.Console.WriteLine("TestByRef: {0}", a)
a = a + 1
End Sub
End Module
Class Base
Public ReadOnly baseInstanceReadonlyFld As Integer
Public Shared ReadOnly baseStaticReadonlyFld As Integer
End Class
Class TestClass
Inherits Base
Public ReadOnly instanceReadonlyFld As Integer
Public Shared ReadOnly staticReadonlyFld As Integer
Public Shared output As Integer
Public Shared staticField As Byte
Sub New()
TestByRef(instanceReadonlyFld)
End Sub
Sub New(tc As TestClass)
TestByRef(tc.instanceReadonlyFld)
End Sub
Sub New(tc1 As TestClass, tc2 As TestClass)
TestByRef(Me.staticReadonlyFld)
End Sub
Sub New(tc1 As TestClass, tc2 As TestClass, tc3 As TestClass)
TestByRef(Me.baseInstanceReadonlyFld)
End Sub
Shared Sub New()
TestByRef(staticReadonlyFld)
TestByRef(baseStaticReadonlyFld)
Dim tc As TestClass = New TestClass()
TestByRef(tc.instanceReadonlyFld)
output = tc.instanceReadonlyFld
End Sub
End Class
</file>
</compilation>
Dim verifier = CompileAndVerify(compilationDef,
expectedOutput:=
<![CDATA[
---
TestByRef: -2147483648
---
0
TestByRef: 0
TestByRef: 0
TestByRef: 0
TestByRef: 1
1
1
---
TestByRef: 0
1
---
TestByRef: 1
1
0
---
TestByRef: 1
1
---
TestByRef: 0
0
---
TestByRef: 0
1
---
TestByRef: 3
4
]]>)
verifier.VerifyIL("Module1.Test1",
<![CDATA[
{
// Code size 14 (0xe)
.maxstack 1
.locals init (Integer V_0)
IL_0000: ldc.i4 0x80000000
IL_0005: stloc.0
IL_0006: ldloca.s V_0
IL_0008: call "Sub Module1.TestByRef(ByRef Integer)"
IL_000d: ret
}
]]>)
verifier.VerifyIL("TestClass..ctor",
<![CDATA[
{
// Code size 18 (0x12)
.maxstack 1
IL_0000: ldarg.0
IL_0001: call "Sub Base..ctor()"
IL_0006: ldarg.0
IL_0007: ldflda "TestClass.instanceReadonlyFld As Integer"
IL_000c: call "Sub Module1.TestByRef(ByRef Integer)"
IL_0011: ret
}
]]>)
verifier.VerifyIL("TestClass..ctor(TestClass)",
<![CDATA[
{
// Code size 21 (0x15)
.maxstack 1
.locals init (Integer V_0)
IL_0000: ldarg.0
IL_0001: call "Sub Base..ctor()"
IL_0006: ldarg.1
IL_0007: ldfld "TestClass.instanceReadonlyFld As Integer"
IL_000c: stloc.0
IL_000d: ldloca.s V_0
IL_000f: call "Sub Module1.TestByRef(ByRef Integer)"
IL_0014: ret
}
]]>)
verifier.VerifyIL("TestClass..ctor(TestClass, TestClass)",
<![CDATA[
{
// Code size 20 (0x14)
.maxstack 1
.locals init (Integer V_0)
IL_0000: ldarg.0
IL_0001: call "Sub Base..ctor()"
IL_0006: ldsfld "TestClass.staticReadonlyFld As Integer"
IL_000b: stloc.0
IL_000c: ldloca.s V_0
IL_000e: call "Sub Module1.TestByRef(ByRef Integer)"
IL_0013: ret
}
]]>)
verifier.VerifyIL("TestClass..ctor(TestClass, TestClass, TestClass)",
<![CDATA[
{
// Code size 21 (0x15)
.maxstack 1
.locals init (Integer V_0)
IL_0000: ldarg.0
IL_0001: call "Sub Base..ctor()"
IL_0006: ldarg.0
IL_0007: ldfld "Base.baseInstanceReadonlyFld As Integer"
IL_000c: stloc.0
IL_000d: ldloca.s V_0
IL_000f: call "Sub Module1.TestByRef(ByRef Integer)"
IL_0014: ret
}
]]>)
verifier.VerifyIL("TestClass..cctor",
<![CDATA[
{
// Code size 53 (0x35)
.maxstack 2
.locals init (Integer V_0)
IL_0000: ldsflda "TestClass.staticReadonlyFld As Integer"
IL_0005: call "Sub Module1.TestByRef(ByRef Integer)"
IL_000a: ldsfld "Base.baseStaticReadonlyFld As Integer"
IL_000f: stloc.0
IL_0010: ldloca.s V_0
IL_0012: call "Sub Module1.TestByRef(ByRef Integer)"
IL_0017: newobj "Sub TestClass..ctor()"
IL_001c: dup
IL_001d: ldfld "TestClass.instanceReadonlyFld As Integer"
IL_0022: stloc.0
IL_0023: ldloca.s V_0
IL_0025: call "Sub Module1.TestByRef(ByRef Integer)"
IL_002a: ldfld "TestClass.instanceReadonlyFld As Integer"
IL_002f: stsfld "TestClass.output As Integer"
IL_0034: ret
}
]]>)
verifier.VerifyIL("Module1.Test2",
<![CDATA[
{
// Code size 21 (0x15)
.maxstack 1
.locals init (Integer V_0)
IL_0000: ldsfld "TestClass.staticField As Byte"
IL_0005: stloc.0
IL_0006: ldloca.s V_0
IL_0008: call "Sub Module1.TestByRef(ByRef Integer)"
IL_000d: ldloc.0
IL_000e: conv.ovf.u1
IL_000f: stsfld "TestClass.staticField As Byte"
IL_0014: ret
}
]]>)
#If DONT_USE_BYREF_LOCALS_FOR_USE_TWICE Then
verifier.VerifyIL("Module1.Test3",
<![CDATA[
{
// Code size 19 (0x13)
.maxstack 3
.locals init (Byte() V_0,
Integer V_1)
IL_0000: ldarg.0
IL_0001: dup
IL_0002: stloc.0
IL_0003: ldc.i4.1
IL_0004: ldelem.u1
IL_0005: stloc.1
IL_0006: ldloca.s V_1
IL_0008: call "Sub Module1.TestByRef(ByRef Integer)"
IL_000d: ldloc.0
IL_000e: ldc.i4.1
IL_000f: ldloc.1
IL_0010: conv.ovf.u1
IL_0011: stelem.i1
IL_0012: ret
}
]]>)
#Else
verifier.VerifyIL("Module1.Test3",
<![CDATA[
{
// Code size 21 (0x15)
.maxstack 2
.locals init (Integer V_0)
IL_0000: ldarg.0
IL_0001: ldc.i4.1
IL_0002: ldelema "Byte"
IL_0007: dup
IL_0008: ldind.u1
IL_0009: stloc.0
IL_000a: ldloca.s V_0
IL_000c: call "Sub Module1.TestByRef(ByRef Integer)"
IL_0011: ldloc.0
IL_0012: conv.ovf.u1
IL_0013: stind.i1
IL_0014: ret
}
]]>)
#End If
End Sub
<Fact>
Public Sub ByRefArguments5()
Dim compilationDef =
<compilation name="VBByRefArguments5">
<file name="a.vb">
Option Strict Off
Imports System
Module Module1
Sub Main()
Dim s2 As TestStruct2 = New TestStruct2()
s2.fld2.fld1 = 1
System.Console.WriteLine((s2.fld2).Increment())
System.Console.WriteLine(s2.fld2.fld1)
System.Console.WriteLine((s2.fld2).Increment())
System.Console.WriteLine(s2.fld2.fld1)
System.Console.WriteLine((s2.fld2).Increment())
System.Console.WriteLine(s2.fld2.fld1)
System.Console.WriteLine("----")
System.Console.WriteLine(s2.fld2.fld1)
Test1(s2)
System.Console.WriteLine(s2.fld2.fld1)
Test2(s2)
System.Console.WriteLine(s2.fld2.fld1)
Test3(s2)
System.Console.WriteLine(s2.fld2.fld1)
Test4(s2)
System.Console.WriteLine(s2.fld2.fld1)
End Sub
Sub Test1(ByRef s2 As TestStruct2)
Increment(s2.fld2.fld1)
End Sub
Sub Test2(ByRef s2 As TestStruct2)
Increment((s2).fld2.fld1)
End Sub
Sub Test3(ByRef s2 As TestStruct2)
Increment((s2.fld2).fld1)
End Sub
Sub Test4(ByRef s2 As TestStruct2)
Increment((s2.fld2.fld1))
End Sub
Sub Increment(ByRef x As Integer)
x = x + 1
End Sub
End Module
Structure TestStruct1
Public fld1 As Integer
Function Increment() As Integer
fld1 = fld1 + 1
Return fld1
End Function
End Structure
Structure TestStruct2
Public fld2 As TestStruct1
End Structure
</file>
</compilation>
Dim verifier = CompileAndVerify(compilationDef,
expectedOutput:=
<![CDATA[
2
2
3
3
4
4
----
4
5
5
5
5
]]>)
verifier.VerifyIL("Module1.Test1",
<![CDATA[
{
// Code size 17 (0x11)
.maxstack 1
IL_0000: ldarg.0
IL_0001: ldflda "TestStruct2.fld2 As TestStruct1"
IL_0006: ldflda "TestStruct1.fld1 As Integer"
IL_000b: call "Sub Module1.Increment(ByRef Integer)"
IL_0010: ret
}
]]>)
verifier.VerifyIL("Module1.Test2",
<![CDATA[
{
// Code size 20 (0x14)
.maxstack 1
.locals init (Integer V_0)
IL_0000: ldarg.0
IL_0001: ldflda "TestStruct2.fld2 As TestStruct1"
IL_0006: ldfld "TestStruct1.fld1 As Integer"
IL_000b: stloc.0
IL_000c: ldloca.s V_0
IL_000e: call "Sub Module1.Increment(ByRef Integer)"
IL_0013: ret
}
]]>)
verifier.VerifyIL("Module1.Test3",
<![CDATA[
{
// Code size 20 (0x14)
.maxstack 1
.locals init (Integer V_0)
IL_0000: ldarg.0
IL_0001: ldflda "TestStruct2.fld2 As TestStruct1"
IL_0006: ldfld "TestStruct1.fld1 As Integer"
IL_000b: stloc.0
IL_000c: ldloca.s V_0
IL_000e: call "Sub Module1.Increment(ByRef Integer)"
IL_0013: ret
}
]]>)
verifier.VerifyIL("Module1.Test4",
<![CDATA[
{
// Code size 20 (0x14)
.maxstack 1
.locals init (Integer V_0)
IL_0000: ldarg.0
IL_0001: ldflda "TestStruct2.fld2 As TestStruct1"
IL_0006: ldfld "TestStruct1.fld1 As Integer"
IL_000b: stloc.0
IL_000c: ldloca.s V_0
IL_000e: call "Sub Module1.Increment(ByRef Integer)"
IL_0013: ret
}
]]>)
End Sub
<Fact()>
Public Sub ByRefArguments6()
Dim compilationDef =
<compilation name="LambdaTests1">
<file name="a.vb"><![CDATA[
Module Program
Sub Test1(ByRef x As Object)
x = -2
End Sub
Function Test2(Of T)(a As T(), i As Integer) As System.Action
Return Sub()
Test1(a(i))
End Sub
End Function
Sub Main()
Dim a = New Integer() {1, 2, 3}
Dim x As System.Action = Test2(a, 1)
x()
System.Console.WriteLine(a(1))
End Sub
End Module
]]></file>
</compilation>
Dim compilation = CompilationUtils.CreateCompilationWithMscorlib40AndVBRuntime(compilationDef, TestOptions.ReleaseExe)
Dim verifier = CompileAndVerify(compilation, expectedOutput:=
<![CDATA[
-2
]]>)
End Sub
<Fact>
Public Sub PassByRef()
Dim source =
<compilation>
<file name="c.vb">
Imports System
Class A
Public Sub New(i As Short)
FI = i
_PI = i
FB = New B(3)
_PB = New B(3)
FC = New C(4)
_PC = New C(4)
FT = New T(5)
_PT = New T(5)
End Sub
Public FI As Short
Private _PI As Short
Property PI As Short
Get
Console.WriteLine("A.get_PI")
Return _PI
End Get
Set(value As Short)
Console.WriteLine("A.set_PI")
_PI = value
End Set
End Property
Public FC As C
Private _PC As C
Property PC As C
Get
Console.WriteLine("A.get_PC")
Return _PC
End Get
Set(value As C)
Console.WriteLine("A.set_PC")
_PC = value
End Set
End Property
Public FT As T
Private _PT As T
Property PT As T
Get
Console.WriteLine("A.get_PT")
Return _PT
End Get
Set(value As T)
Console.WriteLine("A.set_PT")
_PT = value
End Set
End Property
Public FB As B
Private _PB As B
Property PB As B
Get
Console.WriteLine("A.get_PB")
Return _PB
End Get
Set(value As B)
Console.WriteLine("A.set_PB")
_PB = value
End Set
End Property
End Class
Class B
Public Sub New(i As Short)
FI = i
_PI = i
FC = New C(5)
_PC = New C(5)
End Sub
Public FI As Short
Private _PI As Short
Property PI As Short
Get
Console.WriteLine("B.get_PI")
Return _PI
End Get
Set(value As Short)
Console.WriteLine("B.set_PI")
_PI = value
End Set
End Property
Public FC As C
Private _PC As C
Property PC As C
Get
Console.WriteLine("B.get_PC")
Return _PC
End Get
Set(value As C)
Console.WriteLine("B.set_PC")
_PC = value
End Set
End Property
End Class
Structure S
Public Sub New(i As Short)
FI = i
_PI = i
FA = New A(2)
_PA = New A(2)
FC = New C(3)
_PC = New C(3)
FT = New T(4)
_PT = New T(4)
End Sub
Public FI As Short
Private _PI As Short
Property PI As Short
Get
Console.WriteLine("S.get_PI")
Return _PI
End Get
Set(value As Short)
Console.WriteLine("S.set_PI")
_PI = value
End Set
End Property
Public FC As C
Private _PC As C
Property PC As C
Get
Console.WriteLine("S.get_PC")
Return _PC
End Get
Set(value As C)
Console.WriteLine("S.set_PC")
_PC = value
End Set
End Property
Public FT As T
Private _PT As T
Property PT As T
Get
Console.WriteLine("S.get_PT")
Return _PT
End Get
Set(value As T)
Console.WriteLine("S.set_PT")
_PT = value
End Set
End Property
Public FA As A
Private _PA As A
Property PA As A
Get
Console.WriteLine("S.get_PA")
Return _PA
End Get
Set(value As A)
Console.WriteLine("S.set_PA")
_PA = value
End Set
End Property
End Structure
Structure T
Public Sub New(i As Short)
FI = i
_PI = i
FC = New C(6)
_PC = New C(6)
End Sub
Public FI As Short
Private _PI As Short
Property PI As Short
Get
Console.WriteLine("T.get_PI")
Return _PI
End Get
Set(value As Short)
Console.WriteLine("T.set_PI")
_PI = value
End Set
End Property
Public FC As C
Private _PC As C
Property PC As C
Get
Console.WriteLine("T.get_PC")
Return _PC
End Get
Set(value As C)
Console.WriteLine("T.set_PC")
_PC = value
End Set
End Property
End Structure
Class C
Public N As Short
Public Sub New(i As Short)
N = i
End Sub
Public Overrides Function ToString() As String
Return N.ToString()
End Function
End Class
Class Prog
Shared Sub Report(i As Integer)
Console.WriteLine("=> {0}", i)
End Sub
Shared Sub Report(i As C)
Console.WriteLine("=> {0}", i)
End Sub
Shared Sub M(ByRef i As Integer)
Console.WriteLine("M")
i = i + 1
End Sub
Shared Sub M(ByRef i As C)
Console.WriteLine("M")
i = New C(i.N + 1)
End Sub
Shared Sub Main()
Dim x As A = New A(7)
' Value type members on class.
M(x.FI)
Report(x.FI)
M(x.PI)
Report(x.PI)
' Reference type members on class.
M(x.FC)
Report(x.FC)
M(x.PC)
Report(x.PC)
' Value type members on nested class.
M(x.FB.FI)
Report(x.FB.FI)
M(x.FB.PI)
Report(x.FB.PI)
M(x.PB.FI)
Report(x.PB.FI)
M(x.PB.PI)
Report(x.PB.PI)
' Reference type members on nested class.
M(x.FB.FC)
Report(x.FB.FC)
M(x.FB.PC)
Report(x.FB.PC)
M(x.PB.FC)
Report(x.PB.FC)
M(x.PB.PC)
Report(x.PB.PC)
' Value type members on nested struct.
M(x.FT.FI)
Report(x.FT.FI)
M(x.FT.PI)
Report(x.FT.PI)
M(x.PT.FI)
Report(x.PT.FI)
M(x.PT.PI)
Report(x.PT.PI)
' Reference type members on nested struct.
M(x.FT.FC)
Report(x.FT.FC)
M(x.FT.PC)
Report(x.FT.PC)
M(x.PT.FC)
Report(x.PT.FC)
M(x.PT.PC)
Report(x.PT.PC)
Dim y As S = New S(9)
' Value type members on class.
M(y.FI)
Report(y.FI)
M(y.PI)
Report(y.PI)
' Reference type members on class.
M(y.FC)
Report(y.FC)
M(y.PC)
Report(y.PC)
' Value type members on nested class.
M(y.FA.FI)
Report(y.FA.FI)
M(y.FA.PI)
Report(y.FA.PI)
M(y.PA.FI)
Report(y.PA.FI)
M(y.PA.PI)
Report(y.PA.PI)
' Reference type members on nested class.
M(y.FA.FC)
Report(y.FA.FC)
M(y.FA.PC)
Report(y.FA.PC)
M(y.PA.FC)
Report(y.PA.FC)
M(y.PA.PC)
Report(y.PA.PC)
' Value type members on nested struct.
M(y.FT.FI)
Report(y.FT.FI)
M(y.FT.PI)
Report(y.FT.PI)
M(y.PT.FI)
Report(y.PT.FI)
M(y.PT.PI)
Report(y.PT.PI)
' Reference type members on nested struct.
M(y.FT.FC)
Report(y.FT.FC)
M(y.FT.PC)
Report(y.FT.PC)
M(y.PT.FC)
Report(y.PT.FC)
M(y.PT.PC)
Report(y.PT.PC)
End Sub
End Class
</file>
</compilation>
Dim compilationVerifier = CompileAndVerify(source, expectedOutput:=
<![CDATA[M
=> 8
A.get_PI
M
A.set_PI
A.get_PI
=> 8
M
=> 5
A.get_PC
M
A.set_PC
A.get_PC
=> 5
M
=> 4
B.get_PI
M
B.set_PI
B.get_PI
=> 4
A.get_PB
M
A.get_PB
=> 4
A.get_PB
B.get_PI
M
B.set_PI
A.get_PB
B.get_PI
=> 4
M
=> 6
B.get_PC
M
B.set_PC
B.get_PC
=> 6
A.get_PB
M
A.get_PB
=> 6
A.get_PB
B.get_PC
M
B.set_PC
A.get_PB
B.get_PC
=> 6
M
=> 6
T.get_PI
M
T.set_PI
T.get_PI
=> 6
A.get_PT
M
A.get_PT
=> 5
A.get_PT
T.get_PI
M
T.set_PI
A.get_PT
T.get_PI
=> 5
M
=> 7
T.get_PC
M
T.set_PC
T.get_PC
=> 7
A.get_PT
M
A.get_PT
=> 6
A.get_PT
T.get_PC
M
T.set_PC
A.get_PT
T.get_PC
=> 6
M
=> 10
S.get_PI
M
S.set_PI
S.get_PI
=> 10
M
=> 4
S.get_PC
M
S.set_PC
S.get_PC
=> 4
M
=> 3
A.get_PI
M
A.set_PI
A.get_PI
=> 3
S.get_PA
M
S.get_PA
=> 3
S.get_PA
A.get_PI
M
A.set_PI
S.get_PA
A.get_PI
=> 3
M
=> 5
A.get_PC
M
A.set_PC
A.get_PC
=> 5
S.get_PA
M
S.get_PA
=> 5
S.get_PA
A.get_PC
M
A.set_PC
S.get_PA
A.get_PC
=> 5
M
=> 5
T.get_PI
M
T.set_PI
T.get_PI
=> 5
S.get_PT
M
S.get_PT
=> 4
S.get_PT
T.get_PI
M
T.set_PI
S.get_PT
T.get_PI
=> 4
M
=> 7
T.get_PC
M
T.set_PC
T.get_PC
=> 7
S.get_PT
M
S.get_PT
=> 6
S.get_PT
T.get_PC
M
T.set_PC
S.get_PT
T.get_PC
=> 6
]]>)
End Sub
' Instance expressions used to reference
' statics should be skipped.
<Fact>
Public Sub PassByRefStaticFromInstance()
Dim source =
<compilation>
<file name="c.vb">
Imports System
Class A
Public N As Short
Public Sub New(i As Short)
N = i
End Sub
Public Overrides Function ToString() As String
Return N.ToString()
End Function
End Class
Class B
Public Shared FI As Short = 1
Public Shared _PI As Short = 4
Shared Property PI As Short
Get
Console.WriteLine("get_PI")
Return _PI
End Get
Set(value As Short)
Console.WriteLine("set_PI")
_PI = value
End Set
End Property
Public Shared FC As A = New A(7)
Public Shared _PC As A = New A(10)
Shared Property PC As A
Get
Console.WriteLine("get_PC")
Return _PC
End Get
Set(value As A)
Console.WriteLine("set_PC")
_PC = value
End Set
End Property
Public Function G() As B
Console.WriteLine("G")
Return Me
End Function
End Class
Class Prog
Shared Function F() As B
Console.WriteLine("F")
Return Nothing
End Function
Shared Sub Report(i As Integer)
Console.WriteLine("=> {0}", i)
End Sub
Shared Sub Report(i As A)
Console.WriteLine("=> {0}", i)
End Sub
Shared Sub M(ByRef i As Integer)
Console.WriteLine("M")
i = i + 1
End Sub
Shared Sub M(ByRef i As A)
Console.WriteLine("M")
i = New A(i.N + 1)
End Sub
Shared Sub Main()
Dim x As B = New B()
M(x.G().FI)
Report(B.FI)
M(x.G().PI)
Report(B._PI)
M(F().FC)
Report(B.FC)
M(F().PC)
Report(B._PC)
End Sub
End Class
</file>
</compilation>
Dim compilationVerifier = CompileAndVerify(source, expectedOutput:=
<![CDATA[M
=> 2
get_PI
M
set_PI
=> 5
M
=> 8
get_PC
M
set_PC
=> 11
]]>)
End Sub
<Fact>
Public Sub PassByRefArgs()
Dim source =
<compilation>
<file name="c.vb">
Imports System
Class Value
Private Shared _n As Integer = 0
Shared Function [Next]()
_n = _n + 1
Return _n
End Function
End Class
Class C
Private Shared _P
Shared Property P(x As Object)
Get
Console.WriteLine("P({0}) (= {1})", x, _P)
Return _P
End Get
Set(value)
Console.WriteLine("P({0}) = {1}", x, value)
_P = value
End Set
End Property
Shared Sub Main()
_P = Value.Next()
F(C.P(F(C.P(Value.Next()))))
End Sub
Shared Function F(ByRef o)
Console.WriteLine("F({0})", o)
o = Value.Next()
Return o
End Function
End Class
</file>
</compilation>
Dim compilationVerifier = CompileAndVerify(source, expectedOutput:=
<![CDATA[P(2) (= 1)
F(1)
P(2) = 3
P(3) (= 3)
F(3)
P(3) = 4
]]>)
compilationVerifier.VerifyIL("C.Main",
<![CDATA[
{
// Code size 104 (0x68)
.maxstack 3
.locals init (Object V_0,
Object V_1,
Object V_2)
IL_0000: call "Function Value.Next() As Object"
IL_0005: call "Function System.Runtime.CompilerServices.RuntimeHelpers.GetObjectValue(Object) As Object"
IL_000a: stsfld "C._P As Object"
IL_000f: call "Function Value.Next() As Object"
IL_0014: dup
IL_0015: stloc.1
IL_0016: call "Function System.Runtime.CompilerServices.RuntimeHelpers.GetObjectValue(Object) As Object"
IL_001b: call "Function C.get_P(Object) As Object"
IL_0020: call "Function System.Runtime.CompilerServices.RuntimeHelpers.GetObjectValue(Object) As Object"
IL_0025: stloc.2
IL_0026: ldloca.s V_2
IL_0028: call "Function C.F(ByRef Object) As Object"
IL_002d: ldloc.1
IL_002e: call "Function System.Runtime.CompilerServices.RuntimeHelpers.GetObjectValue(Object) As Object"
IL_0033: ldloc.2
IL_0034: call "Function System.Runtime.CompilerServices.RuntimeHelpers.GetObjectValue(Object) As Object"
IL_0039: call "Sub C.set_P(Object, Object)"
IL_003e: dup
IL_003f: call "Function System.Runtime.CompilerServices.RuntimeHelpers.GetObjectValue(Object) As Object"
IL_0044: call "Function C.get_P(Object) As Object"
IL_0049: call "Function System.Runtime.CompilerServices.RuntimeHelpers.GetObjectValue(Object) As Object"
IL_004e: stloc.0
IL_004f: ldloca.s V_0
IL_0051: call "Function C.F(ByRef Object) As Object"
IL_0056: pop
IL_0057: call "Function System.Runtime.CompilerServices.RuntimeHelpers.GetObjectValue(Object) As Object"
IL_005c: ldloc.0
IL_005d: call "Function System.Runtime.CompilerServices.RuntimeHelpers.GetObjectValue(Object) As Object"
IL_0062: call "Sub C.set_P(Object, Object)"
IL_0067: ret
}
]]>)
End Sub
<Fact>
Public Sub CopyBackDiagnostic1()
Dim compilationDef =
<compilation name="VBCopyBackDiagnostic1">
<file name="a.vb">
Module Module1
Sub Main()
Dim By As Byte = 53
TestByRef(By)
End Sub
Sub TestByRef(ByRef a As Integer)
End Sub
End Module
</file>
</compilation>
CompilationUtils.CreateCompilationWithMscorlib40AndVBRuntime(
compilationDef,
New VisualBasicCompilationOptions(OutputKind.ConsoleApplication).WithOptionStrict(OptionStrict.Custom)).
VerifyDiagnostics(Diagnostic(ERRID.WRN_ImplicitConversionCopyBack, "By").WithArguments("a", "Integer", "Byte"))
End Sub
<Fact>
Public Sub Bug4275()
Dim compilationDef =
<compilation name="Bug4275">
<file name="a.vb">
Module M
Sub Goo()
End Sub
Sub Bar(Of T)()
End Sub
Function Goo1() As Integer
Return 0
End Function
Sub Main()
Goo$()
Goo$
M.Goo$()
M.Goo$
Bar%(Of Integer)()
Bar$(Of Integer)
Dim x As Object
x=Goo1$
End Sub
End Module
</file>
</compilation>
CompilationUtils.CreateCompilationWithMscorlib40AndVBRuntime(compilationDef).
VerifyDiagnostics(
Diagnostic(ERRID.ERR_TypecharNoMatch2, "Goo$()").WithArguments("$", "Void"),
Diagnostic(ERRID.ERR_TypecharNoMatch2, "Goo$").WithArguments("$", "Void"),
Diagnostic(ERRID.ERR_TypecharNoMatch2, "M.Goo$()").WithArguments("$", "Void"),
Diagnostic(ERRID.ERR_TypecharNoMatch2, "M.Goo$").WithArguments("$", "Void"),
Diagnostic(ERRID.ERR_TypecharNoMatch2, "Bar%(Of Integer)()").WithArguments("%", "Void"),
Diagnostic(ERRID.ERR_TypecharNoMatch2, "Bar$(Of Integer)").WithArguments("$", "Void"),
Diagnostic(ERRID.ERR_TypecharNoMatch2, "Goo1$").WithArguments("$", "Integer"))
End Sub
<Fact>
Public Sub CallGenericMethod()
Dim compilationDef =
<compilation name="CallGenericMethod">
<file name="a.vb">
Module M
Sub Bar(Of T)(x as T)
System.Console.WriteLine(x)
End Sub
Sub Main()
Bar(Of Integer)("1234")
End Sub
End Module
</file>
</compilation>
CompileAndVerify(compilationDef, expectedOutput:="1234")
End Sub
<Fact>
Public Sub ConstructorCallDiagnostic()
Dim compilation = CompilationUtils.CreateCompilationWithMscorlib40AndVBRuntime(
<compilation name="ConstructorCallDiagnostic">
<file name="a.vb">
Module Module1
Sub Main()
Dim z1 = New TC1()
Dim z2 = New TC1(1, 2, 3)
End Sub
End Module
Class TC1
Sub New(x As Integer)
End Sub
Sub New(x As Integer, y As Double)
End Sub
End Class
</file>
</compilation>)
CompilationUtils.AssertTheseDiagnostics(compilation,
<expected>
BC30516: Overload resolution failed because no accessible 'New' accepts this number of arguments.
Dim z1 = New TC1()
~~~
BC30516: Overload resolution failed because no accessible 'New' accepts this number of arguments.
Dim z2 = New TC1(1, 2, 3)
~~~
</expected>)
End Sub
<WorkItem(539691, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539691")>
<Fact>
Public Sub DiagnosticsOnInvalidConstructorCall()
Dim compilation = CompilationUtils.CreateCompilationWithMscorlib40AndVBRuntime(
<compilation name="DiagnosticsOnInvalidConstructorCall">
<file name="a.vb">
class C
sub Goo()
dim x = new C(4,5,6)
end sub
end class
</file>
</compilation>)
Dim tree As SyntaxTree = (From t In compilation.SyntaxTrees Where t.FilePath = "a.vb").Single()
Dim semanticModel = compilation.GetSemanticModel(tree)
Dim objectCreationNode = tree.FindNodeOrTokenByKind(SyntaxKind.ObjectCreationExpression)
Dim semanticInfo = semanticModel.GetSemanticInfoSummary(CType(objectCreationNode, ExpressionSyntax))
Assert.Equal(CandidateReason.OverloadResolutionFailure, semanticInfo.CandidateReason)
End Sub
<Fact>
Public Sub ByRefParamArraysFromMetadata()
Dim source =
<compilation name="ByRefParamArraysFromMetadata">
<file name="a.vb">
Imports System
Module M
Sub Main()
Test(Nothing)
End Sub
Sub Test(d0 As DelegateByRefParamArray_Base())
Dim d1 As DelegateByRefParamArray_Base() = Nothing
DelegateByRefParamArray.SubWithByRefParamArrayOfReferenceTypes_Identify_1(d0)
Console.WriteLine(d0 Is Nothing)
DelegateByRefParamArray.SubWithByRefParamArrayOfReferenceTypes_Identify_1(d1)
Console.WriteLine(d1 Is Nothing)
DelegateByRefParamArray.SubWithByRefParamArrayOfReferenceTypes_Identify_1(_d2)
Console.WriteLine(_d2 Is Nothing)
DelegateByRefParamArray.SubWithByRefParamArrayOfReferenceTypes_Identify_1(d2)
Console.WriteLine(d2 Is Nothing)
DelegateByRefParamArray.SubWithByRefParamArrayOfReferenceTypes_Identify_1((d2))
Console.WriteLine(d2 Is Nothing)
Dim d3()() As DelegateByRefParamArray_Base = New DelegateByRefParamArray_Base()() {Nothing}
DelegateByRefParamArray.SubWithByRefParamArrayOfReferenceTypes_Identify_1(d3(0))
Console.WriteLine(d3(0) Is Nothing)
End Sub
Dim _d2 As DelegateByRefParamArray_Base() = Nothing
Property d2 As DelegateByRefParamArray_Base()
Get
Return _d2
End Get
Set(value As DelegateByRefParamArray_Base())
System.Console.WriteLine("d2.Set")
_d2 = value
End Set
End Property
End Module
</file>
</compilation>
Dim assemblyPath = TestReferences.SymbolsTests.DelegateImplementation.DelegateByRefParamArray
CompileAndVerify(source,
references:={assemblyPath},
expectedOutput:=<![CDATA[
Called SubWithByRefParamArrayOfReferenceTypes_Identify_1.
True
Called SubWithByRefParamArrayOfReferenceTypes_Identify_1.
True
Called SubWithByRefParamArrayOfReferenceTypes_Identify_1.
True
Called SubWithByRefParamArrayOfReferenceTypes_Identify_1.
True
Called SubWithByRefParamArrayOfReferenceTypes_Identify_1.
True
Called SubWithByRefParamArrayOfReferenceTypes_Identify_1.
True
]]>)
End Sub
<Fact>
Public Sub ByRefParametersOnProperties1()
Dim source =
<compilation name="ByRefParametersOnProperties1">
<file name="a.vb">
Option Strict On
Module Module1
Sub Main()
DoTest(129)
End Sub
Sub DoTest(y6 As Integer)
Dim x As New PropertiesWithByRef()
Dim y1 As Integer = 123
Dim y2 As Byte = 124
Dim z As Integer
z = x.P1(y1)
System.Console.WriteLine(y1)
x.P1(y1) = z + 1
System.Console.WriteLine(y1)
z = x.P1(y2)
System.Console.WriteLine(y2)
x.P1(y2) = z + 1
System.Console.WriteLine(y2)
y3 = 125
z = x.P1(y3)
System.Console.WriteLine(y3)
x.P1(y3) = z + 1
System.Console.WriteLine(y3)
y4 = 126
z = x.P1(y4)
System.Console.WriteLine(y4)
x.P1(y4) = z + 1
System.Console.WriteLine(y4)
Dim t As New Test1()
t.y5 = 127
z = x.P1(t.y5)
System.Console.WriteLine(t.y5)
x.P1(t.y5) = z + 1
System.Console.WriteLine(t.y5)
Dim ar As Integer() = New Integer() {128}
z = x.P1(ar(0))
System.Console.WriteLine(ar(0))
x.P1(ar(0)) = z + 1
System.Console.WriteLine(ar(0))
z = x.P1(y6)
System.Console.WriteLine(y6)
x.P1(y6) = z + 1
System.Console.WriteLine(y6)
End Sub
Private _y3 As Integer
Property y3 As Integer
Get
System.Console.WriteLine("Executing get_y3")
Return _y3
End Get
Set(value As Integer)
System.Console.WriteLine("Executing set_y3")
_y3 = value
End Set
End Property
Private y4 As Integer
End Module
Class Test1
Public y5 As Integer
End Class
</file>
</compilation>
CompileAndVerify(source,
references:={TestReferences.SymbolsTests.PropertiesWithByRef},
expectedOutput:=<![CDATA[
get_P1(123)
123
set_P1(123)
123
get_P1(124)
124
set_P1(124)
124
Executing set_y3
Executing get_y3
get_P1(125)
Executing get_y3
125
Executing get_y3
set_P1(125)
Executing get_y3
125
get_P1(126)
126
set_P1(126)
126
get_P1(127)
127
set_P1(127)
127
get_P1(128)
128
set_P1(128)
128
get_P1(129)
129
set_P1(129)
129
]]>)
End Sub
<Fact>
Public Sub ByRefParametersOnProperties2()
Dim source =
<compilation name="ByRefParametersOnProperties2">
<file name="a.vb">
Option Strict On
Module Module1
Sub Main()
Dim x As New PropertiesWithByRef()
Dim ar As Integer() = New Integer() {1}
DoTest(x, ar)
System.Console.WriteLine(ar(0))
End Sub
Sub DoTest(x As PropertiesWithByRef, ar As Integer())
PassByRef(x.P1(ar(0)), ar)
End Sub
Sub PassByRef(ByRef x As Integer, ar As Integer())
System.Console.WriteLine("PassByRef: {0}, {1}.", x, ar(0))
End Sub
End Module
</file>
</compilation>
Dim compilationVerifier = CompileAndVerify(source,
references:={TestReferences.SymbolsTests.PropertiesWithByRef},
expectedOutput:=<![CDATA[
get_P1(1)
PassByRef: 2, 1.
set_P1(1)
1
]]>)
compilationVerifier.VerifyIL("Module1.DoTest",
<![CDATA[
{
// Code size 35 (0x23)
.maxstack 4
.locals init (Integer V_0,
Integer V_1,
Integer V_2)
IL_0000: ldarg.0
IL_0001: dup
IL_0002: ldarg.1
IL_0003: ldc.i4.0
IL_0004: ldelem.i4
IL_0005: dup
IL_0006: stloc.0
IL_0007: stloc.2
IL_0008: ldloca.s V_2
IL_000a: callvirt "Function PropertiesWithByRef.get_P1(ByRef Integer) As Integer"
IL_000f: stloc.1
IL_0010: ldloca.s V_1
IL_0012: ldarg.1
IL_0013: call "Sub Module1.PassByRef(ByRef Integer, Integer())"
IL_0018: ldloc.0
IL_0019: stloc.2
IL_001a: ldloca.s V_2
IL_001c: ldloc.1
IL_001d: callvirt "Sub PropertiesWithByRef.set_P1(ByRef Integer, Integer)"
IL_0022: ret
}
]]>)
End Sub
<Fact>
Public Sub ByRefParametersOnProperties3()
Dim source =
<compilation name="ByRefParametersOnProperties3">
<file name="a.vb">
Option Strict On
Module Module1
Sub Main()
Dim x As New PropertiesWithByRef()
Dim y As Integer = 1
System.Console.WriteLine(DoTest(x, y))
End Sub
Function DoTest(x As PropertiesWithByRef, y As Integer) As Integer
PassByRef(x.P1(y), y)
Return y
End Function
Sub PassByRef(ByRef x As Integer, y As Integer)
System.Console.WriteLine("PassByRef: {0}, {1}.", x, y)
End Sub
End Module
</file>
</compilation>
Dim compilationVerifier = CompileAndVerify(source,
references:={TestReferences.SymbolsTests.PropertiesWithByRef},
expectedOutput:=<![CDATA[
get_P1(1)
PassByRef: 2, 1.
set_P1(1)
1
]]>)
compilationVerifier.VerifyIL("Module1.DoTest",
<![CDATA[
{
// Code size 34 (0x22)
.maxstack 4
.locals init (Integer V_0,
Integer V_1,
Integer V_2)
IL_0000: ldarg.0
IL_0001: dup
IL_0002: ldarg.1
IL_0003: dup
IL_0004: stloc.0
IL_0005: stloc.2
IL_0006: ldloca.s V_2
IL_0008: callvirt "Function PropertiesWithByRef.get_P1(ByRef Integer) As Integer"
IL_000d: stloc.1
IL_000e: ldloca.s V_1
IL_0010: ldarg.1
IL_0011: call "Sub Module1.PassByRef(ByRef Integer, Integer)"
IL_0016: ldloc.0
IL_0017: stloc.2
IL_0018: ldloca.s V_2
IL_001a: ldloc.1
IL_001b: callvirt "Sub PropertiesWithByRef.set_P1(ByRef Integer, Integer)"
IL_0020: ldarg.1
IL_0021: ret
}
]]>)
End Sub
<Fact>
Public Sub ByRefParametersOnProperties4()
Dim source =
<compilation name="ByRefParametersOnProperties4">
<file name="a.vb">
Option Strict On
Module Module1
Sub Main()
Dim x As New PropertiesWithByRef()
System.Console.WriteLine(DoTest(x))
End Sub
Function DoTest(x As PropertiesWithByRef) As Integer
Dim y As Integer = 1
PassByRef(x.P1(y), y)
Return y
End Function
Sub PassByRef(ByRef x As Integer, y As Integer)
System.Console.WriteLine("PassByRef: {0}, {1}.", x, y)
End Sub
End Module
</file>
</compilation>
Dim compilationVerifier = CompileAndVerify(source,
references:={TestReferences.SymbolsTests.PropertiesWithByRef},
expectedOutput:=<![CDATA[
get_P1(1)
PassByRef: 2, 1.
set_P1(1)
1
]]>)
compilationVerifier.VerifyIL("Module1.DoTest",
<![CDATA[
{
// Code size 36 (0x24)
.maxstack 4
.locals init (Integer V_0, //y
Integer V_1,
Integer V_2,
Integer V_3)
IL_0000: ldc.i4.1
IL_0001: stloc.0
IL_0002: ldarg.0
IL_0003: dup
IL_0004: ldloc.0
IL_0005: dup
IL_0006: stloc.1
IL_0007: stloc.3
IL_0008: ldloca.s V_3
IL_000a: callvirt "Function PropertiesWithByRef.get_P1(ByRef Integer) As Integer"
IL_000f: stloc.2
IL_0010: ldloca.s V_2
IL_0012: ldloc.0
IL_0013: call "Sub Module1.PassByRef(ByRef Integer, Integer)"
IL_0018: ldloc.1
IL_0019: stloc.3
IL_001a: ldloca.s V_3
IL_001c: ldloc.2
IL_001d: callvirt "Sub PropertiesWithByRef.set_P1(ByRef Integer, Integer)"
IL_0022: ldloc.0
IL_0023: ret
}
]]>)
End Sub
<Fact>
Public Sub ByRefParametersOnProperties5()
Dim source =
<compilation name="ByRefParametersOnProperties5">
<file name="a.vb">
Option Strict On
Module Module1
Sub Main()
Dim x As New PropertiesWithByRef()
DoTest(x)
System.Console.WriteLine(y)
End Sub
Dim y As Integer = 1
Sub DoTest(x As PropertiesWithByRef)
PassByRef(x.P1(y), y)
End Sub
Sub PassByRef(ByRef x As Integer, y As Integer)
System.Console.WriteLine("PassByRef: {0}, {1}.", x, y)
End Sub
End Module
</file>
</compilation>
Dim compilationVerifier = CompileAndVerify(source,
references:={TestReferences.SymbolsTests.PropertiesWithByRef},
expectedOutput:=<![CDATA[
get_P1(1)
PassByRef: 2, 1.
set_P1(1)
1
]]>)
compilationVerifier.VerifyIL("Module1.DoTest",
<![CDATA[
{
// Code size 41 (0x29)
.maxstack 4
.locals init (Integer V_0,
Integer V_1,
Integer V_2)
IL_0000: ldarg.0
IL_0001: dup
IL_0002: ldsfld "Module1.y As Integer"
IL_0007: dup
IL_0008: stloc.0
IL_0009: stloc.2
IL_000a: ldloca.s V_2
IL_000c: callvirt "Function PropertiesWithByRef.get_P1(ByRef Integer) As Integer"
IL_0011: stloc.1
IL_0012: ldloca.s V_1
IL_0014: ldsfld "Module1.y As Integer"
IL_0019: call "Sub Module1.PassByRef(ByRef Integer, Integer)"
IL_001e: ldloc.0
IL_001f: stloc.2
IL_0020: ldloca.s V_2
IL_0022: ldloc.1
IL_0023: callvirt "Sub PropertiesWithByRef.set_P1(ByRef Integer, Integer)"
IL_0028: ret
}
]]>)
End Sub
<Fact>
Public Sub ByRefParametersOnProperties6()
Dim source =
<compilation name="ByRefParametersOnProperties6">
<file name="a.vb">
Option Strict On
Module Module1
Sub Main()
Dim x As New PropertiesWithByRef()
s.y = 1
DoTest(x)
System.Console.WriteLine(s.y)
End Sub
Dim s As S1
Sub DoTest(x As PropertiesWithByRef)
PassByRef(x.P1(s.y), s.y)
End Sub
Sub PassByRef(ByRef x As Integer, y As Integer)
System.Console.WriteLine("PassByRef: {0}, {1}.", x, y)
End Sub
Structure S1
Public y As Integer
End Structure
End Module
</file>
</compilation>
Dim compilationVerifier = CompileAndVerify(source,
references:={TestReferences.SymbolsTests.PropertiesWithByRef},
expectedOutput:=<![CDATA[
get_P1(1)
PassByRef: 2, 1.
set_P1(1)
1
]]>)
compilationVerifier.VerifyIL("Module1.DoTest",
<![CDATA[
{
// Code size 51 (0x33)
.maxstack 4
.locals init (Integer V_0,
Integer V_1,
Integer V_2)
IL_0000: ldarg.0
IL_0001: dup
IL_0002: ldsflda "Module1.s As Module1.S1"
IL_0007: ldfld "Module1.S1.y As Integer"
IL_000c: dup
IL_000d: stloc.0
IL_000e: stloc.2
IL_000f: ldloca.s V_2
IL_0011: callvirt "Function PropertiesWithByRef.get_P1(ByRef Integer) As Integer"
IL_0016: stloc.1
IL_0017: ldloca.s V_1
IL_0019: ldsflda "Module1.s As Module1.S1"
IL_001e: ldfld "Module1.S1.y As Integer"
IL_0023: call "Sub Module1.PassByRef(ByRef Integer, Integer)"
IL_0028: ldloc.0
IL_0029: stloc.2
IL_002a: ldloca.s V_2
IL_002c: ldloc.1
IL_002d: callvirt "Sub PropertiesWithByRef.set_P1(ByRef Integer, Integer)"
IL_0032: ret
}
]]>)
End Sub
<Fact>
Public Sub ByRefParametersOnProperties7()
Dim source =
<compilation name="ByRefParametersOnProperties7">
<file name="a.vb">
Option Strict Off
Module Module1
Sub Main()
DoTest(129)
End Sub
Sub DoTest(y6 As Integer)
Dim x As New PropertiesWithByRef()
Dim y1 As Integer = 123
Dim y2 As Byte = 124
PassByRef(x.P1(y1), y1)
System.Console.WriteLine(y1)
PassByRef(x.P1(y2), y2)
System.Console.WriteLine(y2)
y3 = 125
PassByRef(x.P1(y3), y3)
System.Console.WriteLine(y3)
y4 = 126
PassByRef(x.P1(y4), y4)
System.Console.WriteLine(y4)
Dim t As New Test1()
t.y5 = 127
PassByRef(x.P1(t.y5), t.y5)
System.Console.WriteLine(t.y5)
Dim ar As Integer() = New Integer() {128}
PassByRef(x.P1(ar(0)), ar(0))
System.Console.WriteLine(ar(0))
PassByRef(x.P1(y6), y6)
System.Console.WriteLine(y6)
End Sub
Sub PassByRef(ByRef x As Integer, ByRef y As Integer)
System.Console.WriteLine("PassByRef: {0}, {1}.", x, y)
x = x + 25
y = y + 50
End Sub
Private _y3 As Integer
Property y3 As Integer
Get
System.Console.WriteLine("Executing get_y3")
Return _y3
End Get
Set(value As Integer)
System.Console.WriteLine("Executing set_y3")
_y3 = value
End Set
End Property
Private y4 As Integer
End Module
Class Test1
Public y5 As Integer
End Class
</file>
</compilation>
Dim compilationVerifier = CompileAndVerify(source,
references:={TestReferences.SymbolsTests.PropertiesWithByRef},
expectedOutput:=<![CDATA[
get_P1(123)
PassByRef: 124, 123.
set_P1(123)
173
get_P1(124)
PassByRef: 125, 124.
set_P1(124)
174
Executing set_y3
Executing get_y3
get_P1(125)
Executing get_y3
PassByRef: 126, 125.
Executing set_y3
set_P1(125)
Executing get_y3
175
get_P1(126)
PassByRef: 127, 126.
set_P1(126)
176
get_P1(127)
PassByRef: 128, 127.
set_P1(127)
177
get_P1(128)
PassByRef: 129, 128.
set_P1(128)
178
get_P1(129)
PassByRef: 130, 129.
set_P1(129)
179
]]>)
End Sub
<Fact>
Public Sub MeInByRefContext1()
Dim source =
<compilation name="MeInByRefContext1">
<file name="a.vb">
Option Strict Off
Imports System
Module Module1
Sub Main()
Dim x As New TestStruct1(100)
x.Test1()
x.Test2()
System.Console.WriteLine("-----")
Dim y As New TestClass1(50)
y.Test1()
y.Test2()
y.Test3()
End Sub
Function PassByRef0(ByRef x As Integer) As Integer
x = x + 1
Return x
End Function
End Module
Structure TestStruct1
Public fld1 As Integer
Sub New(x As Integer)
fld1 = x
System.Console.WriteLine(PassByRef0(Me.fld1))
System.Console.WriteLine(Me.fld1)
System.Console.WriteLine(PassByRef1(Me))
System.Console.WriteLine(Me.fld1)
End Sub
Sub Test1()
System.Console.WriteLine(PassByRef0(Me.fld1))
System.Console.WriteLine(Me.fld1)
End Sub
Sub Test2()
System.Console.WriteLine(PassByRef1(Me))
System.Console.WriteLine(Me.fld1)
End Sub
Shared Function PassByRef1(ByRef x As TestStruct1) As Integer
x.fld1 = x.fld1 + 1
Return x.fld1
End Function
End Structure
Class TestClass1
Public fld1 As Integer
Sub New(x As Integer)
fld1 = x
System.Console.WriteLine(PassByRef0(Me.fld1))
System.Console.WriteLine(Me.fld1)
If x = 50 Then
System.Console.WriteLine(PassByRef2(Me))
System.Console.WriteLine(Me.fld1)
End If
End Sub
Sub Test1()
System.Console.WriteLine(PassByRef0(Me.fld1))
System.Console.WriteLine(Me.fld1)
End Sub
Sub Test2()
System.Console.WriteLine(PassByRef1(Me))
System.Console.WriteLine(Me.fld1)
End Sub
Sub Test3()
System.Console.WriteLine(PassByRef2(Me))
System.Console.WriteLine(Me.fld1)
End Sub
Shared Function PassByRef1(ByRef x As TestClass1) As Integer
x.fld1 = x.fld1 + 1
Return x.fld1
End Function
Shared Function PassByRef2(ByRef x As TestClass1) As Integer
Dim old As TestClass1 = x
x = New TestClass1(x.fld1 + 15)
Return old.fld1
End Function
End Class
Structure S1
Sub Test1()
PassByRef1(Me)
End Sub
Sub Test2()
PassByRef1((Me))
End Sub
Sub Test3()
Me.Test1()
End Sub
Shared Sub PassByRef1(ByRef x As S1)
End Sub
End Structure
Class C2
Sub Test1()
PassByRef1(Me)
End Sub
Sub Test2()
PassByRef1((Me))
End Sub
Sub Test3()
Me.Test1()
End Sub
Shared Sub PassByRef1(ByRef x As C2)
End Sub
End Class
</file>
</compilation>
Dim compilationVerifier = CompileAndVerify(source,
references:={TestReferences.SymbolsTests.PropertiesWithByRef},
expectedOutput:=<![CDATA[
101
101
102
101
102
102
103
102
-----
51
51
67
67
51
51
52
52
53
53
69
69
53
53
]]>)
compilationVerifier.VerifyIL("TestStruct1..ctor(Integer)",
<![CDATA[
{
// Code size 72 (0x48)
.maxstack 2
.locals init (TestStruct1 V_0)
IL_0000: ldarg.0
IL_0001: initobj "TestStruct1"
IL_0007: ldarg.0
IL_0008: ldarg.1
IL_0009: stfld "TestStruct1.fld1 As Integer"
IL_000e: ldarg.0
IL_000f: ldflda "TestStruct1.fld1 As Integer"
IL_0014: call "Function Module1.PassByRef0(ByRef Integer) As Integer"
IL_0019: call "Sub System.Console.WriteLine(Integer)"
IL_001e: ldarg.0
IL_001f: ldfld "TestStruct1.fld1 As Integer"
IL_0024: call "Sub System.Console.WriteLine(Integer)"
IL_0029: ldarg.0
IL_002a: ldobj "TestStruct1"
IL_002f: stloc.0
IL_0030: ldloca.s V_0
IL_0032: call "Function TestStruct1.PassByRef1(ByRef TestStruct1) As Integer"
IL_0037: call "Sub System.Console.WriteLine(Integer)"
IL_003c: ldarg.0
IL_003d: ldfld "TestStruct1.fld1 As Integer"
IL_0042: call "Sub System.Console.WriteLine(Integer)"
IL_0047: ret
}
]]>)
compilationVerifier.VerifyIL("TestStruct1.Test1",
<![CDATA[
{
// Code size 28 (0x1c)
.maxstack 1
IL_0000: ldarg.0
IL_0001: ldflda "TestStruct1.fld1 As Integer"
IL_0006: call "Function Module1.PassByRef0(ByRef Integer) As Integer"
IL_000b: call "Sub System.Console.WriteLine(Integer)"
IL_0010: ldarg.0
IL_0011: ldfld "TestStruct1.fld1 As Integer"
IL_0016: call "Sub System.Console.WriteLine(Integer)"
IL_001b: ret
}
]]>)
compilationVerifier.VerifyIL("TestStruct1.Test2",
<![CDATA[
{
// Code size 31 (0x1f)
.maxstack 1
.locals init (TestStruct1 V_0)
IL_0000: ldarg.0
IL_0001: ldobj "TestStruct1"
IL_0006: stloc.0
IL_0007: ldloca.s V_0
IL_0009: call "Function TestStruct1.PassByRef1(ByRef TestStruct1) As Integer"
IL_000e: call "Sub System.Console.WriteLine(Integer)"
IL_0013: ldarg.0
IL_0014: ldfld "TestStruct1.fld1 As Integer"
IL_0019: call "Sub System.Console.WriteLine(Integer)"
IL_001e: ret
}
]]>)
compilationVerifier.VerifyIL("TestClass1..ctor",
<![CDATA[
{
// Code size 71 (0x47)
.maxstack 2
.locals init (TestClass1 V_0)
IL_0000: ldarg.0
IL_0001: call "Sub Object..ctor()"
IL_0006: ldarg.0
IL_0007: ldarg.1
IL_0008: stfld "TestClass1.fld1 As Integer"
IL_000d: ldarg.0
IL_000e: ldflda "TestClass1.fld1 As Integer"
IL_0013: call "Function Module1.PassByRef0(ByRef Integer) As Integer"
IL_0018: call "Sub System.Console.WriteLine(Integer)"
IL_001d: ldarg.0
IL_001e: ldfld "TestClass1.fld1 As Integer"
IL_0023: call "Sub System.Console.WriteLine(Integer)"
IL_0028: ldarg.1
IL_0029: ldc.i4.s 50
IL_002b: bne.un.s IL_0046
IL_002d: ldarg.0
IL_002e: stloc.0
IL_002f: ldloca.s V_0
IL_0031: call "Function TestClass1.PassByRef2(ByRef TestClass1) As Integer"
IL_0036: call "Sub System.Console.WriteLine(Integer)"
IL_003b: ldarg.0
IL_003c: ldfld "TestClass1.fld1 As Integer"
IL_0041: call "Sub System.Console.WriteLine(Integer)"
IL_0046: ret
}
]]>)
compilationVerifier.VerifyIL("TestClass1.Test1",
<![CDATA[
{
// Code size 28 (0x1c)
.maxstack 1
IL_0000: ldarg.0
IL_0001: ldflda "TestClass1.fld1 As Integer"
IL_0006: call "Function Module1.PassByRef0(ByRef Integer) As Integer"
IL_000b: call "Sub System.Console.WriteLine(Integer)"
IL_0010: ldarg.0
IL_0011: ldfld "TestClass1.fld1 As Integer"
IL_0016: call "Sub System.Console.WriteLine(Integer)"
IL_001b: ret
}
]]>)
compilationVerifier.VerifyIL("TestClass1.Test2",
<![CDATA[
{
// Code size 26 (0x1a)
.maxstack 1
.locals init (TestClass1 V_0)
IL_0000: ldarg.0
IL_0001: stloc.0
IL_0002: ldloca.s V_0
IL_0004: call "Function TestClass1.PassByRef1(ByRef TestClass1) As Integer"
IL_0009: call "Sub System.Console.WriteLine(Integer)"
IL_000e: ldarg.0
IL_000f: ldfld "TestClass1.fld1 As Integer"
IL_0014: call "Sub System.Console.WriteLine(Integer)"
IL_0019: ret
}
]]>)
compilationVerifier.VerifyIL("TestClass1.Test3",
<![CDATA[
{
// Code size 26 (0x1a)
.maxstack 1
.locals init (TestClass1 V_0)
IL_0000: ldarg.0
IL_0001: stloc.0
IL_0002: ldloca.s V_0
IL_0004: call "Function TestClass1.PassByRef2(ByRef TestClass1) As Integer"
IL_0009: call "Sub System.Console.WriteLine(Integer)"
IL_000e: ldarg.0
IL_000f: ldfld "TestClass1.fld1 As Integer"
IL_0014: call "Sub System.Console.WriteLine(Integer)"
IL_0019: ret
}
]]>)
compilationVerifier.VerifyIL("S1.Test1",
<![CDATA[
{
// Code size 15 (0xf)
.maxstack 1
.locals init (S1 V_0)
IL_0000: ldarg.0
IL_0001: ldobj "S1"
IL_0006: stloc.0
IL_0007: ldloca.s V_0
IL_0009: call "Sub S1.PassByRef1(ByRef S1)"
IL_000e: ret
}
]]>)
compilationVerifier.VerifyIL("S1.Test2",
<![CDATA[
{
// Code size 15 (0xf)
.maxstack 1
.locals init (S1 V_0)
IL_0000: ldarg.0
IL_0001: ldobj "S1"
IL_0006: stloc.0
IL_0007: ldloca.s V_0
IL_0009: call "Sub S1.PassByRef1(ByRef S1)"
IL_000e: ret
}
]]>)
compilationVerifier.VerifyIL("S1.Test3",
<![CDATA[
{
// Code size 7 (0x7)
.maxstack 1
IL_0000: ldarg.0
IL_0001: call "Sub S1.Test1()"
IL_0006: ret
}
]]>)
compilationVerifier.VerifyIL("C2.Test1",
<![CDATA[
{
// Code size 10 (0xa)
.maxstack 1
.locals init (C2 V_0)
IL_0000: ldarg.0
IL_0001: stloc.0
IL_0002: ldloca.s V_0
IL_0004: call "Sub C2.PassByRef1(ByRef C2)"
IL_0009: ret
}
]]>)
compilationVerifier.VerifyIL("C2.Test2",
<![CDATA[
{
// Code size 10 (0xa)
.maxstack 1
.locals init (C2 V_0)
IL_0000: ldarg.0
IL_0001: stloc.0
IL_0002: ldloca.s V_0
IL_0004: call "Sub C2.PassByRef1(ByRef C2)"
IL_0009: ret
}
]]>)
compilationVerifier.VerifyIL("C2.Test3",
<![CDATA[
{
// Code size 7 (0x7)
.maxstack 1
IL_0000: ldarg.0
IL_0001: call "Sub C2.Test1()"
IL_0006: ret
}
]]>)
End Sub
<Fact>
Public Sub Bug7195()
Dim compilationDef =
<compilation name="Bug7195">
<file name="a.vb">
Option Strict Off
Imports System
Module Module1
Sub Main()
Dim s2 As TestStruct2 = New TestStruct2()
s2.fld2.fld1 = 1
System.Console.WriteLine((s2).fld2.Increment())
System.Console.WriteLine(s2.fld2.fld1)
System.Console.WriteLine((s2.fld2).Increment())
System.Console.WriteLine(s2.fld2.fld1)
System.Console.WriteLine(((s2).fld2).Increment())
System.Console.WriteLine(s2.fld2.fld1)
End Sub
End Module
Structure TestStruct1
Public fld1 As Integer
Function Increment() As Integer
fld1 = fld1 + 1
Return fld1
End Function
End Structure
Structure TestStruct2
Public fld2 As TestStruct1
End Structure
</file>
</compilation>
CompileAndVerify(compilationDef,
expectedOutput:=
<![CDATA[
2
2
3
3
4
4
]]>)
End Sub
<Fact>
Public Sub ByRefParametersOnPropertiesInLambda1()
Dim source =
<compilation name="ByRefParametersOnPropertiesInLambda1">
<file name="a.vb">
Option Strict On
Module Module1
Sub Main()
Dim x As New PropertiesWithByRef()
Dim y1 As Integer = 123
Dim z As Integer
Dim d1 As System.Action = Sub()
z = x.P1(y1)
End Sub
d1()
System.Console.WriteLine(y1)
Dim d2 As System.Action = Sub()
x.P1(y1) = z + 1
End Sub
d2()
System.Console.WriteLine(y1)
End Sub
End Module
</file>
</compilation>
CompileAndVerify(source,
references:={TestReferences.SymbolsTests.PropertiesWithByRef},
expectedOutput:=<![CDATA[
get_P1(123)
123
set_P1(123)
123
]]>)
End Sub
<Fact>
Public Sub ByRefInInitializer1()
Dim compilation = CompilationUtils.CreateCompilationWithMscorlib40AndVBRuntime(
<compilation name="ByRefInInitializer1">
<file name="a.vb">
Class T1
Public ReadOnly x1 As Integer
Public ReadOnly x2 As Integer
Public Shared ReadOnly x3 As Integer
Public Shared ReadOnly x4 As Integer
Public ReadOnly x5 As Integer
Public ReadOnly x6 As Integer
Public Shared ReadOnly x7 As Integer
Public Shared ReadOnly x8 As Integer
Public ReadOnly x9 As Integer
Public Shared ReadOnly x10 As Integer
Public y1 As Integer = TestByRef(x1)
Public Shared y2 As Integer = TestByRef(x2)
Public z1 As Integer = TestByRef(x3)
Public Shared z2 As Integer = TestByRef(x4)
Public Property y3 As Integer = TestByRef(x5)
Public Shared Property y4 As Integer = TestByRef(x6)
Public Property z3 As Integer = TestByRef(x7)
Public Shared Property z4 As Integer = TestByRef(x8)
Public Const y5 As Integer = TestByRef(x9).MaxValue
Public Const y6 As Integer = TestByRef(x10).MaxValue
End Class
Module Module1
Sub Main()
End Sub
Function TestByRef(ByRef x As Integer) As Integer
x = x + 100
Return x
End Function
End Module
</file>
</compilation>)
CompilationUtils.AssertTheseDiagnostics(compilation,
<expected>
BC30369: Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class.
Public Shared y2 As Integer = TestByRef(x2)
~~
BC30369: Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class.
Public Shared Property y4 As Integer = TestByRef(x6)
~~
BC30369: Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class.
Public Const y5 As Integer = TestByRef(x9).MaxValue
~~
BC42025: Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated.
Public Const y6 As Integer = TestByRef(x10).MaxValue
~~~~~~~~~~~~~~~~~~~~~~~
</expected>)
End Sub
<Fact>
Public Sub ByRefInInitializer2()
Dim source =
<compilation name="ByRefInInitializer2">
<file name="a.vb">
Imports System
Class T1
Public ReadOnly x1 As Integer
Public ReadOnly x2 As Integer
Public Shared ReadOnly x3 As Integer
Public Shared ReadOnly x4 As Integer
Public ReadOnly x5 As Integer
Public ReadOnly x6 As Integer
Public Shared ReadOnly x7 As Integer
Public Shared ReadOnly x8 As Integer
Public ReadOnly x9 As Integer
Public Shared ReadOnly x10 As Integer
Public y1 As Integer = TestByRef(x1)
'Public Shared y2 As Integer = TestByRef(x2)
Public z1 As Integer = TestByRef(x3)
Public Shared z2 As Integer = TestByRef(x4)
Public Property y3 As Integer = TestByRef(x5)
'Public Shared Property y4 As Integer = TestByRef(x6)
Public Property z3 As Integer = TestByRef(x7)
Public Shared Property z4 As Integer = TestByRef(x8)
'Public Const y5 As Integer = TestByRef(x9).MaxValue
Public Const y6 As Integer = TestByRef(x10).MaxValue
End Class
Module Module1
Sub Main()
Dim t As New T1()
Console.WriteLine(t.x1)
Console.WriteLine(t.x2)
Console.WriteLine(T1.x3)
Console.WriteLine(T1.x4)
Console.WriteLine(t.x5)
Console.WriteLine(t.x6)
Console.WriteLine(T1.x7)
Console.WriteLine(T1.x8)
Console.WriteLine(t.x9)
Console.WriteLine(T1.x10)
End Sub
Function TestByRef(ByRef x As Integer) As Integer
x = x + 100
Return x
End Function
End Module
</file>
</compilation>
CompileAndVerify(source,
references:={TestReferences.SymbolsTests.PropertiesWithByRef},
expectedOutput:=<![CDATA[
100
0
0
100
100
0
0
100
0
0
]]>)
End Sub
<Fact>
Public Sub ByRefInInitializer3()
Dim compilation = CompilationUtils.CreateCompilationWithMscorlib40AndVBRuntime(
<compilation name="ByRefInInitializer3">
<file name="a.vb">
Imports System
Class T1
Public ReadOnly x1 As Integer
Public ReadOnly x2 As Integer
Public Shared ReadOnly x3 As Integer
Public Shared ReadOnly x4 As Integer
Public ReadOnly x5 As Integer
Public ReadOnly x6 As Integer
Public Shared ReadOnly x7 As Integer
Public Shared ReadOnly x8 As Integer
Public ReadOnly x9 As Integer
Public Shared ReadOnly x10 As Integer
Public y1 As Action = Sub() TestByRef(x1)
Public Shared y2 As Action = Sub() TestByRef(x2)
Public z1 As Action = Sub() TestByRef(x3)
Public Shared z2 As Action = Sub() TestByRef(x4)
Public Property y3 As Action = Sub() TestByRef(x5)
Public Shared Property y4 As Action = Sub() TestByRef(x6)
Public Property z3 As Action = Sub() TestByRef(x7)
Public Shared Property z4 As Action = Sub() TestByRef(x8)
Public Const y5 As Object = CType(Function() TestByRef(x9), Func(Of Integer)).Invoke().MaxValue
Public Const y6 As Object = CType(Function() TestByRef(x10), Func(Of Integer)).Invoke().MaxValue
End Class
Module Module1
Sub Main()
End Sub
Function TestByRef(ByRef x As Integer) As Integer
x = x + 100
Return x
End Function
End Module
</file>
</compilation>)
CompilationUtils.AssertTheseDiagnostics(compilation,
<expected>
BC36602: 'ReadOnly' variable cannot be the target of an assignment in a lambda expression inside a constructor.
Public y1 As Action = Sub() TestByRef(x1)
~~
BC30369: Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class.
Public Shared y2 As Action = Sub() TestByRef(x2)
~~
BC36602: 'ReadOnly' variable cannot be the target of an assignment in a lambda expression inside a constructor.
Public Shared z2 As Action = Sub() TestByRef(x4)
~~
BC36602: 'ReadOnly' variable cannot be the target of an assignment in a lambda expression inside a constructor.
Public Property y3 As Action = Sub() TestByRef(x5)
~~
BC30369: Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class.
Public Shared Property y4 As Action = Sub() TestByRef(x6)
~~
BC36602: 'ReadOnly' variable cannot be the target of an assignment in a lambda expression inside a constructor.
Public Shared Property z4 As Action = Sub() TestByRef(x8)
~~
BC30369: Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class.
Public Const y5 As Object = CType(Function() TestByRef(x9), Func(Of Integer)).Invoke().MaxValue
~~
BC36602: 'ReadOnly' variable cannot be the target of an assignment in a lambda expression inside a constructor.
Public Const y6 As Object = CType(Function() TestByRef(x10), Func(Of Integer)).Invoke().MaxValue
~~~
</expected>)
End Sub
<Fact>
Public Sub NamedArgumentsAndOverriding()
Dim compilation = CompilationUtils.CreateCompilationWithMscorlib40AndVBRuntime(
<compilation name="NamedArgumentsAndOverriding">
<file name="a.vb">
Class Test1
Overridable Sub Goo(x As Integer)
End Sub
End Class
Class Test2
Inherits Test1
Overrides Sub Goo(y As Integer)
End Sub
End Class
Class Test3
Inherits Test2
Overrides Sub Goo(z As Integer)
End Sub
End Class
Module Module1
Sub Main()
Dim t3 As New Test3()
t3.Goo(z:=1)
t3.Goo(y:=1)
t3.Goo(x:=1)
End Sub
End Module
Namespace GenMethod4140
Friend Module GenMethod4140mod
Class Base
Overridable Function fun1(Of T)(ByRef t1 As T) As Object
Return Nothing
End Function
End Class
Class Derived
Inherits Base
Overrides Function fun1(Of T)(ByRef t2 As T) As Object
Return Nothing
End Function
End Class
Sub GenMethod4140()
Dim c3 As New Derived
c3.fun1(t1:=3US)
End Sub
End Module
End Namespace
</file>
</compilation>)
CompilationUtils.AssertTheseDiagnostics(compilation,
<expected>
BC30455: Argument not specified for parameter 'z' of 'Public Overrides Sub Goo(z As Integer)'.
t3.Goo(y:=1)
~~~
BC30272: 'y' is not a parameter of 'Public Overrides Sub Goo(z As Integer)'.
t3.Goo(y:=1)
~
BC30455: Argument not specified for parameter 'z' of 'Public Overrides Sub Goo(z As Integer)'.
t3.Goo(x:=1)
~~~
BC30272: 'x' is not a parameter of 'Public Overrides Sub Goo(z As Integer)'.
t3.Goo(x:=1)
~
BC30455: Argument not specified for parameter 't2' of 'Public Overrides Function fun1(Of T)(ByRef t2 As T) As Object'.
c3.fun1(t1:=3US)
~~~~
BC30272: 't1' is not a parameter of 'Public Overrides Function fun1(Of T)(ByRef t2 As T) As Object'.
c3.fun1(t1:=3US)
~~
</expected>)
End Sub
<Fact()>
Public Sub SharedThroughInstance1()
Dim compilation = CompilationUtils.CreateCompilationWithMscorlib40AndVBRuntime(
<compilation name="NamedArgumentsAndOverriding">
<file name="a.vb">
Module Module1
Sub Main()
Dim x As New TestC()
x.Test(1, 2)
End Sub
End Module
Class TestC
Public Shared Sub Test(x As Integer)
End Sub
Public Shared Sub Test(x As Integer, y As Integer)
System.Console.WriteLine("Success")
End Sub
End Class
</file>
</compilation>, TestOptions.ReleaseExe)
CompilationUtils.AssertTheseDiagnostics(compilation,
<expected>
BC42025: Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated.
x.Test(1, 2)
~~~~~~
</expected>)
CompileAndVerify(compilation, expectedOutput:=
<![CDATA[
Success
]]>)
End Sub
<Fact()>
Public Sub InaccessibleOverloads1()
Dim compilation = CompilationUtils.CreateCompilationWithMscorlib40AndVBRuntime(
<compilation name="NamedArgumentsAndOverriding">
<file name="a.vb">
Module Module1
Sub Main()
Dim x As New TestC()
x.Test(1)
x.Test(2, 1)
x.Test()
Dim d1 As System.Action(Of Integer) = AddressOf x.Test
Dim d2 As System.Action(Of Integer, Integer) = AddressOf x.Test
Dim d3 As System.Action = AddressOf x.Test
End Sub
End Module
Class TestC
Protected Sub Test(x As Integer)
End Sub
Protected Sub Test(x As Integer, y As Integer)
End Sub
End Class
</file>
</compilation>, TestOptions.ReleaseExe)
CompilationUtils.AssertTheseDiagnostics(compilation,
<expected>
BC30390: 'TestC.Protected Sub Test(x As Integer)' is not accessible in this context because it is 'Protected'.
x.Test(1)
~~~~~~
BC30390: 'TestC.Protected Sub Test(x As Integer, y As Integer)' is not accessible in this context because it is 'Protected'.
x.Test(2, 1)
~~~~~~
BC30517: Overload resolution failed because no 'Test' is accessible.
x.Test()
~~~~~~
BC30390: 'TestC.Protected Sub Test(x As Integer)' is not accessible in this context because it is 'Protected'.
Dim d1 As System.Action(Of Integer) = AddressOf x.Test
~~~~~~
BC30390: 'TestC.Protected Sub Test(x As Integer, y As Integer)' is not accessible in this context because it is 'Protected'.
Dim d2 As System.Action(Of Integer, Integer) = AddressOf x.Test
~~~~~~
BC30517: Overload resolution failed because no 'Test' is accessible.
Dim d3 As System.Action = AddressOf x.Test
~~~~~~
</expected>)
End Sub
<Fact()>
Public Sub InaccessibleOverloads2()
Dim compilation = CompilationUtils.CreateCompilationWithMscorlib40AndVBRuntime(
<compilation name="NamedArgumentsAndOverriding">
<file name="a.vb">
Module Module1
Sub Main()
Dim x As New TestC()
x.Test(1)
x.Test(2, 1)
x.Test()
Dim d1 As System.Action(Of Integer) = AddressOf x.Test
Dim d2 As System.Action(Of Integer, Integer) = AddressOf x.Test
Dim d3 As System.Action = AddressOf x.Test
End Sub
End Module
Class TestC
Protected Shared Sub Test(x As Integer)
End Sub
Protected Shared Sub Test(x As Integer, y As Integer)
End Sub
End Class
</file>
</compilation>, TestOptions.ReleaseExe)
CompilationUtils.AssertTheseDiagnostics(compilation,
<expected>
BC30390: 'TestC.Protected Shared Sub Test(x As Integer)' is not accessible in this context because it is 'Protected'.
x.Test(1)
~~~~~~
BC30390: 'TestC.Protected Shared Sub Test(x As Integer, y As Integer)' is not accessible in this context because it is 'Protected'.
x.Test(2, 1)
~~~~~~
BC30517: Overload resolution failed because no 'Test' is accessible.
x.Test()
~~~~~~
BC30390: 'TestC.Protected Shared Sub Test(x As Integer)' is not accessible in this context because it is 'Protected'.
Dim d1 As System.Action(Of Integer) = AddressOf x.Test
~~~~~~
BC30390: 'TestC.Protected Shared Sub Test(x As Integer, y As Integer)' is not accessible in this context because it is 'Protected'.
Dim d2 As System.Action(Of Integer, Integer) = AddressOf x.Test
~~~~~~
BC30517: Overload resolution failed because no 'Test' is accessible.
Dim d3 As System.Action = AddressOf x.Test
~~~~~~
</expected>)
End Sub
<Fact()>
Public Sub InaccessibleOverloads3()
Dim compilation = CompilationUtils.CreateCompilationWithMscorlib40AndVBRuntime(
<compilation name="NamedArgumentsAndOverriding">
<file name="a.vb">
Module Module1
Sub Main()
Dim x As New TestC()
x.Test1(1)
x.Test2(1)
x.Test1(Of Integer)(1)
x.Test2(Of Integer)(1)
x.Test1(1,2)
x.Test3(1)
x.Test4(1)
x.Test1(DoesntExist)
x.Test2(DoesntExist)
Dim y as Long = 0
x.Test5(y)
Dim d1 As System.Action(Of Integer) = AddressOf x.Test1
Dim d2 As System.Action(Of Integer) = AddressOf x.Test2
Dim d3 As System.Action(Of Integer) = AddressOf x.Test1(Of Integer)
Dim d4 As System.Action(Of Integer) = AddressOf x.Test2(Of Integer)
Dim d5 As System.Action(Of Integer, Integer) = AddressOf x.Test1
Dim d6 As System.Action(Of Integer) = AddressOf x.Test3
Dim d7 As System.Action(Of Integer) = AddressOf x.Test4
Dim d8 As System.Action(Of Long) = AddressOf x.Test5
System.Console.WriteLine(1 + AddressOf x.Test1)
System.Console.WriteLine(1 + AddressOf x.Test2)
End Sub
End Module
Class TestC
Protected Sub Test1(x As System.Guid)
End Sub
Protected Sub Test2(x As System.Guid)
End Sub
Protected Sub Test2(x As System.Type)
End Sub
Protected Sub Test3(Of T)(x As Integer)
End Sub
Protected Sub Test4(Of T)(x As Integer)
End Sub
Protected Sub Test4(Of T)(x As String)
End Sub
Protected Sub Test5(x As Integer)
End Sub
Protected Sub Test5(x As String)
End Sub
End Class
</file>
</compilation>, TestOptions.ReleaseExe)
CompilationUtils.AssertTheseDiagnostics(compilation,
<expected>
BC30390: 'TestC.Protected Sub Test1(x As Guid)' is not accessible in this context because it is 'Protected'.
x.Test1(1)
~~~~~~~
BC30311: Value of type 'Integer' cannot be converted to 'Guid'.
x.Test1(1)
~
BC30517: Overload resolution failed because no 'Test2' is accessible.
x.Test2(1)
~~~~~~~
BC30390: 'TestC.Protected Sub Test1(x As Guid)' is not accessible in this context because it is 'Protected'.
x.Test1(Of Integer)(1)
~~~~~~~~~~~~~~~~~~~
BC32045: 'Protected Sub Test1(x As Guid)' has no type parameters and so cannot have type arguments.
x.Test1(Of Integer)(1)
~~~~~~~~~~~~
BC30517: Overload resolution failed because no 'Test2' is accessible.
x.Test2(Of Integer)(1)
~~~~~~~~~~~~~~~~~~~
BC30390: 'TestC.Protected Sub Test1(x As Guid)' is not accessible in this context because it is 'Protected'.
x.Test1(1,2)
~~~~~~~
BC30311: Value of type 'Integer' cannot be converted to 'Guid'.
x.Test1(1,2)
~
BC30057: Too many arguments to 'Protected Sub Test1(x As Guid)'.
x.Test1(1,2)
~
BC30390: 'TestC.Protected Sub Test3(Of T)(x As Integer)' is not accessible in this context because it is 'Protected'.
x.Test3(1)
~~~~~~~
BC32050: Type parameter 'T' for 'Protected Sub Test3(Of T)(x As Integer)' cannot be inferred.
x.Test3(1)
~~~~~
BC30517: Overload resolution failed because no 'Test4' is accessible.
x.Test4(1)
~~~~~~~
BC30390: 'TestC.Protected Sub Test1(x As Guid)' is not accessible in this context because it is 'Protected'.
x.Test1(DoesntExist)
~~~~~~~
BC30451: 'DoesntExist' is not declared. It may be inaccessible due to its protection level.
x.Test1(DoesntExist)
~~~~~~~~~~~
BC30517: Overload resolution failed because no 'Test2' is accessible.
x.Test2(DoesntExist)
~~~~~~~
BC30451: 'DoesntExist' is not declared. It may be inaccessible due to its protection level.
x.Test2(DoesntExist)
~~~~~~~~~~~
BC30517: Overload resolution failed because no 'Test5' is accessible.
x.Test5(y)
~~~~~~~
BC30390: 'TestC.Protected Sub Test1(x As Guid)' is not accessible in this context because it is 'Protected'.
Dim d1 As System.Action(Of Integer) = AddressOf x.Test1
~~~~~~~
BC31143: Method 'Protected Sub Test1(x As Guid)' does not have a signature compatible with delegate 'Delegate Sub Action(Of Integer)(obj As Integer)'.
Dim d1 As System.Action(Of Integer) = AddressOf x.Test1
~~~~~~~
BC30517: Overload resolution failed because no 'Test2' is accessible.
Dim d2 As System.Action(Of Integer) = AddressOf x.Test2
~~~~~~~
BC30390: 'TestC.Protected Sub Test1(x As Guid)' is not accessible in this context because it is 'Protected'.
Dim d3 As System.Action(Of Integer) = AddressOf x.Test1(Of Integer)
~~~~~~~~~~~~~~~~~~~
BC32045: 'Protected Sub Test1(x As Guid)' has no type parameters and so cannot have type arguments.
Dim d3 As System.Action(Of Integer) = AddressOf x.Test1(Of Integer)
~~~~~~~~~~~~
BC30517: Overload resolution failed because no 'Test2' is accessible.
Dim d4 As System.Action(Of Integer) = AddressOf x.Test2(Of Integer)
~~~~~~~~~~~~~~~~~~~
BC30390: 'TestC.Protected Sub Test1(x As Guid)' is not accessible in this context because it is 'Protected'.
Dim d5 As System.Action(Of Integer, Integer) = AddressOf x.Test1
~~~~~~~
BC31143: Method 'Protected Sub Test1(x As Guid)' does not have a signature compatible with delegate 'Delegate Sub Action(Of Integer, Integer)(arg1 As Integer, arg2 As Integer)'.
Dim d5 As System.Action(Of Integer, Integer) = AddressOf x.Test1
~~~~~~~
BC30390: 'TestC.Protected Sub Test3(Of T)(x As Integer)' is not accessible in this context because it is 'Protected'.
Dim d6 As System.Action(Of Integer) = AddressOf x.Test3
~~~~~~~
BC36564: Type arguments could not be inferred from the delegate.
Dim d6 As System.Action(Of Integer) = AddressOf x.Test3
~~~~~~~
BC30517: Overload resolution failed because no 'Test4' is accessible.
Dim d7 As System.Action(Of Integer) = AddressOf x.Test4
~~~~~~~
BC30517: Overload resolution failed because no 'Test5' is accessible.
Dim d8 As System.Action(Of Long) = AddressOf x.Test5
~~~~~~~
BC30491: Expression does not produce a value.
System.Console.WriteLine(1 + AddressOf x.Test1)
~~~~~~~~~~~~~~~~~
BC30390: 'TestC.Protected Sub Test1(x As Guid)' is not accessible in this context because it is 'Protected'.
System.Console.WriteLine(1 + AddressOf x.Test1)
~~~~~~~
BC30491: Expression does not produce a value.
System.Console.WriteLine(1 + AddressOf x.Test2)
~~~~~~~~~~~~~~~~~
BC30517: Overload resolution failed because no 'Test2' is accessible.
System.Console.WriteLine(1 + AddressOf x.Test2)
~~~~~~~
</expected>)
End Sub
<WorkItem(543719, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543719")>
<Fact()>
Public Sub CallByRefWithTwoArgs()
Dim compilationDef =
<compilation name="Test.vb">
<file name="a.vb">
Imports System
Module Program
Sub SUB8(ByRef X1 As Integer, ByRef X2 As Integer)
Console.WriteLine(X1)
Console.WriteLine(X2)
End Sub
Sub Main(args As String())
SUB8(10, 40)
End Sub
End Module
</file>
</compilation>
CompileAndVerify(compilationDef,
expectedOutput:=
<![CDATA[
10
40
]]>)
End Sub
<Fact, WorkItem(544511, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544511")>
Public Sub Bug12877_1()
Dim source =
<compilation name="AscW">
<file name="a.vb">
Imports Microsoft.VisualBasic.Strings
Module Module1
Sub Main()
System.Console.WriteLine(Test1("a"c))
System.Console.WriteLine(Test2("b"))
End Sub
Function Test1(x As Char) As Integer
Return AscW(x)
End Function
Function Test2(x As String) As Integer
Return AscW(x)
End Function
End Module
</file>
</compilation>
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntime(source, TestOptions.ReleaseExe)
Dim compilationVerifier = CompileAndVerify(compilation,
expectedOutput:=
<![CDATA[
97
98
]]>)
compilationVerifier.VerifyIL("Module1.Test1",
<![CDATA[
{
// Code size 2 (0x2)
.maxstack 1
IL_0000: ldarg.0
IL_0001: ret
}
]]>)
compilationVerifier.VerifyIL("Module1.Test2",
<![CDATA[
{
// Code size 7 (0x7)
.maxstack 1
IL_0000: ldarg.0
IL_0001: call "Function Microsoft.VisualBasic.Strings.AscW(String) As Integer"
IL_0006: ret
}
]]>)
compilation = CreateCompilationWithMscorlib40AndReferences(source, {SystemRef}, TestOptions.ReleaseExe.WithEmbedVbCoreRuntime(True))
compilationVerifier = CompileAndVerify(compilation,
expectedOutput:=
<![CDATA[
97
98
]]>)
compilationVerifier.VerifyIL("Module1.Test1",
<![CDATA[
{
// Code size 2 (0x2)
.maxstack 1
IL_0000: ldarg.0
IL_0001: ret
}
]]>)
compilationVerifier.VerifyIL("Module1.Test2",
<![CDATA[
{
// Code size 7 (0x7)
.maxstack 1
IL_0000: ldarg.0
IL_0001: call "Function Microsoft.VisualBasic.Strings.AscW(String) As Integer"
IL_0006: ret
}
]]>)
End Sub
<Fact, WorkItem(545521, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545521")>
Public Sub Bug14020()
Dim source =
<compilation name="AscW">
<file name="a.vb">
Option Strict On
Class A
Shared Sub Goo(Of T)(x As T)
System.Console.WriteLine("Goo(Of T)(x As T)")
End Sub
End Class
Class B
Inherits A
Overloads Shared Sub Goo(Of T)(y As Integer)
End Sub
Shared Sub Main()
Goo(x:=1)
End Sub
End Class
</file>
</compilation>
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntime(source, TestOptions.ReleaseExe)
Dim compilationVerifier = CompileAndVerify(compilation,
expectedOutput:=
<![CDATA[
Goo(Of T)(x As T)
]]>)
End Sub
<Fact, WorkItem(545522, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545522")>
Public Sub Bug14021()
Dim source =
<compilation name="AscW">
<file name="a.vb">
<![CDATA[
Option Strict On
Imports System.Runtime.CompilerServices
Module M
Sub Main()
Dim s As String = Nothing
s.Goo(y:=1)
End Sub
<Extension>
Sub Goo(x As Object, y As Integer)
System.Console.WriteLine("Goo(x As Object, y As Integer)")
End Sub
<Extension>
Sub Goo(Of T)(x As T, z As Integer)
System.Console.WriteLine("Goo(Of T)(x As T, z As Integer)")
End Sub
End Module
]]>
</file>
</compilation>
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntimeAndReferences(source, {SystemCoreRef}, TestOptions.ReleaseExe)
Dim compilationVerifier = CompileAndVerify(compilation,
expectedOutput:=
<![CDATA[
Goo(x As Object, y As Integer)
]]>)
End Sub
<Fact, WorkItem(545522, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545522")>
Public Sub Bug14021_2()
Dim source =
<compilation name="AscW">
<file name="a.vb">
<![CDATA[
Option Strict On
Imports System.Runtime.CompilerServices
Module M
Sub Main()
Dim s As String = Nothing
s.Goo(y:=1)
End Sub
<Extension>
Sub Goo(x As String, z As Integer)
System.Console.WriteLine("Goo(x As String, z As Integer)")
End Sub
<Extension>
Sub Goo(x As Object, y As Integer)
System.Console.WriteLine("Goo(x As Object, y As Integer)")
End Sub
End Module
]]>
</file>
</compilation>
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntimeAndReferences(source, {SystemCoreRef}, TestOptions.ReleaseExe)
Dim compilationVerifier = CompileAndVerify(compilation,
expectedOutput:=
<![CDATA[
Goo(x As Object, y As Integer)
]]>)
End Sub
<Fact, WorkItem(545524, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545524")>
Public Sub Bug14024()
Dim source =
<compilation name="AscW">
<file name="a.vb">
<![CDATA[
Option Strict On
Class B
Overloads Function Goo(Of T)() As Integer
System.Console.WriteLine("Function Goo(Of T)() As Integer")
Return 4321
End Function
End Class
Class C
Inherits B
Overloads Shared Function Goo() As Integer()
System.Console.WriteLine("Function Goo() As Integer()")
Return {1234}
End Function
Shared Sub Main()
Goo(0).ToString()
End Sub
End Class
]]>
</file>
</compilation>
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntime(source, TestOptions.ReleaseExe)
Dim compilationVerifier = CompileAndVerify(compilation,
expectedOutput:=
<![CDATA[
Function Goo() As Integer()
]]>)
End Sub
<Fact, WorkItem(545524, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545524")>
Public Sub Bug14024_2()
Dim source =
<compilation name="AscW">
<file name="a.vb">
<![CDATA[
Option Strict On
Class B
Overloads Function Goo(Of T)() As Integer
System.Console.WriteLine("Function Goo(Of T)() As Integer")
Return 4321
End Function
End Class
Class C
Inherits B
Shared Sub Main()
Goo(0).ToString()
End Sub
End Class
]]>
</file>
</compilation>
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntime(source, TestOptions.ReleaseExe)
CompilationUtils.AssertTheseDiagnostics(compilation,
<expected>
BC30057: Too many arguments to 'Public Overloads Function Goo(Of T)() As Integer'.
Goo(0).ToString()
~
</expected>)
End Sub
<Fact, WorkItem(546006, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/546006")>
Public Sub Bug14936()
Dim source =
<compilation name="Bug14936">
<file name="a.vb">
<![CDATA[
Module Program
Sub Main()
Dim o As New cls1
Dim x1 As Object = 1
o.goo(x1)
End Sub
End Module
Class cls1
Sub goo(ByVal x As cls1)
System.Console.WriteLine("goo(ByVal x As cls1)")
End Sub
Sub goo(ByVal x As Integer)
System.Console.WriteLine("goo(ByVal x As Integer)")
End Sub
End Class
]]>
</file>
</compilation>
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntime(source, TestOptions.ReleaseExe.WithOptionStrict(OptionStrict.Custom))
Dim compilationVerifier = CompileAndVerify(compilation,
expectedOutput:=
<![CDATA[
goo(ByVal x As Integer)
]]>)
AssertTheseDiagnostics(compilation,
<expected>
BC42017: Late bound resolution; runtime errors could occur.
o.goo(x1)
~~~
</expected>)
End Sub
<Fact, WorkItem(547132, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/547132")>
Public Sub Bug18047()
Dim source =
<compilation>
<file name="a.vb">
<![CDATA[
Imports System
Module Program
Property S1 As String
Get
Return ""
End Get
Set(value As String)
Console.WriteLine("S1")
End Set
End Property
Property S2 As String
Get
Return ""
End Get
Set(value As String)
Console.WriteLine("S2")
End Set
End Property
Property S3 As String
Get
Return ""
End Get
Set(value As String)
Console.WriteLine("S3")
End Set
End Property
Sub Verify1(ByRef x As String, ByRef y As String, ByRef z As String)
x = "a"
y = "b"
z = "c"
End Sub
Sub Main(args As String())
Verify1(S1, S2, S3)
End Sub
End Module
]]>
</file>
</compilation>
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntime(source, TestOptions.ReleaseExe)
Dim compilationVerifier = CompileAndVerify(compilation,
expectedOutput:=
<![CDATA[
S3
S2
S1
]]>)
End Sub
<WorkItem(531448, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/531448")>
<ConditionalFact(GetType(WindowsDesktopOnly), Reason:="https://github.com/dotnet/roslyn/issues/28044")>
Public Sub Bug18133_1()
Dim source =
<compilation>
<file name="a.vb">
<![CDATA[
Option Compare Text
Imports System
Imports Microsoft.VisualBasic
Module module1
Sub Main(args As String())
Console.WriteLine(InStr(1, "SSHORTDATE", "Date"))
End Sub
End Module
]]>
</file>
</compilation>
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntime(source, TestOptions.ReleaseExe)
Dim compilationVerifier = CompileAndVerify(compilation,
expectedOutput:=
<![CDATA[
7
]]>)
End Sub
<WorkItem(531448, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/531448")>
<ConditionalFact(GetType(WindowsDesktopOnly), Reason:="https://github.com/dotnet/roslyn/issues/28044")>
Public Sub Bug18133_2()
Dim source =
<compilation>
<file name="a.vb">
<![CDATA[
Option Compare Text
Imports System
Imports Microsoft.VisualBasic
Module module1
Sub Main(args As String())
Console.WriteLine(MyInStr(1, "SSHORTDATE", "Date"))
End Sub
Function MyInStr(Start As Integer, String1 As String, String2 As String, <CompilerServices.OptionCompareAttribute()> Optional Compare As CompareMethod = CompareMethod.Binary) As Integer
Return InStr(Start, String1, String2, Compare)
End Function
End Module
]]>
</file>
</compilation>
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntime(source, TestOptions.ReleaseExe)
Dim compilationVerifier = CompileAndVerify(compilation,
expectedOutput:=
<![CDATA[
0
]]>)
End Sub
<Fact, WorkItem(531413, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/531413")>
Public Sub Bug18089()
Dim source =
<compilation>
<file name="a.vb">
<![CDATA[
Friend Class Class1
Sub New(ByVal x As Short, Optional ByVal y As Integer = 0)
System.Console.WriteLine("1")
End Sub
Sub New(ByVal x As Integer, Optional ByVal y As Short = 0)
System.Console.WriteLine("2")
End Sub
Shared Sub Goo(ByVal x As Short, Optional ByVal y As Integer = 0)
System.Console.WriteLine("3")
End Sub
Shared Sub Goo(ByVal x As Integer, Optional ByVal y As Short = 0)
System.Console.WriteLine("4")
End Sub
End Class
Module Module1
Sub Main(args As String())
Dim x As New Class1(CShort(0), )
Dim y As New Class1(CShort(0))
Class1.Goo(CShort(0), )
Class1.Goo(CShort(0))
End Sub
End Module
]]>
</file>
</compilation>
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntime(source, TestOptions.ReleaseExe)
Dim compilationVerifier = CompileAndVerify(compilation,
expectedOutput:=
<![CDATA[
1
1
3
3
]]>)
End Sub
<Fact, WorkItem(570936, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/570936")>
Public Sub Bug570936()
Dim source =
<compilation>
<file name="a.vb">
<![CDATA[
Imports System
Imports System.Runtime.CompilerServices
Module Module1
Sub Main
Dim x As New C3
Dim sResult As String = x.Goo3(1)
Console.writeline("C3 Pass")
Console.writeline( sResult)
End Sub
Class C3
Function Goo3(<[ParamArray]()> ByVal x As Integer) As String
Return "C3 Fail"
End Function
End Class
End Module
Module NonArrayMarkedAsParamArray1
<Extension()> Function Goo3(ByVal x As C3, ByVal y As Integer) As String
Return "C3 Pass"
End Function
End Module
]]>
</file>
</compilation>
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntimeAndReferences(source, {SystemCoreRef}, TestOptions.ReleaseExe)
Dim compilationVerifier = CompileAndVerify(compilation,
expectedOutput:=
<![CDATA[
C3 Pass
C3 Pass
]]>)
End Sub
<Fact()>
Public Sub ParameterSyntax_ModifiersAndAttributes()
CompileAndVerify(
<compilation>
<file name="a.vb">
<![CDATA[Imports System
Imports Microsoft.VisualBasic
Imports System.Collections
Imports System.Collections.Generic
Module Module1
Sub main()
Goo("test", "test2")
Bar("Test")
Bar("Test", 2)
GooAttributes({"Test", "Test2"})
GooAttributes2({"Test2", "Test"})
GooAttributes3({"Test", "Test2"}, 1)
End Sub
Sub Goo(ByVal ParamArray x() As String)
Console.WriteLine("Goo")
End Sub
Sub Bar(ByRef x As String, Optional ByVal y As Integer = 1)
Console.WriteLine("Bar")
End Sub
Sub GooAttributes(<Test> <Test2> x() As String)
Console.WriteLine("GooAttributes")
End Sub
Sub GooAttributes2(<Test, Test2> x() As String)
Console.WriteLine("GooAttributes2")
End Sub
Sub GooAttributes3(<Test, Test2> x() As String, <Test> z As Integer)
Console.WriteLine("GooAttributes3")
End Sub
End Module
<AttributeUsageAttribute(AttributeTargets.Parameter, Inherited:=True)>
Public NotInheritable Class TestAttribute
Inherits Attribute
End Class
<AttributeUsageAttribute(AttributeTargets.Parameter, Inherited:=True)>
Public NotInheritable Class Test2Attribute
Inherits Attribute
End Class
]]>
</file>
</compilation>,
expectedOutput:=<![CDATA[Goo
Bar
Bar
GooAttributes
GooAttributes2
GooAttributes3
]]>)
End Sub
<Fact()>
Public Sub AutoImplementedPropertiesWithGenericTypeParameters()
Dim TEMP = CompileAndVerify(
<compilation>
<file name="a.vb">
Imports System
Imports Microsoft.VisualBasic
Imports System.Collections
Imports System.Collections.Generic
Module Module1
Sub main()
Dim x As New Goo
x.Items = New List(Of String) From {"A", "B", "C"}
Console.WriteLine(x.Items.Count)
Dim y As New GooWithInterface
Dim i As IPropTest = y
i.Items = New List(Of String) From {"A", "B", "C"}
End Sub
End Module
Class Goo
Public Property Items As New List(Of String)
End Class
Class GooWithInterface
Implements IPropTest
Public Property Items As New List(Of String) Implements IPropTest.Items
End Class
Interface IPropTest
Property Items As List(Of String)
End Interface
</file>
</compilation>, expectedOutput:=<![CDATA[3
]]>)
End Sub
<Fact(), WorkItem(758861, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/758861")>
Public Sub Bug758861()
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntime(
<compilation>
<file name="a.vb">
Module Program
Const c1 As String = "DefaultValue1"
Const c2 As String = "DefaultValue2"
Declare Ansi Sub subAnsiByValStr1 Lib "DeclDll" Alias "subAnsiByValStr1" (Optional ByVal str As String = c1) 'BIND1:"c1"
Declare Ansi Function subAnsiByValStr2 Lib "DeclDll" Alias "subAnsiByValStr2" (Optional ByVal str As String = c2) 'BIND2:"c2"
Sub Main(args As String())
subAnsiByValStr1()
subAnsiByValStr2()
End Sub
End Module
</file>
</compilation>, TestOptions.ReleaseDll)
Dim verifier = CompileAndVerify(compilation)
verifier.VerifyIL("Program.Main",
<![CDATA[
{
// Code size 28 (0x1c)
.maxstack 1
.locals init (String V_0)
IL_0000: ldstr "DefaultValue1"
IL_0005: stloc.0
IL_0006: ldloca.s V_0
IL_0008: call "Declare Ansi Sub Program.subAnsiByValStr1 Lib "DeclDll" Alias "subAnsiByValStr1" (String)"
IL_000d: ldstr "DefaultValue2"
IL_0012: stloc.0
IL_0013: ldloca.s V_0
IL_0015: call "Declare Ansi Function Program.subAnsiByValStr2 Lib "DeclDll" Alias "subAnsiByValStr2" (String) As Object"
IL_001a: pop
IL_001b: ret
}
]]>)
Dim model = GetSemanticModel(compilation, "a.vb")
Dim node1 As ExpressionSyntax = CompilationUtils.FindBindingText(Of ExpressionSyntax)(compilation, "a.vb", 1)
Dim node2 As ExpressionSyntax = CompilationUtils.FindBindingText(Of ExpressionSyntax)(compilation, "a.vb", 2)
Dim cnt = model.GetConstantValue(node1)
Assert.Equal("DefaultValue1", CStr(cnt.Value))
cnt = model.GetConstantValue(node2)
Assert.Equal("DefaultValue2", CStr(cnt.Value))
End Sub
<Fact(), WorkItem(762717, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/762717")>
Public Sub Bug762717()
Dim library = CreateCompilationWithMscorlib40(
<compilation>
<file name="a.vb"><![CDATA[
Public Class Test1
Public Shared Sub Test1(a As Integer, <System.Runtime.InteropServices.OptionalAttribute> x As Integer, <System.ParamArrayAttribute> y As Integer())
End Sub
End Class
Public Class Test2
Public Shared Sub Test2(a As Integer, <System.Runtime.InteropServices.OptionalAttribute> x As Integer, <System.ParamArrayAttribute> y As Integer())
End Sub
Public Shared Sub Test2(a As String, <System.Runtime.InteropServices.OptionalAttribute> x As Integer, <System.ParamArrayAttribute> y As Integer())
End Sub
End Class
]]></file>
</compilation>, options:=TestOptions.ReleaseDll)
CompileAndVerify(library)
Dim compilation = CreateCompilationWithMscorlib40AndReferences(
<compilation>
<file name="a.vb"><![CDATA[
Class Module1
Sub Main1()
Test1.Test1(1)
End Sub
Sub Main2()
Test2.Test2(2)
End Sub
End Class
]]></file>
</compilation>, {library.EmitToImageReference()}, TestOptions.ReleaseDll)
Dim verifier = CompileAndVerify(compilation)
verifier.VerifyIL("Module1.Main1",
<![CDATA[
{
// Code size 14 (0xe)
.maxstack 3
IL_0000: ldc.i4.1
IL_0001: ldc.i4.0
IL_0002: ldc.i4.0
IL_0003: newarr "Integer"
IL_0008: call "Sub Test1.Test1(Integer, Integer, ParamArray Integer())"
IL_000d: ret
}
]]>)
verifier.VerifyIL("Module1.Main2",
<![CDATA[
{
// Code size 14 (0xe)
.maxstack 3
IL_0000: ldc.i4.2
IL_0001: ldc.i4.0
IL_0002: ldc.i4.0
IL_0003: newarr "Integer"
IL_0008: call "Sub Test2.Test2(Integer, Integer, ParamArray Integer())"
IL_000d: ret
}
]]>)
End Sub
<Fact(), WorkItem(1040093, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1040093"), WorkItem(1026678, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1026678")>
Public Sub ParenthesizedVariableAsAReceiver_01()
Dim compilationDef =
<compilation>
<file name="a.vb">
Imports System
Imports System.Threading.Tasks
Module Module1
Sub Main()
System.Console.WriteLine("Non-Async")
System.Console.WriteLine()
TestLocal()
TestParameter()
TestSharedField()
TestInstanceField()
TestArrayElement()
System.Console.WriteLine()
System.Console.WriteLine("Async")
System.Console.WriteLine()
Task.WaitAll(TestLocalAsync())
Task.WaitAll(TestParameterAsync())
Task.WaitAll(TestSharedFieldAsync())
Task.WaitAll(TestInstanceFieldAsync())
Task.WaitAll(TestArrayElementAsync())
End Sub
Sub TestLocal()
Dim l = TestStruct1.Create()
Call (l).Change()
System.Console.WriteLine("Local : {0}", l.State())
End Sub
Sub TestParameter(Optional p As TestStruct1 = Nothing)
p = TestStruct1.Create()
Call (p).Change()
System.Console.WriteLine("Parameter : {0}", p.State())
End Sub
Private f As TestStruct1
Sub TestSharedField()
f = TestStruct1.Create()
Call (f).Change()
System.Console.WriteLine("Shared Field : {0}", f.State())
End Sub
Sub TestInstanceField()
Dim i = New TestClass()
Call (i.fld2).Change()
System.Console.WriteLine("Instance Field: {0}", i.fld2.State())
End Sub
Sub TestArrayElement()
Dim a = {TestStruct1.Create()}
Call (a(0)).Change()
System.Console.WriteLine("Array element : {0}", a(0).State())
End Sub
Async Function DummyAsync() As Task(Of Object)
Return Nothing
End Function
Async Function TestLocalAsync() As Task
Dim l = TestStruct1.Create()
Call (l).Change(Await DummyAsync())
System.Console.WriteLine("Local : {0}", l.State())
End Function
Async Function TestParameterAsync(Optional p As TestStruct1 = Nothing) As Task
p = TestStruct1.Create()
Call (p).Change(Await DummyAsync())
System.Console.WriteLine("Parameter : {0}", p.State())
End Function
Async Function TestSharedFieldAsync() As Task
f = TestStruct1.Create()
Call (f).Change(Await DummyAsync())
System.Console.WriteLine("Shared Field : {0}", f.State())
End Function
Async Function TestInstanceFieldAsync() As Task
Dim i = New TestClass()
Call (i.fld2).Change(Await DummyAsync())
System.Console.WriteLine("Instance Field: {0}", i.fld2.State())
End Function
Async Function TestArrayElementAsync() As Task
Dim a = {TestStruct1.Create()}
Call (a(0)).Change(Await DummyAsync())
System.Console.WriteLine("Array element : {0}", a(0).State())
End Function
End Module
Structure TestStruct1
Private fld1 As String
Shared Function Create() As TestStruct1
Return New TestStruct1() With {.fld1 = "Unchanged"}
End Function
Sub Change(Optional x As Object = Nothing)
fld1 = "Changed"
End Sub
Function State() As String
Return fld1
End Function
End Structure
Class TestClass
Public fld2 As TestStruct1 = TestStruct1.Create()
End Class
</file>
</compilation>
Dim compilation = CompilationUtils.CreateEmptyCompilationWithReferences(compilationDef, {MscorlibRef_v4_0_30316_17626, MsvbRef_v4_0_30319_17929}, TestOptions.ReleaseExe, parseOptions:=TestOptions.ReleaseExe.ParseOptions)
Dim verifier = CompileAndVerify(compilation, expectedOutput:=
<![CDATA[
Non-Async
Local : Changed
Parameter : Changed
Shared Field : Changed
Instance Field: Changed
Array element : Changed
Async
Local : Changed
Parameter : Changed
Shared Field : Changed
Instance Field: Changed
Array element : Changed
]]>)
End Sub
<Fact(), WorkItem(1040093, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1040093"), WorkItem(1026678, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1026678")>
Public Sub ParenthesizedVariableAsAReceiver_02()
Dim compilationDef =
<compilation>
<file name="a.vb">
Imports System
Imports System.Threading.Tasks
Module Module1
Sub Main()
System.Console.WriteLine("Non-Async")
System.Console.WriteLine()
TestLocal()
TestParameter()
TestSharedField()
TestInstanceField()
TestArrayElement()
System.Console.WriteLine()
System.Console.WriteLine("Async")
System.Console.WriteLine()
Task.WaitAll(TestLocalAsync())
Task.WaitAll(TestParameterAsync())
Task.WaitAll(TestSharedFieldAsync())
Task.WaitAll(TestInstanceFieldAsync())
Task.WaitAll(TestArrayElementAsync())
End Sub
Sub TestLocal()
Dim l As TestStruct2
l = TestStruct2.Create()
Call (l).fld2.Change()
System.Console.WriteLine("Local : {0}", l.fld2.State())
l = TestStruct2.Create()
Call ((l).fld2).Change()
System.Console.WriteLine("Local : {0}", l.fld2.State())
l = TestStruct2.Create()
Call (l.fld2).Change()
System.Console.WriteLine("Local : {0}", l.fld2.State())
End Sub
Sub TestParameter(Optional p As TestStruct2 = Nothing)
p = TestStruct2.Create()
Call (p).fld2.Change()
System.Console.WriteLine("Parameter : {0}", p.fld2.State())
p = TestStruct2.Create()
Call ((p).fld2).Change()
System.Console.WriteLine("Parameter : {0}", p.fld2.State())
p = TestStruct2.Create()
Call (p.fld2).Change()
System.Console.WriteLine("Parameter : {0}", p.fld2.State())
End Sub
Private f As TestStruct2
Sub TestSharedField()
f = TestStruct2.Create()
Call (f).fld2.Change()
System.Console.WriteLine("Shared Field : {0}", f.fld2.State())
f = TestStruct2.Create()
Call ((f).fld2).Change()
System.Console.WriteLine("Shared Field : {0}", f.fld2.State())
f = TestStruct2.Create()
Call (f.fld2).Change()
System.Console.WriteLine("Shared Field : {0}", f.fld2.State())
End Sub
Sub TestInstanceField()
Dim i As TestClass
i = New TestClass()
Call (i).fld3.fld2.Change()
System.Console.WriteLine("Instance Field: {0}", i.fld3.fld2.State())
i = New TestClass()
Call ((i).fld3).fld2.Change()
System.Console.WriteLine("Instance Field: {0}", i.fld3.fld2.State())
i = New TestClass()
Call (((i).fld3).fld2).Change()
System.Console.WriteLine("Instance Field: {0}", i.fld3.fld2.State())
i = New TestClass()
Call (i.fld3).fld2.Change()
System.Console.WriteLine("Instance Field: {0}", i.fld3.fld2.State())
i = New TestClass()
Call ((i.fld3).fld2).Change()
System.Console.WriteLine("Instance Field: {0}", i.fld3.fld2.State())
i = New TestClass()
Call (i.fld3.fld2).Change()
System.Console.WriteLine("Instance Field: {0}", i.fld3.fld2.State())
End Sub
Sub TestArrayElement()
Dim a = {TestStruct2.Create()}
Call (a(0)).fld2.Change()
System.Console.WriteLine("Array element : {0}", a(0).fld2.State())
a = {TestStruct2.Create()}
Call ((a(0)).fld2).Change()
System.Console.WriteLine("Array element : {0}", a(0).fld2.State())
a = {TestStruct2.Create()}
Call (a(0).fld2).Change()
System.Console.WriteLine("Array element : {0}", a(0).fld2.State())
End Sub
Async Function DummyAsync() As Task(Of Object)
Return Nothing
End Function
Async Function TestLocalAsync() As Task
Dim l As TestStruct2
l = TestStruct2.Create()
Call (l).fld2.Change(Await DummyAsync())
System.Console.WriteLine("Local : {0}", l.fld2.State())
l = TestStruct2.Create()
Call ((l).fld2).Change(Await DummyAsync())
System.Console.WriteLine("Local : {0}", l.fld2.State())
l = TestStruct2.Create()
Call (l.fld2).Change(Await DummyAsync())
System.Console.WriteLine("Local : {0}", l.fld2.State())
End Function
Async Function TestParameterAsync(Optional p As TestStruct2 = Nothing) As Task
p = TestStruct2.Create()
Call (p).fld2.Change(Await DummyAsync())
System.Console.WriteLine("Parameter : {0}", p.fld2.State())
p = TestStruct2.Create()
Call ((p).fld2).Change(Await DummyAsync())
System.Console.WriteLine("Parameter : {0}", p.fld2.State())
p = TestStruct2.Create()
Call (p.fld2).Change(Await DummyAsync())
System.Console.WriteLine("Parameter : {0}", p.fld2.State())
End Function
Async Function TestSharedFieldAsync() As Task
f = TestStruct2.Create()
Call (f).fld2.Change(Await DummyAsync())
System.Console.WriteLine("Shared Field : {0}", f.fld2.State())
f = TestStruct2.Create()
Call ((f).fld2).Change(Await DummyAsync())
System.Console.WriteLine("Shared Field : {0}", f.fld2.State())
f = TestStruct2.Create()
Call (f.fld2).Change(Await DummyAsync())
System.Console.WriteLine("Shared Field : {0}", f.fld2.State())
End Function
Async Function TestInstanceFieldAsync() As Task
Dim i As TestClass
i = New TestClass()
Call (i).fld3.fld2.Change(Await DummyAsync())
System.Console.WriteLine("Instance Field: {0}", i.fld3.fld2.State())
i = New TestClass()
Call ((i).fld3).fld2.Change(Await DummyAsync())
System.Console.WriteLine("Instance Field: {0}", i.fld3.fld2.State())
i = New TestClass()
Call (((i).fld3).fld2).Change(Await DummyAsync())
System.Console.WriteLine("Instance Field: {0}", i.fld3.fld2.State())
i = New TestClass()
Call (i.fld3).fld2.Change(Await DummyAsync())
System.Console.WriteLine("Instance Field: {0}", i.fld3.fld2.State())
i = New TestClass()
Call ((i.fld3).fld2).Change(Await DummyAsync())
System.Console.WriteLine("Instance Field: {0}", i.fld3.fld2.State())
i = New TestClass()
Call (i.fld3.fld2).Change(Await DummyAsync())
System.Console.WriteLine("Instance Field: {0}", i.fld3.fld2.State())
End Function
Async Function TestArrayElementAsync() As Task
Dim a = {TestStruct2.Create()}
Call (a(0)).fld2.Change(Await DummyAsync())
System.Console.WriteLine("Array element : {0}", a(0).fld2.State())
a = {TestStruct2.Create()}
Call ((a(0)).fld2).Change(Await DummyAsync())
System.Console.WriteLine("Array element : {0}", a(0).fld2.State())
a = {TestStruct2.Create()}
Call (a(0).fld2).Change(Await DummyAsync())
System.Console.WriteLine("Array element : {0}", a(0).fld2.State())
End Function
End Module
Structure TestStruct1
Private fld1 As String
Shared Function Create() As TestStruct1
Return New TestStruct1() With {.fld1 = "Unchanged"}
End Function
Sub Change(Optional x As Object = Nothing)
fld1 = "Changed"
End Sub
Function State() As String
Return fld1
End Function
End Structure
Structure TestStruct2
Public fld2 As TestStruct1
Shared Function Create() As TestStruct2
Return New TestStruct2() With {.fld2 = TestStruct1.Create()}
End Function
End Structure
Class TestClass
Public fld3 As TestStruct2 = TestStruct2.Create()
End Class
</file>
</compilation>
Dim compilation = CompilationUtils.CreateEmptyCompilationWithReferences(compilationDef, {MscorlibRef_v4_0_30316_17626, MsvbRef_v4_0_30319_17929}, TestOptions.ReleaseExe, parseOptions:=TestOptions.ReleaseExe.ParseOptions)
Dim verifier = CompileAndVerify(compilation, expectedOutput:=
<![CDATA[
Non-Async
Local : Changed
Local : Changed
Local : Changed
Parameter : Changed
Parameter : Changed
Parameter : Changed
Shared Field : Changed
Shared Field : Changed
Shared Field : Changed
Instance Field: Changed
Instance Field: Changed
Instance Field: Changed
Instance Field: Changed
Instance Field: Changed
Instance Field: Changed
Array element : Changed
Array element : Changed
Array element : Changed
Async
Local : Changed
Local : Changed
Local : Changed
Parameter : Changed
Parameter : Changed
Parameter : Changed
Shared Field : Changed
Shared Field : Changed
Shared Field : Changed
Instance Field: Changed
Instance Field: Changed
Instance Field: Changed
Instance Field: Changed
Instance Field: Changed
Instance Field: Changed
Array element : Changed
Array element : Changed
Array element : Changed
]]>)
End Sub
<Fact(), WorkItem(2903, "https://github.com/dotnet/roslyn/issues/2903")>
Public Sub DelegateWithParamArray()
Dim source1 =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
Public Delegate Function MessageFormatter(ByVal format As String, <[ParamArray]> args As Object()) As String
]]></file>
</compilation>
Dim compilation1 = CreateCompilationWithMscorlib40(source1, options:=TestOptions.DebugDll)
Dim source2 =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
Module Program
Sub Main()
Log(Function(f) f("Test {0}", 1))
Log(Function(f) f("Test"))
Log(Function(f) "test")
End Sub
Sub Log(messageFunc As Func(Of MessageFormatter, String))
Console.WriteLine(messageFunc(New MessageFormatter(Function(format, args) String.Format(format, args))))
End Sub
End Module
]]></file>
</compilation>
Dim expectedOutput = <![CDATA[
Test 1
Test
test
]]>
Dim compilation2 = CreateCompilationWithMscorlib40AndVBRuntimeAndReferences(source2, {compilation1.EmitToImageReference()}, options:=TestOptions.DebugExe)
CompileAndVerify(compilation2, expectedOutput:=expectedOutput)
Dim compilation3 = CreateCompilationWithMscorlib40AndVBRuntimeAndReferences(source2, {New VisualBasicCompilationReference(compilation1)}, options:=TestOptions.DebugExe)
CompileAndVerify(compilation3, expectedOutput:=expectedOutput)
Dim source4 =
<compilation>
<file name="a.vb"><![CDATA[
Imports System
Public Delegate Function MessageFormatter(ByVal format As String, <[ParamArray]> args As Object()) As String
Module Program
Sub Main()
Log(Function(f) f("Test {0}", 1))
Log(Function(f) f("Test"))
Log(Function(f) "test")
End Sub
Sub Log(messageFunc As Func(Of MessageFormatter, String))
Console.WriteLine(messageFunc(New MessageFormatter(Function(format, args) String.Format(format, args))))
End Sub
End Module
]]></file>
</compilation>
Dim compilation4 = CreateCompilationWithMscorlib40AndVBRuntime(source4, options:=TestOptions.DebugExe)
CompileAndVerify(compilation4, expectedOutput:=expectedOutput)
End Sub
End Class
End Namespace
|
davkean/roslyn
|
src/Compilers/VisualBasic/Test/Semantic/Semantics/MethodCalls.vb
|
Visual Basic
|
apache-2.0
| 150,187
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports Microsoft.CodeAnalysis
Imports Microsoft.VisualStudio.LanguageServices.CSharp.CodeModel.Extenders
Imports Microsoft.VisualStudio.LanguageServices.CSharp.CodeModel.Interop
Imports Roslyn.Test.Utilities
Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.CodeModel.CSharp
Public Class CodeFunctionTests
Inherits AbstractCodeFunctionTests
#Region "Access tests"
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Access1()
Dim code =
<Code>
class C
{
int $$F() { throw new System.NotImplementedException(); }
}
</Code>
TestAccess(code, EnvDTE.vsCMAccess.vsCMAccessPrivate)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Access2()
Dim code =
<Code>
class C
{
private int $$F() { throw new System.NotImplementedException(); }
}
</Code>
TestAccess(code, EnvDTE.vsCMAccess.vsCMAccessPrivate)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Access3()
Dim code =
<Code>
class C
{
protected int $$F() { throw new System.NotImplementedException(); }
}
</Code>
TestAccess(code, EnvDTE.vsCMAccess.vsCMAccessProtected)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Access4()
Dim code =
<Code>
class C
{
protected internal int $$F() { throw new System.NotImplementedException(); }
}
</Code>
TestAccess(code, EnvDTE.vsCMAccess.vsCMAccessProjectOrProtected)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Access5()
Dim code =
<Code>
class C
{
internal int $$F() { throw new System.NotImplementedException(); }
}
</Code>
TestAccess(code, EnvDTE.vsCMAccess.vsCMAccessProject)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Access6()
Dim code =
<Code>
class C
{
public int $$F() { throw new System.NotImplementedException(); }
}
</Code>
TestAccess(code, EnvDTE.vsCMAccess.vsCMAccessPublic)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Access7()
Dim code =
<Code>
interface I
{
int $$Foo();
}
</Code>
TestAccess(code, EnvDTE.vsCMAccess.vsCMAccessPublic)
End Sub
#End Region
#Region "CanOverride tests"
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub CanOverride1()
Dim code =
<Code>
abstract class C
{
protected abstract void $$Foo();
}
</Code>
TestCanOverride(code, True)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub CanOverride2()
Dim code =
<Code>
interface I
{
void $$Foo();
}
</Code>
TestCanOverride(code, True)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub CanOverride3()
Dim code =
<Code>
class C
{
protected virtual void $$Foo() { }
}
</Code>
TestCanOverride(code, True)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub CanOverride4()
Dim code =
<Code>
class C
{
protected void $$Foo() { }
}
</Code>
TestCanOverride(code, False)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub CanOverride5()
Dim code =
<Code>
class B
{
protected virtual void Foo()
{
}
}
class C : B
{
protected override void $$Foo()
{
base.Foo();
}
}
</Code>
TestCanOverride(code, False)
End Sub
#End Region
#Region "FullName tests"
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub FullName_Destructor()
Dim code =
<Code>
class C
{
~C$$() { }
}
</Code>
TestFullName(code, "C.~C")
End Sub
#End Region
#Region "FunctionKind tests"
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub FunctionKind_Destructor()
Dim code =
<Code>
class C
{
~C$$() { }
}
</Code>
TestFunctionKind(code, EnvDTE.vsCMFunction.vsCMFunctionDestructor)
End Sub
#End Region
#Region "MustImplement tests"
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub MustImplement1()
Dim code =
<Code>
abstract class C
{
protected abstract void $$Foo();
}
</Code>
TestMustImplement(code, True)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub MustImplement2()
Dim code =
<Code>
interface I
{
void $$Foo();
}
</Code>
TestMustImplement(code, True)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub MustImplement3()
Dim code =
<Code>
class C
{
protected virtual void $$Foo() { }
}
</Code>
TestMustImplement(code, False)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub MustImplement4()
Dim code =
<Code>
class C
{
protected void $$Foo() { }
}
</Code>
TestMustImplement(code, False)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub MustImplement5()
Dim code =
<Code>
class B
{
protected virtual void Foo()
{
}
}
class C : B
{
protected override void $$Foo()
{
base.Foo();
}
}
</Code>
TestMustImplement(code, False)
End Sub
#End Region
#Region "Name tests"
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Name_Destructor()
Dim code =
<Code>
class C
{
~C$$() { }
}
</Code>
TestName(code, "~C")
End Sub
#End Region
#Region "OverrideKind tests"
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub OverrideKind_Abstract()
Dim code =
<Code>
abstract class C
{
protected abstract void $$Foo();
}
</Code>
TestOverrideKind(code, EnvDTE80.vsCMOverrideKind.vsCMOverrideKindAbstract)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub OverrideKind_Virtual()
Dim code =
<Code>
class C
{
protected virtual void $$Foo() { }
}
</Code>
TestOverrideKind(code, EnvDTE80.vsCMOverrideKind.vsCMOverrideKindVirtual)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub OverrideKind_Sealed()
Dim code =
<Code>
class C
{
protected sealed void $$Foo() { }
}
</Code>
TestOverrideKind(code, EnvDTE80.vsCMOverrideKind.vsCMOverrideKindSealed)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub OverrideKind_Override()
Dim code =
<Code>
abstract class B
{
protected abstract void Foo();
}
class C : B
{
protected override void $$Foo() { }
}
</Code>
TestOverrideKind(code, EnvDTE80.vsCMOverrideKind.vsCMOverrideKindOverride)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub OverrideKind_New()
Dim code =
<Code>
abstract class B
{
protected void Foo();
}
class C : B
{
protected new void $$Foo() { }
}
</Code>
TestOverrideKind(code, EnvDTE80.vsCMOverrideKind.vsCMOverrideKindNew)
End Sub
#End Region
#Region "Prototype tests"
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Prototype_FullNameOnly()
Dim code =
<Code>
class A
{
internal static bool $$MethodC(int intA, bool boolB)
{
return boolB;
}
}
</Code>
TestPrototype(code, EnvDTE.vsCMPrototype.vsCMPrototypeFullname, "A.MethodC")
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Prototype_UniqueSignature()
Dim code =
<Code>
class A
{
internal static bool $$MethodC(int intA, bool boolB)
{
return boolB;
}
}
</Code>
TestPrototype(code, EnvDTE.vsCMPrototype.vsCMPrototypeUniqueSignature, "A.MethodC(int,bool)")
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Prototype_ParamTypesOnly()
Dim code =
<Code>
class A
{
internal static bool $$MethodC(int intA, bool boolB)
{
return boolB;
}
}
</Code>
TestPrototype(code, EnvDTE.vsCMPrototype.vsCMPrototypeParamTypes, "MethodC (int, bool)")
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Prototype_ParamNamesOnly()
Dim code =
<Code>
class A
{
internal static bool $$MethodC(int intA, bool boolB)
{
return boolB;
}
}
</Code>
TestPrototype(code, EnvDTE.vsCMPrototype.vsCMPrototypeParamNames, "MethodC (intA, boolB)")
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Prototype_ReturnType()
Dim code =
<Code>
class A
{
internal static bool $$MethodC(int intA, bool boolB)
{
return boolB;
}
}
</Code>
TestPrototype(code, EnvDTE.vsCMPrototype.vsCMPrototypeType, "bool MethodC")
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Prototype_ClassName1()
Dim code =
<Code>
class A
{
internal static bool $$MethodC(int intA, bool boolB)
{
return boolB;
}
}
</Code>
TestPrototype(code, EnvDTE.vsCMPrototype.vsCMPrototypeClassName, "A.MethodC")
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Prototype_ClassName2()
Dim code =
<Code>
class A<T>
{
internal static bool $$MethodC(int intA, bool boolB)
{
return boolB;
}
}
</Code>
TestPrototype(code, EnvDTE.vsCMPrototype.vsCMPrototypeClassName, "A<>.MethodC")
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Prototype_ClassName3()
Dim code =
<Code>
class C<T>
{
class A
{
internal static bool $$MethodC(int intA, bool boolB)
{
return boolB;
}
}
}
</Code>
TestPrototype(code, EnvDTE.vsCMPrototype.vsCMPrototypeClassName, "C<>.A.MethodC")
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Prototype_ClassName4()
Dim code =
<Code>
class C
{
class A<T>
{
internal static bool $$MethodC(int intA, bool boolB)
{
return boolB;
}
}
}
</Code>
TestPrototype(code, EnvDTE.vsCMPrototype.vsCMPrototypeClassName, "C.A<>.MethodC")
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Prototype_ClassName5()
Dim code =
<Code>
class C
{
class A
{
internal static bool $$MethodC(int intA, bool boolB)
{
return boolB;
}
}
}
</Code>
TestPrototype(code, EnvDTE.vsCMPrototype.vsCMPrototypeClassName, "C.A.MethodC")
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Prototype_ClassName6()
Dim code =
<Code>
namespace N
{
class A
{
internal static bool $$MethodC(int intA, bool boolB)
{
return boolB;
}
}
}
</Code>
TestPrototype(code, EnvDTE.vsCMPrototype.vsCMPrototypeClassName, "A.MethodC")
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Prototype_Constructor_Unique()
Dim code =
<Code>
class A
{
public $$A()
{
}
}
</Code>
TestPrototype(code, EnvDTE.vsCMPrototype.vsCMPrototypeUniqueSignature, "A.#ctor()")
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Prototype_Finalizer_Unique()
Dim code =
<Code>
class A
{
~A$$()
{
}
}
</Code>
TestPrototype(code, EnvDTE.vsCMPrototype.vsCMPrototypeUniqueSignature, "A.#dtor()")
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Prototype_Unique_InvalidCombination()
Dim code =
<Code>
class A
{
internal static bool $$MethodC(int intA, bool boolB)
{
return boolB;
}
}
</Code>
TestPrototypeThrows(Of ArgumentException)(code, EnvDTE.vsCMPrototype.vsCMPrototypeUniqueSignature Or EnvDTE.vsCMPrototype.vsCMPrototypeClassName)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Prototype_Constructor_FullName()
Dim code =
<Code>
class A
{
public A$$()
{
}
}
</Code>
TestPrototype(code, EnvDTE.vsCMPrototype.vsCMPrototypeFullname, "A.A")
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Prototype_Finalizer_FullName()
Dim code =
<Code>
class A
{
~A$$()
{
}
}
</Code>
TestPrototype(code, EnvDTE.vsCMPrototype.vsCMPrototypeFullname, "A.~A")
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Prototype_Operator_FullName()
Dim code =
<Code>
class A
{
public static A operator +$$(A a1, A a2)
{
return a1;
}
}
</Code>
TestPrototype(code, EnvDTE.vsCMPrototype.vsCMPrototypeFullname, "A.operator +")
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Prototype_Constructor_ReturnType()
Dim code =
<Code>
class A
{
public A$$()
{
}
}
</Code>
TestPrototype(code, EnvDTE.vsCMPrototype.vsCMPrototypeType, "void A")
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Prototype_Finalizer_ReturnType()
Dim code =
<Code>
class A
{
~A$$()
{
}
}
</Code>
TestPrototype(code, EnvDTE.vsCMPrototype.vsCMPrototypeType, "void ~A")
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Prototype_Operator_ReturnType()
Dim code =
<Code>
class A
{
public static A operator +$$(A a1, A a2)
{
return a1;
}
}
</Code>
TestPrototype(code, EnvDTE.vsCMPrototype.vsCMPrototypeType, "A operator +")
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Prototype_Constructor_ClassName()
Dim code =
<Code>
class A
{
public A$$()
{
}
}
</Code>
TestPrototype(code, EnvDTE.vsCMPrototype.vsCMPrototypeClassName, "A.A")
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Prototype_Finalizer_ClassName()
Dim code =
<Code>
class A
{
~A$$()
{
}
}
</Code>
TestPrototype(code, EnvDTE.vsCMPrototype.vsCMPrototypeClassName, "A.~A")
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Prototype_Operator_ClassName()
Dim code =
<Code>
class A
{
public static A operator +$$(A a1, A a2)
{
return a1;
}
}
</Code>
TestPrototype(code, EnvDTE.vsCMPrototype.vsCMPrototypeClassName, "A.operator +")
End Sub
#End Region
#Region "Type tests"
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Type_Constructor()
Dim code =
<Code>
class A
{
public $$A()
{
}
}
</Code>
TestTypeProp(code,
New CodeTypeRefData With
{
.AsFullName = "System.Void",
.AsString = "void",
.CodeTypeFullName = "System.Void",
.TypeKind = EnvDTE.vsCMTypeRef.vsCMTypeRefVoid
})
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Type_Finalizer()
Dim code =
<Code>
class A
{
$$~A()
{
}
}
</Code>
TestTypeProp(code,
New CodeTypeRefData With
{
.AsFullName = "System.Void",
.AsString = "void",
.CodeTypeFullName = "System.Void",
.TypeKind = EnvDTE.vsCMTypeRef.vsCMTypeRefVoid
})
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub Type_Operator()
Dim code =
<Code>
class A
{
public static A operator +$$(A a1, A a2)
{
return a1;
}
}
</Code>
TestTypeProp(code,
New CodeTypeRefData With
{
.AsFullName = "A",
.AsString = "A",
.CodeTypeFullName = "A",
.TypeKind = EnvDTE.vsCMTypeRef.vsCMTypeRefCodeType
})
End Sub
#End Region
#Region "RemoveParameter tests"
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub RemoveParameter1()
Dim code =
<Code>
class C
{
void $$M(int a) { }
}
</Code>
Dim expected =
<Code>
class C
{
void M() { }
}
</Code>
TestRemoveChild(code, expected, "a")
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub RemoveParameter2()
Dim code =
<Code>
class C
{
void $$M(int a, string b) { }
}
</Code>
Dim expected =
<Code>
class C
{
void M(int a) { }
}
</Code>
TestRemoveChild(code, expected, "b")
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub RemoveParameter3()
Dim code =
<Code>
class C
{
void $$M(int a, string b) { }
}
</Code>
Dim expected =
<Code>
class C
{
void M(string b) { }
}
</Code>
TestRemoveChild(code, expected, "a")
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub RemoveParameter4()
Dim code =
<Code>
class C
{
void $$M(int a, string b, int c) { }
}
</Code>
Dim expected =
<Code>
class C
{
void M(int a, int c) { }
}
</Code>
TestRemoveChild(code, expected, "b")
End Sub
#End Region
#Region "AddParameter tests"
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub AddParameter1()
Dim code =
<Code>
class C
{
void $$M() { }
}
</Code>
Dim expected =
<Code>
class C
{
void M(int a) { }
}
</Code>
TestAddParameter(code, expected, New ParameterData With {.Name = "a", .Type = "int"})
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub AddParameter2()
Dim code =
<Code>
class C
{
void $$M(int a) { }
}
</Code>
Dim expected =
<Code>
class C
{
void M(string b, int a) { }
}
</Code>
TestAddParameter(code, expected, New ParameterData With {.Name = "b", .Type = "string"})
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub AddParameter3()
Dim code =
<Code>
class C
{
void $$M(int a, string b) { }
}
</Code>
Dim expected =
<Code>
class C
{
void M(int a, bool c, string b) { }
}
</Code>
TestAddParameter(code, expected, New ParameterData With {.Name = "c", .Type = "System.Boolean", .Position = 1})
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub AddParameter4()
Dim code =
<Code>
class C
{
void $$M(int a) { }
}
</Code>
Dim expected =
<Code>
class C
{
void M(int a, string b) { }
}
</Code>
TestAddParameter(code, expected, New ParameterData With {.Name = "b", .Type = "string", .Position = -1})
End Sub
#End Region
#Region "Set Access tests"
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub SetAccess1()
Dim code =
<Code>
class C
{
int $$Foo()
{
throw new System.NotImplementedException();
}
}
</Code>
Dim expected =
<Code>
class C
{
public int Foo()
{
throw new System.NotImplementedException();
}
}
</Code>
TestSetAccess(code, expected, EnvDTE.vsCMAccess.vsCMAccessPublic)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub SetAccess2()
Dim code =
<Code>
class C
{
public int $$Foo()
{
throw new System.NotImplementedException();
}
}
</Code>
Dim expected =
<Code>
class C
{
internal int Foo()
{
throw new System.NotImplementedException();
}
}
</Code>
TestSetAccess(code, expected, EnvDTE.vsCMAccess.vsCMAccessProject)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub SetAccess3()
Dim code =
<Code>
class C
{
protected internal int $$Foo()
{
throw new System.NotImplementedException();
}
}
</Code>
Dim expected =
<Code>
class C
{
public int Foo()
{
throw new System.NotImplementedException();
}
}
</Code>
TestSetAccess(code, expected, EnvDTE.vsCMAccess.vsCMAccessPublic)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub SetAccess4()
Dim code =
<Code>
class C
{
public int $$Foo()
{
throw new System.NotImplementedException();
}
}
</Code>
Dim expected =
<Code>
class C
{
protected internal int Foo()
{
throw new System.NotImplementedException();
}
}
</Code>
TestSetAccess(code, expected, EnvDTE.vsCMAccess.vsCMAccessProjectOrProtected)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub SetAccess5()
Dim code =
<Code>
class C
{
public int $$Foo()
{
throw new System.NotImplementedException();
}
}
</Code>
Dim expected =
<Code>
class C
{
int Foo()
{
throw new System.NotImplementedException();
}
}
</Code>
TestSetAccess(code, expected, EnvDTE.vsCMAccess.vsCMAccessDefault)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub SetAccess6()
Dim code =
<Code>
interface I
{
int $$Foo();
}
</Code>
Dim expected =
<Code>
interface I
{
int Foo();
}
</Code>
TestSetAccess(code, expected, EnvDTE.vsCMAccess.vsCMAccessProtected, ThrowsArgumentException(Of EnvDTE.vsCMAccess)())
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub SetAccess7()
Dim code =
<Code>
interface I
{
int $$Foo();
}
</Code>
Dim expected =
<Code>
interface I
{
int Foo();
}
</Code>
TestSetAccess(code, expected, EnvDTE.vsCMAccess.vsCMAccessPublic)
End Sub
#End Region
#Region "Set IsShared tests"
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub SetIsShared1()
Dim code =
<Code>
class C
{
void $$Foo()
{
}
}
</Code>
Dim expected =
<Code>
class C
{
static void Foo()
{
}
}
</Code>
TestSetIsShared(code, expected, True)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub SetIsShared2()
Dim code =
<Code>
class C
{
static void $$Foo()
{
}
}
</Code>
Dim expected =
<Code>
class C
{
void Foo()
{
}
}
</Code>
TestSetIsShared(code, expected, False)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub SetIsShared3()
Dim code =
<Code>
class C
{
$$C()
{
}
}
</Code>
Dim expected =
<Code>
class C
{
static C()
{
}
}
</Code>
TestSetIsShared(code, expected, True)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub SetIsShared4()
Dim code =
<Code>
class C
{
static $$C()
{
}
}
</Code>
Dim expected =
<Code>
class C
{
C()
{
}
}
</Code>
TestSetIsShared(code, expected, False)
End Sub
#End Region
#Region "Set CanOverride tests"
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub SetCanOverride1()
Dim code =
<Code>
class C
{
void $$Foo()
{
}
}
</Code>
Dim expected =
<Code>
class C
{
virtual void Foo()
{
}
}
</Code>
TestSetCanOverride(code, expected, True)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub SetCanOverride2()
Dim code =
<Code>
class C
{
virtual void $$Foo()
{
}
}
</Code>
Dim expected =
<Code>
class C
{
virtual void Foo()
{
}
}
</Code>
TestSetCanOverride(code, expected, True)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub SetCanOverride3()
Dim code =
<Code>
class C
{
void $$Foo()
{
}
}
</Code>
Dim expected =
<Code>
class C
{
void Foo()
{
}
}
</Code>
TestSetCanOverride(code, expected, False)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub SetCanOverride4()
Dim code =
<Code>
class C
{
virtual void $$Foo()
{
}
}
</Code>
Dim expected =
<Code>
class C
{
void Foo()
{
}
}
</Code>
TestSetCanOverride(code, expected, False)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub SetCanOverride5()
Dim code =
<Code>
interface I
{
void $$Foo();
}
</Code>
Dim expected =
<Code>
interface I
{
void Foo();
}
</Code>
TestSetCanOverride(code, expected, True)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub SetCanOverride6()
Dim code =
<Code>
interface I
{
void $$Foo();
}
</Code>
Dim expected =
<Code>
interface I
{
void Foo();
}
</Code>
TestSetCanOverride(code, expected, False, ThrowsArgumentException(Of Boolean))
End Sub
#End Region
#Region "Set MustImplement tests"
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub SetMustImplement1()
Dim code =
<Code>
abstract class C
{
abstract void $$Foo()
{
}
}
</Code>
Dim expected =
<Code>
abstract class C
{
abstract void Foo();
}
</Code>
TestSetMustImplement(code, expected, True)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub SetMustImplement2()
Dim code =
<Code>
abstract class C
{
void $$Foo()
{
int i = 0;
}
}
</Code>
Dim expected =
<Code>
abstract class C
{
abstract void Foo()
{
int i = 0;
}
}
</Code>
TestSetMustImplement(code, expected, True)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub SetMustImplement3()
Dim code =
<Code>
abstract class C
{
abstract void $$Foo();
}
</Code>
Dim expected =
<Code>
abstract class C
{
void Foo()
{
}
}
</Code>
TestSetMustImplement(code, expected, False)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub SetMustImplement4()
Dim code =
<Code>
abstract class C
{
abstract void $$Foo();
}
</Code>
Dim expected =
<Code>
abstract class C
{
abstract void Foo();
}
</Code>
TestSetMustImplement(code, expected, True)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub SetMustImplement5()
Dim code =
<Code>
abstract class C
{
void $$Foo()
{
}
}
</Code>
Dim expected =
<Code>
abstract class C
{
void Foo()
{
}
}
</Code>
TestSetMustImplement(code, expected, False)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub SetMustImplement6()
Dim code =
<Code>
class C
{
void $$Foo()
{
}
}
</Code>
Dim expected =
<Code>
class C
{
void Foo()
{
}
}
</Code>
TestSetMustImplement(code, expected, True, ThrowsArgumentException(Of Boolean))
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub SetMustImplement7()
Dim code =
<Code>
class C
{
void $$Foo()
{
}
}
</Code>
Dim expected =
<Code>
class C
{
void Foo()
{
}
}
</Code>
TestSetMustImplement(code, expected, False)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub SetMustImplement8()
Dim code =
<Code>
interface I
{
void $$Foo()
{
}
}
</Code>
Dim expected =
<Code>
interface I
{
void Foo()
{
}
}
</Code>
TestSetMustImplement(code, expected, False, ThrowsArgumentException(Of Boolean))
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub SetMustImplement9()
Dim code =
<Code>
interface I
{
void $$Foo()
{
}
}
</Code>
Dim expected =
<Code>
interface I
{
void Foo()
{
}
}
</Code>
TestSetMustImplement(code, expected, True)
End Sub
#End Region
#Region "Set OverrideKind tests"
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub SetOverrideKind1()
Dim code =
<Code>
class C
{
void $$Foo()
{
}
}
</Code>
Dim expected =
<Code>
class C
{
virtual void Foo()
{
}
}
</Code>
TestSetOverrideKind(code, expected, EnvDTE80.vsCMOverrideKind.vsCMOverrideKindVirtual)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub SetOverrideKind2()
Dim code =
<Code>
class C
{
void $$Foo()
{
}
}
</Code>
Dim expected =
<Code>
class C
{
sealed void Foo()
{
}
}
</Code>
TestSetOverrideKind(code, expected, EnvDTE80.vsCMOverrideKind.vsCMOverrideKindSealed)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub SetOverrideKind3()
Dim code =
<Code>
abstract class C
{
void $$Foo()
{
}
}
</Code>
Dim expected =
<Code>
abstract class C
{
abstract void Foo();
}
</Code>
TestSetOverrideKind(code, expected, EnvDTE80.vsCMOverrideKind.vsCMOverrideKindAbstract)
End Sub
#End Region
#Region "Set Name tests"
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub SetName1()
Dim code =
<Code>
class C
{
void $$Foo()
{
}
}
</Code>
Dim expected =
<Code>
class C
{
void Bar()
{
}
}
</Code>
TestSetName(code, expected, "Bar", NoThrow(Of String)())
End Sub
#End Region
#Region "Set Type tests"
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub SetType1()
Dim code =
<Code>
class C
{
void $$Foo()
{
}
}
</Code>
Dim expected =
<Code>
class C
{
int Foo()
{
}
}
</Code>
TestSetTypeProp(code, expected, "System.Int32")
End Sub
#End Region
#Region "ExtensionMethodExtender"
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub ExtensionMethodExtender_IsExtension1()
Dim code =
<Code>
public static class C
{
public static void $$Foo(this C c)
{
}
}
</Code>
TestExtensionMethodExtender_IsExtension(code, True)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub ExtensionMethodExtender_IsExtension2()
Dim code =
<Code>
public static class C
{
public static void $$Foo(C c)
{
}
}
</Code>
TestExtensionMethodExtender_IsExtension(code, False)
End Sub
#End Region
#Region "PartialMethodExtender"
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub PartialMethodExtender_IsPartial1()
Dim code =
<Code>
public partial class C
{
partial void $$M();
partial void M()
{
}
void M(int i)
{
}
}
</Code>
TestPartialMethodExtender_IsPartial(code, True)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub PartialMethodExtender_IsPartial2()
Dim code =
<Code>
public partial class C
{
partial void M();
partial void $$M()
{
}
void M(int i)
{
}
}
</Code>
TestPartialMethodExtender_IsPartial(code, True)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub PartialMethodExtender_IsPartial3()
Dim code =
<Code>
public partial class C
{
partial void M();
partial void M()
{
}
void $$M(int i)
{
}
}
</Code>
TestPartialMethodExtender_IsPartial(code, False)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub PartialMethodExtender_IsDeclaration1()
Dim code =
<Code>
public partial class C
{
partial void $$M();
partial void M()
{
}
void M(int i)
{
}
}
</Code>
TestPartialMethodExtender_IsDeclaration(code, True)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub PartialMethodExtender_IsDeclaration2()
Dim code =
<Code>
public partial class C
{
partial void M();
partial void $$M()
{
}
void M(int i)
{
}
}
</Code>
TestPartialMethodExtender_IsDeclaration(code, False)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub PartialMethodExtender_IsDeclaration3()
Dim code =
<Code>
public partial class C
{
partial void M();
partial void M()
{
}
void $$M(int i)
{
}
}
</Code>
TestPartialMethodExtender_IsDeclaration(code, False)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub PartialMethodExtender_HasOtherPart1()
Dim code =
<Code>
public partial class C
{
partial void $$M();
partial void M()
{
}
void M(int i)
{
}
}
</Code>
TestPartialMethodExtender_HasOtherPart(code, True)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub PartialMethodExtender_HasOtherPart2()
Dim code =
<Code>
public partial class C
{
partial void M();
partial void $$M()
{
}
void M(int i)
{
}
}
</Code>
TestPartialMethodExtender_HasOtherPart(code, True)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub PartialMethodExtender_HasOtherPart3()
Dim code =
<Code>
public partial class C
{
partial void M();
partial void M()
{
}
void $$M(int i)
{
}
}
</Code>
TestPartialMethodExtender_HasOtherPart(code, False)
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub PartialMethodExtender_HasOtherPart4()
Dim code =
<Code>
public partial class C
{
partial void $$M();
}
</Code>
TestPartialMethodExtender_HasOtherPart(code, False)
End Sub
#End Region
#Region "Overloads Tests"
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub TestOverloads1()
Dim code =
<Code>
public static class C
{
public static void $$Foo()
{
}
public static void Foo(C c)
{
}
}
</Code>
TestOverloadsUniqueSignatures(code, "C.Foo()", "C.Foo(C)")
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub TestOverloads2()
Dim code =
<Code>
public static class C
{
public static void $$Foo()
{
}
}
</Code>
TestOverloadsUniqueSignatures(code, "C.Foo()")
End Sub
<ConditionalFact(GetType(x86)), Trait(Traits.Feature, Traits.Features.CodeModel)>
Sub TestOverloads3()
Dim code =
<Code>
class A
{
public static A operator +$$(A a1, A a2)
{
return a1;
}
}
</Code>
TestOverloadsUniqueSignatures(code, "A.#op_Plus(A,A)")
End Sub
#End Region
Private Function GetExtensionMethodExtender(codeElement As EnvDTE80.CodeFunction2) As ICSExtensionMethodExtender
Return CType(codeElement.Extender(ExtenderNames.ExtensionMethod), ICSExtensionMethodExtender)
End Function
Private Function GetPartialMethodExtender(codeElement As EnvDTE80.CodeFunction2) As ICSPartialMethodExtender
Return CType(codeElement.Extender(ExtenderNames.PartialMethod), ICSPartialMethodExtender)
End Function
Protected Overrides Function ExtensionMethodExtender_GetIsExtension(codeElement As EnvDTE80.CodeFunction2) As Boolean
Return GetExtensionMethodExtender(codeElement).IsExtension
End Function
Protected Overrides Function PartialMethodExtender_GetIsPartial(codeElement As EnvDTE80.CodeFunction2) As Boolean
Return GetPartialMethodExtender(codeElement).IsPartial
End Function
Protected Overrides Function PartialMethodExtender_GetIsDeclaration(codeElement As EnvDTE80.CodeFunction2) As Boolean
Return GetPartialMethodExtender(codeElement).IsDeclaration
End Function
Protected Overrides Function PartialMethodExtender_GetHasOtherPart(codeElement As EnvDTE80.CodeFunction2) As Boolean
Return GetPartialMethodExtender(codeElement).HasOtherPart
End Function
Protected Overrides ReadOnly Property LanguageName As String
Get
Return LanguageNames.CSharp
End Get
End Property
End Class
End Namespace
|
DavidKarlas/roslyn
|
src/VisualStudio/Core/Test/CodeModel/CSharp/CodeFunctionTests.vb
|
Visual Basic
|
apache-2.0
| 41,389
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports Microsoft.CodeAnalysis.Diagnostics
Imports Microsoft.CodeAnalysis.FxCopAnalyzers.Performance
Imports Microsoft.CodeAnalysis.FxCopAnalyzers.Utilities
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic.FxCopAnalyzers.Performance
<DiagnosticAnalyzer(LanguageNames.VisualBasic)>
Public Class BasicCA1821DiagnosticAnalyzer
Inherits CA1821DiagnosticAnalyzer(Of SyntaxKind)
Protected Overrides Function GetCodeBlockEndedAnalyzer() As AbstractCodeBlockEndedAnalyzer
Return New CodeBlockEndedAnalyzer()
End Function
Private NotInheritable Class CodeBlockEndedAnalyzer
Inherits AbstractCodeBlockEndedAnalyzer
Protected Overrides Function IsEmptyFinalizer(node As SyntaxNode, model As SemanticModel) As Boolean
Dim symbol = model.GetDeclaredSymbol(node)
Dim method As IMethodSymbol = TryCast(symbol, IMethodSymbol)
' First, validate the signature
If (symbol.IsStatic OrElse method.IsAbstract OrElse method.ReturnType.SpecialType <> SpecialType.System_Void OrElse
method.Parameters.Length > 0 OrElse Not CaseInsensitiveComparison.Equals(method.Name, "Finalize")) Then
Return False
End If
' Second, validate that the method overrides Object.Finalize
' Otherwise, it is not a genuine finalizer.
While Not (method.OverriddenMethod Is Nothing)
method = method.OverriddenMethod
End While
If method.ContainingType.SpecialType = SpecialType.System_Object Then
For Each exp In node.DescendantNodes(descendIntoTrivia:=False).OfType(Of StatementSyntax)() _
.Where(Function(n) Not n.IsKind(SyntaxKind.SubStatement) AndAlso Not n.IsKind(SyntaxKind.EndSubStatement))
' NOTE: FxCop only checks if there Is any method call within a given destructor to decide an empty finalizer.
' Here in order to minimize false negatives, we conservatively treat it as non-empty finalizer if its body contains any statements.
' But, still conditional methods Like Debug.Fail() will be considered as being empty as FxCop currently does.
' If a method has conditional attributes (e.g., Debug.Assert), Continue.
Dim stmt As ExpressionStatementSyntax = TryCast(exp, ExpressionStatementSyntax)
If stmt IsNot Nothing AndAlso HasConditionalAttribute(stmt.Expression, model) Then
Continue For
End If
' TODO: check if a method is reachable.
Return False
Next
Return True
End If
Return False
End Function
Protected Function HasConditionalAttribute(root As SyntaxNode, model As SemanticModel) As Boolean
Dim node = TryCast(root, InvocationExpressionSyntax)
If node IsNot Nothing Then
Dim exp = TryCast(node.Expression, MemberAccessExpressionSyntax)
If exp IsNot Nothing Then
Dim symbol = model.GetSymbolInfo(exp.Name).Symbol
If symbol IsNot Nothing AndAlso symbol.GetAttributes().Any(Function(n) n.AttributeClass.Equals(WellKnownTypes.ConditionalAttribute(model.Compilation))) Then
Return True
End If
End If
End If
Return False
End Function
End Class
End Class
End Namespace
|
wschae/roslyn
|
src/Diagnostics/FxCop/VisualBasic/Performance/BasicCA1821DiagnosticAnalyzer.vb
|
Visual Basic
|
apache-2.0
| 3,976
|
' Licensed to the .NET Foundation under one or more agreements.
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.
Imports System.Collections.Generic
Imports System.Collections.Immutable
Imports System.Threading
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.Collections
Imports Microsoft.CodeAnalysis.PooledObjects
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Partial Friend NotInheritable Class AnonymousTypeManager
Friend NotInheritable Class AnonymousDelegatePublicSymbol
Inherits AnonymousTypeOrDelegatePublicSymbol
Private ReadOnly _members As ImmutableArray(Of SynthesizedDelegateMethodSymbol)
Public Sub New(manager As AnonymousTypeManager, typeDescr As AnonymousTypeDescriptor)
MyBase.New(manager, typeDescr)
Debug.Assert(typeDescr.IsImplicitlyDeclared)
Debug.Assert(typeDescr.Parameters.Length > 0)
Debug.Assert(typeDescr.Parameters.Last().Name Is AnonymousTypeDescriptor.FunctionReturnParameterName OrElse
typeDescr.Parameters.Last().Name Is AnonymousTypeDescriptor.SubReturnParameterName)
Dim parameterDescriptors As ImmutableArray(Of AnonymousTypeField) = typeDescr.Parameters
Dim returnType As TypeSymbol = If(parameterDescriptors.IsSubDescription(), DirectCast(manager.System_Void, TypeSymbol), parameterDescriptors.Last.Type)
Dim parameters = ArrayBuilder(Of ParameterSymbol).GetInstance(parameterDescriptors.Length + 1)
Dim i As Integer
' A delegate has the following members: (see CLI spec 13.6)
' (1) a method named Invoke with the specified signature
Dim delegateInvoke = New SynthesizedDelegateMethodSymbol(WellKnownMemberNames.DelegateInvokeName,
Me,
SourceNamedTypeSymbol.DelegateCommonMethodFlags Or SourceMemberFlags.MethodKindDelegateInvoke,
returnType)
For i = 0 To parameterDescriptors.Length - 2
parameters.Add(ParameterFromField(delegateInvoke, parameterDescriptors(i), i))
Next
delegateInvoke.SetParameters(parameters.ToImmutable())
parameters.Clear()
' (2) a constructor with argument types (object, System.IntPtr)
Dim delegateCtor = New SynthesizedDelegateMethodSymbol(
WellKnownMemberNames.InstanceConstructorName, Me,
SourceNamedTypeSymbol.DelegateConstructorMethodFlags, manager.System_Void)
delegateCtor.SetParameters(
ImmutableArray.Create(Of ParameterSymbol)(
New SynthesizedParameterSymbol(delegateCtor, manager.System_Object, 0,
False, StringConstants.DelegateConstructorInstanceParameterName),
New SynthesizedParameterSymbol(delegateCtor, manager.System_IntPtr, 1,
False, StringConstants.DelegateConstructorMethodParameterName)
))
Dim delegateBeginInvoke As SynthesizedDelegateMethodSymbol
Dim delegateEndInvoke As SynthesizedDelegateMethodSymbol
' Don't add Begin/EndInvoke members to winmd compilations.
' Invoke must be the last member, regardless.
If Me.IsCompilationOutputWinMdObj() Then
delegateBeginInvoke = Nothing
delegateEndInvoke = Nothing
parameters.Free()
_members = ImmutableArray.Create(delegateCtor, delegateInvoke)
Else
' (3) BeginInvoke
delegateBeginInvoke = New SynthesizedDelegateMethodSymbol(
WellKnownMemberNames.DelegateBeginInvokeName, Me,
SourceNamedTypeSymbol.DelegateCommonMethodFlags Or SourceMemberFlags.MethodKindOrdinary,
manager.System_IAsyncResult)
For i = 0 To parameterDescriptors.Length - 2
parameters.Add(ParameterFromField(delegateBeginInvoke, parameterDescriptors(i), i))
Next
parameters.Add(New SynthesizedParameterSymbol(delegateBeginInvoke, manager.System_AsyncCallback, i,
False, StringConstants.DelegateMethodCallbackParameterName))
i += 1
parameters.Add(New SynthesizedParameterSymbol(delegateBeginInvoke, manager.System_Object, i,
False, StringConstants.DelegateMethodInstanceParameterName))
delegateBeginInvoke.SetParameters(parameters.ToImmutable())
parameters.Clear()
' and (4) EndInvoke methods
delegateEndInvoke = New SynthesizedDelegateMethodSymbol(
WellKnownMemberNames.DelegateEndInvokeName, Me,
SourceNamedTypeSymbol.DelegateCommonMethodFlags Or SourceMemberFlags.MethodKindOrdinary,
returnType)
Dim ordinal As Integer = 0
For i = 0 To parameterDescriptors.Length - 2
If parameterDescriptors(i).IsByRef Then
parameters.Add(ParameterFromField(delegateEndInvoke, parameterDescriptors(i), ordinal))
ordinal += 1
End If
Next
parameters.Add(New SynthesizedParameterSymbol(delegateEndInvoke, manager.System_IAsyncResult, ordinal,
False, StringConstants.DelegateMethodResultParameterName))
delegateEndInvoke.SetParameters(parameters.ToImmutableAndFree())
_members = ImmutableArray.Create(delegateCtor, delegateBeginInvoke, delegateEndInvoke, delegateInvoke)
End If
#If DEBUG Then
For Each m In _members
Debug.Assert(m IsNot Nothing)
Next
#End If
End Sub
Public Overrides ReadOnly Property TypeKind As TypeKind
Get
Return TypeKind.Delegate
End Get
End Property
Friend Overrides ReadOnly Property IsInterface As Boolean
Get
Return False
End Get
End Property
Private Shared Function ParameterFromField(container As SynthesizedDelegateMethodSymbol, field As AnonymousTypeField, ordinal As Integer) As ParameterSymbol
Return New SynthesizedParameterWithLocationSymbol(container, field.Type, ordinal, field.IsByRef, field.Name, field.Location)
End Function
Public Overrides Function GetMembers() As ImmutableArray(Of Symbol)
Return StaticCast(Of Symbol).From(_members)
End Function
Friend Overrides Function InternalSubstituteTypeParameters(substitution As TypeSubstitution) As TypeWithModifiers
Dim newDescriptor As New AnonymousTypeDescriptor
If Not Me.TypeDescriptor.SubstituteTypeParametersIfNeeded(substitution, newDescriptor) Then
Return New TypeWithModifiers(Me)
End If
Return New TypeWithModifiers(Me.Manager.ConstructAnonymousDelegateSymbol(newDescriptor))
End Function
Public Overrides Function MapToImplementationSymbol() As NamedTypeSymbol
Return Me.Manager.ConstructAnonymousDelegateImplementationSymbol(Me)
End Function
Friend Overrides Function MakeAcyclicBaseType(diagnostics As DiagnosticBag) As NamedTypeSymbol
Return Manager.System_MulticastDelegate
End Function
Friend Overrides Function MakeAcyclicInterfaces(diagnostics As DiagnosticBag) As ImmutableArray(Of NamedTypeSymbol)
Return ImmutableArray(Of NamedTypeSymbol).Empty
End Function
Public Overrides ReadOnly Property DelegateInvokeMethod As MethodSymbol
Get
' In both regular and winmd, the last member is invoke
Return _members(_members.Length - 1)
End Get
End Property
Public Overrides Function Equals(obj As Object) As Boolean
If Me Is obj Then
Return True
End If
Dim other = TryCast(obj, AnonymousDelegatePublicSymbol)
Return other IsNot Nothing AndAlso Me.TypeDescriptor.Equals(other.TypeDescriptor)
End Function
Public Overrides Function GetHashCode() As Integer
Return Me.TypeDescriptor.GetHashCode()
End Function
End Class
End Class
End Namespace
|
jmarolf/roslyn
|
src/Compilers/VisualBasic/Portable/Symbols/AnonymousTypes/PublicSymbols/AnonymousDelegate_TypePublicSymbol.vb
|
Visual Basic
|
mit
| 9,791
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports Microsoft.CodeAnalysis.Test.Utilities
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests.Semantics
Partial Public Class IOperationTests
Inherits SemanticModelTestBase
<CompilerTrait(CompilerFeature.IOperation)>
<Fact()>
Public Sub ILockStatement_ObjectLock_FieldReference()
Dim source = <![CDATA[
Option Strict On
Public Class C1
Dim o As New Object
Public Sub M1()
SyncLock o'BIND:"SyncLock o"
End SyncLock
End Sub
End Class]]>.Value
Dim expectedOperationTree = <![CDATA[
ILockOperation (OperationKind.Lock, Type: null) (Syntax: 'SyncLock o' ... nd SyncLock')
Expression:
IFieldReferenceOperation: C1.o As System.Object (OperationKind.FieldReference, Type: System.Object) (Syntax: 'o')
Instance Receiver:
IInstanceReferenceOperation (ReferenceKind: ContainingTypeInstance) (OperationKind.InstanceReference, Type: C1, IsImplicit) (Syntax: 'o')
Body:
IBlockOperation (0 statements) (OperationKind.Block, Type: null, IsImplicit) (Syntax: 'SyncLock o' ... nd SyncLock')
]]>.Value
Dim expectedDiagnostics = String.Empty
VerifyOperationTreeAndDiagnosticsForTest(Of SyncLockBlockSyntax)(source, expectedOperationTree, expectedDiagnostics)
End Sub
<CompilerTrait(CompilerFeature.IOperation)>
<Fact()>
Public Sub ILockStatement_ObjectLock_LocalReference()
Dim source = <![CDATA[
Option Strict On
Public Class C1
Public Sub M1()
Dim o As New Object
SyncLock o'BIND:"SyncLock o"
End SyncLock
End Sub
End Class]]>.Value
Dim expectedOperationTree = <![CDATA[
ILockOperation (OperationKind.Lock, Type: null) (Syntax: 'SyncLock o' ... nd SyncLock')
Expression:
ILocalReferenceOperation: o (OperationKind.LocalReference, Type: System.Object) (Syntax: 'o')
Body:
IBlockOperation (0 statements) (OperationKind.Block, Type: null, IsImplicit) (Syntax: 'SyncLock o' ... nd SyncLock')
]]>.Value
Dim expectedDiagnostics = String.Empty
VerifyOperationTreeAndDiagnosticsForTest(Of SyncLockBlockSyntax)(source, expectedOperationTree, expectedDiagnostics)
End Sub
<CompilerTrait(CompilerFeature.IOperation)>
<Fact()>
Public Sub ILockStatement_ObjectLock_Nothing()
Dim source = <![CDATA[
Option Strict On
Public Class C1
Public Sub M1()
Dim o As New Object
SyncLock o'BIND:"SyncLock o"
End SyncLock
End Sub
End Class]]>.Value
Dim expectedOperationTree = <![CDATA[
ILockOperation (OperationKind.Lock, Type: null) (Syntax: 'SyncLock o' ... nd SyncLock')
Expression:
ILocalReferenceOperation: o (OperationKind.LocalReference, Type: System.Object) (Syntax: 'o')
Body:
IBlockOperation (0 statements) (OperationKind.Block, Type: null, IsImplicit) (Syntax: 'SyncLock o' ... nd SyncLock')
]]>.Value
Dim expectedDiagnostics = String.Empty
VerifyOperationTreeAndDiagnosticsForTest(Of SyncLockBlockSyntax)(source, expectedOperationTree, expectedDiagnostics)
End Sub
<CompilerTrait(CompilerFeature.IOperation)>
<Fact()>
Public Sub ILockStatement_ObjectLock_NonReferenceType()
Dim source = <![CDATA[
Option Strict On
Public Class C1
Public Sub M1()
Dim i As Integer = 1
SyncLock i'BIND:"SyncLock i"
End SyncLock
End Sub
End Class]]>.Value
Dim expectedOperationTree = <![CDATA[
ILockOperation (OperationKind.Lock, Type: null, IsInvalid) (Syntax: 'SyncLock i' ... nd SyncLock')
Expression:
ILocalReferenceOperation: i (OperationKind.LocalReference, Type: System.Int32, IsInvalid) (Syntax: 'i')
Body:
IBlockOperation (0 statements) (OperationKind.Block, Type: null, IsInvalid, IsImplicit) (Syntax: 'SyncLock i' ... nd SyncLock')
]]>.Value
Dim expectedDiagnostics = <![CDATA[
BC30582: 'SyncLock' operand cannot be of type 'Integer' because 'Integer' is not a reference type.
SyncLock i'BIND:"SyncLock i"
~
]]>.Value
VerifyOperationTreeAndDiagnosticsForTest(Of SyncLockBlockSyntax)(source, expectedOperationTree, expectedDiagnostics)
End Sub
<CompilerTrait(CompilerFeature.IOperation)>
<Fact()>
Public Sub ILockStatement_MissingLockExpression()
Dim source = <![CDATA[
Option Strict On
Public Class C1
Public Sub M1()
SyncLock'BIND:"SyncLock"
End SyncLock
End Sub
End Class]]>.Value
Dim expectedOperationTree = <![CDATA[
ILockOperation (OperationKind.Lock, Type: null, IsInvalid) (Syntax: 'SyncLock'BI ... nd SyncLock')
Expression:
IInvalidOperation (OperationKind.Invalid, Type: null, IsInvalid) (Syntax: '')
Children(0)
Body:
IBlockOperation (0 statements) (OperationKind.Block, Type: null, IsInvalid, IsImplicit) (Syntax: 'SyncLock'BI ... nd SyncLock')
]]>.Value
Dim expectedDiagnostics = <![CDATA[
BC30201: Expression expected.
SyncLock'BIND:"SyncLock"
~
]]>.Value
VerifyOperationTreeAndDiagnosticsForTest(Of SyncLockBlockSyntax)(source, expectedOperationTree, expectedDiagnostics)
End Sub
<CompilerTrait(CompilerFeature.IOperation)>
<Fact()>
Public Sub ILockStatement_InvalidLockExpression()
Dim source = <![CDATA[
Option Strict On
Public Class C1
Public Sub M1()
SyncLock InvalidReference'BIND:"SyncLock InvalidReference"
End SyncLock
End Sub
End Class]]>.Value
Dim expectedOperationTree = <![CDATA[
ILockOperation (OperationKind.Lock, Type: null, IsInvalid) (Syntax: 'SyncLock In ... nd SyncLock')
Expression:
IInvalidOperation (OperationKind.Invalid, Type: ?, IsInvalid) (Syntax: 'InvalidReference')
Children(0)
Body:
IBlockOperation (0 statements) (OperationKind.Block, Type: null, IsInvalid, IsImplicit) (Syntax: 'SyncLock In ... nd SyncLock')
]]>.Value
Dim expectedDiagnostics = <![CDATA[
BC30451: 'InvalidReference' is not declared. It may be inaccessible due to its protection level.
SyncLock InvalidReference'BIND:"SyncLock InvalidReference"
~~~~~~~~~~~~~~~~
]]>.Value
VerifyOperationTreeAndDiagnosticsForTest(Of SyncLockBlockSyntax)(source, expectedOperationTree, expectedDiagnostics)
End Sub
<CompilerTrait(CompilerFeature.IOperation)>
<Fact()>
Public Sub ILockStatement_MissingEndLock()
Dim source = <![CDATA[
Option Strict On
Public Class C1
Public Sub M1()
Dim o As New Object
SyncLock o'BIND:"SyncLock o"
End Sub
End Class]]>.Value
Dim expectedOperationTree = <![CDATA[
ILockOperation (OperationKind.Lock, Type: null, IsInvalid) (Syntax: 'SyncLock o' ... SyncLock o"')
Expression:
ILocalReferenceOperation: o (OperationKind.LocalReference, Type: System.Object, IsInvalid) (Syntax: 'o')
Body:
IBlockOperation (0 statements) (OperationKind.Block, Type: null, IsInvalid, IsImplicit) (Syntax: 'SyncLock o' ... SyncLock o"')
]]>.Value
Dim expectedDiagnostics = <![CDATA[
BC30675: 'SyncLock' statement must end with a matching 'End SyncLock'.
SyncLock o'BIND:"SyncLock o"
~~~~~~~~~~
]]>.Value
VerifyOperationTreeAndDiagnosticsForTest(Of SyncLockBlockSyntax)(source, expectedOperationTree, expectedDiagnostics)
End Sub
<CompilerTrait(CompilerFeature.IOperation)>
<Fact()>
Public Sub ILockStatement_ExpressionBody_ObjectCall()
Dim source = <![CDATA[
Option Strict On
Public Class C1
Public Sub M1()
Dim o As New Object
SyncLock o.ToString()'BIND:"SyncLock o.ToString()"
End SyncLock
End Sub
End Class]]>.Value
Dim expectedOperationTree = <![CDATA[
ILockOperation (OperationKind.Lock, Type: null) (Syntax: 'SyncLock o. ... nd SyncLock')
Expression:
IInvocationOperation (virtual Function System.Object.ToString() As System.String) (OperationKind.Invocation, Type: System.String) (Syntax: 'o.ToString()')
Instance Receiver:
ILocalReferenceOperation: o (OperationKind.LocalReference, Type: System.Object) (Syntax: 'o')
Arguments(0)
Body:
IBlockOperation (0 statements) (OperationKind.Block, Type: null, IsImplicit) (Syntax: 'SyncLock o. ... nd SyncLock')
]]>.Value
Dim expectedDiagnostics = String.Empty
VerifyOperationTreeAndDiagnosticsForTest(Of SyncLockBlockSyntax)(source, expectedOperationTree, expectedDiagnostics)
End Sub
<CompilerTrait(CompilerFeature.IOperation)>
<Fact()>
Public Sub ILockStatement_ExpressionLock_ClassMethodCall()
Dim source = <![CDATA[
Option Strict On
Public Class C1
Public Sub M1()
SyncLock M2()'BIND:"SyncLock M2()"
End SyncLock
End Sub
Public Function M2() As Object
Return New Object
End Function
End Class]]>.Value
Dim expectedOperationTree = <![CDATA[
ILockOperation (OperationKind.Lock, Type: null) (Syntax: 'SyncLock M2 ... nd SyncLock')
Expression:
IInvocationOperation ( Function C1.M2() As System.Object) (OperationKind.Invocation, Type: System.Object) (Syntax: 'M2()')
Instance Receiver:
IInstanceReferenceOperation (ReferenceKind: ContainingTypeInstance) (OperationKind.InstanceReference, Type: C1, IsImplicit) (Syntax: 'M2')
Arguments(0)
Body:
IBlockOperation (0 statements) (OperationKind.Block, Type: null, IsImplicit) (Syntax: 'SyncLock M2 ... nd SyncLock')
]]>.Value
Dim expectedDiagnostics = String.Empty
VerifyOperationTreeAndDiagnosticsForTest(Of SyncLockBlockSyntax)(source, expectedOperationTree, expectedDiagnostics)
End Sub
<CompilerTrait(CompilerFeature.IOperation)>
<Fact()>
Public Sub ILockStatement_ExpressionBody_SubMethod()
Dim source = <![CDATA[
Option Strict On
Public Class C1
Public Sub M1()
SyncLock M2()'BIND:"SyncLock M2()"
End SyncLock
End Sub
Public Sub M2()
End Sub
End Class]]>.Value
Dim expectedOperationTree = <![CDATA[
ILockOperation (OperationKind.Lock, Type: null, IsInvalid) (Syntax: 'SyncLock M2 ... nd SyncLock')
Expression:
IInvalidOperation (OperationKind.Invalid, Type: ?, IsInvalid, IsImplicit) (Syntax: 'M2()')
Children(1):
IInvocationOperation ( Sub C1.M2()) (OperationKind.Invocation, Type: System.Void, IsInvalid) (Syntax: 'M2()')
Instance Receiver:
IInstanceReferenceOperation (ReferenceKind: ContainingTypeInstance) (OperationKind.InstanceReference, Type: C1, IsInvalid, IsImplicit) (Syntax: 'M2')
Arguments(0)
Body:
IBlockOperation (0 statements) (OperationKind.Block, Type: null, IsInvalid, IsImplicit) (Syntax: 'SyncLock M2 ... nd SyncLock')
]]>.Value
Dim expectedDiagnostics = <![CDATA[
BC30491: Expression does not produce a value.
SyncLock M2()'BIND:"SyncLock M2()"
~~~~
]]>.Value
VerifyOperationTreeAndDiagnosticsForTest(Of SyncLockBlockSyntax)(source, expectedOperationTree, expectedDiagnostics)
End Sub
<CompilerTrait(CompilerFeature.IOperation)>
<Fact()>
Public Sub ILockStatement_NonEmptyBody()
Dim source = <![CDATA[
Option Strict On
Imports System
Public Class C1
Public Sub M1()
Dim o As New Object
SyncLock o'BIND:"SyncLock o"
Console.WriteLine("Hello World!")
End SyncLock
End Sub
End Class]]>.Value
Dim expectedOperationTree = <![CDATA[
ILockOperation (OperationKind.Lock, Type: null) (Syntax: 'SyncLock o' ... nd SyncLock')
Expression:
ILocalReferenceOperation: o (OperationKind.LocalReference, Type: System.Object) (Syntax: 'o')
Body:
IBlockOperation (1 statements) (OperationKind.Block, Type: null, IsImplicit) (Syntax: 'SyncLock o' ... nd SyncLock')
IExpressionStatementOperation (OperationKind.ExpressionStatement, Type: null) (Syntax: 'Console.Wri ... lo World!")')
Expression:
IInvocationOperation (Sub System.Console.WriteLine(value As System.String)) (OperationKind.Invocation, Type: System.Void) (Syntax: 'Console.Wri ... lo World!")')
Instance Receiver:
null
Arguments(1):
IArgumentOperation (ArgumentKind.Explicit, Matching Parameter: value) (OperationKind.Argument, Type: null) (Syntax: '"Hello World!"')
ILiteralOperation (OperationKind.Literal, Type: System.String, Constant: "Hello World!") (Syntax: '"Hello World!"')
InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
]]>.Value
Dim expectedDiagnostics = String.Empty
VerifyOperationTreeAndDiagnosticsForTest(Of SyncLockBlockSyntax)(source, expectedOperationTree, expectedDiagnostics)
End Sub
<CompilerTrait(CompilerFeature.IOperation, CompilerFeature.Dataflow)>
<Fact()>
Public Sub LockFlow_04()
Dim source = <![CDATA[
Imports System
Public Class C
Sub M(input As Boolean) 'BIND:"Sub M"
SyncLock Nothing
input = true
End SyncLock
End Sub
End Class
]]>.Value
Dim expectedDiagnostics = String.Empty
Dim expectedFlowGraph = <![CDATA[
Block[B0] - Entry
Statements (0)
Next (Regular) Block[B1]
Entering: {R1}
.locals {R1}
{
Locals: [<anonymous local> As System.Boolean]
CaptureIds: [0]
Block[B1] - Block
Predecessors: [B0]
Statements (1)
IFlowCaptureOperation: 0 (OperationKind.FlowCapture, Type: null, IsImplicit) (Syntax: 'Nothing')
Value:
IConversionOperation (TryCast: False, Unchecked) (OperationKind.Conversion, Type: System.Object, Constant: null, IsImplicit) (Syntax: 'Nothing')
Conversion: CommonConversion (Exists: True, IsIdentity: False, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
(WideningNothingLiteral)
Operand:
ILiteralOperation (OperationKind.Literal, Type: null, Constant: null) (Syntax: 'Nothing')
Next (Regular) Block[B2]
Entering: {R2} {R3}
.try {R2, R3}
{
Block[B2] - Block
Predecessors: [B1]
Statements (2)
IInvocationOperation (Sub System.Threading.Monitor.Enter(obj As System.Object, ByRef lockTaken As System.Boolean)) (OperationKind.Invocation, Type: System.Void, IsImplicit) (Syntax: 'Nothing')
Instance Receiver:
null
Arguments(2):
IArgumentOperation (ArgumentKind.Explicit, Matching Parameter: obj) (OperationKind.Argument, Type: null, IsImplicit) (Syntax: 'Nothing')
IFlowCaptureReferenceOperation: 0 (OperationKind.FlowCaptureReference, Type: System.Object, Constant: null, IsImplicit) (Syntax: 'Nothing')
InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
IArgumentOperation (ArgumentKind.Explicit, Matching Parameter: lockTaken) (OperationKind.Argument, Type: null, IsImplicit) (Syntax: 'Nothing')
ILocalReferenceOperation: (IsDeclaration: True) (OperationKind.LocalReference, Type: System.Boolean, IsImplicit) (Syntax: 'Nothing')
InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
IExpressionStatementOperation (OperationKind.ExpressionStatement, Type: null) (Syntax: 'input = true')
Expression:
ISimpleAssignmentOperation (OperationKind.SimpleAssignment, Type: System.Boolean, IsImplicit) (Syntax: 'input = true')
Left:
IParameterReferenceOperation: input (OperationKind.ParameterReference, Type: System.Boolean) (Syntax: 'input')
Right:
ILiteralOperation (OperationKind.Literal, Type: System.Boolean, Constant: True) (Syntax: 'true')
Next (Regular) Block[B6]
Finalizing: {R4}
Leaving: {R3} {R2} {R1}
}
.finally {R4}
{
Block[B3] - Block
Predecessors (0)
Statements (0)
Jump if False (Regular) to Block[B5]
ILocalReferenceOperation: (OperationKind.LocalReference, Type: System.Boolean, IsImplicit) (Syntax: 'Nothing')
Next (Regular) Block[B4]
Block[B4] - Block
Predecessors: [B3]
Statements (1)
IInvocationOperation (Sub System.Threading.Monitor.Exit(obj As System.Object)) (OperationKind.Invocation, Type: System.Void, IsImplicit) (Syntax: 'Nothing')
Instance Receiver:
null
Arguments(1):
IArgumentOperation (ArgumentKind.Explicit, Matching Parameter: obj) (OperationKind.Argument, Type: null, IsImplicit) (Syntax: 'Nothing')
IFlowCaptureReferenceOperation: 0 (OperationKind.FlowCaptureReference, Type: System.Object, Constant: null, IsImplicit) (Syntax: 'Nothing')
InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
Next (Regular) Block[B5]
Block[B5] - Block
Predecessors: [B3] [B4]
Statements (0)
Next (StructuredExceptionHandling) Block[null]
}
}
Block[B6] - Exit
Predecessors: [B2]
Statements (0)
]]>.Value
VerifyFlowGraphAndDiagnosticsForTest(Of MethodBlockSyntax)(source, expectedFlowGraph, expectedDiagnostics)
End Sub
End Class
End Namespace
|
aelij/roslyn
|
src/Compilers/VisualBasic/Test/IOperation/IOperation/IOperationTests_ILockStatement.vb
|
Visual Basic
|
apache-2.0
| 19,134
|
Imports Microsoft.VisualBasic
Imports System.IO
Imports Aspose.Cells
Namespace Articles.ApplySuperscriptAndSubscript
Public Class SettingSuperscripteffect
Public Shared Sub Run()
' ExStart:1
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)
' Create directory if it is not already present.
Dim IsExists As Boolean = System.IO.Directory.Exists(dataDir)
If (Not IsExists) Then
System.IO.Directory.CreateDirectory(dataDir)
End If
' Instantiating a Workbook object
Dim workbook As New Workbook()
' Adding a new worksheet to the Excel object
workbook.Worksheets.Add()
' Obtaining the reference of the newly added worksheet by passing its sheet index
Dim worksheet As Worksheet = workbook.Worksheets(0)
' Accessing the "A1" cell from the worksheet
Dim cell As Cell = worksheet.Cells("A1")
' Adding some value to the "A1" cell
cell.PutValue("Hello")
' Setting the font Superscript
Dim style As Style = cell.GetStyle()
style.Font.IsSuperscript = True
cell.SetStyle(style)
' Saving the Excel file
workbook.Save(dataDir & "Superscript.output.xls", SaveFormat.Auto)
' ExEnd:1
End Sub
End Class
End Namespace
|
maria-shahid-aspose/Aspose.Cells-for-.NET
|
Examples/VisualBasic/Articles/ApplySuperscriptAndSubscript/SettingSuperscripteffect.vb
|
Visual Basic
|
mit
| 1,533
|
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.ctlCodeEditor = New T3000.NewEditor.T3000Editor()
Me.SuspendLayout()
'
'ctlCodeEditor
'
Me.ctlCodeEditor.Dock = System.Windows.Forms.DockStyle.Fill
Me.ctlCodeEditor.Location = New System.Drawing.Point(0, 0)
Me.ctlCodeEditor.Name = "ctlCodeEditor"
Me.ctlCodeEditor.Size = New System.Drawing.Size(579, 365)
Me.ctlCodeEditor.TabIndex = 0
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(579, 365)
Me.Controls.Add(Me.ctlCodeEditor)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
Friend WithEvents ctlCodeEditor As T3000.NewEditor.T3000Editor
End Class
|
temcocontrols/T3000_CrossPlatform
|
T3000 New Editor/TestControls/Form1.Designer.vb
|
Visual Basic
|
mit
| 1,755
|
''' <summary>
''' A gallery of only videos.
''' </summary>
''' <remarks></remarks>
#If DEBUG Then
Public Class DTIVideoGallery
Inherits DTISlideGallery
#Else
<ComponentModel.EditorBrowsable(ComponentModel.EditorBrowsableState.Never), ComponentModel.ToolboxItem(False)> _
Public Class DTIVideoGallery
Inherits DTISlideGallery
#End If
Private Sub DTIImageGallery_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
mediaSearcher.Content_Types.Add("Video")
End Sub
Private Sub DTIVideoGallery_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
addUploadLink("Upload Videos", "~/res/DTIGallery/UploadFiles.aspx?f=video")
End Sub
End Class
|
Micmaz/DTIControls
|
DTIContentManagement/DTIGalleryControl/DTIGalleryControl/DTIVideoGallery.vb
|
Visual Basic
|
mit
| 771
|
Imports System.Data.SqlClient
Imports System.Net.Mail
Imports System
Imports System.IO
Partial Class MyProfileTest
Inherits System.Web.UI.Page
Public Const EMAIL_SERVER As String = "relay-hosting.secureserver.net"
Public personID As String = "0"
Private userName, userName1, userName2, userName3 As String
Private FNAME As String
Private LNAME As String
Private strEmail As String
Private firstContactID As Integer = 0
Private strGender As String
Private strTshirt As String
Private strNAGVA As String
Private strPhone1 As String
Private strPhone2 As String
Private strPhone3 As String
Private strBirthDate As String
Private strADDRESS_LINE1 As String
Private strADDRESS_LINE2 As String
Private strCITY As String
Private strSTATE As String
Private strZIP As String
Private strEMERGENCY_FIRST_NAME As String
Private strEMERGENCY_LAST_NAME As String
Private strEMERGENCY_PHONE As String
Private strSUPPRESS_EMAIL_IND As String
Private strSUPPRESS_SNAIL_MAIL_IND As String
Private strSUPPRESS_LAST_NAME_IND As String
'Private strPassword1 As String
'Private strPassword2 As String
'Private securityQuestion As Integer
'Private securityAnswer As String
Private SQL As String
Private connStr As String = ConfigurationManager.AppSettings("ConnectionString")
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Response.Cache.SetCacheability(HttpCacheability.NoCache)
'Dim myString As String
If Not (Session("PERSON_ID") Is Nothing) Then
personID = Session("PERSON_ID").ToString
Else
personID = "0"
End If
If personID = "0" Then
Response.Redirect("Login.aspx?timeout=true")
Exit Sub
End If
''Response.Write(myString)
If Not IsPostBack Then
Dim cn As SqlConnection
Dim rs As SqlCommand
Dim rsReply As SqlDataReader
cn = New SqlConnection
cn.ConnectionString = connStr
cn.Open()
'get information for this PERSON_ID
SQL = "SELECT *,IsNull([2ND_PHONE_NUM],'') as 'PHONE2', " _
& "IsNull([3RD_PHONE_NUM],'') as 'PHONE3', " _
& "IsNull(ADDRESS_LINE1,'') as 'ADD_LINE1', " _
& "IsNull(ADDRESS_LINE2,'') as 'ADD_LINE2', " _
& "IsNull(CITY,'') as 'vCITY', " _
& "IsNull(ZIP,'') as 'vZIP', " _
& "IsNull(STATE,'') as 'vSTATE', " _
& "IsNull(EMERGENCY_FIRST_NAME,'') as 'vEMER_FNAME', " _
& "IsNull(EMERGENCY_LAST_NAME,'') as 'vEMER_LNAME', " _
& "IsNull(EMERGENCY_PHONE,'') as 'vEMER_PHONE', " _
& "IsNull(NAGVA_RATING,'') as 'vNAGVA', " _
& "IsNull(TSHIRT_SIZE,'') as 'vTSHIRT' " _
& "FROM db_accessadmin.[PERSON_TBL] " _
& "WHERE PERSON_ID = '" & Me.personID & "'"
'Response.Write(SQL)
'Response.End()
rs = New SqlCommand(SQL, cn)
rsReply = rs.ExecuteReader
If rsReply.Read Then
'fill data fields
Me.FIRST_NAME.Text = rsReply("FIRST_NAME")
Me.LAST_NAME.Text = rsReply("LAST_NAME")
Me.EMAIL.Text = rsReply("EMAIL")
Me.BIRTH_DATE.Text = Replace(rsReply("BIRTH_DATE"), "1/1/1900", "")
Me.GENDER.SelectedValue = rsReply("GENDER")
Me.PRIMARY_PHONE_NUM.Text = rsReply("PRIMARY_PHONE_NUM")
Me.PHONE2.Text = rsReply("PHONE2")
Me.PHONE3.Text = rsReply("PHONE3")
Me.ADDRESS_LINE1.Text = rsReply("ADD_LINE1")
Me.ADDRESS_LINE2.Text = rsReply("ADD_LINE2")
Me.CITY.Text = rsReply("vCITY")
Me.STATE.SelectedValue = rsReply("vSTATE")
Me.ZIP.Text = rsReply("vZIP")
Me.EMERGENCY_FIRST_NAME.Text = rsReply("vEMER_FNAME")
Me.EMERGENCY_LAST_NAME.Text = rsReply("vEMER_LNAME")
Me.EMERGENCY_PHONE.Text = rsReply("vEMER_PHONE")
Me.SUPPRESS_EMAIL_IND.SelectedValue = rsReply("SUPPRESS_EMAIL_IND")
Me.SUPPRESS_SNAIL_MAIL_IND.SelectedValue = rsReply("SUPPRESS_SNAIL_MAIL_IND")
Me.SUPPRESS_LAST_NAME_IND.SelectedValue = rsReply("SUPPRESS_LAST_NAME_IND")
Me.FIRST_CONTACT_ID.SelectedValue = rsReply("FIRST_CONTACT_ID")
'Me.PHOTO_FILENAME.Text = rsReply("FIRST_NAME")
Me.NAGVA_RATING.Text = rsReply("vNAGVA")
Me.TSHIRT_SIZE.SelectedValue = rsReply("vTSHIRT")
Else
'redirect out of this area
End If
rsReply.Close()
'see if there is an image for this user
getImage()
End If
End Sub
Public Sub getImage()
'check for image file
Dim imgPath As String = Request.ServerVariables("APPL_PHYSICAL_PATH") & "personnel_images\"
Dim str As String
Dim imgFound As Boolean = False
For Each str In Directory.GetFiles(imgPath, Session("PERSON_ID").ToString + "_*")
Me.imgFile.ImageUrl = "http://cgva.org/personnel_images/" + Path.GetFileName(str)
Me.imgFile.Width = 200
'Response.Write(Me.imgFile.ImageUrl & "<br />")
imgFound = True
Exit For
Next
If Not imgFound Then
'Me.lblImage.Text = ""
Me.lblImageFound.Text = "NO"
Me.imgFile.Visible = False
Else
Me.lblImageFound.Text = ""
Me.imgFile.Visible = True
End If
End Sub
Public Sub removeImage()
'check for image file
Dim imgPath As String = Request.ServerVariables("APPL_PHYSICAL_PATH") & "personnel_images\"
Dim str As String
Dim imgFound As Boolean = False
For Each str In Directory.GetFiles(imgPath, Session("PERSON_ID").ToString + "_*")
'Response.Write(Request.ServerVariables("APPL_PHYSICAL_PATH") & "personnel_images\" & str)
Try
System.IO.File.Delete(str)
Catch ex As Exception
'Response.Write(ex.Message & "-" & str & "<br />")
End Try
Next
'If Not imgFound Then
'Me.lblImage.Text = ""
'Me.imgFile.Visible = False
'End If
End Sub
Public Function CheckNull(ByVal fieldValue As String) As String
If fieldValue.Equals(DBNull.Value) Then
Return ""
Else
Return fieldValue
End If
End Function
Public Shared Function isEmail(ByVal inputEmail As String) As Boolean
Dim strRegex As String = "^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" & "\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" & ".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"
Dim re As New Regex(strRegex)
If re.IsMatch(inputEmail) Then
Return (True)
Else
Return (False)
End If
End Function
Protected Sub submitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submitButton.Click
If Not Page.IsValid Then
Me.messageLabel.Text = "There is an error on the page."
Exit Sub
Else
Me.messageLabel.Text = ""
End If
FNAME = Trim(Me.FIRST_NAME.Text)
LNAME = Trim(Me.LAST_NAME.Text)
strEmail = Trim(Me.EMAIL.Text)
firstContactID = Me.FIRST_CONTACT_ID.SelectedValue
strGender = Me.GENDER.SelectedValue
strTshirt = Me.TSHIRT_SIZE.SelectedValue
strNAGVA = Me.NAGVA_RATING.Text
strPhone1 = Trim(Me.PRIMARY_PHONE_NUM.Text)
strPhone2 = Trim(Me.PHONE2.Text)
strPhone3 = Trim(Me.PHONE3.Text)
strBirthDate = Trim(Me.BIRTH_DATE.Text)
strADDRESS_LINE1 = Trim(Me.ADDRESS_LINE1.Text)
strADDRESS_LINE2 = Trim(Me.ADDRESS_LINE2.Text)
strCITY = Trim(Me.CITY.Text)
strSTATE = Me.STATE.SelectedValue
strZIP = Trim(Me.ZIP.Text)
strEMERGENCY_FIRST_NAME = Trim(Me.EMERGENCY_FIRST_NAME.Text)
strEMERGENCY_LAST_NAME = Trim(Me.EMERGENCY_LAST_NAME.Text)
strEMERGENCY_PHONE = Trim(Me.EMERGENCY_PHONE.Text)
strSUPPRESS_EMAIL_IND = Trim(Me.SUPPRESS_EMAIL_IND.SelectedValue)
strSUPPRESS_SNAIL_MAIL_IND = Trim(Me.SUPPRESS_SNAIL_MAIL_IND.SelectedValue)
strSUPPRESS_LAST_NAME_IND = Trim(Me.SUPPRESS_LAST_NAME_IND.SelectedValue)
'strPassword1 = Trim(Me.PASSWORD1.Text)
'strPassword2 = Trim(Me.PASSWORD2.Text)
'securityQuestion = Me.SECURITY_QUESTION.SelectedValue
'securityAnswer = Trim(Me.SECURITY_ANSWER.Text)
If FNAME = "" Then
Me.messageLabel.Text = "Please enter your first name."
Exit Sub
ElseIf LNAME = "" Then
Me.messageLabel.Text = "Please enter your last name."
Exit Sub
ElseIf strEmail = "" Then
Me.messageLabel.Text = "Please enter your email address."
Exit Sub
ElseIf Not isEmail(strEmail) Then
Me.messageLabel.Text = "The email address entered is not valid."
Exit Sub
ElseIf firstContactID = 0 Then
Me.messageLabel.Text = "Please enter how you first heard about CGVA."
Exit Sub
Else
Dim cn As SqlConnection
Dim rs As SqlCommand
'Dim rsReply As SqlDataReader
cn = New SqlConnection
cn.ConnectionString = connStr
cn.Open()
SQL = "UPDATE db_accessadmin.[PERSON_TBL] " _
& "SET FIRST_NAME='" & Me.FNAME & "', " _
& "LAST_NAME='" & Me.LNAME & "', " _
& "EMAIL='" & Me.strEmail & "', " _
& "FIRST_CONTACT_ID='" & Me.firstContactID.ToString & "', " _
& "GENDER='" & Me.strGender & "', " _
& "BIRTH_DATE='" & Me.strBirthDate & "', " _
& "TSHIRT_SIZE='" & Me.strTshirt & "', " _
& "NAGVA_RATING='" & Me.strNAGVA & "', " _
& "PRIMARY_PHONE_NUM='" & Me.strPhone1 & "', " _
& "[2ND_PHONE_NUM]='" & Me.strPhone2 & "', " _
& "[3RD_PHONE_NUM]='" & Me.strPhone3 & "', " _
& "ADDRESS_LINE1='" & Me.strADDRESS_LINE1 & "', " _
& "ADDRESS_LINE2='" & Me.strADDRESS_LINE2 & "', " _
& "CITY = '" & Me.strCITY & "', " _
& "STATE='" & Me.strSTATE & "', " _
& "ZIP='" & Me.strZIP & "', " _
& "EMERGENCY_FIRST_NAME='" & Me.strEMERGENCY_FIRST_NAME & "', " _
& "EMERGENCY_LAST_NAME='" & Me.strEMERGENCY_LAST_NAME & "', " _
& "EMERGENCY_PHONE='" & Me.strEMERGENCY_PHONE & "', " _
& "SUPPRESS_EMAIL_IND='" & Me.strSUPPRESS_EMAIL_IND & "', " _
& "SUPPRESS_SNAIL_MAIL_IND='" & Me.strSUPPRESS_SNAIL_MAIL_IND & "', " _
& "SUPPRESS_LAST_NAME_IND='" & Me.strSUPPRESS_LAST_NAME_IND & "' " _
& "WHERE PERSON_ID='" & Me.personID & "'"
'Response.Write(SQL)
rs = New SqlCommand(SQL, cn)
rs.ExecuteNonQuery()
Try
'upload new image
Dim sFileDir As String = Request.ServerVariables("APPL_PHYSICAL_PATH") & "personnel_images\"
'picture to upload?
If (Not PHOTO_NAME.PostedFile Is Nothing) _
And (PHOTO_NAME.PostedFile.ContentLength > 0) Then
'get rid of old image first
removeImage()
'determine file name
Dim sFileName As String = _
System.IO.Path.GetFileName(PHOTO_NAME.PostedFile.FileName)
System.IO.Path.GetFileName(PHOTO_NAME.PostedFile.FileName)
'save file on disk
PHOTO_NAME.PostedFile.SaveAs(sFileDir + Session("PERSON_ID").ToString + "_" + sFileName)
Me.lblImageFound.Text = "Yes"
Me.imgFile.Visible = False
'show new image
'getImage()
End If
Catch ex As Exception
Me.messageLabel.Text = ex.StackTrace + "The image file you attempted to upload was not valid.<br />Please contact support@cgva.org for assistance with this issue."
Exit Sub
End Try
Me.messageLabel.Text = "<font class='cfontSuccess10'>Your profile information has been updated successfully.</font>"
End If
End Sub
End Class
|
CGVA/cgva_asp_website
|
MyCGVA/MyProfileTest.aspx.vb
|
Visual Basic
|
apache-2.0
| 13,143
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports Roslyn.Test.Utilities
Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests
Partial Public Class FlowAnalysisTests
Inherits FlowTestBase
<Fact()>
Public Sub NullArgsToFlowAnalysisMethods()
Dim compilation = CreateCompilationWithMscorlib40(
<compilation name="TestEntryPoints01">
<file name="a.b">
class C
public sub F()
end sub
end class
</file>
</compilation>)
Dim semanticModel = compilation.GetSemanticModel(compilation.SyntaxTrees(0))
Dim statement = compilation.SyntaxTrees(0).GetCompilationUnitRoot().DescendantNodesAndSelf().OfType(Of StatementSyntax)().First()
Assert.Throws(Of ArgumentNullException)(Sub() semanticModel.AnalyzeControlFlow(statement, Nothing))
Assert.Throws(Of ArgumentNullException)(Sub() semanticModel.AnalyzeControlFlow(Nothing, statement))
Assert.Throws(Of ArgumentNullException)(Sub() semanticModel.AnalyzeDataFlow(statement, Nothing))
Assert.Throws(Of ArgumentNullException)(Sub() semanticModel.AnalyzeDataFlow(Nothing, statement))
Assert.Throws(Of ArgumentNullException)(Sub() semanticModel.AnalyzeDataFlow(CType(Nothing, ExecutableStatementSyntax)))
End Sub
<Fact()>
Public Sub TestEntryPoints01()
Dim analysis = CompileAndAnalyzeControlFlow(
<compilation name="TestEntryPoints01">
<file name="a.b">
class C
public sub F()
goto L1 ' 1
[|
L1:
|]
goto L1 ' 2
end sub
end class
</file>
</compilation>)
Assert.Equal(1, analysis.EntryPoints.Count())
End Sub
<Fact()>
Public Sub ByRefExtensionMethod()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.b">
Option Strict Off
Imports System
Imports System.Threading
Imports System.Threading.Tasks
Imports System.Runtime.CompilerServices
Module Module1
Public Sub Main(args As String())
Dim s As String = "b"
[|s.EM()|]
Console.Write(s)
End Sub
<Extension()>
Public Sub EM(ByRef c As String)
c = "a"
End Sub
End Module
Public Class Clazz
End Class
</file>
</compilation>)
Assert.True(analysis.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.AlwaysAssigned))
Assert.Equal("s", GetSymbolNamesJoined(analysis.DataFlowsIn))
Assert.Equal("s", GetSymbolNamesJoined(analysis.DataFlowsOut))
Assert.Equal("args, s", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("args, s", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
Assert.Equal("s", GetSymbolNamesJoined(analysis.ReadInside))
Assert.Equal("s", GetSymbolNamesJoined(analysis.WrittenInside))
End Sub
<WorkItem(768095, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/768095")>
<Fact()>
Public Sub Bug768095()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.b">
Public Class RichTextBox2
Private Sub UndoRestorableItem(ByVal restorableItem As RestorableItem)
With [|restorableItem|]
End With
End Sub
Private Structure RestorableItem
Public Property EditType As String
Public Property Position As Integer
Public Property Text As String
End Structure
End Class
</file>
</compilation>)
Assert.False(analysis.Succeeded)
End Sub
<WorkItem(531223, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/531223")>
<Fact()>
Public Sub Bug17780a()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.b">
Class Test
Public Shared Sub Main()
On Error GoTo [| 0 |]
End Sub
End Class
</file>
</compilation>)
Assert.False(analysis.Succeeded)
End Sub
<WorkItem(531223, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/531223")>
<Fact()>
Public Sub Bug17780b()
' TODO: Rewrite the test when Yield is supported
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.b">
Imports System
Imports System.Collections.Generic
Friend Class SourceFileScope
Public Iterator Function GetTypesToSearchIn() As IEnumerable(Of Object)
Yield [| Nothing |]
End Function
End Class
</file>
</compilation>)
Assert.True(analysis.Succeeded)
End Sub
<WorkItem(543362, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543362")>
<Fact()>
Public Sub Bug11067()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="Bug11067">
<file name="a.b">
Class Test
Public Shared Sub Main()
Dim y(,) = New Integer(,) {{[|From|]}}
End Sub
End Class
</file>
</compilation>)
Assert.True(analysis.Succeeded)
End Sub
<WorkItem(529967, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/529967")>
<Fact()>
Public Sub Bug14894a()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.b">
Imports System
Module Program
Sub Main(args As String())
Dim o3 As Object = "hi"
[| Dim col1 = {o3, o3} |]
End Sub
End Module
</file>
</compilation>)
Assert.True(analysis.Succeeded)
Assert.Equal("o3", GetSymbolNamesJoined(analysis.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.ReadOutside))
Assert.Equal("args, o3", GetSymbolNamesJoined(analysis.WrittenOutside))
Assert.Equal("col1", GetSymbolNamesJoined(analysis.WrittenInside))
Assert.Equal("o3", GetSymbolNamesJoined(analysis.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DataFlowsOut))
Assert.Equal("args, o3", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("args, o3, col1", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
End Sub
<WorkItem(529967, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/529967")>
<Fact()>
Public Sub Bug14894b()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.b">
Imports System
Module Program
Sub Main(args As String())
Dim o3 As Object = "hi"
Dim col1 = [| {o3, o3} |]
End Sub
End Module
</file>
</compilation>)
Assert.True(analysis.Succeeded)
Assert.Equal("o3", GetSymbolNamesJoined(analysis.DataFlowsIn))
Assert.Equal("args, o3", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("args, o3", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
End Sub
<WorkItem(544602, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544602")>
<Fact()>
Public Sub Bug13053a()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="Bug13053a">
<file name="a.b">
Class Test
Public Shared Sub Main()
Dim i As Integer = 1
Dim o = New MyObject With { .A = [| i |] }
End Sub
End Class
</file>
</compilation>)
Assert.True(analysis.Succeeded)
End Sub
<WorkItem(545069, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545069")>
<Fact()>
Public Sub ParameterNameAsAnInvalidRegion()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="ParameterNameAsAnInvalidRegion">
<file name="a.b">
Module Module1
Sub S(par As Integer)
S([| par |]:=12)
End Sub
End Module
</file>
</compilation>)
Assert.False(analysis.Succeeded)
End Sub
<WorkItem(545443, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545443")>
<Fact()>
Public Sub XmlNameInsideEndTag()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="XmlNameInsideEndTag">
<file name="a.b">
Module Module1
Sub S(par As Integer)
Dim a = <tag> </ [| tag |] >
End Sub
End Module
</file>
</compilation>)
Assert.False(analysis.Succeeded)
End Sub
<WorkItem(545077, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545077")>
<Fact()>
Public Sub ExpressionsInAttributeValues()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="ExpressionsInAttributeValues">
<file name="a.b">
Imports System
Imports System.Reflection
<Assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute([| "Microsoft.CodeAnalysis.Workspaces, PublicKey=002400000480000094000000060200000024000052534131000400"& _
"000100010055e0217eb635f69281051f9a823e0c7edd90f28063eb6c7a742a19b4f6139778ee0af4"& _
"38f47aed3b6e9f99838aa8dba689c7a71ddb860c96d923830b57bbd5cd6119406ddb9b002cf1c723"& _
"bf272d6acbb7129e9d6dd5a5309c94e0ff4b2c884d45a55f475cd7dba59198086f61f5a8c8b5e601"& _
"c0edbf269733f6f578fc8579c2" |])>
</file>
</compilation>)
Assert.False(analysis.Succeeded)
End Sub
<WorkItem(545077, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545077")>
<Fact()>
Public Sub ExpressionsInAttributeValues2()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="ExpressionsInAttributeValues2">
<file name="a.b">
Imports System
Imports System.Reflection
Public Class MyAttribute
Public Sub New(p As Object)
End Sub
End Class
<MyAttribute(p:=Sub()
[|Dim a As Integer = 1
While a < 110
a += 1
End While|]
End Sub)>
Module Program
Sub Main(args As String())
End Sub
End Module
</file>
</compilation>)
Assert.False(analysis.Succeeded)
End Sub
<Fact()>
Public Sub OptionalParameterDefaultValue()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="OptionalParameterDefaultValue">
<file name="a.b">
Class Test
Public Shared Sub S(Optional x As Integer = [| 1 |])
End Sub
End Class
</file>
</compilation>)
Assert.False(analysis.Succeeded)
End Sub
<WorkItem(545432, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545432")>
<Fact()>
Public Sub LowerBoundOfArrayDefinitionSize()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="LowerBoundOfArrayDefinitionSize">
<file name="a.b">
Class Test
Public Shared Sub S(x As Integer)
Dim newTypeArguments([|0|] To x - 1) As String
End Sub
End Class
</file>
</compilation>)
Assert.False(analysis.Succeeded)
End Sub
<WorkItem(544602, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544602")>
<Fact()>
Public Sub Bug13053b()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="Bug13053b">
<file name="a.b">
Imports System
Class Test
Public Shared Sub Main()
Console.Write(GetXmlNamespace([| ns |]))
End Sub
End Class
</file>
</compilation>)
Assert.True(analysis.Succeeded)
End Sub
<WorkItem(679765, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/679765")>
<Fact()>
Public Sub Bug679765a()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="Bug13053b">
<file name="a.b">
Imports System
Class Test
Public Shared Sub Main()
Console.Write([| "A" |] + "B" + "C" + "D")
End Sub
End Class
</file>
</compilation>)
Assert.True(analysis.Succeeded)
End Sub
<WorkItem(679765, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/679765")>
<Fact()>
Public Sub Bug679765b()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="Bug13053b">
<file name="a.b">
Imports System
Class Test
Public Shared Sub Main()
Console.Write([| "A" + "B" + "C" + "D" |] )
End Sub
End Class
</file>
</compilation>)
Assert.True(analysis.Succeeded)
End Sub
<WorkItem(679765, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/679765")>
<Fact()>
Public Sub Bug679765c()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="Bug13053b">
<file name="a.b">
Imports System
Class Test
Public Shared Sub Main()
Console.Write([| "A" + "B" + "C" |] + "D" )
End Sub
End Class
</file>
</compilation>)
Assert.True(analysis.Succeeded)
End Sub
<WorkItem(543570, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543570")>
<Fact()>
Public Sub Bug11428()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="Bug11428">
<file name="a.b">
Module Program
Sub Main(args As String())
End Sub
End Module
Class C
Public Sub Goo()
End Sub
End Class
Class M
Inherits C
Public r As Double
Public Overrides Sub Goo()
Return [|MyBase.Total|] * r
End Sub
End Class
</file>
</compilation>)
Assert.True(analysis.Succeeded)
End Sub
<WorkItem(543581, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543581")>
<Fact()>
Public Sub Bug11440a()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="Bug11440">
<file name="a.b">
Imports System
Module Program
Sub Main(args As String())
Dim lambda = Function(ByRef arg As Integer)
Return Function(ByRef arg1 As Integer)
GoTo Label
Dim arg2 As Integer = 2
Label:
Return [| arg2 * arg1 |]
End Function
End Function
End Sub
End Module
</file>
</compilation>)
Assert.True(analysis.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.Captured))
Assert.Equal("arg1, arg2", GetSymbolNamesJoined(analysis.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DataFlowsOut))
Assert.Equal("args, lambda, arg, arg1", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("args, lambda, arg, arg1", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
Assert.Equal("arg1, arg2", GetSymbolNamesJoined(analysis.ReadInside))
Assert.Equal("arg, arg1", GetSymbolNamesJoined(analysis.ReadOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.WrittenInside))
Assert.Equal("args, lambda, arg, arg1, arg2", GetSymbolNamesJoined(analysis.WrittenOutside))
End Sub
<WorkItem(543581, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543581")>
<Fact()>
Public Sub Bug11440b()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="Bug11440">
<file name="a.b">
Imports System
Module Program
Sub Main(args As String())
GoTo Label
Dim arg2 As Integer = 2
Label:
dim y = [| arg2 |]
End Sub
End Module
</file>
</compilation>)
Assert.True(analysis.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.Captured))
Assert.Equal("arg2", GetSymbolNamesJoined(analysis.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DataFlowsOut))
Assert.Equal("args", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("args", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
Assert.Equal("arg2", GetSymbolNamesJoined(analysis.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.ReadOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.WrittenInside))
Assert.Equal("args, arg2, y", GetSymbolNamesJoined(analysis.WrittenOutside))
End Sub
<WorkItem(544330, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544330")>
<Fact()>
Public Sub Bug12609()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="Bug12609">
<file name="a.b">
Class A
Sub Goo(Optional i As Integer = [|1|])
End Sub
End Class
</file>
</compilation>)
Assert.False(analysis.Succeeded)
End Sub
<WorkItem(542231, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542231")>
<Fact()>
Public Sub TestUnreachableRegion()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.b">
Class A
Sub Goo()
Dim i As Integer
Return
[| i = i + 1 |]
Dim j As Integer = i
End Sub
End Class
</file>
</compilation>)
Assert.True(analysis.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DataFlowsOut))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
End Sub
<WorkItem(542231, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542231")>
<Fact()>
Public Sub TestUnreachableRegion2()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.b">
Class A
Sub Goo()
Dim i As Integer = 0
Dim j As Integer = 0
Dim k As Integer = 0
Dim l As Integer = 0
GoTo l1
[|
Console.WriteLine(i)
j = 1
l1:
Console.WriteLine(j)
k = 1
GoTo l2
Console.WriteLine(k)
l = 1
l3:
Console.WriteLine(l)
i = 1
|]
l2:
Console.WriteLine(i + j + k + l)
GoTo l3
End Sub
End Class
</file>
</compilation>)
Assert.True(analysis.Succeeded)
Assert.Equal("j, l", GetSymbolNamesJoined(analysis.DataFlowsIn))
Assert.Equal("i, k", GetSymbolNamesJoined(analysis.DataFlowsOut))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("Me, i, j, k, l", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
End Sub
<WorkItem(542231, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542231")>
<Fact()>
Public Sub TestUnreachableRegionInExpression()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.b">
Class A
Function Goo() As Boolean
Dim i As Boolean = True
Dim j As Boolean = False
dim ext as external = new external
Return False AndAlso [| ((i = ext.M1(i)) Or (i = ext.M1(j))) |]
End Function
End Class
</file>
</compilation>, s_customIL)
Assert.True(analysis.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DataFlowsOut))
End Sub
<WorkItem(545445, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545445")>
<Fact()>
Public Sub ExpressionInside()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="Bug12609">
<file name="a.b">
Class A
Sub Goo()
Dim outputAuthoringDocument = <?xml version=[|"1.0"|]?>
<wix:Wix>
<wix:Fragment>
<wix:DirectoryRef Id="VisualStudio11Extensions">
</wix:DirectoryRef>
</wix:Fragment>
</wix:Wix>
End Sub
End Class
</file>
</compilation>)
Assert.False(analysis.Succeeded)
End Sub
<WorkItem(544201, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544201")>
<Fact()>
Public Sub Bug12423a()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="Bug12423a">
<file name="a.b">
Class A
Sub Goo()
Dim x = { [| New B (abc) |] }
End Sub
End Class
Class B
Public Sub New(i As Integer)
End Sub
End Class
</file>
</compilation>)
Assert.True(analysis.Succeeded)
End Sub
<WorkItem(544201, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544201")>
<Fact()>
Public Sub Bug12423b()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="Bug12423b">
<file name="a.b">
Class A
Sub Goo(i As Integer)
Dim x = New B([| i |] ) { New B (abc) }
End Sub
End Class
Class B
Public Sub New(i As Integer)
End Sub
End Class
</file>
</compilation>)
Assert.True(analysis.Succeeded)
End Sub
<Fact()>
Public Sub TestDataFlowForValueTypes()
' WARNING: test matches the same test in C# (TestDataFlowForValueTypes)
' Keep the two tests in sync!
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestDataFlowForValueTypes">
<file name="a.b">
Imports System
Class Tst
Shared Sub Tst()
Dim a As S0
Dim b As S1
Dim c As S2
Dim d As S3
Dim e As E0
Dim f As E1
[|
Console.WriteLine(a)
Console.WriteLine(b)
Console.WriteLine(c)
Console.WriteLine(d)
Console.WriteLine(e)
Console.WriteLine(f)
|]
End Sub
End Class
Structure S0
End Structure
Structure S1
Public s0 As S0
End Structure
Structure S2
Public s0 As S0
Public s1 As Integer
End Structure
Structure S3
Public s0 As S0
Public s1 As Object
End Structure
Enum E0
End Enum
Enum E1
V1
End Enum
</file>
</compilation>)
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.Captured))
Assert.Equal("c, d, e, f", GetSymbolNamesJoined(analysis.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DataFlowsOut))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
Assert.Equal("a, b, c, d, e, f", GetSymbolNamesJoined(analysis.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.ReadOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.WrittenInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.WrittenOutside))
End Sub
<WorkItem(768094, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/768094")>
<Fact()>
Public Sub Bug768094a()
Dim program =
<compilation>
<file name="a.b">
<![CDATA[
class C
public sub F1(dim x as integer)
end sub
' During the search for the best function definition, this procedure
** is called to test how well the function passed as the first argument
** matches the request for a function with nArg arguments in a system
** that uses encoding enc. The value returned indicates how well the
** request is matched. A higher value indicates a better match.
**
** The returned value is always between 0 and 6, as follows:
**
** 0: Not a match, or if nArg<0 and the function is has no implementation.
** 1: A variable arguments function that prefers UTF-8 when a UTF-16
** encoding is requested, or vice versa.
** 2: A variable arguments function that uses UTF-16BE when UTF-16LE is
** requested, or vice versa.
** 3: A variable arguments function using the same text encoding.
** 4: A function with the exact number of arguments requested that
** prefers UTF-8 when a UTF-16 encoding is requested, or vice versa.
** 5: [|A function|] with the exact number of arguments requested that
** prefers UTF-16LE when UTF-16BE is requested, or vice versa.
** 6: An exact match.
**
*/
public sub F(dim x as integer)
end sub
end class
]]>
</file>
</compilation>
Dim startNodes As New List(Of VisualBasicSyntaxNode)
Dim endNodes As New List(Of VisualBasicSyntaxNode)
Dim comp = CompileAndGetModelAndSpan(program, startNodes, endNodes, Nothing, Nothing)
Assert.Equal(3, startNodes.Count)
Assert.Equal(SyntaxKind.ExpressionStatement, startNodes(2).Kind)
Dim expr = DirectCast(startNodes(2), ExpressionStatementSyntax)
Dim model = comp.GetSemanticModel(comp.SyntaxTrees(0))
Dim analysis = model.AnalyzeControlFlow(expr) ' NO THROW
Assert.Equal(0, analysis.EntryPoints.Count())
End Sub
<WorkItem(768094, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/768094")>
<Fact()>
Public Sub Bug768094b()
Dim program =
<compilation>
<file name="a.b">
<![CDATA[
'CONVERTED BY ROSLYN
Imports System.Diagnostics
Imports System.Text
Imports i64 = System.Int64
Imports u8 = System.Byte
Imports u16 = System.UInt16
Namespace Community.CsharpSqlite
Partial Public Class Sqlite3
#If SQLITE_DEBUG Then
/*
** Write a nice string representation of the contents of cell pMem
** into buffer zBuf, length nBuf.
*/
static StringBuilder zCsr = new StringBuilder( 100 );
static void sqlite3VdbeMemPrettyPrint( Mem pMem, StringBuilder zBuf )
{
zBuf.Length = 0;
zCsr.Length = 0;
int f = pMem.flags;
string[] encnames = new string[] { "(X)", "(8)", "(16LE)", "(16BE)" };
if ( ( f & MEM_Blob ) != 0 )
{
int i;
char c;
if ( ( f & MEM_Dyn ) != 0 )
{
c = 'z';
Debug.Assert( ( f & ( MEM_Static | MEM_Ephem ) ) == 0 );
}
else if ( ( f & MEM_Static ) != 0 )
{
c = 't';
Debug.Assert( ( f & ( MEM_Dyn | MEM_Ephem ) ) == 0 );
}
else if ( ( f & MEM_Ephem ) != 0 )
{
c = 'e';
Debug.Assert( ( f & ( MEM_Static | MEM_Dyn ) ) == 0 );
}
else
{
c = 's';
}
sqlite3_snprintf( 100, zCsr, "%c", c );
zBuf.Append( zCsr );//zCsr += sqlite3Strlen30(zCsr);
sqlite3_snprintf( 100, zCsr, "%d[", pMem.n );
zBuf.Append( zCsr );//zCsr += sqlite3Strlen30(zCsr);
for ( i = 0; i < 16 && i < pMem.n; i++ )
{
sqlite3_snprintf( 100, zCsr, "%02X", ( (int)pMem.zBLOB[i] & 0xFF ) );
zBuf.Append( zCsr );//zCsr += sqlite3Strlen30(zCsr);
}
for ( i = 0; i < 16 && i < pMem.n; i++ )
{
char z = (char)pMem.zBLOB[i];
if ( z < 32 || z > 126 )
zBuf.Append( '.' );//*zCsr++ = '.';
else
zBuf.Append( z );//*zCsr++ = z;
}
sqlite3_snprintf( 100, zCsr, "]%s", encnames[pMem.enc] );
zBuf.Append( zCsr );//zCsr += sqlite3Strlen30(zCsr);
if ( ( f & MEM_Zero ) != 0 )
{
sqlite3_snprintf( 100, zCsr, "+%dz", pMem.u.nZero );
zBuf.Append( zCsr );//zCsr += sqlite3Strlen30(zCsr);
}
//*zCsr = '\0';
}
else if ( ( f & MEM_Str ) != 0 )
{
int j;//, k;
zBuf.Append( ' ' );
if ( ( f & MEM_Dyn ) != 0 )
{
zBuf.Append( 'z' );
Debug.Assert( ( f & ( MEM_Static | MEM_Ephem ) ) == 0 );
}
else if ( ( f & MEM_Static ) != 0 )
{
zBuf.Append( 't' );
Debug.Assert( ( f & ( MEM_Dyn | MEM_Ephem ) ) == 0 );
}
else if ( ( f & MEM_Ephem ) != 0 )
{
zBuf.Append( 's' ); //zBuf.Append( 'e' );
Debug.Assert( ( f & ( MEM_Static | MEM_Dyn ) ) == 0 );
}
else
{
zBuf.Append( 's' );
}
//k = 2;
sqlite3_snprintf( 100, zCsr, "%d", pMem.n );//zBuf[k], "%d", pMem.n );
zBuf.Append( zCsr );
//k += sqlite3Strlen30( &zBuf[k] );
zBuf.Append( '[' );// zBuf[k++] = '[';
for ( j = 0; j < 15 && j < pMem.n; j++ )
{
u8 c = [|pMem.z|] != null ? (u8)pMem.z[j] : pMem.zBLOB[j];
if ( c >= 0x20 && c < 0x7f )
{
zBuf.Append( (char)c );//zBuf[k++] = c;
}
else
{
zBuf.Append( '.' );//zBuf[k++] = '.';
}
}
zBuf.Append( ']' );//zBuf[k++] = ']';
sqlite3_snprintf( 100, zCsr, encnames[pMem.enc] );//& zBuf[k], encnames[pMem.enc] );
zBuf.Append( zCsr );
//k += sqlite3Strlen30( &zBuf[k] );
//zBuf[k++] = 0;
}
}
#End If
End Class
End Namespace
]]>
</file>
</compilation>
Dim startNodes As New List(Of VisualBasicSyntaxNode)
Dim endNodes As New List(Of VisualBasicSyntaxNode)
Dim comp = CompileAndGetModelAndSpan(program, startNodes, endNodes, Nothing, Nothing,
parseOptions:=
VisualBasicParseOptions.Default.WithPreprocessorSymbols(
KeyValuePairUtil.Create("SQLITE_DEBUG", CObj(True))))
Assert.Equal(4, startNodes.Count)
Assert.Equal(SyntaxKind.DictionaryAccessExpression, startNodes(2).Kind)
Dim expr = DirectCast(startNodes(2), MemberAccessExpressionSyntax)
Dim model = comp.GetSemanticModel(comp.SyntaxTrees(0))
Dim analysis = model.AnalyzeDataFlow(expr) ' NO THROW
analysis = model.AnalyzeDataFlow(expr.Expression) ' NO THROW
analysis = model.AnalyzeDataFlow(expr.Name) ' NO THROW
End Sub
<WorkItem(768094, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/768094")>
<Fact()>
Public Sub Bug768094c()
Dim program =
<compilation>
<file name="a.b">
<![CDATA[
Imports u32 = System.UInt32
Class Clazz
u32 aFrameCksum([|2|]) = {0, 0}
End Class
]]>
</file>
</compilation>
Dim startNodes As New List(Of VisualBasicSyntaxNode)
Dim endNodes As New List(Of VisualBasicSyntaxNode)
Dim comp = CompileAndGetModelAndSpan(program, startNodes, endNodes, Nothing, Nothing)
Assert.Equal(2, startNodes.Count)
Assert.Equal(SyntaxKind.NumericLiteralExpression, startNodes(0).Kind)
Dim expr = DirectCast(startNodes(0), ExpressionSyntax)
Dim model = comp.GetSemanticModel(comp.SyntaxTrees(0))
Dim analysis = model.AnalyzeDataFlow(expr) ' NO THROW
End Sub
<WorkItem(768094, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/768094")>
<Fact()>
Public Sub Bug768094d()
Dim program =
<compilation>
<file name="a.b">
<![CDATA[
Imports u32 = System.UInt32
Class Clazz
u32 aFrameCksum([|2|])
End Class
]]>
</file>
</compilation>
Dim startNodes As New List(Of VisualBasicSyntaxNode)
Dim endNodes As New List(Of VisualBasicSyntaxNode)
Dim comp = CompileAndGetModelAndSpan(program, startNodes, endNodes, Nothing, Nothing)
Assert.Equal(2, startNodes.Count)
Assert.Equal(SyntaxKind.NumericLiteralExpression, startNodes(0).Kind)
Dim expr = DirectCast(startNodes(0), ExpressionSyntax)
Dim model = comp.GetSemanticModel(comp.SyntaxTrees(0))
Dim analysis = model.AnalyzeDataFlow(expr) ' NO THROW
End Sub
<Fact()>
Public Sub TestExitPoints01()
Dim analysis = CompileAndAnalyzeControlFlow(
<compilation name="TestExitPoints01">
<file name="a.b">
class C
public sub F(dim x as integer)
L1: ' 1
[|
if x = 0 then goto L1
if x = 1 then goto L2
if x = 3 then goto L3
L3:
|]
L2: ' 2
end sub
end class
</file>
</compilation>)
Assert.Equal(2, analysis.ExitPoints.Count())
End Sub
<Fact()>
Public Sub TestRegionCompletesNormally01()
Dim analysis = CompileAndAnalyzeControlFlow(
<compilation name="TestRegionCompletesNormally01">
<file name="a.b">
class C
public sub F(x as integer)
[|
goto L1
|]
L1:
end sub
end class
</file>
</compilation>)
Assert.True(analysis.StartPointIsReachable)
Assert.False(analysis.EndPointIsReachable)
End Sub
<Fact()>
Public Sub TestRegionCompletesNormally02()
Dim analysis = CompileAndAnalyzeControlFlow(
<compilation name="TestRegionCompletesNormally02">
<file name="a.b">
class C
public sub F(x as integer)
[|
x = 2
|]
end sub
end class
</file>
</compilation>)
Assert.True(analysis.StartPointIsReachable)
Assert.True(analysis.EndPointIsReachable)
End Sub
<Fact()>
Public Sub TestRegionCompletesNormally03()
Dim analysis = CompileAndAnalyzeControlFlow(
<compilation name="TestRegionCompletesNormally03">
<file name="a.b">
class C
public sub F(x as integer)
[|
if x = 0 then return
|]
end sub
end class
</file>
</compilation>)
Assert.True(analysis.StartPointIsReachable)
Assert.True(analysis.EndPointIsReachable)
End Sub
<WorkItem(543320, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543320")>
<Fact()>
Public Sub Bug10987()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="Bug10987">
<file name="a.b">
Class Test
Public Shared Sub Main()
Dim y(1, 2) = [|New Integer|]
End Sub
End Class
</file>
</compilation>)
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DataFlowsOut))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.WrittenInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.ReadOutside))
Assert.Equal("y", GetSymbolNamesJoined(analysis.WrittenOutside))
End Sub
<Fact()>
Public Sub TestExpressionInIfStatement()
Dim dataFlowAnalysis = CompileAndAnalyzeDataFlow(
<compilation name="TestExpressionInIfStatement">
<file name="a.b">
Module Program
Sub Main()
Dim x = 1
If 1 = [|x|] Then
End If
End Sub
End Module
</file>
</compilation>)
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysis.DataFlowsIn))
End Sub
<Fact()>
Public Sub CallingMethodsOnUninitializedStructs()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="CallingMethodsOnUninitializedStructs2">
<file name="a.b">
Public Structure XXX
Public x As S(Of Object)
Public y As S(Of String)
End Structure
Public Structure S(Of T)
Public x As String
Public Property y As T
End Structure
Public Class Test
Public Shared Sub Main(args As String())
Dim s As XXX
s.x = New S(Of Object)()
[|s.x.y.ToString()|]
Dim t As Object = s
End Sub
Public Shared Sub S1(ByRef arg As XXX)
arg.x.x = ""
arg.x.y = arg.x.x
End Sub
End Class
</file>
</compilation>)
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.CapturedOutside))
Assert.Equal("s", GetSymbolNamesJoined(analysis.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DataFlowsOut))
Assert.Equal("args", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("args", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
Assert.Equal("s", GetSymbolNamesJoined(analysis.ReadInside))
Assert.Equal("s", GetSymbolNamesJoined(analysis.ReadOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.WrittenInside))
Assert.Equal("args, s, t", GetSymbolNamesJoined(analysis.WrittenOutside))
End Sub
<WorkItem(542789, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542789")>
<Fact()>
Public Sub Bug10172()
Dim analysis = CompileAndAnalyzeControlAndDataFlow(
<compilation name="Bug10172">
<file name="a.b">
Imports System
Imports System.Collections.Generic
Imports System.Linq
Module Module1
Sub Main()
Dim list = New Integer() {1, 2, 3, 4, 5, 6, 7, 8}
Dim b = From i In list Where i > Function(i) As String
[|Return i|]
End Function.Invoke
End Sub
End Module
</file>
</compilation>)
Assert.True(analysis.Item1.Succeeded)
Assert.True(analysis.Item2.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.Item2.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.Item2.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.Item2.CapturedOutside))
End Sub
<WorkItem(1312, "https://github.com/dotnet/roslyn/issues/1312")>
<Fact()>
Public Sub Bug1312()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="Bug10172">
<file name="a.b">
Imports System
Imports System.Collections.Generic
Imports System.Linq
Class C
Function Z(f As Func(Of Integer)) As Integer
Return 1
End Function
Sub F()
Dim result1 = From a In {1}
From b In {2}
Where Z(Function() a+b)
Select a
Dim result2 = From c In {1}
From d In {2}
Where Z(Function() [|c|]+d) > 0
Select c
End Sub
End Class</file>
</compilation>)
Assert.Equal("Me, c", GetSymbolNamesJoined(analysis.Captured))
Assert.Equal("c", GetSymbolNamesJoined(analysis.CapturedInside))
Assert.Equal("Me", GetSymbolNamesJoined(analysis.CapturedOutside))
End Sub
<WorkItem(543645, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543645")>
<Fact()>
Public Sub Bug11526()
Dim analysis = CompileAndAnalyzeControlAndDataFlow(
<compilation name="Bug10172">
<file name="a.b">
Imports System
Imports System.Collections.Generic
Imports System.Linq
Module Module1
Sub Main()
Dim x = True
Dim y = DateTime.Now
[|
Try
Catch ex as Exception when x orelse y = #12:00:00 AM#
End Try
|]
End Sub
End Module
</file>
</compilation>)
Assert.True(analysis.Item1.Succeeded)
Assert.True(analysis.Item2.Succeeded)
End Sub
<WorkItem(543111, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543111")>
<Fact()>
Public Sub Bug10683a()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="Bug10683a">
<file name="a.b">
Imports System
Imports System.Collections.Generic
Imports System.Linq
Module Module1
Sub Main()
Dim x = New Integer() {}
x.First([|Function(i As Integer, r As Integer) As Boolean
Return True
End Function|])
End Sub
End Module
</file>
</compilation>)
Assert.True(analysis.Succeeded)
End Sub
<Fact()>
Public Sub TestArrayDeclaration01()
Dim analysis = CompileAndAnalyzeControlAndDataFlow(
<compilation name="TestArrayDeclaration01">
<file name="a.b">
Module Program
Sub Main(args As String())
[|
Dim x(5), y As Integer |]
End Sub
End Module
</file>
</compilation>)
Dim controlFlowAnalysis = analysis.Item1
Dim dataFlowAnalysis = analysis.Item2
Assert.Equal(0, controlFlowAnalysis.ExitPoints.Count())
Assert.Equal(0, controlFlowAnalysis.EntryPoints.Count())
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysis.AlwaysAssigned))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysis.WrittenInside))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysis.VariablesDeclared))
Assert.Equal("args", GetSymbolNamesJoined(dataFlowAnalysis.DefinitelyAssignedOnEntry))
Assert.Equal("args, x", GetSymbolNamesJoined(dataFlowAnalysis.DefinitelyAssignedOnExit))
Assert.True(controlFlowAnalysis.EndPointIsReachable)
End Sub
<Fact()>
Public Sub TestPreprocessorSymbol()
Dim analysis = CompileAndAnalyzeControlAndDataFlow(
<compilation name="TestPreprocessorSymbol">
<file name="a.b">
Module Program
Sub Main()
[|
Console.WriteLine()
#Const X = 1
Console.WriteLine()
|]
End Sub
End Module
</file>
</compilation>)
Dim controlFlowAnalysis = analysis.Item1
Dim dataFlowAnalysis = analysis.Item2
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.DefinitelyAssignedOnEntry))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.DefinitelyAssignedOnExit))
End Sub
<Fact()>
Public Sub TestArrayDeclaration02()
Dim analysis = CompileAndAnalyzeControlAndDataFlow(
<compilation name="TestArrayDeclaration02">
<file name="a.b">
Module Program
Sub Main(args As String())
[|If True Then Dim x(5), y As Integer |]
End Sub
End Module
</file>
</compilation>)
Dim controlFlowAnalysis = analysis.Item1
Dim dataFlowAnalysis = analysis.Item2
Assert.Equal(0, controlFlowAnalysis.ExitPoints.Count())
Assert.Equal(0, controlFlowAnalysis.EntryPoints.Count())
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysis.AlwaysAssigned))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysis.WrittenInside))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysis.VariablesDeclared))
Assert.Equal("args", GetSymbolNamesJoined(dataFlowAnalysis.DefinitelyAssignedOnEntry))
Assert.Equal("args, x", GetSymbolNamesJoined(dataFlowAnalysis.DefinitelyAssignedOnExit))
Assert.True(controlFlowAnalysis.EndPointIsReachable)
End Sub
<Fact()>
Public Sub TestArrayDeclaration02_()
Dim analysis = CompileAndAnalyzeControlAndDataFlow(
<compilation name="TestArrayDeclaration02">
<file name="a.b">
Module Program
Sub Main(args As String())
Dim b As Boolean = True
[|If b Then Dim x(5), y As Integer |]
End Sub
End Module
</file>
</compilation>)
Dim controlFlowAnalysis = analysis.Item1
Dim dataFlowAnalysis = analysis.Item2
Assert.Equal(0, controlFlowAnalysis.ExitPoints.Count())
Assert.Equal(0, controlFlowAnalysis.EntryPoints.Count())
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.AlwaysAssigned))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysis.WrittenInside))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysis.VariablesDeclared))
Assert.Equal("args, b", GetSymbolNamesJoined(dataFlowAnalysis.DefinitelyAssignedOnEntry))
Assert.Equal("args, b", GetSymbolNamesJoined(dataFlowAnalysis.DefinitelyAssignedOnExit))
Assert.True(controlFlowAnalysis.EndPointIsReachable)
End Sub
<Fact()>
Public Sub TestVariablesWithSameName()
Dim analysis = CompileAndAnalyzeControlAndDataFlow(
<compilation name="TestVariablesWithSameName">
<file name="a.b">
Module Program
Sub Main(args As String())
[|If True Then Dim x = 1 Else Dim x = 1 |]
End Sub
End Module
</file>
</compilation>)
Dim controlFlowAnalysis = analysis.Item1
Dim dataFlowAnalysis = analysis.Item2
Assert.Equal(0, controlFlowAnalysis.ExitPoints.Count())
Assert.Equal(0, controlFlowAnalysis.EntryPoints.Count())
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysis.AlwaysAssigned))
Assert.Equal("x, x", GetSymbolNamesJoined(dataFlowAnalysis.WrittenInside))
Assert.Equal("x, x", GetSymbolNamesJoined(dataFlowAnalysis.VariablesDeclared))
Assert.Equal("args", GetSymbolNamesJoined(dataFlowAnalysis.DefinitelyAssignedOnEntry))
Assert.Equal("args, x", GetSymbolNamesJoined(dataFlowAnalysis.DefinitelyAssignedOnExit))
Assert.True(controlFlowAnalysis.EndPointIsReachable)
End Sub
<Fact()>
Public Sub TestVariablesWithSameName2()
Dim analysis = CompileAndAnalyzeControlAndDataFlow(
<compilation name="TestVariablesWithSameName2">
<file name="a.b">
Module Program
Sub Main(args As String())
Dim b As Boolean = false
[|If b Then Dim x = 1 Else Dim x = 1 |]
End Sub
End Module
</file>
</compilation>)
Dim controlFlowAnalysis = analysis.Item1
Dim dataFlowAnalysis = analysis.Item2
Assert.Equal(0, controlFlowAnalysis.ExitPoints.Count())
Assert.Equal(0, controlFlowAnalysis.EntryPoints.Count())
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.AlwaysAssigned))
Assert.Equal("x, x", GetSymbolNamesJoined(dataFlowAnalysis.WrittenInside))
Assert.Equal("x, x", GetSymbolNamesJoined(dataFlowAnalysis.VariablesDeclared))
Assert.Equal("args, b", GetSymbolNamesJoined(dataFlowAnalysis.DefinitelyAssignedOnEntry))
Assert.Equal("args, b", GetSymbolNamesJoined(dataFlowAnalysis.DefinitelyAssignedOnExit))
Assert.True(controlFlowAnalysis.EndPointIsReachable)
End Sub
<WorkItem(540454, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/540454")>
<Fact()>
Public Sub TestDataFlowAnalysisWithErrorsInStaticContext()
Dim analysis = CompileAndAnalyzeControlAndDataFlow(
<compilation name="TestDataFlowAnalysisWithErrorsInStaticContext">
<file name="a.b">
Class C
Sub Goo()
End Sub
Shared Sub Bar()
[|
Goo() |]
End Sub
End Class </file>
</compilation>)
Dim dataFlowAnalysis = analysis.Item2
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.CapturedOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.DataFlowsOut))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.DefinitelyAssignedOnEntry))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.DefinitelyAssignedOnExit))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.ReadOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.WrittenInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.WrittenOutside))
End Sub
<Fact()>
Public Sub TestImplicitReturnVariable()
Dim analysis = CompileAndAnalyzeControlAndDataFlow(
<compilation name="TestImplicitReturnVariable">
<file name="a.b">
Module Program
Function Goo() As Integer
[|
Goo = 1
|]
End Function
End Module
</file>
</compilation>)
Dim controlFlowAnalysis = analysis.Item1
Dim dataFlowAnalysis = analysis.Item2
Assert.Equal(0, controlFlowAnalysis.ExitPoints.Count())
Assert.Equal(0, controlFlowAnalysis.EntryPoints.Count())
Assert.Equal("Goo", GetSymbolNamesJoined(dataFlowAnalysis.AlwaysAssigned))
Assert.Equal("Goo", GetSymbolNamesJoined(dataFlowAnalysis.WrittenInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.DefinitelyAssignedOnEntry))
Assert.Equal("Goo", GetSymbolNamesJoined(dataFlowAnalysis.DefinitelyAssignedOnExit))
Assert.True(controlFlowAnalysis.EndPointIsReachable)
End Sub
<Fact()>
Public Sub TestVariablesDeclared01()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestVariablesDeclared01">
<file name="a.b">
class C
public sub F(x as integer)
dim a as integer
[|
dim b as integer
dim x as integer, y = 1
if true then
dim z = "a"
end if
|]
dim c as integer
end sub
end class</file>
</compilation>)
Assert.Equal("b, x, y, z", GetSymbolNamesJoined(analysis.VariablesDeclared))
Assert.Equal("Me, x", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("Me, x, y, z", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
End Sub
<Fact()>
Public Sub TestIfElseBranch()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestIfElseBranch">
<file name="a.b">
Imports System
Module Program
Function Goo() As Integer
Dim x, y, z
[|
If True
x = 1
ElseIf True
y = 1
Else
z = 1
End If
|]
Console.WriteLine(x + y + z)
End Function
End Module
</file>
</compilation>)
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.VariablesDeclared))
Assert.Equal("x", GetSymbolNamesJoined(analysis.AlwaysAssigned))
Assert.Equal("x", GetSymbolNamesJoined(analysis.DataFlowsOut))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("x", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
End Sub
<Fact()>
Public Sub TestIfElseBranch_()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestIfElseBranch">
<file name="a.b">
Imports System
Module Program
Function Goo() As Integer
Dim x, y, z
Dim b As Boolean = True
[|
If b
x = 1
ElseIf b
y = 1
Else
z = 1
End If
|]
Console.WriteLine(x + y + z)
End Function
End Module
</file>
</compilation>)
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.AlwaysAssigned))
Assert.Equal("x, y, z", GetSymbolNamesJoined(analysis.DataFlowsOut))
Assert.Equal("b", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("b", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
End Sub
<Fact()>
Public Sub TestIfElseBranchReachability01()
Dim analysis = CompileAndAnalyzeControlFlow(
<compilation name="TestIfElseBranchReachability01">
<file name="a.b">
Imports System
Module Program
Function Goo() As Integer
Dim x, y
If True Then x = 1 Else If True Then Return 1 Else [|Return 1|]
Return x + y
End Function
End Module
</file>
</compilation>)
Assert.Equal(1, analysis.ExitPoints.Count())
Assert.Equal(0, analysis.EntryPoints.Count())
Assert.False(analysis.StartPointIsReachable())
Assert.False(analysis.EndPointIsReachable())
End Sub
<Fact()>
Public Sub TestIfElseBranchReachability02()
Dim analysis = CompileAndAnalyzeControlFlow(
<compilation name="TestIfElseBranchReachability02">
<file name="a.b">
Imports System
Module Program
Function Goo() As Integer
Dim x, y
If True Then x = 1 Else [|If True Then Return 1 Else Return 1|]
Return x + y
End Function
End Module
</file>
</compilation>)
Assert.Equal(2, analysis.ExitPoints.Count())
Assert.Equal(0, analysis.EntryPoints.Count())
Assert.False(analysis.StartPointIsReachable())
Assert.False(analysis.EndPointIsReachable())
End Sub
<Fact()>
Public Sub TestIfElseBranchReachability03()
Dim analysis = CompileAndAnalyzeControlFlow(
<compilation name="TestIfElseBranchReachability03">
<file name="a.b">
Imports System
Module Program
Function Goo() As Integer
Dim x, y
[|If True Then x = 1 Else If True Then Return 1 Else Return 1|]
Return x + y
End Function
End Module
</file>
</compilation>)
Assert.Equal(2, analysis.ExitPoints.Count())
Assert.Equal(0, analysis.EntryPoints.Count())
Assert.True(analysis.StartPointIsReachable())
Assert.True(analysis.EndPointIsReachable())
End Sub
<Fact()>
Public Sub TestIfElseBranch01()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestIfElseBranch01">
<file name="a.b">
Imports System
Module Program
Function Goo() As Integer
Dim x, y
[|If True Then x = 1 Else y = 1|]
Dim z = x + y
End Function
End Module
</file>
</compilation>)
Assert.Equal("x", GetSymbolNamesJoined(analysis.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DataFlowsIn))
Assert.Equal("x", GetSymbolNamesJoined(analysis.DataFlowsOut))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("x", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.ReadInside))
Assert.Equal("x, y", GetSymbolNamesJoined(analysis.WrittenInside))
End Sub
<Fact()>
Public Sub TestIfElseBranch01_()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestIfElseBranch01">
<file name="a.b">
Imports System
Module Program
Function Goo() As Integer
Dim b As Boolean = True
Dim x, y
[|If b Then x = 1 Else y = 1|]
Dim z = x + y
End Function
End Module
</file>
</compilation>)
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.AlwaysAssigned))
Assert.Equal("b", GetSymbolNamesJoined(analysis.DataFlowsIn))
Assert.Equal("x, y", GetSymbolNamesJoined(analysis.DataFlowsOut))
Assert.Equal("b", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("b", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
Assert.Equal("b", GetSymbolNamesJoined(analysis.ReadInside))
Assert.Equal("x, y", GetSymbolNamesJoined(analysis.WrittenInside))
End Sub
<Fact()>
Public Sub TestIfElseBranch02()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestIfElseBranch02">
<file name="a.b">
Imports System
Module Program
Function Goo() As Integer
Dim x, y
If True Then [|x = 1|] Else y = 1
Dim z = x + y
End Function
End Module
</file>
</compilation>)
Assert.Equal("x", GetSymbolNamesJoined(analysis.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DataFlowsIn))
Assert.Equal("x", GetSymbolNamesJoined(analysis.DataFlowsOut))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("x", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.ReadInside))
Assert.Equal("x", GetSymbolNamesJoined(analysis.WrittenInside))
End Sub
<Fact()>
Public Sub TestIfElseBranch03()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestIfElseBranch03">
<file name="a.b">
Imports System
Module Program
Function Goo() As Integer
Dim x, y, z
If True Then x = 1 Else [|y = 1|]
Dim z = x + y
End Function
End Module
</file>
</compilation>)
Assert.Equal("y", GetSymbolNamesJoined(analysis.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DataFlowsOut)) '' else clause is unreachable
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.ReadInside))
Assert.Equal("y", GetSymbolNamesJoined(analysis.WrittenInside))
End Sub
<Fact()>
Public Sub TestIfElseBranch03_()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestIfElseBranch03">
<file name="a.b">
Imports System
Module Program
Function Goo() As Integer
Dim b As Boolean = True
Dim x, y, z
If b Then x = 1 Else [|y = 1|]
Dim z = x + y
End Function
End Module
</file>
</compilation>)
Assert.Equal("y", GetSymbolNamesJoined(analysis.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DataFlowsIn))
Assert.Equal("y", GetSymbolNamesJoined(analysis.DataFlowsOut))
Assert.Equal("b", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("b, y", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.ReadInside))
Assert.Equal("y", GetSymbolNamesJoined(analysis.WrittenInside))
End Sub
<Fact()>
Public Sub TestIfElseBranch04()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestIfElseBranch04">
<file name="a.b">
Imports System
Module Program
Function Goo() As Integer
Dim x, y, z
If True Then x = 1 Else If True Then y = 1 Else [|z = 1|]
Dim zz = z + x + y
End Function
End Module
</file>
</compilation>)
Assert.Equal("z", GetSymbolNamesJoined(analysis.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DataFlowsOut)) '' else clause is unreachable
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.ReadInside))
Assert.Equal("z", GetSymbolNamesJoined(analysis.WrittenInside))
End Sub
<Fact()>
Public Sub TestIfElseBranch04_()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestIfElseBranch04">
<file name="a.b">
Imports System
Module Program
Function Goo() As Integer
Dim b As Boolean = True
Dim x, y, z
If b Then x = 1 Else If b Then y = 1 Else [|z = 1|]
Dim zz = z + x + y
End Function
End Module
</file>
</compilation>)
Assert.Equal("z", GetSymbolNamesJoined(analysis.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DataFlowsIn))
Assert.Equal("z", GetSymbolNamesJoined(analysis.DataFlowsOut))
Assert.Equal("b", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("b, z", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.ReadInside))
Assert.Equal("z", GetSymbolNamesJoined(analysis.WrittenInside))
End Sub
<Fact()>
Public Sub TestIfElseBranch05()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestIfElseBranch05">
<file name="a.b">
Imports System
Module Program
Function Goo() As Integer
Dim x, y, z
If True Then x = 1 Else [|If True Then y = 1 Else y = 1|]
Dim zz = z + x + y
End Function
End Module
</file>
</compilation>)
Assert.Equal("y", GetSymbolNamesJoined(analysis.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DataFlowsOut))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.ReadInside))
Assert.Equal("y", GetSymbolNamesJoined(analysis.WrittenInside))
End Sub
<Fact()>
Public Sub TestIfElseBranch05_()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestIfElseBranch05">
<file name="a.b">
Imports System
Module Program
Function Goo() As Integer
Dim b As Boolean = True
Dim x, y, z
If b Then x = 1 Else [|If b Then y = 1 Else y = 1|]
Dim zz = z + x + y
End Function
End Module
</file>
</compilation>)
Assert.Equal("y", GetSymbolNamesJoined(analysis.AlwaysAssigned))
Assert.Equal("b", GetSymbolNamesJoined(analysis.DataFlowsIn))
Assert.Equal("y", GetSymbolNamesJoined(analysis.DataFlowsOut))
Assert.Equal("b", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("b, y", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
Assert.Equal("b", GetSymbolNamesJoined(analysis.ReadInside))
Assert.Equal("y", GetSymbolNamesJoined(analysis.WrittenInside))
End Sub
<Fact()>
Public Sub TestVariablesInitializedWithSelfReference()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestVariablesInitializedWithSelfReference">
<file name="a.b">
class C
public sub F(x as integer)
[|
dim x as integer = x
dim y as integer, z as integer = 1
|]
end sub
end class</file>
</compilation>)
Assert.Equal("x, y, z", GetSymbolNamesJoined(analysis.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DataFlowsOut))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DataFlowsIn))
Assert.Equal("Me, x", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("Me, x, x, z", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
Assert.Equal("x, z", GetSymbolNamesJoined(analysis.AlwaysAssigned))
End Sub
<Fact()>
Public Sub TestVariablesDeclared02()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestVariablesDeclared02">
<file name="a.b">
class C
public sub F(x as integer)
[|
dim a as integer
dim b as integer
dim x as integer, y as integer = 1
if true then
dim z as string = "a"
end if
dim c as integer
|]
end sub
end class</file>
</compilation>)
Assert.Equal("a, b, x, y, z, c", GetSymbolNamesJoined(analysis.VariablesDeclared))
Assert.Equal("Me, x", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("Me, x, y, z", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
End Sub
<Fact()>
Public Sub AlwaysAssignedUnreachable()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="AlwaysAssignedUnreachable">
<file name="a.b">
class C
Public Sub F(x As Integer)
[|
Dim y As Integer
If x = 1 Then
y = 2
Return
Else
y = 3
Throw New Exception
End If
Dim c As Integer
|]
End Sub
end class</file>
</compilation>)
Assert.Equal("y", GetSymbolNamesJoined(analysis.AlwaysAssigned))
Assert.Equal("Me, x", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
End Sub
<Fact()>
Public Sub TestDataFlowLateCall()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestDataFlowLateCall">
<file name="a.b">
Option Strict Off
Imports System
Imports System.Collections.Generic
Imports System.Linq
Module Program
Sub Main(args As String())
Dim o as object = 1
[|
goo(o)
|]
End Sub
Sub goo(x As String)
End Sub
Sub goo(Byref x As Integer)
End Sub
End Module
</file>
</compilation>)
Assert.Equal("o", GetSymbolNamesJoined(analysis.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DataFlowsOut))
Assert.Equal("args, o", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("args, o", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
Assert.Equal("o", GetSymbolNamesJoined(analysis.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.ReadOutside))
Assert.Equal("o", GetSymbolNamesJoined(analysis.WrittenInside))
Assert.Equal("args, o", GetSymbolNamesJoined(analysis.WrittenOutside))
End Sub
<Fact()>
Public Sub TestDataFlowLateCall001()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestDataFlowLateCall001">
<file name="a.b">
Option Strict Off
Imports System
Imports System.Collections.Generic
Imports System.Linq
Class Program
shared Sub Main(args As String())
Dim o as object = 1
Dim oo as object = new Program
[|
oo.goo(o)
|]
End Sub
Sub goo(x As String)
End Sub
Sub goo(Byref x As Integer)
End Sub
End Class
</file>
</compilation>)
Assert.Equal("o, oo", GetSymbolNamesJoined(analysis.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DataFlowsOut))
Assert.Equal("args, o, oo", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("args, o, oo", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
Assert.Equal("o, oo", GetSymbolNamesJoined(analysis.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.ReadOutside))
Assert.Equal("o", GetSymbolNamesJoined(analysis.WrittenInside))
Assert.Equal("args, o, oo", GetSymbolNamesJoined(analysis.WrittenOutside))
End Sub
<Fact()>
Public Sub TestDataFlowIndex()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestDataFlowsOut01">
<file name="a.b">
Option Strict Off
Imports System
Imports System.Collections.Generic
Imports System.Linq
Module Program
Sub Main(args As String())
Dim o as object = 1
[|
Dim oo = o(o)
|]
End Sub
Sub goo(x As String)
End Sub
Sub goo(Byref x As Integer)
End Sub
End Module
</file>
</compilation>)
Assert.Equal("o", GetSymbolNamesJoined(analysis.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DataFlowsOut))
Assert.Equal("args, o", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("args, o, oo", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
Assert.Equal("o", GetSymbolNamesJoined(analysis.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.ReadOutside))
Assert.Equal("oo", GetSymbolNamesJoined(analysis.WrittenInside))
Assert.Equal("args, o", GetSymbolNamesJoined(analysis.WrittenOutside))
End Sub
<Fact()>
Public Sub UnassignedVariableFlowsOut01()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="UnassignedVariableFlowsOut01">
<file name="a.b">
class C
public sub F()
Dim i as Integer = 10
[|
Dim j as Integer = j + i
|]
Console.Write(i)
Console.Write(j)
end sub
end class</file>
</compilation>)
Assert.Equal("j", GetSymbolNamesJoined(analysis.VariablesDeclared))
Assert.Equal("i", GetSymbolNamesJoined(analysis.DataFlowsIn))
Assert.Equal("j", GetSymbolNamesJoined(analysis.DataFlowsOut))
Assert.Equal("Me, i", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("Me, i, j", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
Assert.Equal("i, j", GetSymbolNamesJoined(analysis.ReadInside))
Assert.Equal("i, j", GetSymbolNamesJoined(analysis.ReadOutside))
Assert.Equal("j", GetSymbolNamesJoined(analysis.WrittenInside))
Assert.Equal("Me, i", GetSymbolNamesJoined(analysis.WrittenOutside))
End Sub
<Fact()>
Public Sub TestDataFlowsIn01()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestDataFlowsIn01">
<file name="a.b">
class C
public sub F(x as integer)
dim a as integer = 1, y as integer = 2
[|
dim b as integer = a + x + 3
|]
dim c as integer = a + 4 + y
end sub
end class</file>
</compilation>)
Assert.Equal("x, a", GetSymbolNamesJoined(analysis.DataFlowsIn))
Assert.Equal("Me, x, a, y", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("Me, x, a, y, b", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
End Sub
<Fact()>
Public Sub TestDataFlowsIn02()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestDataFlowsIn02">
<file name="a.b">
class Program
sub Test(of T as class, new)(byref t as T)
[|
dim t1 as T
Test(t1)
t = t1
|]
System.Console.WriteLine(t1.ToString())
end sub
end class
</file>
</compilation>)
Assert.Equal("Me", GetSymbolNamesJoined(analysis.DataFlowsIn))
End Sub
<Fact()>
Public Sub TestDataFlowsIn03()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestDataFlowsIn03">
<file name="a.b">
class Program
shared sub Main(args() as string)
dim x as integer = 1
dim y as integer = 2
[|
dim z as integer = x + y
|]
end sub
end class
</file>
</compilation>)
Assert.Equal("x, y", GetSymbolNamesJoined(analysis.DataFlowsIn))
Assert.Equal("args, x, y", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("args, x, y, z", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
End Sub
<Fact()>
Public Sub TestDataFlowsOut01()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestDataFlowsOut01">
<file name="a.b">
class C
public sub F(x as integer)
dim a as integer = 1, y as integer
[|
if x = 1 then
x = 2
y = x
end if
|]
dim c as integer = a + 4 + x + y
end sub
end class</file>
</compilation>)
Assert.Equal("x, y", GetSymbolNamesJoined(analysis.DataFlowsOut))
Assert.Equal("Me, x, a", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("Me, x, a", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
End Sub
<Fact()>
Public Sub TestDataFlowsOut02()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestDataFlowsOut02">
<file name="a.b">
class Program
public sub Test(args() as string)
[|
dim s as integer = 10, i as integer = 1
dim b as integer = s + i
|]
System.Console.WriteLine(s)
System.Console.WriteLine(i)
end sub
end class</file>
</compilation>)
Assert.Equal("s, i", GetSymbolNamesJoined(analysis.DataFlowsOut))
Assert.Equal("Me, args", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("Me, args, s, i, b", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
End Sub
<Fact()>
Public Sub TestDataFlowsOut03()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestDataFlowsOut03">
<file name="a.b">
imports System.Text
module Program
sub Main() as string
dim builder as StringBuilder = new StringBuilder()
[|
builder.Append("Hello")
builder.Append("From")
builder.Append("Roslyn")
|]
return builder.ToString()
end sub
end module</file>
</compilation>)
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DataFlowsOut))
Assert.Equal("builder", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("builder", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
End Sub
<Fact()>
Public Sub TestDataFlowsOut04()
Dim analysisResults = CompileAndAnalyzeControlAndDataFlow(
<compilation>
<file name="a.b"><![CDATA[
Class C
Sub F(ByRef x As Integer)
[|x = 12|]
End Sub
End Class
]]></file>
</compilation>)
Dim controlFlowAnalysisResults = analysisResults.Item1
Dim dataFlowAnalysisResults = analysisResults.Item2
Assert.Equal(0, controlFlowAnalysisResults.EntryPoints.Count())
Assert.Equal(0, controlFlowAnalysisResults.ExitPoints.Count())
Assert.Equal(True, controlFlowAnalysisResults.StartPointIsReachable)
Assert.Equal(True, controlFlowAnalysisResults.EndPointIsReachable)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("Me, x", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("Me, x", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("Me, x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedOutside))
End Sub
<Fact()>
Public Sub TestDataFlowsOut06()
Dim analysisResults = CompileAndAnalyzeControlAndDataFlow(
<compilation>
<file name="a.b"><![CDATA[
Class C
Sub F(b As Boolean)
Dim i As Integer = 1
While b
[|i = i + 1|]
End While
End Sub
End Class
]]></file>
</compilation>)
Dim controlFlowAnalysisResults = analysisResults.Item1
Dim dataFlowAnalysisResults = analysisResults.Item2
Assert.Equal(0, controlFlowAnalysisResults.EntryPoints.Count())
Assert.Equal(0, controlFlowAnalysisResults.ExitPoints.Count())
Assert.Equal(True, controlFlowAnalysisResults.StartPointIsReachable)
Assert.Equal(True, controlFlowAnalysisResults.EndPointIsReachable)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal("i", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("i", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("i", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("Me, b, i", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("Me, b, i", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("i", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("b", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("i", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("Me, b, i", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedOutside))
End Sub
<Fact()>
Public Sub TestDataFlowsOut07()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestDataFlowsOut07">
<file name="a.b">
class Program
sub F(b as boolean)
dim i as integer
[|
i = 2
goto [next]
|]
[next]:
dim j as integer = i
end sub
end class</file>
</compilation>)
Assert.Equal("i", GetSymbolNamesJoined(analysis.DataFlowsOut))
Assert.Equal("Me, b", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
End Sub
<Fact()>
Public Sub TestDataFlowsOut08()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestDataFlowsOut08">
<file name="a.b">
Class Program
Sub F()
Dim i As Integer = 2
Try
[|
i = 1
|]
Finally
Dim j As Integer = i
End Try
End Sub
End Class
</file>
</compilation>)
Assert.Equal("i", GetSymbolNamesJoined(analysis.DataFlowsOut))
Assert.Equal("Me, i", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("Me, i", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
End Sub
<Fact()>
Public Sub TestDataFlowsOut09()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestDataFlowsOut09">
<file name="a.b">
class Program
sub Test(args() as string)
dim i as integer
dim s as string
[|i = 10
s = args(0) + i.ToString()|]
end sub
end class</file>
</compilation>)
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DataFlowsOut))
Assert.Equal("Me, args", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("Me, args, i, s", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
End Sub
<WorkItem(543492, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543492")>
<Fact()>
Public Sub MeAndMyBaseReference1()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="MeIsWrittenOutside1">
<file name="a.b">
Imports System
Public Class BaseClass
Public Overridable Sub MyMeth()
End Sub
End Class
Public Class MyClass : Inherits BaseClass
Public Overrides Sub MyMeth()
[|MyBase.MyMeth()|]
End Sub
End Class
</file>
</compilation>)
Assert.Equal("Me", GetSymbolNamesJoined(analysis.WrittenOutside))
Assert.Equal("Me", GetSymbolNamesJoined(analysis.DataFlowsIn))
Assert.Equal("Me", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("Me", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
End Sub
<WorkItem(543492, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543492")>
<Fact()>
Public Sub MeAndMyBaseReference2()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="MeIsWrittenOutside2">
<file name="a.b">
Imports System
Public Class BaseClass
Public Overridable Function MyMeth() As Boolean
Return False
End Function
End Class
Public Class MyClass1 : Inherits BaseClass
Public Overrides Function MyMeth() As Boolean
Return MyBase.MyMeth()
End Function
Public Sub OtherMeth()
Dim f = Function() [|MyBase.MyMeth|]
End Sub
End Class
</file>
</compilation>)
Assert.Equal("Me, f", GetSymbolNamesJoined(analysis.WrittenOutside))
Assert.Equal("Me", GetSymbolNamesJoined(analysis.DataFlowsIn))
Assert.Equal("Me, f", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("Me, f", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
End Sub
<Fact()>
Public Sub TestDataFlowsOutExpression01()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestDataFlowsOutExpression01">
<file name="a.b">
class C
public sub F(x as integer)
dim a as integer = 1, y as integer
dim tmp as integer = x
[|
x = 2
y = x
|]
temp += (a = 2)
dim c as integer = a + 4 + x + y
end sub
end class</file>
</compilation>)
Assert.Equal("x, y", GetSymbolNamesJoined(analysis.DataFlowsOut))
Assert.Equal("Me, x, a, tmp", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("Me, x, a, y, tmp", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
End Sub
<Fact()>
Public Sub TestAlwaysAssigned01()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestAlwaysAssigned01">
<file name="a.b">
class C
public sub F(x as integer)
dim a as integer = 1, y as integer= 1
[|
if x = 2 then
a = 3
else
a = 4
end if
x = 4
if x = 3 then
y = 12
end if
|]
dim c as integer = a + 4 + y
end sub
end class</file>
</compilation>)
Assert.Equal("x, a", GetSymbolNamesJoined(analysis.AlwaysAssigned))
Assert.Equal("Me, x, a, y", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("Me, x, a, y", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
End Sub
<Fact()>
Public Sub TestAlwaysAssigned03()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestAlwaysAssigned03">
<file name="a.b">
module C
sub Main(args() as string)
dim i as integer = [|
int.Parse(args(0).ToString())
|]
end sub
end module</file>
</compilation>)
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.AlwaysAssigned))
End Sub
<Fact()>
Public Sub TestWrittenInside02()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestWrittenInside02">
<file name="a.b">
module C
sub Main(args() as string)
dim i as integer = [|
int.Parse(args(0).ToString())
|]
end sub
end module</file>
</compilation>)
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.WrittenInside))
Assert.Equal("args", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("args", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
End Sub
<Fact()>
Public Sub TestWrittenInside03()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestWrittenInside03">
<file name="a.b">
module C
sub Main(args() as string)
dim i as integer
i = [|
int.Parse(args(0).ToString())
|]
end sub
end module</file>
</compilation>)
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.WrittenInside))
Assert.Equal("args", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("args", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
End Sub
<Fact()>
Public Sub TestAlwaysAssigned04()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestAlwaysAssigned04">
<file name="a.b">
module C
sub Main(args() as string)
dim i as integer
i = [|
int.Parse(args(0).ToString())
|]
end sub
end module</file>
</compilation>)
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.AlwaysAssigned))
Assert.Equal("args", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("args", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
End Sub
<Fact()>
Public Sub TestAlwaysAssignedDuplicateVariables()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestAlwaysAssignedDuplicateVariables">
<file name="a.b">
class C
public sub F(x as integer)
[|
dim a, a, b, b as integer
b = 1
|]
end sub
end class</file>
</compilation>)
Assert.Equal("b", GetSymbolNamesJoined(analysis.AlwaysAssigned))
End Sub
<Fact()>
Public Sub TestAlwaysAssigned02_LocalConst()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestAlwaysAssigned02">
<file name="a.b">
class C
public sub F(x as integer)
[|
const dim a as integer = 1
|]
end sub
end class</file>
</compilation>)
Assert.Equal("a", GetSymbolNamesJoined(analysis.AlwaysAssigned))
Assert.Equal("Me, x", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("Me, x, a", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
End Sub
<Fact()>
Public Sub TestAccessedInsideOutside()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestAccessedInsideOutside">
<file name="a.b">
class C
public sub F(x as integer)
dim a, b, c, d, e, f, g, h, i as integer
a = 1
b = a + x
c = a + x
[|
d = c
f = d
e = d
|]
g = e
i = g
h = g
end sub
end class</file>
</compilation>)
Assert.Equal("c, d", GetSymbolNamesJoined(analysis.ReadInside))
Assert.Equal("d, e, f", GetSymbolNamesJoined(analysis.WrittenInside))
Assert.Equal("x, a, e, g", GetSymbolNamesJoined(analysis.ReadOutside))
Assert.Equal("Me, x, a, b, c, g, h, i", GetSymbolNamesJoined(analysis.WrittenOutside))
Assert.Equal("Me, x, a, b, c", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("Me, x, a, b, c, d, e, f", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
End Sub
<Fact()>
Public Sub TestAlwaysAssignedViaPassingAsByRefParameter()
Dim analysisResults = CompileAndAnalyzeControlAndDataFlow(
<compilation>
<file name="a.b"><![CDATA[
Class C
Public Sub F(x As Integer)
[| Dim a As Integer
G(a)|]
End Sub
Sub G(ByRef x As Integer)
x = 1
End Sub
End Class
]]></file>
</compilation>)
Dim controlFlowAnalysisResults = analysisResults.Item1
Dim dataFlowAnalysisResults = analysisResults.Item2
Assert.Equal(0, controlFlowAnalysisResults.EntryPoints.Count())
Assert.Equal(0, controlFlowAnalysisResults.ExitPoints.Count())
Assert.Equal(True, controlFlowAnalysisResults.StartPointIsReachable)
Assert.Equal(True, controlFlowAnalysisResults.EndPointIsReachable)
Assert.Equal("a", GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("Me, x", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("Me, x, a", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("Me, a", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("a", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("Me, x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedOutside))
End Sub
<Fact()>
Public Sub TestRedimPreserveDataFlow()
VerifyReDimDataFlowAnalysis(
<![CDATA[
Dim x(2) As Integer
[|ReDim Preserve x(3)|]
]]>,
alwaysAssigned:={"x"},
captured:={},
dataFlowsIn:={"x"},
dataFlowsOut:={},
definitelyAssignedOnEntry:={"x"},
definitelyAssignedOnExit:={"x"},
readInside:={"x"},
readOutside:={},
variablesDeclared:={},
writtenInside:={"x"},
writtenOutside:={"x"})
End Sub
<Fact()>
Public Sub TestRedimDataFlow()
VerifyReDimDataFlowAnalysis(
<![CDATA[
Dim x(2) As Integer
[|ReDim x(3)|]
x(0) = 1
]]>,
alwaysAssigned:={"x"},
captured:={},
dataFlowsIn:={},
dataFlowsOut:={"x"},
definitelyAssignedOnEntry:={"x"},
definitelyAssignedOnExit:={"x"},
readInside:={},
readOutside:={"x"},
variablesDeclared:={},
writtenInside:={"x"},
writtenOutside:={"x"})
End Sub
<WorkItem(542156, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542156")>
<Fact()>
Public Sub TestRedimImplicitDataFlow()
VerifyReDimDataFlowAnalysis(
<![CDATA[
[|ReDim x(3)|]
Dim y = x(0)
]]>,
alwaysAssigned:={"x"},
captured:={},
dataFlowsIn:={},
dataFlowsOut:={"x"},
definitelyAssignedOnEntry:={},
definitelyAssignedOnExit:={"x"},
readInside:={},
readOutside:={"x"},
variablesDeclared:={},
writtenInside:={"x"},
writtenOutside:={"y"})
End Sub
<WorkItem(542156, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542156")>
<Fact()>
Public Sub TestRedimMultipleImplicitDataFlow()
VerifyReDimDataFlowAnalysis(
<![CDATA[
[|ReDim x(3, z), y(4, z)|]
y = x
System.Console.WriteLine(z)
]]>,
alwaysAssigned:={"x", "y"},
captured:={},
dataFlowsIn:={"z"},
dataFlowsOut:={"x"},
definitelyAssignedOnEntry:={},
definitelyAssignedOnExit:={"x", "y"},
readInside:={"z"},
readOutside:={"x", "z"},
variablesDeclared:={},
writtenInside:={"x", "y"},
writtenOutside:={"y"})
End Sub
#Region "Ternary Operator"
<Fact()>
Public Sub TestAlwaysAssignedWithTernaryOperator()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestAlwaysAssignedWithTernaryOperator">
<file name="a.b">
class C
public sub F(x as integer)
dim ext as External = New External
dim a as boolean
[|dim c as boolean = if(true,ext.M1(a),ext.M1(a))|]
end sub
end class
</file>
</compilation>, s_customIL)
Assert.Equal("a, c", GetSymbolNamesJoined(analysis.AlwaysAssigned))
Assert.Equal("Me, x, ext", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("Me, x, ext, a, c", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
End Sub
<Fact()>
Public Sub TestAlwaysAssignedWithTernaryOperator2()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestAlwaysAssignedWithTernaryOperator2">
<file name="a.b">
class C
public sub F(x as integer)
dim ext as External = New External
dim a, b as boolean
[|dim c as boolean = if(true,ext.M1(a),ext.M1(b))|]
end sub
end class
</file>
</compilation>, s_customIL)
Assert.Equal("a, c", GetSymbolNamesJoined(analysis.AlwaysAssigned))
Assert.Equal("Me, x, ext", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnEntry))
Assert.Equal("Me, x, ext, a, c", GetSymbolNamesJoined(analysis.DefinitelyAssignedOnExit))
End Sub
<Fact()>
Public Sub TestDeclarationWithSelfReferenceAndTernaryOperator()
Dim analysisResults = CompileAndAnalyzeControlAndDataFlow(
<compilation name="TestDeclarationWithSelfReferenceAndTernaryOperator">
<file name="a.b">
class C
shared sub Main()
[|
dim x as integer = if(true, 1, x)
|]
end sub
end class
</file>
</compilation>)
Dim controlFlowAnalysisResults = analysisResults.Item1
Dim dataFlowAnalysisResults = analysisResults.Item2
Assert.Equal(0, controlFlowAnalysisResults.EntryPoints.Count())
Assert.Equal(0, controlFlowAnalysisResults.ExitPoints.Count())
Assert.True(controlFlowAnalysisResults.StartPointIsReachable)
Assert.True(controlFlowAnalysisResults.EndPointIsReachable)
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<Fact()>
Public Sub TestDeclarationWithTernaryOperatorAndAssignment()
Dim analysisResults = CompileAndAnalyzeControlAndDataFlow(
<compilation name="TestDeclarationWithTernaryOperatorAndAssignment">
<file name="a.b">
class C
shared sub Main()
dim x, y as boolean
dim ext as external = new external
[|
y = if(true, 1, ext.M1(x))
|]
end sub
end class
</file>
</compilation>, s_customIL)
Dim controlFlowAnalysisResults = analysisResults.Item1
Dim dataFlowAnalysisResults = analysisResults.Item2
Assert.Equal(0, controlFlowAnalysisResults.EntryPoints.Count())
Assert.Equal(0, controlFlowAnalysisResults.ExitPoints.Count())
Assert.True(controlFlowAnalysisResults.StartPointIsReachable)
Assert.True(controlFlowAnalysisResults.EndPointIsReachable)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal("y", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("y, ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<Fact()>
Public Sub TestTernaryExpressionWithAssignments()
Dim analysisResults = CompileAndAnalyzeControlAndDataFlow(
<compilation name="TestTernaryExpressionWithAssignments">
<file name="a.b">
class C
shared sub Main()
dim x as boolean = true
dim y as integer
[|
dim z as integer
y = if(x, 1, 2)
z = y
|]
y.ToString()
end sub
end class
</file>
</compilation>)
Dim dataFlowAnalysisResults = analysisResults.Item2
Assert.Equal("z", GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal("y, z", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("y", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("x, y, z", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("y", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("y, z", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<Fact()>
Public Sub TestBranchOfTernaryOperator()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation name="TestBranchOfTernaryOperator">
<file name="a.b">
class C
shared sub Main()
dim x as boolean = true
dim y as boolean = if(x,[|x|],true)
end sub
end class
</file>
</compilation>)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<Fact()>
Public Sub TestAssignmentExpressionAsBranchOfTernaryOperator()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.b">
class C
shared sub Main()
dim x as boolean
dim ext as external = new external
dim y as boolean = if(true,[|ext.M1(x)|],x)
end sub
end class
</file>
</compilation>, s_customIL)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("x, ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("ext, y", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<Fact()>
Public Sub TestTernaryConditional01()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation name="TestTernaryConditional01">
<file name="a.b">
class C
shared sub Main()
dim x, y, z as boolean
dim ext as external = new external
dim zz as boolean = if([|ext.M1(x)|],ext.M1(y),ext.M1(z))
end sub
end class
</file>
</compilation>, s_customIL)
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("x, ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
End Sub
<Fact()>
Public Sub TestTernaryConditional02()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation name="TestTernaryConditional02">
<file name="a.b">
class C
shared sub Main()
dim x, y, z as boolean
dim ext as external = new external
dim zz as boolean = if(ext.M1(x),[|ext.M1(y)|],ext.M1(z))
end sub
end class
</file>
</compilation>, s_customIL)
Assert.Equal("y", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("x, ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("x, y, ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("y", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
End Sub
<Fact()>
Public Sub TestTernaryConditional03()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation name="TestTernaryConditional03">
<file name="a.b">
class C
shared sub Main()
dim x, y, z as boolean
dim ext as external = new external
dim zz as boolean = if(ext.M1(x),ext.M1(y),[|ext.M1(z)|])
end sub
end class
</file>
</compilation>, s_customIL)
Assert.Equal("z", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("x, ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("x, z, ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("z", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
End Sub
<Fact()>
Public Sub TestTernaryConditional04()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation name="TestTernaryConditional04">
<file name="a.b">
class C
shared sub Main()
dim x, y, z as boolean
dim ext as external = new external
dim zz as boolean = [|if(ext.M1(x),ext.M1(y),ext.M1(z))|]
end sub
end class
</file>
</compilation>, s_customIL)
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("x, ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("x, y, z", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
End Sub
<Fact()>
Public Sub TestTernaryConditional05()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation name="TestTernaryConditional05">
<file name="a.b">
class C
shared sub Main()
dim x, y as boolean
dim ext as external = new external
dim zz as boolean = [|if(ext.M1(x),ext.M1(y),ext.M1(y))|]
end sub
end class
</file>
</compilation>, s_customIL)
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("x, y, ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
End Sub
#End Region
<Fact()>
Public Sub TestDeclarationWithSelfReference()
Dim analysisResults = CompileAndAnalyzeControlAndDataFlow(
<compilation name="TestDeclarationWithSelfReference">
<file name="a.b">
class C
shared sub Main()
[|
dim x as integer = x
|]
end sub
end class
</file>
</compilation>)
Dim controlFlowAnalysisResults = analysisResults.Item1
Dim dataFlowAnalysisResults = analysisResults.Item2
Assert.Equal(0, controlFlowAnalysisResults.EntryPoints.Count())
Assert.Equal(0, controlFlowAnalysisResults.ExitPoints.Count())
Assert.True(controlFlowAnalysisResults.StartPointIsReachable)
Assert.True(controlFlowAnalysisResults.EndPointIsReachable)
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<Fact()>
Public Sub TestIfStatementWithAssignments()
Dim analysisResults = CompileAndAnalyzeControlAndDataFlow(
<compilation name="TestIfStatementWithAssignments">
<file name="a.b">
class C
shared sub Main()
dim x as boolean = true
dim y as integer
[|
if x then
y = 1
else
y = 2
end if
|]
y.ToString()
end sub
end class
</file>
</compilation>)
Dim controlFlowAnalysisResults = analysisResults.Item1
Dim dataFlowAnalysisResults = analysisResults.Item2
Assert.Equal(0, controlFlowAnalysisResults.EntryPoints.Count())
Assert.Equal(0, controlFlowAnalysisResults.ExitPoints.Count())
Assert.True(controlFlowAnalysisResults.StartPointIsReachable)
Assert.True(controlFlowAnalysisResults.EndPointIsReachable)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal("y", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("y", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("y", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("y", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<Fact()>
Public Sub TestIfStatementWithConstantCondition()
Dim analysisResults = CompileAndAnalyzeControlAndDataFlow(
<compilation name="TestIfStatementWithConstantCondition">
<file name="a.b">
class C
shared sub Main()
dim x as boolean = true
dim y as integer
[|
if true then
y = x
end if
|]
y.ToString()
end sub
end class
</file>
</compilation>)
Dim controlFlowAnalysisResults = analysisResults.Item1
Dim dataFlowAnalysisResults = analysisResults.Item2
Assert.Equal(0, controlFlowAnalysisResults.EntryPoints.Count())
Assert.Equal(0, controlFlowAnalysisResults.ExitPoints.Count())
Assert.True(controlFlowAnalysisResults.StartPointIsReachable)
Assert.True(controlFlowAnalysisResults.EndPointIsReachable)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal("y", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("y", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("y", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("y", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<Fact()>
Public Sub TestIfStatementWithNonConstantCondition()
Dim analysisResults = CompileAndAnalyzeControlAndDataFlow(
<compilation name="TestIfStatementWithNonConstantCondition">
<file name="a.b">
class C
shared sub Main()
dim x as boolean = true
dim y as integer
[|
if true or x then
y = x
end if
|]
y.ToString()
end sub
end class
</file>
</compilation>)
Dim controlFlowAnalysisResults = analysisResults.Item1
Dim dataFlowAnalysisResults = analysisResults.Item2
Assert.Equal(0, controlFlowAnalysisResults.EntryPoints.Count())
Assert.Equal(0, controlFlowAnalysisResults.ExitPoints.Count())
Assert.True(controlFlowAnalysisResults.StartPointIsReachable)
Assert.True(controlFlowAnalysisResults.EndPointIsReachable)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("y", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("y", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("y", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<Fact()>
Public Sub TestSingleVariableSelection()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation name="TestSingleVariableSelection">
<file name="a.b">
class C
shared sub Main()
dim x as boolean = true
dim y as boolean = x or [|
x |]
end sub
end class
</file>
</compilation>)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<Fact()>
Public Sub TestParenthesizedExpressionSelection()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation name="TestParenthesizedExpressionSelection">
<file name="a.b">
class C
shared sub Main()
dim x as boolean = true
dim y as boolean = x or [|(x = x) |] orelse x
end sub
end class
</file>
</compilation>)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned)) ' In C# '=' is an assignment while in VB it is a comparison.
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut)) 'C# flows out because this is an assignment expression. In VB this is an equality test.
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside)) 'C# this is an assignment. In VB, this is a comparison so no assignment.
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<Fact()>
Public Sub TestRefArgumentSelection()
Dim analysisResults = CompileAndAnalyzeControlAndDataFlow(
<compilation name="TestRefArgumentSelection">
<file name="a.b">
class C
shared sub Main()
dim x as integer = 0
[|
Goo(
x
)
|]
System.Console.WriteLine(x)
end sub
shared sub Goo(byref x as integer)
end sub
end class
</file>
</compilation>)
Dim controlFlowAnalysisResults = analysisResults.Item1
Dim dataFlowAnalysisResults = analysisResults.Item2
Assert.Equal(0, controlFlowAnalysisResults.EntryPoints.Count())
Assert.Equal(0, controlFlowAnalysisResults.ExitPoints.Count())
Assert.True(controlFlowAnalysisResults.StartPointIsReachable)
Assert.True(controlFlowAnalysisResults.EndPointIsReachable)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<WorkItem(541891, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/541891")>
<Fact()>
Public Sub TestRefArgumentSelection02()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation name="TestRefArgumentSelection02">
<file name="a.b">
class C
Sub Main()
Dim x As UInteger
System.Console.WriteLine([|Goo(x)|])
End Sub
Function Goo(ByRef x As ULong)
x = 123
Return x + 1
End Function
end class
</file>
</compilation>)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("Me, x", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("Me, x", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("Me, x", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<WorkItem(541891, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/541891")>
<Fact()>
Public Sub TestRefArgumentSelection02a()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation name="TestRefArgumentSelection02">
<file name="a.b">
class C
Sub Main()
Dim x As UInteger
System.Console.WriteLine(Goo([|x|]))
End Sub
Function Goo(ByRef x As ULong)
x = 123
Return x + 1
End Function
end class
</file>
</compilation>)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("Me, x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<Fact()>
Public Sub TestCompoundAssignmentTargetSelection01()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation name="TestCompoundAssignmentTargetSelection01">
<file name="a.b">
class C
Sub Main()
Dim x As String = ""
[|x|]+=1
End Sub
end class
</file>
</compilation>)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("Me, x", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("Me, x", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("Me, x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<Fact()>
Public Sub TestCompoundAssignmentTargetSelection02()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation name="TestCompoundAssignmentTargetSelection02">
<file name="a.b">
class C
Sub Main()
Dim x As String = ""
[|x+=1|]
End Sub
end class
</file>
</compilation>)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("Me, x", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("Me, x", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("Me, x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<Fact()>
Public Sub TestCompoundAssignmentTargetSelection03()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation name="TestCompoundAssignmentTargetSelection03">
<file name="a.b">
Imports System
Module M1
Sub M(ParamArray ary As Long())
Dim local01 As Integer = 1
Dim local02 As Short = 2
[|
local01 ^= local02
Try
local02 <<= ary(0)
ary(1) *= local01
Dim flocal As Single = 0
flocal /= ary(0)
ary(1) \= ary(0)
Catch ex As Exception
Finally
Dim slocal = Nothing
slocal &= Nothing
End Try
|]
End Sub
End Module
</file>
</compilation>)
Assert.Equal("flocal, ex, slocal", GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal("local01, slocal", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("ary, local01, local02", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("ary, local01, local02", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("ary, local01, local02, slocal", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("ary, local01, local02, flocal, slocal", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("local01, local02, flocal, ex, slocal", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("ary, local01, local02", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<WorkItem(541891, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/541891")>
<Fact()>
Public Sub TestRefArgumentSelection03()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation name="TestRefArgumentSelection03">
<file name="a.b">
class C
Sub Main()
Dim x As ULong
System.Console.WriteLine([|Goo(x)|])
End Sub
Function Goo(ByRef x As ULong)
x = 123
Return x + 1
End Function
end class
</file>
</compilation>)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("Me, x", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("Me, x", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("Me, x", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<Fact()>
Public Sub TestInvocation()
Dim analysisResults = CompileAndAnalyzeControlAndDataFlow(
<compilation name="TestInvocation">
<file name="a.b">
class C
shared sub Main()
dim x as integer = 1, y as integer = 1
[|
Goo(x)
|]
end sub
shared sub Goo(int x)
end sub
end class
</file>
</compilation>)
Dim controlFlowAnalysisResults = analysisResults.Item1
Dim dataFlowAnalysisResults = analysisResults.Item2
Assert.Equal(0, controlFlowAnalysisResults.EntryPoints.Count())
Assert.Equal(0, controlFlowAnalysisResults.ExitPoints.Count())
Assert.True(controlFlowAnalysisResults.StartPointIsReachable)
Assert.True(controlFlowAnalysisResults.EndPointIsReachable)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside)) ' Sees Me beng read
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<Fact()>
Public Sub TestInvocationWithAssignmentInArguments()
Dim analysisResults = CompileAndAnalyzeControlAndDataFlow(
<compilation name="TestInvocationWithAssignmentInArguments">
<file name="a.b">
class C
shared sub Main()
dim x as integer = 1, y as integer = 1
[|
x = y
y = 2
Goo(y, 2) ' VB does not support expression assignment F(x = y, y = 2)
|]
dim z as integer = x + y
}
shared sub Goo(int x, int y)
end sub
}
</file>
</compilation>)
Dim controlFlowAnalysisResults = analysisResults.Item1
Dim dataFlowAnalysisResults = analysisResults.Item2
Assert.Equal(0, controlFlowAnalysisResults.EntryPoints.Count())
Assert.Equal(0, controlFlowAnalysisResults.ExitPoints.Count())
Assert.True(controlFlowAnalysisResults.StartPointIsReachable)
Assert.True(controlFlowAnalysisResults.EndPointIsReachable)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("y", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("y", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside)) ' Sees Me being read
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("x, y, z", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<Fact>
Public Sub TestArrayInitializer()
Dim analysisResults = CompileAndAnalyzeControlAndDataFlow(
<compilation>
<file name="a.b"><![CDATA[
Class C
Sub Main(args As String())
Dim y As Integer = 1
Dim x(,) As Integer x = { {
[|y|]
} }
End Sub
End Class
]]></file>
</compilation>)
Dim controlFlowAnalysisResults = analysisResults.Item1
Dim dataFlowAnalysisResults = analysisResults.Item2
Assert.Equal(0, controlFlowAnalysisResults.EntryPoints.Count())
Assert.Equal(0, controlFlowAnalysisResults.ExitPoints.Count())
Assert.Equal(True, controlFlowAnalysisResults.StartPointIsReachable)
Assert.Equal(True, controlFlowAnalysisResults.EndPointIsReachable)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("y", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("Me, args, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("Me, args, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("y", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("Me, args, y", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedOutside))
End Sub
<Fact, WorkItem(538979, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538979")>
Public Sub AssertFromInvalidLocalDeclaration()
Dim analysisResults = CompileAndAnalyzeControlAndDataFlow(
<compilation name="AssertFromInvalidLocalDeclaration">
<file name="a.b">
Imports System
Public Class C
Public Shared Function Main() As Integer
[|
Dim v As Variant = New Byte(2)
|]
Dim b as Byte = v(0)
Return 1
End Function
End Class
end class
</file>
</compilation>)
Dim controlFlowAnalysisResults = analysisResults.Item1
Dim dataFlowAnalysisResults = analysisResults.Item2
Assert.Equal(0, controlFlowAnalysisResults.EntryPoints.Count())
Assert.Equal(0, controlFlowAnalysisResults.ExitPoints.Count())
Assert.True(controlFlowAnalysisResults.StartPointIsReachable)
Assert.True(controlFlowAnalysisResults.EndPointIsReachable)
Assert.Equal("v", GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal("v", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("v", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("v", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("v", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("v", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("b", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<Fact(), WorkItem(538979, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538979")>
Public Sub AssertFromInvalidKeywordAsExpr()
Dim analysisResults = CompileAndAnalyzeControlAndDataFlow(
<compilation name="AssertFromInvalidKeywordAsExpr">
<file name="a.b">
class B : A
public Function M() as float
[|
return mybase
|]
End Function
end class
class A
end class
</file>
</compilation>)
Dim controlFlowAnalysisResults = analysisResults.Item1
Dim dataFlowAnalysisResults = analysisResults.Item2
Assert.Equal(0, controlFlowAnalysisResults.EntryPoints.Count())
Assert.Equal(1, controlFlowAnalysisResults.ExitPoints.Count())
Assert.True(controlFlowAnalysisResults.StartPointIsReachable)
Assert.False(controlFlowAnalysisResults.EndPointIsReachable)
End Sub
<WorkItem(539286, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539286")>
<Fact()>
Public Sub RegionAnalysisInFieldInitializers_Simple()
Dim dataResults1 = CompileAndAnalyzeDataFlow(
<compilation name="RegionAnalysisInFieldInitializers_Simple">
<file name="a.b">
Class Class1
Public Shared A As Integer = 10
Public B As Integer = [|
10 + A + Me.F() |]
Public Function F() As Integer
Return Nothing
End Function
End Class
</file>
</compilation>)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataResults1.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataResults1.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataResults1.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataResults1.CapturedOutside))
Assert.Equal("Me", GetSymbolNamesJoined(dataResults1.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataResults1.DataFlowsOut))
Assert.Equal("Me", GetSymbolNamesJoined(dataResults1.DefinitelyAssignedOnEntry))
Assert.Equal("Me", GetSymbolNamesJoined(dataResults1.DefinitelyAssignedOnExit))
Assert.Equal("Me", GetSymbolNamesJoined(dataResults1.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataResults1.ReadOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataResults1.WrittenInside))
Assert.Equal("Me", GetSymbolNamesJoined(dataResults1.WrittenOutside))
End Sub
<WorkItem(539286, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539286")>
<Fact()>
Public Sub RegionAnalysisInPropertyInitializers_Simple()
Dim dataResults1 = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.b">
Class Class1
Public Shared A As Integer = 10
Public Property B As Integer = [|
10 + A + Me.F() |]
Public Function F() As Integer
Return Nothing
End Function
End Class
</file>
</compilation>)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataResults1.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataResults1.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataResults1.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataResults1.CapturedOutside))
Assert.Equal("Me", GetSymbolNamesJoined(dataResults1.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataResults1.DataFlowsOut))
Assert.Equal("Me", GetSymbolNamesJoined(dataResults1.DefinitelyAssignedOnEntry))
Assert.Equal("Me", GetSymbolNamesJoined(dataResults1.DefinitelyAssignedOnExit))
Assert.Equal("Me", GetSymbolNamesJoined(dataResults1.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataResults1.ReadOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataResults1.WrittenInside))
Assert.Equal("Me", GetSymbolNamesJoined(dataResults1.WrittenOutside))
End Sub
<WorkItem(539286, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539286")>
<Fact()>
Public Sub RegionAnalysisInFieldInitializers_WithMyBase()
Dim source =
<compilation name="RegionAnalysisInFieldInitializers_WithMyBase">
<file name="a.b">
Class Class1
Inherits Base
Public Shared A As Integer = 10
Public B As Integer = [|
10 + A + Me.F() + MyBase.F() +
Function()
Return 10 + A + Me.F() + MyBase.F()
End Function.Invoke |]
Public Overrides Function F() As Integer
Return Nothing
End Function
End Class
Class Base
Public Overridable Function F() As Integer
Return Nothing
End Function
End Class
</file>
</compilation>
Dim dataResults1 = CompileAndAnalyzeDataFlow(source)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataResults1.AlwaysAssigned))
Assert.Equal("Me", GetSymbolNamesJoined(dataResults1.Captured))
Assert.Equal("Me", GetSymbolNamesJoined(dataResults1.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataResults1.CapturedOutside))
Assert.Equal("Me", GetSymbolNamesJoined(dataResults1.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataResults1.DataFlowsOut))
Assert.Equal("Me", GetSymbolNamesJoined(dataResults1.DefinitelyAssignedOnEntry))
Assert.Equal("Me", GetSymbolNamesJoined(dataResults1.DefinitelyAssignedOnExit))
Assert.Equal("Me", GetSymbolNamesJoined(dataResults1.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataResults1.ReadOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataResults1.WrittenInside))
Assert.Equal("Me", GetSymbolNamesJoined(dataResults1.WrittenOutside))
End Sub
<WorkItem(539286, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539286")>
<Fact()>
Public Sub RegionAnalysisInFieldInitializers_Lambda()
Dim results1 = CompileAndAnalyzeControlAndDataFlow(
<compilation name="RegionAnalysisInFieldInitializers_Lambda">
<file name="a.b">
Imports System
Class Class1
Public Sub TST()
Dim f As Func(Of Integer, Integer) =
Function(p)
Dim a As Integer = 1
Dim b As Integer = 2
[|
b = 3
Dim c As Integer = 1 + a + b + Me.Goo() |]
Return c
End Function
End Sub
Public Function Goo() As Integer
Return Nothing
End Function
End Class
</file>
</compilation>)
Dim results2 = CompileAndAnalyzeControlAndDataFlow(
<compilation name="AssertFromInvalidKeywordAsExpr">
<file name="a.b">
Imports System
Class Class1
Dim f As Func(Of Integer, Integer) =
Function(p)
Dim a As Integer = 1
Dim b As Integer = 2
[|
b = 3
Dim c As Integer = 1 + a + b + Me.Goo() |]
Return c
End Function
Public Function Goo() As Integer
Return Nothing
End Function
End Class
</file>
</compilation>)
Dim controlResults1 = results1.Item1
Dim dataResults1 = results1.Item2
Dim controlResults2 = results2.Item1
Dim dataResults2 = results2.Item2
Assert.Equal(GetSymbolNamesJoined(dataResults1.AlwaysAssigned),
GetSymbolNamesJoined(dataResults2.AlwaysAssigned))
Assert.Equal(GetSymbolNamesJoined(dataResults1.Captured),
GetSymbolNamesJoined(dataResults2.Captured))
Assert.Equal(GetSymbolNamesJoined(dataResults1.CapturedInside),
GetSymbolNamesJoined(dataResults2.CapturedInside))
Assert.Equal(GetSymbolNamesJoined(dataResults1.CapturedOutside),
GetSymbolNamesJoined(dataResults2.CapturedOutside))
Assert.Equal(GetSymbolNamesJoined(dataResults1.DataFlowsIn),
GetSymbolNamesJoined(dataResults2.DataFlowsIn))
Assert.Equal(GetSymbolNamesJoined(dataResults1.DataFlowsOut),
GetSymbolNamesJoined(dataResults2.DataFlowsOut))
Assert.Equal(GetSymbolNamesJoined(dataResults1.ReadInside),
GetSymbolNamesJoined(dataResults2.ReadInside))
Assert.Equal(GetSymbolNamesJoined(dataResults1.ReadOutside),
GetSymbolNamesJoined(dataResults2.ReadOutside))
Assert.Equal(GetSymbolNamesJoined(dataResults1.WrittenInside),
GetSymbolNamesJoined(dataResults2.WrittenInside))
Assert.True(dataResults1.WrittenOutside.Any(Function(ByVal s) s.Name = "f"))
Assert.False(dataResults2.WrittenOutside.Any(Function(ByVal s) s.Name = "f"))
Assert.Equal(GetSymbolNamesJoined(dataResults1.WrittenOutside.Where(Function(ByVal s) s.Name <> "f")), GetSymbolNamesJoined(dataResults2.WrittenOutside))
End Sub
<WorkItem(539286, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539286")>
<Fact()>
Public Sub RegionAnalysisInFieldInitializers_NestedLambdaAndTwoConstructors()
Dim results1 = CompileAndAnalyzeControlAndDataFlow(
<compilation name="RegionAnalysisInFieldInitializers_NestedLambdaAndTwoConstructors">
<file name="a.b">
Class Class1(Of T)
Private Sub TST()
Dim f As Func(Of T, Integer, Integer) =
Function(x, p)
Dim a_outer As Integer = 1
Dim tx As T = x
Dim ff As Func(Of T, Integer, Integer) =
Function(xx, pp)
Dim a As Integer = 1
Dim b As Integer = 2
Dim ttx As T = tx
[|
b = 3
Dim c As Integer = Goo() + p + pp + a + b + a_outer |]
Return c
End Function
Return ff(Nothing, p)
End Function
End Sub
Public Function Goo() As Integer
Return Nothing
End Function
Public Sub New()
End Sub
Public Sub New(i As Integer)
End Sub
End Class
</file>
</compilation>)
Dim results2 = CompileAndAnalyzeControlAndDataFlow(
<compilation name="AssertFromInvalidKeywordAsExpr">
<file name="a.b">
Class Class1(Of T)
Dim f As Func(Of T, Integer, Integer) =
Function(x, p)
Dim a_outer As Integer = 1
Dim tx As T = x
Dim ff As Func(Of T, Integer, Integer) =
Function(xx, pp)
Dim a As Integer = 1
Dim b As Integer = 2
Dim ttx As T = tx
[|
b = 3
Dim c As Integer = Goo() + p + pp + a + b + a_outer |]
Return c
End Function
Return ff(Nothing, p)
End Function
Public Function Goo() As Integer
Return Nothing
End Function
Public Sub New()
End Sub
Public Sub New(i As Integer)
End Sub
End Class
</file>
</compilation>)
Dim controlResults1 = results1.Item1
Dim dataResults1 = results1.Item2
Dim controlResults2 = results2.Item1
Dim dataResults2 = results2.Item2
Assert.Equal(GetSymbolNamesJoined(dataResults1.AlwaysAssigned),
GetSymbolNamesJoined(dataResults2.AlwaysAssigned))
Assert.Equal(GetSymbolNamesJoined(dataResults1.Captured),
GetSymbolNamesJoined(dataResults2.Captured))
Assert.Equal(GetSymbolNamesJoined(dataResults1.CapturedInside),
GetSymbolNamesJoined(dataResults2.CapturedInside))
Assert.Equal(GetSymbolNamesJoined(dataResults1.CapturedOutside),
GetSymbolNamesJoined(dataResults2.CapturedOutside))
Assert.Equal(GetSymbolNamesJoined(dataResults1.DataFlowsIn),
GetSymbolNamesJoined(dataResults2.DataFlowsIn))
Assert.Equal(GetSymbolNamesJoined(dataResults1.DataFlowsOut),
GetSymbolNamesJoined(dataResults2.DataFlowsOut))
Assert.Equal(GetSymbolNamesJoined(dataResults1.ReadInside),
GetSymbolNamesJoined(dataResults2.ReadInside))
Assert.Equal(GetSymbolNamesJoined(dataResults1.ReadOutside),
GetSymbolNamesJoined(dataResults2.ReadOutside))
Assert.Equal(GetSymbolNamesJoined(dataResults1.WrittenInside),
GetSymbolNamesJoined(dataResults2.WrittenInside))
Assert.Equal(GetSymbolNamesJoined(dataResults1.WrittenOutside.Where(Function(x) x.Name <> "f")),
GetSymbolNamesJoined(dataResults2.WrittenOutside))
End Sub
<WorkItem(539197, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539197")>
<Fact()>
Public Sub ByRefParameterNotInAppropriateCollections1()
' ByRef parameters are not considered assigned
Dim analysisResults = CompileAndAnalyzeControlAndDataFlow(
<compilation name="AssertFromInvalidKeywordAsExpr">
<file name="a.b">
Imports System
Imports System.Collections.Generic
Class Program
Sub Test(of T)(ByRef t As T)
[|
Dim t1 As T
Test(t1)
t = t1
|]
System.Console.WriteLine(t1.ToString())
End Sub
End Class
</file>
</compilation>)
Dim controlFlowAnalysisResults = analysisResults.Item1
Dim dataFlowAnalysisResults = analysisResults.Item2
Assert.Equal(0, controlFlowAnalysisResults.EntryPoints.Count())
Assert.Equal(0, controlFlowAnalysisResults.ExitPoints.Count())
Assert.True(controlFlowAnalysisResults.StartPointIsReachable)
Assert.True(controlFlowAnalysisResults.EndPointIsReachable)
Assert.Equal("t1", GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal("t", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("t, t1", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("Me, t", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("Me, t, t1", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("Me, t1", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("t, t1", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("t, t1", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("Me, t, t1", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<WorkItem(539197, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539197")>
<Fact()>
Public Sub ByRefParameterNotInAppropriateCollections2()
' ByRef parameters are not considered assigned
Dim analysisResults = CompileAndAnalyzeControlAndDataFlow(
<compilation name="AssertFromInvalidKeywordAsExpr">
<file name="a.b">
Imports System
Imports System.Collections.Generic
Class Program
Sub Test(Of T)(ByRef t As T)
[|
Dim t1 As T = GetValue(of T)(t)
|]
System.Console.WriteLine(t1.ToString())
End Sub
Private Function GetValue(Of T)(ByRef t As T) As T
Return t
End Function
End Class
</file>
</compilation>)
Dim controlFlowAnalysisResults = analysisResults.Item1
Dim dataFlowAnalysisResults = analysisResults.Item2
Assert.Equal(0, controlFlowAnalysisResults.EntryPoints.Count())
Assert.Equal(0, controlFlowAnalysisResults.ExitPoints.Count())
Assert.True(controlFlowAnalysisResults.StartPointIsReachable)
Assert.True(controlFlowAnalysisResults.EndPointIsReachable)
Assert.Equal("t1", GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal("t1", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("Me, t", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("t, t1", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("Me, t", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("Me, t, t1", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("Me, t", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("t, t1", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("t, t1", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("Me, t, t1", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
Private Shared ReadOnly s_customIL As XCData = <![CDATA[
.class public auto ansi beforefieldinit External
extends [mscorlib]System.Object
{
.method public hidebysig instance bool
M1([out] bool& x) cil managed
{
// Code size 11 (0xb)
.maxstack 2
.locals init ([0] bool CS$1$0000)
IL_0000: nop
IL_0001: ldarg.1
IL_0002: ldc.i4.1
IL_0003: stind.i1
IL_0004: ldarg.1
IL_0005: ldind.i1
IL_0006: stloc.0
IL_0007: br.s IL_0009
IL_0009: ldloc.0
IL_000a: ret
} // end of method External::M1
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret
} // end of method External::.ctor
} // end of class External
]]>
<Fact()>
Public Sub TestOutParameterAlwaysAssigned()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.b">
class C
shared sub Main()
dim b as boolean = true
dim ext as external = new external
dim zz as boolean = [|ext.M1(b)|]
end sub
end class
</file>
</compilation>, s_customIL)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal("b", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned)) ' NOTE: always assigned
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("b, ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("b, ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("b", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("b, ext, zz", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<Fact()>
Public Sub BinaryConditional()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation name="BinaryConditional">
<file name="a.b">
Class A
Function Test1() As Integer
Dim ext As External = New External
Dim x As Boolean = True
Dim y As Boolean = IF(New Object(), [|ext.M1(x)|])
End Function
End Class
</file>
</compilation>, s_customIL)
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("Me, ext, x", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("Me, ext, x", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
End Sub
<Fact()>
Public Sub BinaryConditional01()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation name="BinaryConditional01">
<file name="a.b">
Class A
Function Test1() As Integer
Dim ext As External = New External
Dim x As Boolean = True
Dim y As True = IF("", [|ext.M1(x)|])
End Function
End Class
</file>
</compilation>, s_customIL)
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("Me, ext, x", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("Me, ext, x", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
End Sub
<Fact()>
Public Sub BinaryConditional02()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation name="BinaryConditional02">
<file name="a.b">
Class A
Function Test1() As Integer
Dim ext As External = New External
Dim x As Boolean = True
Dim y As True = [|IF("", ext.M1(x))|]
End Function
End Class
</file>
</compilation>, s_customIL)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("Me, ext, x", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("Me, ext, x", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
End Sub
<Fact()>
Public Sub BinaryConditional03()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation name="BinaryConditional03">
<file name="a.b">
Class A
Function Test1() As Integer
Dim ext As External = New External
Dim x As Boolean = True
Dim xx As Boolean = True
Dim y As True = [|IF(ext.M1(xx), ext.M1(x))|]
End Function
End Class
</file>
</compilation>, s_customIL)
Assert.Equal("xx", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("Me, ext, x, xx", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("Me, ext, x, xx", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("x, xx", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
End Sub
<Fact()>
Public Sub BinaryConditional04()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation name="BinaryConditional04">
<file name="a.b">
Class A
Function Test1() As Integer
Dim ext As External = New External
Dim x As Boolean = True
Dim xx As Boolean = True
Dim y As True = IF([|ext.M1(xx)|], ext.M1(x))
End Function
End Class
</file>
</compilation>, s_customIL)
Assert.Equal("xx", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("Me, ext, x, xx", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("Me, ext, x, xx", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("xx", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
End Sub
<Fact()>
Public Sub BinaryConditional05()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation name="BinaryConditional05">
<file name="a.b">
Class A
Sub Test1()
Dim ext As External = New External
Dim x As Boolean = Nothing
Dim z As Object = [|IF(Nothing, ext.M1(x))|]
End Sub
End Class
</file>
</compilation>, s_customIL)
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("Me, ext, x", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("Me, ext, x", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
End Sub
<Fact()>
Public Sub BinaryAndAlso01()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation name="BinaryAndAlso01">
<file name="a.b">
Class A
Function F(ByRef p As Boolean) As Boolean
Return Nothing
End Function
Sub Test1()
Dim x As Boolean = True
Dim y As Boolean = False
Dim z As Boolean = IF(Nothing, [|F(x)|]) AndAlso IF(Nothing, F(y)) AndAlso False
End Sub
End Class
</file>
</compilation>)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("Me, x", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("Me, x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("Me, x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("Me, x", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("Me, y", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("Me, x, y, z", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<Fact()>
Public Sub BinaryAndAlso02()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation name="BinaryAndAlso02">
<file name="a.b">
Class A
Function F(ByRef p As Boolean) As Boolean
Return Nothing
End Function
Sub Test1()
Dim x As Boolean
Dim y As Boolean = False
Dim z As Boolean = x AndAlso [|y|] AndAlso False
End Sub
End Class
</file>
</compilation>)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("y", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("Me, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("Me, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("y", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("Me, y, z", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<Fact()>
Public Sub BinaryAndAlso03()
Dim source =
<compilation name="BinaryAndAlso03">
<file name="a.b">
Class A
Function F(ByRef p As Boolean) As Boolean
Return Nothing
End Function
Sub Test1()
Dim ext As External = New External
Dim x As Boolean = True
Dim y As Boolean = False
Dim z As Boolean = [|ext.M1(x)|] AndAlso ext.M1(y)
End Sub
End Class
</file>
</compilation>
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(source, s_customIL)
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("Me, ext, x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("Me, ext, x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
End Sub
<Fact()>
Public Sub BinaryAndAlso04()
Dim source =
<compilation name="BinaryAndAlso04">
<file name="a.b">
Class A
Function F(ByRef p As Boolean) As Boolean
Return Nothing
End Function
Sub Test1()
Dim ext As External = New External
Dim x As Boolean = True
Dim y As Boolean = False
Dim z As Boolean = ext.M1(x) AndAlso [|ext.M1(y)|]
End Sub
End Class
</file>
</compilation>
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(source, s_customIL)
Assert.Equal("y", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("Me, ext, x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("Me, ext, x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("y", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
End Sub
<Fact()>
Public Sub BinaryAndAlso05()
Dim source =
<compilation name="BinaryAndAlso05">
<file name="a.b">
Class A
Function F(ByRef p As Boolean) As Boolean
Return Nothing
End Function
Sub Test1()
Dim ext As External = New External
Dim x As Boolean = True
Dim y As Boolean = False
Dim z As Boolean = [|ext.M1(x) AndAlso ext.M1(y)|] AndAlso True
End Sub
End Class
</file>
</compilation>
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(source, s_customIL)
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("Me, ext, x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("Me, ext, x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
End Sub
<Fact()>
Public Sub BinaryAndAlso06()
Dim source =
<compilation name="BinaryAndAlso06">
<file name="a.b">
Class A
Function F(ByRef p As Boolean) As Boolean
Return Nothing
End Function
Sub Test1()
Dim ext As External = New External
Dim x As Boolean = True
Dim y As Boolean = False
Dim z As Boolean = [|ext.M1(x) AndAlso ext.M1(y) AndAlso True|]
End Sub
End Class
</file>
</compilation>
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(source, s_customIL)
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("Me, ext, x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("Me, ext, x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
End Sub
<Fact()>
Public Sub BinaryOrElse01()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation name="BinaryOrElse01">
<file name="a.b">
Class A
Function F(ByRef p As Boolean) As Boolean
Return Nothing
End Function
Sub Test1()
Dim x As Boolean = True
Dim y As Boolean = False
Dim z As Boolean = IF(Nothing, [|F(x)|]) OrElse IF(Nothing, F(y)) OrElse False
End Sub
End Class
</file>
</compilation>)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("Me, x", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("Me, x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("Me, x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("Me, x", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
End Sub
<Fact()>
Public Sub BinaryOrElse02()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation name="BinaryOrElse02">
<file name="a.b">
Class A
Function F(ByRef p As Boolean) As Boolean
Return Nothing
End Function
Sub Test1()
Dim x As Boolean
Dim y As Boolean = False
Dim z As Boolean = x OrElse [|y|] OrElse False
End Sub
End Class
</file>
</compilation>)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("y", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("Me, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("Me, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("y", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
End Sub
<Fact()>
Public Sub BinaryOrElse03()
Dim source =
<compilation name="BinaryOrElse03">
<file name="a.b">
Class A
Function F(ByRef p As Boolean) As Boolean
Return Nothing
End Function
Sub Test1()
Dim ext As External = New External
Dim x As Boolean = True
Dim y As Boolean = False
Dim z As Boolean = [|ext.M1(x)|] OrElse ext.M1(y)
End Sub
End Class
</file>
</compilation>
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(source, s_customIL)
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("Me, ext, x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("Me, ext, x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
End Sub
<Fact()>
Public Sub BinaryOrElse04()
Dim source =
<compilation name="BinaryOrElse04">
<file name="a.b">
Class A
Function F(ByRef p As Boolean) As Boolean
Return Nothing
End Function
Sub Test1()
Dim ext As External = New External
Dim x As Boolean = True
Dim y As Boolean = False
Dim z As Boolean = ext.M1(x) OrElse [|ext.M1(y)|]
End Sub
End Class
</file>
</compilation>
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(source, s_customIL)
Assert.Equal("y", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("Me, ext, x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("Me, ext, x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("y", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
End Sub
<Fact()>
Public Sub BinaryOrElse05()
Dim source =
<compilation name="BinaryOrElse05">
<file name="a.b">
Class A
Function F(ByRef p As Boolean) As Boolean
Return Nothing
End Function
Sub Test1()
Dim ext As External = New External
Dim x As Boolean = True
Dim y As Boolean = False
Dim z As Boolean = [|ext.M1(x) OrElse ext.M1(y)|] OrElse True
End Sub
End Class
</file>
</compilation>
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(source, s_customIL)
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("Me, ext, x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("Me, ext, x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
End Sub
<Fact()>
Public Sub BinaryOrElse06()
Dim source =
<compilation name="BinaryOrElse06">
<file name="a.b">
Class A
Function F(ByRef p As Boolean) As Boolean
Return Nothing
End Function
Sub Test1()
Dim ext As External = New External
Dim x As Boolean = True
Dim y As Boolean = False
Dim z As Boolean = [|ext.M1(x) OrElse ext.M1(y) OrElse True|]
End Sub
End Class
</file>
</compilation>
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(source, s_customIL)
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("Me, ext, x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("Me, ext, x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal("ext", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
End Sub
<WorkItem(541005, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/541005")>
<Fact()>
Public Sub TestMultipleLocalsInitializedByAsNew1()
Dim dataFlowAnalysis = CompileAndAnalyzeDataFlow(
<compilation name="TestMultipleLocalsInitializedByAsNew">
<file name="a.b">
Module Program
Class c
Sub New(i As Integer)
End Sub
End Class
Sub Main(args As String())
Dim a As Integer = 1
Dim x, y, z As New c([|a|]+1)
End Sub
End Module
</file>
</compilation>)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.WrittenInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.VariablesDeclared))
Assert.Equal("args, a, x, y, z", GetSymbolNamesJoined(dataFlowAnalysis.WrittenOutside))
End Sub
<WorkItem(541005, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/541005")>
<Fact()>
Public Sub TestMultipleLocalsInitializedByAsNew2()
Dim analysis = CompileAndAnalyzeControlAndDataFlow(
<compilation name="TestMultipleLocalsInitializedByAsNew">
<file name="a.b">
Module Program
Class c
Sub New(i As Integer)
End Sub
End Class
Sub Main(args As String())
Dim a As Integer = 1
[|Dim x, y, z As New c(a)|]
End Sub
End Module
</file>
</compilation>)
Dim controlFlowAnalysis = analysis.Item1
Dim dataFlowAnalysis = analysis.Item2
Assert.Equal(0, controlFlowAnalysis.ExitPoints.Count())
Assert.Equal(0, controlFlowAnalysis.EntryPoints.Count())
Assert.Equal("x, y, z", GetSymbolNamesJoined(dataFlowAnalysis.AlwaysAssigned))
Assert.Equal("x, y, z", GetSymbolNamesJoined(dataFlowAnalysis.WrittenInside))
Assert.Equal("x, y, z", GetSymbolNamesJoined(dataFlowAnalysis.VariablesDeclared))
Assert.Equal("args, a", GetSymbolNamesJoined(dataFlowAnalysis.WrittenOutside))
Assert.True(controlFlowAnalysis.StartPointIsReachable)
Assert.True(controlFlowAnalysis.EndPointIsReachable)
End Sub
<WorkItem(528623, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/528623")>
<Fact()>
Public Sub TestElementAccess01()
Dim analysis = CompileAndAnalyzeControlAndDataFlow(
<compilation name="TestElementAccess">
<file name="elem.b">
Imports System
Public Class Test
Sub F(p as Long())
Dim v() As Long = new Long() { 1, 2, 3 }
[|
v(0) = p(0)
p(0) = v(1)
|]
v(1) = v(0)
' p(2) = p(0)
End Sub
End Class
</file>
</compilation>)
Dim dataFlowAnalysis = analysis.Item2
Assert.True(dataFlowAnalysis.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.AlwaysAssigned))
Assert.Equal("p, v", GetSymbolNamesJoined(dataFlowAnalysis.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.DataFlowsOut))
Assert.Equal("Me, p, v", GetSymbolNamesJoined(dataFlowAnalysis.DefinitelyAssignedOnEntry))
Assert.Equal("Me, p, v", GetSymbolNamesJoined(dataFlowAnalysis.DefinitelyAssignedOnExit))
Assert.Equal("p, v", GetSymbolNamesJoined(dataFlowAnalysis.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.WrittenInside))
Assert.Equal("v", GetSymbolNamesJoined(dataFlowAnalysis.ReadOutside))
Assert.Equal("Me, p, v", GetSymbolNamesJoined(dataFlowAnalysis.WrittenOutside))
End Sub
<Fact()>
Public Sub DataFlowForDeclarationOfEnumTypedVariable()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.b"><![CDATA[
Class C
Sub Main(args As String())
[|Dim s As color|]
Try
Catch ex As Exception When s = color.black
Console.Write("Exception")
End Try
End Sub
End Class
Enum color
black
End Enum
]]></file>
</compilation>)
Assert.Equal("s", GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("s", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("Me, args", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnEntry))
Assert.Equal("Me, args", GetSymbolNamesJoined(dataFlowAnalysisResults.DefinitelyAssignedOnExit))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("s", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("Me, args, ex", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<WorkItem(542565, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542565")>
<Fact()>
Public Sub IdentifierNameInForStatement()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Module Module1
Sub Main()
For [|Idx|] = 0 To ubound(arry) Step 1
Next Idx
End Sub
End Module
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
End Sub
<WorkItem(528860, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/528860")>
<Fact()>
Public Sub IdentifierNameInMemberAccessExpr()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Public Class Goo
Sub M()
Dim c As C = New C()
Dim n1 = c.[|M|]
End Sub
End Class
</file>
</compilation>)
Assert.False(dataFlowResults.Succeeded)
End Sub
<WorkItem(528860, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/528860")>
<Fact()>
Public Sub IdentifierNameInMemberAccessExpr2()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Public Class C
Sub M()
Dim c As C = New C()
Dim n1 = c.[|M|]
End Sub
End Class
</file>
</compilation>)
Assert.False(dataFlowResults.Succeeded)
End Sub
<WorkItem(542860, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542860")>
<Fact()>
Public Sub IdentifierNameSyntax()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports Microsoft.VisualBasic
Public Class C
Sub M()
Dim n1 = [|ChrW|](85)
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
End Sub
<WorkItem(542860, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542860")>
<Fact()>
Public Sub IdentifierNameSyntax2()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports Microsoft.VisualBasic
Public Class C
Sub M()
Dim n1 = [|Goo|](85)
End Sub
Function Goo(i As Integer) As Integer
Return i
End Function
End Class
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
End Sub
<WorkItem(542860, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542860")>
<Fact()>
Public Sub IdentifierNameSyntax3()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports Microsoft.VisualBasic
Public Class C
Sub M()
Dim n1 = [|Goo|](85)
End Sub
ReadOnly Property Goo(i As Integer) As Integer
Get
Return i
End Get
End Property
End Class
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
End Sub
<WorkItem(543369, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543369")>
<Fact()>
Public Sub PredefinedTypeIncompleteSub()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Friend Module AcceptVB7_12mod
Sub AcceptVB7_12()
Dim lng As [|Integer|]
Dim int1 As Short
</file>
</compilation>)
Assert.False(dataFlowResults.Succeeded)
End Sub
<WorkItem(543369, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543369")>
<Fact()>
Public Sub PredefinedType2()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Friend Module AcceptVB7_12mod
Sub AcceptVB7_12()
Dim lng As [|Integer|]
Dim int1 As Short
End Sub
And Module
</file>
</compilation>)
Assert.False(dataFlowResults.Succeeded)
End Sub
<WorkItem(543461, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543461")>
<Fact()>
Public Sub CollectionInitSyntax()
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntime(
<compilation>
<file name="a.vb">
Module Program
Sub Main(args As String())
Dim i1 = New Integer() {4, 5}
End Sub
End Module
</file>
</compilation>)
Dim tree = compilation.SyntaxTrees.First()
Dim model = compilation.GetSemanticModel(tree)
Dim exprSyntaxNode = DirectCast(tree.GetCompilationUnitRoot().FindToken(tree.GetRoot.ToFullString().IndexOf("{4, 5}", StringComparison.Ordinal)).Parent, CollectionInitializerSyntax)
Dim analysis = model.AnalyzeDataFlow(exprSyntaxNode)
Assert.False(analysis.Succeeded)
End Sub
<WorkItem(543461, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543461")>
<Fact()>
Public Sub CollectionInitSyntax2()
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntime(
<compilation>
<file name="a.vb">
Imports System.Collections.Generic
Module Program
Sub Main(args As String())
Dim i1 = New List(Of Integer) From {4, 5}
End Sub
End Module
</file>
</compilation>)
Dim tree = compilation.SyntaxTrees.First()
Dim model = compilation.GetSemanticModel(tree)
Dim exprSyntaxNode = DirectCast(tree.GetCompilationUnitRoot().FindToken(tree.GetRoot.ToFullString().IndexOf("{4, 5}", StringComparison.Ordinal)).Parent, CollectionInitializerSyntax)
Dim analysis = model.AnalyzeDataFlow(exprSyntaxNode)
Assert.False(analysis.Succeeded)
End Sub
<WorkItem(543461, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543461")>
<Fact()>
Public Sub CollectionInitSyntax3()
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntime(
<compilation>
<file name="a.vb">
Imports System.Collections.Generic
Module Program
Sub Main(args As String())
Dim i1 = {4, 5}
End Sub
End Module
</file>
</compilation>)
Dim tree = compilation.SyntaxTrees.First()
Dim model = compilation.GetSemanticModel(tree)
Dim exprSyntaxNode = DirectCast(tree.GetCompilationUnitRoot().FindToken(tree.GetRoot.ToFullString().IndexOf("{4, 5}", StringComparison.Ordinal)).Parent, CollectionInitializerSyntax)
Dim analysis = model.AnalyzeDataFlow(exprSyntaxNode)
Assert.True(analysis.Succeeded)
End Sub
<WorkItem(543509, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543509")>
<Fact()>
Public Sub IfStatementSyntax()
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntime(
<compilation>
<file name="a.vb">
Module Program
Sub Main(args As String())
Dim x = 10
If False
x = x + 1
End If
End Sub
End Module
</file>
</compilation>)
Dim tree = compilation.SyntaxTrees.First()
Dim model = compilation.GetSemanticModel(tree)
Dim stmtSyntaxNode = DirectCast(tree.GetCompilationUnitRoot().FindToken(tree.GetRoot.ToFullString().IndexOf("If False", StringComparison.Ordinal)).Parent, IfStatementSyntax)
Dim analysis = model.AnalyzeControlFlow(stmtSyntaxNode, stmtSyntaxNode)
Assert.False(analysis.Succeeded)
End Sub
<Fact()>
Public Sub ElseStatementSyntax()
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntime(
<compilation>
<file name="a.vb">
Module Program
Sub Main(args As String())
Dim x = 10
If False
x = x + 1
Else
x = x - 1
End If
End Sub
End Module
</file>
</compilation>)
Dim tree = compilation.SyntaxTrees.First()
Dim model = compilation.GetSemanticModel(tree)
Dim stmtSyntaxNode = DirectCast(tree.GetCompilationUnitRoot().FindToken(tree.GetRoot.ToFullString().IndexOf("Else", StringComparison.Ordinal)).Parent, ElseStatementSyntax)
Dim analysis = model.AnalyzeControlFlow(stmtSyntaxNode, stmtSyntaxNode)
Assert.False(analysis.Succeeded)
End Sub
<Fact()>
Public Sub WithStatementSyntax()
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntime(
<compilation>
<file name="a.vb">
Module Program
Sub Main(args As String())
With New Object()
End With
End Sub
End Module
</file>
</compilation>)
Dim tree = compilation.SyntaxTrees.First()
Dim model = compilation.GetSemanticModel(tree)
Dim stmtSyntaxNode = DirectCast(tree.GetCompilationUnitRoot().FindToken(tree.GetRoot.ToFullString().IndexOf("With New Object()", StringComparison.Ordinal)).Parent, WithStatementSyntax)
Dim analysis = model.AnalyzeControlFlow(stmtSyntaxNode, stmtSyntaxNode)
Assert.False(analysis.Succeeded)
End Sub
<WorkItem(757796, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/757796")>
<Fact()>
Public Sub Bug757796()
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntime(
<compilation>
<file name="a.vb">
Imports System
Module Program
Sub Main(args As String())
Dim tableauEmission(123) As Integer
For t As Integer = 0 To 123 - 1
With tableauEmission(t)
End With
Next
End Sub
End Module </file>
</compilation>)
Dim tree = compilation.SyntaxTrees.First()
Dim model = compilation.GetSemanticModel(tree)
Dim withStatement = DirectCast(tree.GetCompilationUnitRoot().FindToken(tree.GetRoot.ToFullString().IndexOf("With tableauEmission(t)", StringComparison.Ordinal)).Parent, WithStatementSyntax)
Dim tableauEmissionNode = DirectCast(withStatement.Expression, Microsoft.CodeAnalysis.VisualBasic.Syntax.InvocationExpressionSyntax).Expression
Dim analysis = model.AnalyzeDataFlow(tableauEmissionNode)
Assert.True(analysis.Succeeded)
End Sub
<Fact()>
Public Sub TryStatementSyntax()
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntime(
<compilation>
<file name="a.vb">
Module Program
Sub Main(args As String())
Try
Dim a = 123
Catch e As Exception
End Try
End Sub
End Module
</file>
</compilation>)
Dim tree = compilation.SyntaxTrees.First()
Dim model = compilation.GetSemanticModel(tree)
Dim stmtSyntaxNode = DirectCast(tree.GetCompilationUnitRoot().FindToken(tree.GetRoot.ToFullString().IndexOf("Try", StringComparison.Ordinal)).Parent, TryStatementSyntax)
Dim analysis = model.AnalyzeControlFlow(stmtSyntaxNode, stmtSyntaxNode)
Assert.False(analysis.Succeeded)
End Sub
<Fact()>
Public Sub CatchStatementSyntax()
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntime(
<compilation>
<file name="a.vb">
Module Program
Sub Main(args As String())
Try
Dim a = 123
Catch e As Exception
End Try
End Sub
End Module
</file>
</compilation>)
Dim tree = compilation.SyntaxTrees.First()
Dim model = compilation.GetSemanticModel(tree)
Dim stmtSyntaxNode = DirectCast(tree.GetCompilationUnitRoot().FindToken(tree.GetRoot.ToFullString().IndexOf("Catch e As Exception", StringComparison.Ordinal)).Parent, CatchStatementSyntax)
Dim analysis = model.AnalyzeControlFlow(stmtSyntaxNode, stmtSyntaxNode)
Assert.False(analysis.Succeeded)
End Sub
<Fact()>
Public Sub FinallyStatementSyntax()
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntime(
<compilation>
<file name="a.vb">
Module Program
Sub Main(args As String())
Try
Dim a = 123
Finally
End Try
End Sub
End Module
</file>
</compilation>)
Dim tree = compilation.SyntaxTrees.First()
Dim model = compilation.GetSemanticModel(tree)
Dim stmtSyntaxNode = DirectCast(tree.GetCompilationUnitRoot().FindToken(tree.GetRoot.ToFullString().IndexOf("Finally", StringComparison.Ordinal)).Parent, FinallyStatementSyntax)
Dim analysis = model.AnalyzeControlFlow(stmtSyntaxNode, stmtSyntaxNode)
Assert.False(analysis.Succeeded)
End Sub
<WorkItem(543722, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543722")>
<Fact()>
Public Sub SyncLockStatementSyntax()
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntime(
<compilation>
<file name="a.vb">
Module Program
Sub Main(args As String())
SyncLock New With {.x = 0}
End SyncLock
End Sub
End Module
</file>
</compilation>)
Dim tree = compilation.SyntaxTrees.First()
Dim model = compilation.GetSemanticModel(tree)
Dim stmtSyntaxNode = DirectCast(tree.GetCompilationUnitRoot().FindToken(tree.GetRoot.ToFullString().IndexOf("SyncLock New With {.x = 0}", StringComparison.Ordinal)).Parent, SyncLockStatementSyntax)
Dim analysis = model.AnalyzeControlFlow(stmtSyntaxNode, stmtSyntaxNode)
Assert.False(analysis.Succeeded)
End Sub
<WorkItem(543736, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543736")>
<Fact()>
Public Sub WhileStatementSyntax()
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntime(
<compilation>
<file name="a.vb">
Module Program
Sub Main(args As String())
While True
End While
End Sub
End Module
</file>
</compilation>)
Dim tree = compilation.SyntaxTrees.First()
Dim model = compilation.GetSemanticModel(tree)
Dim stmtSyntaxNode = DirectCast(tree.GetCompilationUnitRoot().FindToken(tree.GetRoot.ToFullString().IndexOf("While True", StringComparison.Ordinal)).Parent, WhileStatementSyntax)
Dim analysis = model.AnalyzeControlFlow(stmtSyntaxNode, stmtSyntaxNode)
Assert.False(analysis.Succeeded)
End Sub
<Fact()>
Public Sub UsingStatementSyntax()
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntime(
<compilation>
<file name="a.vb">
Imports System.IO
Module Program
Sub Main(args As String())
Using mem = New MemoryStream()
End Using
End Sub
End Module
</file>
</compilation>)
Dim tree = compilation.SyntaxTrees.First()
Dim model = compilation.GetSemanticModel(tree)
Dim stmtSyntaxNode = DirectCast(tree.GetCompilationUnitRoot().FindToken(tree.GetRoot.ToFullString().IndexOf("Using mem = New MemoryStream()", StringComparison.Ordinal)).Parent, UsingStatementSyntax)
Dim analysis = model.AnalyzeControlFlow(stmtSyntaxNode, stmtSyntaxNode)
Assert.False(analysis.Succeeded)
End Sub
<WorkItem(545449, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545449")>
<Fact()>
Public Sub LoopWhileStatementSyntax()
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntime(
<compilation>
<file name="a.vb">
Imports System.IO
Module Program
Sub Main(args As String())
Do
If Not Me.Scan() Then
Return False
End If
Loop While Me.backwardBranchChanged
Return True
End Sub
End Module
</file>
</compilation>)
Dim tree = compilation.SyntaxTrees.First()
Dim model = compilation.GetSemanticModel(tree)
Dim stmtSyntaxNode = DirectCast(tree.GetCompilationUnitRoot().FindToken(tree.GetRoot.ToFullString().IndexOf("Loop While Me.backwardBranchChanged", StringComparison.Ordinal)).Parent, LoopStatementSyntax)
Dim analysis = model.AnalyzeControlFlow(stmtSyntaxNode)
Assert.False(analysis.Succeeded)
End Sub
<Fact()>
Public Sub SelectStatementSyntax()
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntime(
<compilation>
<file name="a.vb">
Class Frame
Sub Goo()
Select Case 1 + 2 + 3
Case 1
Case 2
End Select
End Sub
End Class
</file>
</compilation>)
Dim tree = compilation.SyntaxTrees.First()
Dim model = compilation.GetSemanticModel(tree)
Dim stmtSyntaxNode = DirectCast(tree.GetCompilationUnitRoot().FindToken(tree.GetRoot.ToFullString().IndexOf("Select Case 1 + 2 + 3", StringComparison.Ordinal)).Parent, SelectStatementSyntax)
Dim analysis = model.AnalyzeControlFlow(stmtSyntaxNode, stmtSyntaxNode)
Assert.False(analysis.Succeeded)
End Sub
<Fact()>
Public Sub CaseStatementSyntax()
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntime(
<compilation>
<file name="a.vb">
Class Frame
Sub Goo()
Select Case 1 + 2 + 3
Case 1
Case 2
End Select
End Sub
End Class
</file>
</compilation>)
Dim tree = compilation.SyntaxTrees.First()
Dim model = compilation.GetSemanticModel(tree)
Dim selectSyntaxNode = DirectCast(tree.GetCompilationUnitRoot().FindToken(tree.GetRoot.ToFullString().IndexOf("Select Case 1 + 2 + 3", StringComparison.Ordinal)).Parent, SelectStatementSyntax)
Dim stmtSyntaxNode = DirectCast(selectSyntaxNode.Parent, SelectBlockSyntax).CaseBlocks(0).CaseStatement
Dim analysis = model.AnalyzeControlFlow(stmtSyntaxNode, stmtSyntaxNode)
Assert.False(analysis.Succeeded)
End Sub
<Fact()>
Public Sub DoStatementSyntax()
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntime(
<compilation>
<file name="a.vb">
Class Frame
Sub Goo()
Do
Exit Do
Loop
End Sub
End Class
</file>
</compilation>)
Dim tree = compilation.SyntaxTrees.First()
Dim model = compilation.GetSemanticModel(tree)
Dim stmtSyntaxNode = DirectCast(tree.GetCompilationUnitRoot().FindToken(tree.GetRoot.ToFullString().IndexOf("Do", StringComparison.Ordinal)).Parent, DoStatementSyntax)
Dim analysis = model.AnalyzeControlFlow(stmtSyntaxNode, stmtSyntaxNode)
Assert.False(analysis.Succeeded)
End Sub
<Fact()>
Public Sub ForStatementSyntax()
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntime(
<compilation>
<file name="a.vb">
Class Frame
Sub Goo()
For i = 0 To 1
Next
End Sub
End Class
</file>
</compilation>)
Dim tree = compilation.SyntaxTrees.First()
Dim model = compilation.GetSemanticModel(tree)
Dim stmtSyntaxNode = DirectCast(tree.GetCompilationUnitRoot().FindToken(tree.GetRoot.ToFullString().IndexOf("For i = 0 To 1", StringComparison.Ordinal)).Parent, ForStatementSyntax)
Dim analysis = model.AnalyzeControlFlow(stmtSyntaxNode, stmtSyntaxNode)
Assert.False(analysis.Succeeded)
End Sub
<Fact()>
Public Sub ForEachStatementSyntax()
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntime(
<compilation>
<file name="a.vb">
Class Frame
Sub Goo()
For Each c In ""
Next
End Sub
End Class
</file>
</compilation>)
Dim tree = compilation.SyntaxTrees.First()
Dim model = compilation.GetSemanticModel(tree)
Dim stmtSyntaxNode = DirectCast(tree.GetCompilationUnitRoot().FindToken(tree.GetRoot.ToFullString().IndexOf("For Each c In """"", StringComparison.Ordinal)).Parent, ForEachStatementSyntax)
Dim analysis = model.AnalyzeControlFlow(stmtSyntaxNode, stmtSyntaxNode)
Assert.False(analysis.Succeeded)
End Sub
<WorkItem(543548, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543548")>
<Fact()>
Public Sub NamespaceIdentifierNameInMemberAccess()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Namespace STForEach01
Friend Module STForEach01mod
Sub STForEach01
End Sub
End Module
End Namespace
Friend Module MainModule
Sub Main()
[|STForEach01|].STForEach01
End Sub
End Module
</file>
</compilation>)
Assert.False(dataFlowResults.Succeeded)
End Sub
<WorkItem(543548, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543548")>
<Fact()>
Public Sub NamespaceIdentifierNameInMemberAccess2()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Namespace STForEach01
Friend Module STForEach01mod
Sub STForEach01
End Sub
End Module
End Namespace
Friend Module MainModule
Sub Main()
[|STForEach01.STForEach01mod|].STForEach01
End Sub
End Module
</file>
</compilation>)
Assert.False(dataFlowResults.Succeeded)
End Sub
<WorkItem(543548, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543548")>
<Fact()>
Public Sub NamespaceIdentifierNameInMemberAccess3()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Namespace STForEach01
Friend Module STForEach01mod
ReadOnly Property STForEach01 As Integer
Get
Return 1
End Get
End Property
End Module
End Namespace
Friend Module MainModule
Sub Main()
Dim a As Integer = [|STForEach01|].STForEach01
End Sub
End Module
</file>
</compilation>)
Assert.False(dataFlowResults.Succeeded)
End Sub
<WorkItem(543548, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543548")>
<Fact()>
Public Sub NamespaceIdentifierNameInMemberAccess4()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Namespace STForEach01
Friend Module STForEach01mod
ReadOnly Property STForEach01 As Integer
Get
Return 1
End Get
End Property
End Module
End Namespace
Friend Module MainModule
Sub Main()
Dim a As Integer = [|STForEach01.STForEach01mod|].STForEach01
End Sub
End Module
</file>
</compilation>)
Assert.False(dataFlowResults.Succeeded)
End Sub
<WorkItem(543695, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543695")>
<Fact()>
Public Sub NamespaceIdentifierNameInMemberAccess5()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Module Program
Sub Main()
Dim d1 = Sub(x As Integer)
[|System|].Console.WriteLine(x)
End Sub
End Sub
End Module
</file>
</compilation>)
Assert.False(dataFlowResults.Succeeded)
End Sub
<WorkItem(543695, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543695")>
<Fact()>
Public Sub NamespaceIdentifierNameInMemberAccess6()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Module Program
Sub Main()
[|System|].Console.WriteLine(x)
End Sub
End Module
</file>
</compilation>)
Assert.False(dataFlowResults.Succeeded)
End Sub
<WorkItem(543695, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543695")>
<Fact()>
Public Sub NamespaceIdentifierNameInMemberAccess7()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Public Class A
Public Class B
Public Shared Sub M()
End Sub
End Class
End Class
Module Program
Sub Main()
[|A.B|].M()
End Sub
End Module
</file>
</compilation>)
Assert.False(dataFlowResults.Succeeded)
End Sub
<WorkItem(543695, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543695")>
<Fact()>
Public Sub NamespaceIdentifierNameInMemberAccess8()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Public Class A
Public Class B
Public Shared Sub M()
End Sub
End Class
End Class
Module Program
Sub Main()
[|A|].B.M()
End Sub
End Module
</file>
</compilation>)
Assert.False(dataFlowResults.Succeeded)
End Sub
<WorkItem(545080, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545080")>
<Fact()>
Public Sub NamespaceIdentifierNameInMemberAccess9()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Public Class Compilation
Public Class B
Public Shared Function M(a As Integer) As Boolean
Return False
End Function
End Class
End Class
Friend Class Program
Public Shared Sub Main()
Dim x = [| Compilation |].B.M(a:=123)
End Sub
Public ReadOnly Property Compilation As Compilation
Get
Return Nothing
End Get
End Property
End Class
</file>
</compilation>)
Assert.False(dataFlowResults.Succeeded)
End Sub
<WorkItem(545080, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545080")>
<Fact()>
Public Sub NamespaceIdentifierNameInMemberAccess10()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Public Class Compilation
Public Shared Function M(a As Integer) As Boolean
Return False
End Function
End Class
Friend Class Program
Public Shared Sub Main()
Dim x = [| Compilation |].M(a:=123)
End Sub
Public ReadOnly Property Compilation As Compilation
Get
Return Nothing
End Get
End Property
End Class
</file>
</compilation>)
Assert.False(dataFlowResults.Succeeded)
End Sub
<Fact()>
Public Sub ConstLocalUsedInLambda01()
Dim analysisResult = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Module M1
Sub Main()
Dim local = 1
Const constLocal = 2
Dim f = [| Function(p as sbyte) As Short
Return local + constlocal + p
End Function |]
Console.Write(f)
End Sub
End Module
</file>
</compilation>)
Assert.Equal("p", GetSymbolNamesJoined(analysisResult.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysisResult.AlwaysAssigned))
Assert.Equal("local", GetSymbolNamesJoined(analysisResult.Captured))
Assert.Equal("local", GetSymbolNamesJoined(analysisResult.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysisResult.CapturedOutside))
Assert.Equal("local, constLocal", GetSymbolNamesJoined(analysisResult.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysisResult.DataFlowsOut))
Assert.Equal("local, constLocal, f", GetSymbolNamesJoined(analysisResult.DefinitelyAssignedOnEntry))
Assert.Equal("local, constLocal, f", GetSymbolNamesJoined(analysisResult.DefinitelyAssignedOnExit))
Assert.Equal("local, constLocal, p", GetSymbolNamesJoined(analysisResult.ReadInside))
' WHY
Assert.Equal("p", GetSymbolNamesJoined(analysisResult.WrittenInside))
Assert.Equal("f", GetSymbolNamesJoined(analysisResult.ReadOutside))
Assert.Equal("local, constLocal, f", GetSymbolNamesJoined(analysisResult.WrittenOutside))
End Sub
<Fact()>
Public Sub ConstLocalUsedInLambda02()
Dim analysisResult = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Class C
Function F(mp As Short) As Integer
Try
Dim local = 1
Const constLocal = 2
Dim lf = [| Sub()
local = constlocal + mp
End Sub |]
lf()
Return local
Finally
End Try
End Function
End Class
</file>
</compilation>)
Assert.Equal(Nothing, GetSymbolNamesJoined(analysisResult.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysisResult.AlwaysAssigned))
Assert.Equal("mp, local", GetSymbolNamesJoined(analysisResult.Captured))
Assert.Equal("mp, local", GetSymbolNamesJoined(analysisResult.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysisResult.CapturedOutside))
Assert.Equal("mp, constLocal", GetSymbolNamesJoined(analysisResult.DataFlowsIn))
Assert.Equal("Me, mp, local, constLocal, lf", GetSymbolNamesJoined(analysisResult.DefinitelyAssignedOnEntry))
Assert.Equal("Me, mp, local, constLocal, lf", GetSymbolNamesJoined(analysisResult.DefinitelyAssignedOnExit))
Assert.Equal("local", GetSymbolNamesJoined(analysisResult.DataFlowsOut))
Assert.Equal("mp, constLocal", GetSymbolNamesJoined(analysisResult.ReadInside))
Assert.Equal("local", GetSymbolNamesJoined(analysisResult.WrittenInside))
Assert.Equal("local, lf", GetSymbolNamesJoined(analysisResult.ReadOutside))
Assert.Equal("Me, mp, local, constLocal, lf", GetSymbolNamesJoined(analysisResult.WrittenOutside))
End Sub
<WorkItem(543701, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543701")>
<Fact()>
Public Sub LiteralExprInVarDeclInsideSingleLineLambda()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Module Test
Sub Sub1()
Dim x = Sub() Dim y = [|10|]
End Sub
End Module
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
End Sub
<WorkItem(543702, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543702")>
<Fact()>
Public Sub LiteralExprInsideEnumMemberDecl()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Module Program
Enum NUMBERS
One = [|1|]
End Enum
End Module
</file>
</compilation>)
Assert.False(dataFlowResults.Succeeded)
End Sub
<WorkItem(11662, "DevDiv_Projects/Roslyn")>
<Fact()>
Public Sub ObjectCreationExpr()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Module Program
Sub Main(args As String())
Dim x As [|New C|]
End Sub
End Module
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
End Sub
#Region "ObjectInitializer"
<Fact()>
Public Sub ObjectInitializersNoLocalsAccessed()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Public Class C1
Public FieldInt As Long
Public FieldStr As String
Public Property PropInt As Integer
End Class
Public Class C2
Public Shared Sub Main()
Dim intlocal As Integer
Dim x = New C1() With {.FieldStr = [|.FieldInt.ToString()|]}
End Sub
End Class
</file>
</compilation>)
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<WorkItem(544298, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544298")>
<Fact()>
Public Sub ObjectInitializersLocalsAccessed1_OnlyImplicitReceiverRegion1()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Public Structure S1
Public FieldInt As Long
Public FieldStr As String
Public Property PropInt As Integer
End Structure
Public Class S2
Public Shared Sub Main()
Dim x, y As New S1() With {.FieldStr = [|.FieldInt.ToString()|]}
End Sub
End Class
</file>
</compilation>)
Assert.False(dataFlowAnalysisResults.Succeeded)
End Sub
<WorkItem(544298, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544298")>
<Fact()>
Public Sub ObjectInitializersLocalsAccessed1_OnlyImplicitReceiverRegion2()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Public Structure S1
Public FieldInt As Long
Public FieldStr As String
Public Property PropInt As Integer
End Structure
Public Class S2
Public Shared Sub Main()
Dim x, y As New S1() With {.FieldInt = [|.FieldStr.Length|]}
End Sub
End Class
</file>
</compilation>)
Assert.False(dataFlowAnalysisResults.Succeeded)
End Sub
<WorkItem(544298, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544298")>
<Fact()>
Public Sub ObjectInitializersLocalsAccessed1_DeclAndImplicitReceiverRegion()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Public Structure S1
Public FieldInt As Long
Public FieldStr As String
Public Property PropInt As Integer
End Structure
Public Class S2
Public Shared Sub Main()
[| Dim x, y As New S1() With {.FieldInt = .FieldStr.Length} |]
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowAnalysisResults.Succeeded)
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<WorkItem(544298, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544298")>
<Fact()>
Public Sub ObjectInitializersLocalsAccessed1_ValidRegion1()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Public Structure S1
Public FieldInt As Long
Public FieldStr As String
Default Public Property PropInt(i As String) As String
Get
Return 0
End Get
Set(value As String)
End Set
End Property
End Structure
Public Class S2
Public Shared Sub Main()
Dim x, y As New S1() With {.FieldInt = !A.Length }
x.FieldInt = [| x!A.Length |]
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowAnalysisResults.Succeeded)
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedOutside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<WorkItem(544298, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544298")>
<Fact()>
Public Sub ObjectInitializersLocalsAccessed1_ValidRegion2()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Public Structure S1
Public FieldInt As Long
Public FieldStr As String
Default Public Property PropInt(i As String) As String
Get
Return 0
End Get
Set(value As String)
End Set
End Property
End Structure
Public Class S2
Public Shared Sub Main()
Dim x, y As New S1() With {.FieldInt = [| x!A.Length |] }
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowAnalysisResults.Succeeded)
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedOutside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<WorkItem(544298, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544298")>
<Fact()>
Public Sub ObjectInitializersLocalsAccessed1_InvalidRegion3()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Public Structure S1
Public FieldInt As Long
Public FieldStr As String
Default Public Property PropInt(i As String) As String
Get
Return 0
End Get
Set(value As String)
End Set
End Property
End Structure
Public Class S2
Public Shared Sub Main()
Dim x, y As New S1() With {.FieldStr = [| !A |] }
End Sub
End Class
</file>
</compilation>)
Assert.False(dataFlowAnalysisResults.Succeeded)
End Sub
<WorkItem(531226, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/531226")>
<Fact()>
Public Sub DisableConstantLiteralRegion()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Public Class S2
Public Shared Sub Main()
Const PERUSER_EXTENSION As String = [|".user"|] 'Project .user file extension
End Sub
End Class
</file>
</compilation>)
Assert.False(dataFlowAnalysisResults.Succeeded)
End Sub
<WorkItem(531226, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/531226")>
<Fact()>
Public Sub WithStatement_LValueExpression()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Public Structure S1
Public F1 As Integer
Public F2 As Integer
End Structure
Public Class S2
Public Shared Sub Main()
Dim arr() As S1 = {}
With arr([|0|])
Console.WriteLine(.F1)
.F2 = 123
Console.WriteLine(.F2)
End With
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowAnalysisResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
End Sub
<WorkItem(531226, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/531226")>
<Fact()>
Public Sub WithStatement_LValueExpression2()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Public Structure S1
Public F1 As Integer
Public F2 As Integer
End Structure
Public Class S2
Public Shared Sub Main()
Dim arr() As S1 = {}
With arr([|0|])
End With
End Sub
End Class
</file>
</compilation>)
Assert.False(dataFlowAnalysisResults.Succeeded)
End Sub
<WorkItem(531226, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/531226")>
<Fact()>
Public Sub WithStatement_LValueExpression3()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Public Structure S1
Public F1 As Integer
Public F2 As Integer
End Structure
Public Class S2
Public Shared Sub Main()
Dim arr() As S1 = {}
With [|arr(0)|]
End With
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowAnalysisResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("arr", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("arr", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
End Sub
<WorkItem(531226, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/531226")>
<Fact()>
Public Sub WithStatement_LValueExpression4()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Public Structure S1
Public F1 As Integer
Public F2 As Integer
End Structure
Public Class S2
Public Shared Sub Main()
Dim arr As New S1
With [|arr|]
End With
End Sub
End Class
</file>
</compilation>)
Assert.False(dataFlowAnalysisResults.Succeeded)
End Sub
<WorkItem(544298, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544298")>
<Fact()>
Public Sub ObjectInitializersLocalsAccessed1a_ObjectInitializer()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Public Structure S1
Public FieldInt As Long
Public FieldStr As String
Public Property PropInt As Integer
End Structure
Public Class S2
Public Shared Sub Main()
Dim o As New S1()
With o
[|Console.WriteLine(New S1() With {.FieldStr = .FieldInt.ToString()})|]
End With
End Sub
End Class
</file>
</compilation>)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("o", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<WorkItem(544298, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544298")>
<Fact()>
Public Sub ObjectInitializersLocalsAccessed1a_ObjectInitializer2()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Public Structure S1
Public FieldInt As Long
Public FieldStr As String
Public Property PropInt As Integer
End Structure
Public Class S2
Public Shared Sub Main()
Dim o As New S1()
With o
Console.WriteLine(New S1() With {.FieldStr = [|.FieldInt.ToString()|] })
End With
End Sub
End Class
</file>
</compilation>)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("o", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<WorkItem(544298, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544298")>
<Fact()>
Public Sub ObjectInitializersLocalsAccessed1b()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Imports System.Collections.Generic
Public Structure S1
Public FieldInt As Long
Public FieldStr As String
Public Property PropInt As Integer
End Structure
Public Class S2
Public Shared Sub Main()
Dim o As New S1()
With o
[|Console.WriteLine(New List(Of String) From {.FieldStr, "Brian", "Tim"})|]
End With
End Sub
End Class
</file>
</compilation>)
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedOutside))
Assert.Equal("o", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("o", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("o", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<WorkItem(544298, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544298")>
<Fact()>
Public Sub ObjectInitializersLocalsAccessed1bb()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Imports System.Collections.Generic
Public Structure S1
Public FieldInt As Long
Public FieldStr As String
Public Property PropInt As Integer
End Structure
Public Class S2
Public Shared Sub Main()
Dim o As New S1()
[|Console.WriteLine(New List(Of String) From {o.FieldStr, "Brian", "Tim"})|]
End Sub
End Class
</file>
</compilation>)
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedOutside))
Assert.Equal("o", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("o", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("o", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<WorkItem(544298, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544298")>
<Fact()>
Public Sub ObjectInitializers_StructWithFieldAccessesInLambda1()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Imports System.Collections.Generic
Structure SS1
Public A As String
Public B As String
End Structure
Structure SS2
Public X As SS1
Public Y As SS1
End Structure
Structure Clazz
Shared Sub TEST()
Dim a, b As New SS2() With {.X = Function() As SS1
With .Y
[| .A = "1" |]
'.B = "2"
End With
Return .Y
End Function.Invoke()}
End Sub
End Structure
</file>
</compilation>)
Assert.False(dataFlowAnalysisResults.Succeeded)
End Sub
<WorkItem(544298, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544298")>
<Fact()>
Public Sub ObjectInitializers_StructWithFieldAccessesInLambda2()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Imports System.Collections.Generic
Structure SS1
Public A As String
Public B As String
End Structure
Structure SS2
Public X As SS1
Public Y As SS1
End Structure
Structure Clazz
Shared Sub TEST()
Dim a, b As New SS2() With {.X = Function() As SS1
With .Y
[|
b.Y.B = a.Y.A
a.Y.A = "1"
|]
End With
Return .Y
End Function.Invoke()}
End Sub
End Structure
</file>
</compilation>)
Assert.True(dataFlowAnalysisResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("a, b", GetSymbolNamesJoined(dataFlowAnalysisResults.Captured))
Assert.Equal("a, b", GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedInside))
Assert.Equal("a, b", GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedOutside))
Assert.Equal("a", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("a", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("a, b", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("a, b", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("a, b", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<WorkItem(544298, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544298")>
<Fact()>
Public Sub ObjectInitializers_StructWithFieldAccessesInLambda3()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Imports System.Collections.Generic
Structure SS1
Public A As String
Public B As String
End Structure
Structure SS2
Public X As SS1
Public Y As SS1
End Structure
Structure Clazz
Sub New(i As Integer)
Dim l = Sub()
Dim a, b As New SS2() With {.X = Function() As SS1
With .Y
[|
b.Y.B = a.Y.A
a.Y.A = "1"
|]
End With
Return .Y
End Function.Invoke()}
End Sub
End Sub
End Structure
</file>
</compilation>)
Assert.True(dataFlowAnalysisResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("a, b", GetSymbolNamesJoined(dataFlowAnalysisResults.Captured))
Assert.Equal("a, b", GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedInside))
Assert.Equal("a, b", GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedOutside))
Assert.Equal("a", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("a", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("Me, a, b", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("a, b", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("Me, i, l, a, b", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<WorkItem(544298, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544298")>
<Fact()>
Public Sub ObjectInitializers_StructWithFieldAccessesInLambda4()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Imports System.Collections.Generic
Structure SS1
Public A As String
Public B As String
End Structure
Structure SS2
Public X As SS1
Public Y As SS1
End Structure
Structure Clazz
Sub New(i As Integer)
Dim a, b As New SS2() With {.X = Function() As SS1
[| a.Y = New SS1()
b.Y = New SS1() |]
Return .Y
End Function.Invoke()}
Console.WriteLine(a.ToString())
End Sub
End Structure
</file>
</compilation>)
Assert.True(dataFlowAnalysisResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("a, b", GetSymbolNamesJoined(dataFlowAnalysisResults.Captured))
Assert.Equal("a, b", GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedInside))
Assert.Equal("a, b", GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("Me, a, b", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("a, b", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("Me, i, a, b", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<WorkItem(544298, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544298")>
<Fact()>
Public Sub ObjectInitializers_StructWithFieldAccessesInLambda5()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Imports System.Collections.Generic
Structure SS1
Public A As String
Public B As String
End Structure
Structure SS2
Public X As SS1
Public Y As SS1
End Structure
Structure Clazz
Sub New(i As Integer)
Dim a, b As New SS2() With {.X = Function() As SS1
[| b.Y = New SS1() |]
Return a.Y
End Function.Invoke()}
Console.WriteLine(a.ToString())
End Sub
End Structure
</file>
</compilation>)
Assert.True(dataFlowAnalysisResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("a, b", GetSymbolNamesJoined(dataFlowAnalysisResults.Captured))
Assert.Equal("b", GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedInside))
Assert.Equal("a", GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("Me, a", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("b", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("Me, i, a, b", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<WorkItem(544298, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544298")>
<Fact()>
Public Sub ObjectInitializers_StructWithFieldAccessesInLambda6()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Imports System.Collections.Generic
Structure SS1
Public A As String
Public B As String
End Structure
Structure SS2
Public X As SS1
Public Y As SS1
End Structure
Structure Clazz
Sub New(i As Integer)
Dim a, b As New SS2() With {.X = Function() As SS1
[| b.Y = New SS1() |]
Return b.Y
End Function.Invoke()}
Console.WriteLine(a.ToString())
End Sub
End Structure
</file>
</compilation>)
Assert.True(dataFlowAnalysisResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("b", GetSymbolNamesJoined(dataFlowAnalysisResults.Captured))
Assert.Equal("b", GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedInside))
Assert.Equal("b", GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("b", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("Me, a, b", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("b", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("Me, i, a, b", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<WorkItem(544298, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544298")>
<Fact()>
Public Sub ObjectInitializers_PassingFieldByRef()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Imports System.Collections.Generic
Structure SS1
Public A As String
Public B As String
End Structure
Structure SS2
Public X As SS1
Public Y As SS1
End Structure
Structure Clazz
Shared Function Transform(ByRef p As SS1) As SS1
Return p
End Function
Sub New(i As Integer)
Dim a, b As New SS2() With {.X = [| Transform(b.Y) |] }
End Sub
End Structure
</file>
</compilation>)
Assert.True(dataFlowAnalysisResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedOutside))
Assert.Equal("b", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("b", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("b", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("Me, i, a, b", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<Fact()>
Public Sub ObjectInitializersLocalsAccessed2()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Public Structure S1
Public FieldInt As Long
Public FieldStr As String
Public Property PropInt As Integer
End Structure
Public Class S2
Public Shared Sub Main()
Dim x As New S1() With {.FieldStr = [|.FieldInt.ToString()|]}
End Sub
End Class
</file>
</compilation>)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedOutside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<Fact()>
Public Sub ObjectInitializersWithLocalsAccessed()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Public Class C1
Public FieldStr As String
End Class
Public Class C2
Public Shared Function GetStr(p as string)
return p
end Function
Public Shared Sub Main()
Dim strlocal As String
Dim x = New C1() With {.FieldStr = [|GetStr(strLocal)|]}
End Sub
End Class
</file>
</compilation>)
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("strlocal", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("strlocal", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.Captured))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedInside))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedOutside))
End Sub
<Fact()>
Public Sub ObjectInitializersWithLocalCaptured()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Class C1
Public Field As Integer = 42
Public Field2 As Func(Of Integer)
End Class
Class C1(Of T)
Public Field As T
End Class
Class C2
Public Shared Sub Main()
Dim localint as integer = 23
Dim x As New C1 With {.Field2 = [|Function() As Integer
Return localint
End Function|]}
x.Field = 42
Console.WriteLine(x.Field2.Invoke())
End Sub
End Class
</file>
</compilation>)
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("localint", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("localint", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("localint, x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
Assert.Equal("localint", GetSymbolNamesJoined(dataFlowAnalysisResults.Captured))
Assert.Equal("localint", GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedOutside))
End Sub
<Fact()>
Public Sub ObjectInitializersWholeStatement()
Dim analysisResults = CompileAndAnalyzeControlAndDataFlow(
<compilation>
<file name="a.vb">
Imports System
Class C1
Public Field As Integer = 42
Public Field2 As Func(Of Integer)
End Class
Class C1(Of T)
Public Field As T
End Class
Class C2
Public Shared Sub Main()
Dim localint as integer
[|Dim x As New C1 With {.Field2 = Function() As Integer
localInt = 23
Return localint
End Function}|]
x.Field = 42
Console.WriteLine(x.Field2.Invoke())
End Sub
End Class
</file>
</compilation>)
Dim dataFlowAnalysisResults = analysisResults.Item2
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("localint", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("localint, x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
Assert.Equal("localint", GetSymbolNamesJoined(dataFlowAnalysisResults.Captured))
Assert.Equal("localint", GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedOutside))
Dim controlFlowAnalysisResults = analysisResults.Item1
Assert.Equal(0, controlFlowAnalysisResults.EntryPoints.Count)
Assert.Equal(0, controlFlowAnalysisResults.ExitPoints.Count)
Assert.True(controlFlowAnalysisResults.EndPointIsReachable)
Assert.True(controlFlowAnalysisResults.StartPointIsReachable)
End Sub
#End Region
#Region "CollectionInitializer"
<Fact()>
Public Sub CollectionInitializersCompleteObjectCreationExpression()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Imports System.Collections.Generic
Public Class C2
Public Shared Sub Main()
dim goo as string = "Hello World"
Dim x as [|New List(Of String) From {goo, "!"}|]
End Sub
End Class
</file>
</compilation>)
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("goo", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("goo", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("goo, x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<Fact()>
Public Sub CollectionInitializersOutermostInitializerAreNoVBExpressions()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Imports System.Collections.Generic
Public Class C2
Public Shared Sub Main()
dim goo as string = "Hello World"
Dim x as New List(Of String) From [|{goo, "!"}|]
End Sub
End Class
</file>
</compilation>)
Assert.False(dataFlowAnalysisResults.Succeeded)
End Sub
<Fact()>
Public Sub CollectionInitializersTopLevelInitializerAreNoVBExpressions()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Imports System.Collections.Generic
Public Class C2
Public Shared Sub Main()
dim goo as string = "Hello World"
Dim x as New Dictionary(Of String, Integer) From {[|{goo, 1}|], {"bar", 42}}
End Sub
End Class
</file>
</compilation>)
Assert.False(dataFlowAnalysisResults.Succeeded)
End Sub
<WorkItem(530032, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530032")>
<Fact>
Public Sub CollectionInitializersNestedInitializer()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Imports System.Collections.Generic
Public Class C2
Public Shared Sub Main(),
dim goo as string = "Hello World"
Dim x as New Dictionary(Of String(), Integer) From { {[|{goo, "!"}|], 1} }
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowAnalysisResults.Succeeded)
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("goo", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("goo", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("goo, x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<Fact()>
Public Sub CollectionInitializersLiftedLocals()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Imports System.Collections.Generic
Public Class C2
Public Shared Sub Main()
Dim goo As String = "Hello World"
Dim x As [|New List(Of Action) From {
Sub()
Console.WriteLine(goo)
End Sub,
Sub()
Console.WriteLine(x.Item(0))
x = nothing
End Sub
}|]
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowAnalysisResults.Succeeded)
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("goo, x", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("goo, x", GetSymbolNamesJoined(dataFlowAnalysisResults.Captured))
Assert.Equal("goo, x", GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.CapturedOutside))
Assert.Equal("goo, x", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Null(GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("goo, x", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<Fact(), WorkItem(12970, "DevDiv_Projects/Roslyn")>
Public Sub CollectionInitUndeclaredIdentifier()
Dim dataFlowAnalysisResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Imports System.Collections.Generic
Imports System.Linq
Module Program
Sub Main(args As String())
Dim f1() As String = {[|X|]}
End Sub
End Module
</file>
</compilation>)
Assert.True(dataFlowAnalysisResults.Succeeded)
End Sub
#End Region
<Fact(), WorkItem(544079, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544079")>
Public Sub UserDefinedOperatorBody()
Dim analysisResults = CompileAndAnalyzeControlAndDataFlow(
<compilation>
<file name="a.vb">
Imports System
Module Module1
Class B2
Public f As Integer
Public Sub New(x As Integer)
f = x
End Sub
Shared Widening Operator CType(x As Integer) As B2
[| Return New B2(x) |]
End Operator
End Class
Sub Main()
Dim x As Integer = 11
Dim b2 As B2 = x
End Sub
End Module
</file>
</compilation>)
Dim ctrlFlowResults = analysisResults.Item1
Assert.True(ctrlFlowResults.Succeeded)
Assert.Equal(1, ctrlFlowResults.ExitPoints.Count())
Assert.Equal(0, ctrlFlowResults.EntryPoints.Count())
Assert.True(ctrlFlowResults.StartPointIsReachable)
Assert.False(ctrlFlowResults.EndPointIsReachable)
Dim dataFlowResults = analysisResults.Item2
Assert.True(dataFlowResults.Succeeded)
Assert.Empty(dataFlowResults.VariablesDeclared)
Assert.Empty(dataFlowResults.AlwaysAssigned)
Assert.Empty(dataFlowResults.Captured)
Assert.Empty(dataFlowResults.CapturedInside)
Assert.Empty(dataFlowResults.CapturedOutside)
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Empty((dataFlowResults.DataFlowsOut))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.DefinitelyAssignedOnEntry))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DefinitelyAssignedOnExit))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Empty(dataFlowResults.WrittenInside)
Assert.Empty(dataFlowResults.ReadOutside)
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact(), WorkItem(544079, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544079")>
Public Sub UserDefinedOperatorBody_1()
Dim analysisResults = CompileAndAnalyzeControlAndDataFlow(
<compilation>
<file name="a.vb">
Imports System
Module Module1
Class B2
Public f As Integer
Public Sub New(x As Integer)
f = x
End Sub
Shared Operator -(x As Integer, y As B2) As B2
[| Return New B2(x) |]
End Operator
End Class
Sub Main()
End Sub
End Module
</file>
</compilation>)
Dim ctrlFlowResults = analysisResults.Item1
Assert.True(ctrlFlowResults.Succeeded)
Assert.Equal(1, ctrlFlowResults.ExitPoints.Count())
Assert.Equal(0, ctrlFlowResults.EntryPoints.Count())
Assert.True(ctrlFlowResults.StartPointIsReachable)
Assert.False(ctrlFlowResults.EndPointIsReachable)
Dim dataFlowResults = analysisResults.Item2
Assert.True(dataFlowResults.Succeeded)
Assert.Empty(dataFlowResults.VariablesDeclared)
Assert.Empty(dataFlowResults.AlwaysAssigned)
Assert.Empty(dataFlowResults.Captured)
Assert.Empty(dataFlowResults.CapturedInside)
Assert.Empty(dataFlowResults.CapturedOutside)
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Empty((dataFlowResults.DataFlowsOut))
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowResults.DefinitelyAssignedOnEntry))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DefinitelyAssignedOnExit))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Empty(dataFlowResults.WrittenInside)
Assert.Empty(dataFlowResults.ReadOutside)
Assert.Equal("x, y", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub UserDefinedOperatorInExpression()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Module Module1
Class B2
Public f As Integer
Public Sub New(x As Integer)
f = x
End Sub
Shared Operator -(x As Integer, y As B2) As B2
Return New B2(x)
End Operator
End Class
Sub Main(args As String())
Dim x As Short = 123
Dim bb = New B2(x)
Dim ret = [| Function(y)
Return args.Length - (y - (x - bb))
End Function |]
End Sub
End Module
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Equal("y", GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Empty(dataFlowResults.AlwaysAssigned)
Assert.Equal("args, x, bb", GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal("args, x, bb", GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal("args, x, bb", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Empty(dataFlowResults.DataFlowsOut)
Assert.Equal("args, x, bb, ret", GetSymbolNamesJoined(dataFlowResults.DefinitelyAssignedOnEntry))
Assert.Equal("args, x, bb, ret", GetSymbolNamesJoined(dataFlowResults.DefinitelyAssignedOnExit))
Assert.Equal("args, x, bb, y", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal("y", GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("args, x, bb, ret", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact(), WorkItem(545047, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545047")>
Public Sub UserDefinedLiftedOperatorInExpr()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Class A
Structure S
Shared Narrowing Operator CType(x As S?) As Integer
System.Console.WriteLine("Operator Conv")
Return 123 'Nothing
End Operator
Shared Operator *(x As S?, y As Integer?) As Integer?
System.Console.WriteLine("Operator *")
Return y
End Operator
End Structure
End Class
Module Program
Sub M(Optional p As Integer? = Nothing)
Dim local As A.S? = New A.S()
Dim f As Func(Of A.S, Integer?) = [| Function(x)
Return x * local * p
End Function |]
Console.Write(f(local))
End Sub
End Module
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Empty(dataFlowResults.AlwaysAssigned)
Assert.Equal("p, local", GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal("p, local", GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal("p, local", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Empty(dataFlowResults.DataFlowsOut)
Assert.Equal("f", GetSymbolNamesJoined(dataFlowResults.DefinitelyAssignedOnEntry))
Assert.Equal("f", GetSymbolNamesJoined(dataFlowResults.DefinitelyAssignedOnExit))
Assert.Equal("p, local, x", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal("local, f", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("p, local, f", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact(), WorkItem(545047, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545047")>
Public Sub DataFlowsInAndNullable()
' WARNING: if this test is edited, the test with the
' test with the same name in C# must be modified too
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Structure S
Public F As Integer
Public Sub New(_f As Integer)
Me.F = _f
End Sub
End Structure
Module Program
Sub Main(args As String())
Dim i As Integer? = 1
Dim s As New S(1)
[|
Console.Write(i.Value)
Console.Write(s.F)
|]
End Sub
End Module
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Empty(dataFlowResults.VariablesDeclared)
Assert.Empty(dataFlowResults.AlwaysAssigned)
Assert.Empty(dataFlowResults.Captured)
Assert.Empty(dataFlowResults.CapturedInside)
Assert.Empty(dataFlowResults.CapturedOutside)
Assert.Equal("i, s", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Empty(dataFlowResults.DataFlowsOut)
Assert.Equal("args", GetSymbolNamesJoined(dataFlowResults.DefinitelyAssignedOnEntry))
Assert.Equal("args", GetSymbolNamesJoined(dataFlowResults.DefinitelyAssignedOnExit))
Assert.Equal("i, s", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Empty(dataFlowResults.WrittenInside)
Assert.Empty(dataFlowResults.ReadOutside)
Assert.Equal("args, i, s", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<WorkItem(545249, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545249")>
<Fact()>
Public Sub TestWithEventsInitializer()
Dim comp = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Class C1
WithEvents e As C1 = [|Me|]
End Class
</file>
</compilation>)
Debug.Assert(comp.Succeeded)
End Sub
<WorkItem(545249, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545249")>
<Fact()>
Public Sub TestWithEventsInitializer2()
Dim comp = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Class C1
Public Sub New(c As C1)
End Sub
WithEvents e As New C1([|Me|])
End Class
</file>
</compilation>)
Debug.Assert(comp.Succeeded)
End Sub
<Fact()>
Public Sub TestWithEventsInitializer3()
Dim comp = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Class C1
Public Sub New(c As C1)
End Sub
WithEvents e, f As C1 = [|Me|]
End Class
</file>
</compilation>)
Debug.Assert(comp.Succeeded)
End Sub
<Fact()>
Public Sub TestWithEventsInitializer4()
Dim comp = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Class C1
Public Sub New(c As C1)
End Sub
WithEvents d As New C1(Me), e, f As New C1([|Me|])
End Class
</file>
</compilation>)
Debug.Assert(comp.Succeeded)
End Sub
<WorkItem(545480, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545480")>
<Fact()>
Public Sub ReturnStatementInElseInsideIncompleteFunction()
Dim comp = CompilationUtils.CreateCompilationWithMscorlib40(
<compilation>
<file name="a.vb">
Public Class vbPartialCls002
Public Function Fun1() As Object
If Nothing Then
Return New Object()
Else
Return Nothing
</file>
</compilation>)
Dim tree = comp.SyntaxTrees.First()
Dim stmtNode = tree.GetCompilationUnitRoot().DescendantNodes().OfType(Of StatementSyntax).Where(Function(node) node.ToString() = "Return Nothing").First()
Dim semanticModel = comp.GetSemanticModel(tree)
Dim controlFlowAnalysis = semanticModel.AnalyzeControlFlow(stmtNode)
Assert.True(controlFlowAnalysis.Succeeded)
End Sub
<WorkItem(545900, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545900")>
<Fact()>
Public Sub AnonymousObjectCreationExprInsideOptionalParamDecl()
Dim comp = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Module Program
Function scen3(Optional ByRef p1 As Object = New With {.abc = [|123|]})
End Function
End Module
</file>
</compilation>)
Assert.False(comp.Succeeded)
End Sub
<WorkItem(545900, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545900")>
<Fact()>
Public Sub AnonymousObjectCreationExprInsideOptionalParamDecl2()
Dim comp = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Class Program
Public XYZ As String = "xyz"
Function scen3(Optional ByRef p1 As Object = New With {.abc = [|Me.XYZ|]}) As String
Return Nothing
End Function
End Class
</file>
</compilation>)
Assert.False(comp.Succeeded)
End Sub
<WorkItem(545900, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545900")>
<Fact()>
Public Sub LambdaExprInsideOptionalParamDecl2()
Dim comp = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Module Program
Sub Main(args As String())
End Sub
Property P(i As Integer, Optional k As String = (Function() As String
Return [| "" |]
End Function)()) As String
Get
Return k
End Get
Set(value As String)
End Set
End Property
End Module
</file>
</compilation>)
Assert.True(comp.Succeeded)
End Sub
<Fact()>
Public Sub ConstantUnevaluatedReceiver()
Dim compilation = CompilationUtils.CreateCompilationWithMscorlib40(
<compilation>
<file name="a.vb"><![CDATA[
Class A
Const F As Object = Nothing
Function M() As Object
Return Me.F
End Function
End Class
]]></file>
</compilation>)
Dim tree = compilation.SyntaxTrees(0)
Dim model = compilation.GetSemanticModel(tree)
Dim expr = FindNodeOfTypeFromText(Of ExpressionSyntax)(tree, "Me")
model.AnalyzeDataFlow(expr)
End Sub
<Fact()>
Public Sub CallUnevaluatedReceiver()
Dim compilation = CompilationUtils.CreateCompilationWithMscorlib40(
<compilation>
<file name="a.vb"><![CDATA[
Class A
Shared Function F() As Object
Return Nothing
End Function
Function M() As Object
Return Me.F()
End Function
End Class
]]></file>
</compilation>)
Dim tree = compilation.SyntaxTrees(0)
Dim model = compilation.GetSemanticModel(tree)
Dim expr = FindNodeOfTypeFromText(Of ExpressionSyntax)(tree, "Me")
model.AnalyzeDataFlow(expr)
End Sub
<WorkItem(546639, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/546639")>
<Fact()>
Public Sub AddressOfUnevaluatedReceiver()
Dim compilation = CompilationUtils.CreateCompilationWithMscorlib40(
<compilation>
<file name="a.vb"><![CDATA[
Class A
Shared Sub M()
End Sub
Function F() As System.Action
Return AddressOf Me.M
End Function
End Class
]]></file>
</compilation>)
Dim tree = compilation.SyntaxTrees(0)
Dim model = compilation.GetSemanticModel(tree)
Dim expr = FindNodeOfTypeFromText(Of ExpressionSyntax)(tree, "Me")
model.AnalyzeDataFlow(expr)
End Sub
<WorkItem(546629, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/546629")>
<Fact()>
Public Sub TypeExpressionUnevaluatedReceiver()
Dim compilation = CompilationUtils.CreateCompilationWithMscorlib40(
<compilation>
<file name="a.vb"><![CDATA[
Class A
Class B
Friend Const F As Object = Nothing
End Class
Function M() As Object
Return (Me.B).F
End Function
End Class
]]></file>
</compilation>)
Dim tree = compilation.SyntaxTrees(0)
Dim model = compilation.GetSemanticModel(tree)
Dim expr = FindNodeOfTypeFromText(Of ExpressionSyntax)(tree, "Me")
model.AnalyzeDataFlow(expr)
End Sub
<WorkItem(545266, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545266")>
<Fact()>
Public Sub DataFlowImplicitLoopVariableInBrokenCodeNotInDataFlowsOut()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Module Program
Sub Main(ByVal args As String())
GoTo Label1
For i = 1 To 5
Label1:
Dim j = [|i|]
Next
End Sub
End Module
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Empty(dataFlowResults.VariablesDeclared)
Assert.Empty(dataFlowResults.AlwaysAssigned)
Assert.Empty(dataFlowResults.Captured)
Assert.Empty(dataFlowResults.CapturedInside)
Assert.Empty(dataFlowResults.CapturedOutside)
Assert.Equal("i", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Empty(dataFlowResults.DataFlowsOut)
Assert.Equal("args", GetSymbolNamesJoined(dataFlowResults.DefinitelyAssignedOnEntry))
Assert.Equal("args", GetSymbolNamesJoined(dataFlowResults.DefinitelyAssignedOnExit))
Assert.Equal("i", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Empty(dataFlowResults.WrittenInside)
Assert.Empty(dataFlowResults.ReadOutside)
Assert.Equal("args, i, j", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<WorkItem(545266, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545266")>
<Fact()>
Public Sub DataFlowImplicitLoopVariableInBrokenCodeNotInDataFlowsOut_2()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Module Program
Sub Main(ByVal args As String())
GoTo Label1
For x = 1 To 5
For i = 1 To 5
Label1:
Dim j = [|i|]
Next
next
End Sub
End Module
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Empty(dataFlowResults.VariablesDeclared)
Assert.Empty(dataFlowResults.AlwaysAssigned)
Assert.Empty(dataFlowResults.Captured)
Assert.Empty(dataFlowResults.CapturedInside)
Assert.Empty(dataFlowResults.CapturedOutside)
Assert.Equal("i", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Empty(dataFlowResults.DataFlowsOut)
Assert.Equal("args", GetSymbolNamesJoined(dataFlowResults.DefinitelyAssignedOnEntry))
Assert.Equal("args", GetSymbolNamesJoined(dataFlowResults.DefinitelyAssignedOnExit))
Assert.Equal("i", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Empty(dataFlowResults.WrittenInside)
Assert.Empty(dataFlowResults.ReadOutside)
Assert.Equal("args, x, i, j", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<WorkItem(545266, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545266")>
<Fact()>
Public Sub DataFlowUnassignedVariablesWithoutAssignmentInsideDoNotFlowOut_1()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Module Program
Sub Main(ByVal args As String())
GoTo Label1
if args(0) > 23 then
dim i as integer = 23
Label1:
Dim j = [|i|]
i = 23
end if
End Sub
End Module
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Empty(dataFlowResults.VariablesDeclared)
Assert.Empty(dataFlowResults.AlwaysAssigned)
Assert.Empty(dataFlowResults.Captured)
Assert.Empty(dataFlowResults.CapturedInside)
Assert.Empty(dataFlowResults.CapturedOutside)
Assert.Equal("i", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Empty(dataFlowResults.DataFlowsOut)
Assert.Equal("args", GetSymbolNamesJoined(dataFlowResults.DefinitelyAssignedOnEntry))
Assert.Equal("args", GetSymbolNamesJoined(dataFlowResults.DefinitelyAssignedOnExit))
Assert.Equal("i", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Empty(dataFlowResults.WrittenInside)
Assert.Equal("args", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("args, i, j", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<WorkItem(545266, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545266")>
<Fact()>
Public Sub DataFlowUnassignedVariablesWithoutAssignmentInsideDoNotFlowOut_2()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Module Program
Sub Main(ByVal args As String())
GoTo Label1
if args(0) > 23 then
dim i as integer
Label1:
dim k = i
Dim j = [|i|]
i = 23
end if
End Sub
End Module
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Empty(dataFlowResults.AlwaysAssigned)
Assert.Empty(dataFlowResults.Captured)
Assert.Empty(dataFlowResults.CapturedInside)
Assert.Empty(dataFlowResults.CapturedOutside)
Assert.Equal("i", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Empty(dataFlowResults.DataFlowsOut)
Assert.Equal("args, k", GetSymbolNamesJoined(dataFlowResults.DefinitelyAssignedOnEntry))
Assert.Equal("args, k", GetSymbolNamesJoined(dataFlowResults.DefinitelyAssignedOnExit))
Assert.Equal("i", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Empty(dataFlowResults.WrittenInside)
Assert.Equal("args, i", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("args, i, k, j", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<WorkItem(545266, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545266")>
<Fact()>
Public Sub DataFlowImplicitUsingVariableInBrokenCodeNotInDataFlowsOut()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Module Program
Sub Main(ByVal args As String())
GoTo Label1
using i as new Object
Label1:
Dim j = [|i|]
end using
End Sub
End Module
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Empty(dataFlowResults.VariablesDeclared)
Assert.Empty(dataFlowResults.AlwaysAssigned)
Assert.Empty(dataFlowResults.Captured)
Assert.Empty(dataFlowResults.CapturedInside)
Assert.Empty(dataFlowResults.CapturedOutside)
Assert.Equal("i", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Empty(dataFlowResults.DataFlowsOut)
Assert.Equal("args", GetSymbolNamesJoined(dataFlowResults.DefinitelyAssignedOnEntry))
Assert.Equal("args", GetSymbolNamesJoined(dataFlowResults.DefinitelyAssignedOnExit))
Assert.Equal("i", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Empty(dataFlowResults.WrittenInside)
Assert.Equal("i", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("args, i, j", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<WorkItem(546995, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/546995")>
<Fact()>
Public Sub DataFlowUnassignedVariablesWithoutAssignmentInsideDoNotFlowOut_3()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Module Program
Sub Main(ByVal args As String())
[|GoTo Label1
For i = 1 To 5
Label1:
Dim q = i
Next|]
End Sub
End Module
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Equal("i, q", GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Empty(dataFlowResults.AlwaysAssigned)
Assert.Empty(dataFlowResults.Captured)
Assert.Empty(dataFlowResults.CapturedInside)
Assert.Empty(dataFlowResults.CapturedOutside)
Assert.Equal("i", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Empty(dataFlowResults.DataFlowsOut)
Assert.Equal("args", GetSymbolNamesJoined(dataFlowResults.DefinitelyAssignedOnEntry))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DefinitelyAssignedOnExit))
Assert.Equal("i", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal("i, q", GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Empty(dataFlowResults.ReadOutside)
Assert.Equal("args", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<WorkItem(669341, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/669341")>
<Fact()>
Public Sub ReceiverRead()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Public Structure X
Public Y As Y
End Structure
Public Structure Y
Public Z As Z
End Structure
Public Structure Z
Public Value As Integer
End Structure
Module Module1
Sub Main()
Dim X As New X
Dim Value = [|X.Y|].Z.Value
End Sub
End Module
</file>
</compilation>)
Assert.Equal("X", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Empty(dataFlowResults.WrittenInside)
Assert.Equal("X", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("X, Value", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<WorkItem(669341, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/669341")>
<Fact()>
Public Sub ReceiverWritten()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Public Structure X
Public Y As Y
End Structure
Public Structure Y
Public Z As Z
End Structure
Public Structure Z
Public Value As Integer
End Structure
Module Module1
Sub Main()
Dim X As New X
[|X.Y|].Z.Value = 12
End Sub
End Module
</file>
</compilation>)
Assert.Empty(dataFlowResults.ReadInside)
Assert.Equal("X", GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Empty(dataFlowResults.ReadOutside)
Assert.Equal("X", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<WorkItem(669341, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/669341")>
<Fact()>
Public Sub ReceiverReadAndWritten()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Public Structure X
Public Y As Y
End Structure
Public Structure Y
Public Z As Z
End Structure
Public Structure Z
Public Value As Integer
End Structure
Module Module1
Sub Main()
Dim X As New X
[|X.Y|].Z.Value += 12
End Sub
End Module
</file>
</compilation>)
Assert.Equal("X", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal("X", GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal("X", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("X", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
#Region "Anonymous Type, Lambda"
<WorkItem(543464, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543464")>
<Fact()>
Public Sub TestCaptured()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestLifted">
<file name="a.b">
class C
Dim field = 123
public sub F(x as integer)
dim a as integer = 1, y as integer = 1
[|
dim l1 = function() x+y+field
|]
dim c as integer = a + 4 + y
end sub
end class</file>
</compilation>)
Assert.Equal("l1", GetSymbolNamesJoined(analysis.VariablesDeclared))
Assert.Equal("l1", GetSymbolNamesJoined(analysis.AlwaysAssigned))
Assert.Equal("Me, x, y", GetSymbolNamesJoined(analysis.Captured))
Assert.Equal("Me, x, y", GetSymbolNamesJoined(analysis.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.CapturedOutside))
Assert.Equal("Me, x, y", GetSymbolNamesJoined(analysis.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DataFlowsOut))
Assert.Equal("Me, x, y", GetSymbolNamesJoined(analysis.ReadInside))
Assert.Equal("l1", GetSymbolNamesJoined(analysis.WrittenInside))
Assert.Equal("a, y", GetSymbolNamesJoined(analysis.ReadOutside))
Assert.Equal("Me, x, a, y, c", GetSymbolNamesJoined(analysis.WrittenOutside))
End Sub
<Fact()>
Public Sub TestCapturedRegion()
Dim analysis = CompileAndAnalyzeDataFlow(
<compilation name="TestLifted">
<file name="a.b">
class C
Dim field = 123
public sub F(x as integer)
dim a as integer = 1, y as integer = 1
dim outside = function() x+field
[|
dim inside = function() y
|]
end sub
end class</file>
</compilation>)
Assert.Equal("inside", GetSymbolNamesJoined(analysis.VariablesDeclared))
Assert.Equal("inside", GetSymbolNamesJoined(analysis.AlwaysAssigned))
Assert.Equal("Me, x, y", GetSymbolNamesJoined(analysis.Captured))
Assert.Equal("y", GetSymbolNamesJoined(analysis.CapturedInside))
Assert.Equal("Me, x", GetSymbolNamesJoined(analysis.CapturedOutside))
Assert.Equal("y", GetSymbolNamesJoined(analysis.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(analysis.DataFlowsOut))
Assert.Equal("y", GetSymbolNamesJoined(analysis.ReadInside))
Assert.Equal("inside", GetSymbolNamesJoined(analysis.WrittenInside))
Assert.Equal("Me, x", GetSymbolNamesJoined(analysis.ReadOutside))
Assert.Equal("Me, x, a, y, outside", GetSymbolNamesJoined(analysis.WrittenOutside))
End Sub
<WorkItem(542629, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542629")>
<Fact()>
Public Sub TestRegionControlFlowAnalysisInsideLambda()
Dim controlFlowAnalysis = CompileAndAnalyzeControlFlow(
<compilation name="TestRegionControlFlowAnalysisInsideLambda">
<file name="a.b">
Imports System
Module Module1
Sub Main()
Dim f1 As Func(Of Integer, Integer) = Function(lambdaParam As Integer)
[| Return lambdaParam + 1 |]
End Function
End Sub
End Module
</file>
</compilation>)
Assert.Equal(1, controlFlowAnalysis.ExitPoints.Count())
Assert.Equal(0, controlFlowAnalysis.EntryPoints.Count())
Assert.True(controlFlowAnalysis.StartPointIsReachable)
Assert.False(controlFlowAnalysis.EndPointIsReachable)
End Sub
<WorkItem(542629, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542629")>
<Fact()>
Public Sub TestRegionControlFlowAnalysisInsideLambda2()
Dim controlFlowAnalysis = CompileAndAnalyzeControlFlow(
<compilation name="TestRegionControlFlowAnalysisInsideLambda2">
<file name="a.b">
Imports System
Module Module1
Sub Main()
Dim f1 As Object = Function(lambdaParam As Integer)
[| Return lambdaParam + 1 |]
End Function
End Sub
End Module
</file>
</compilation>)
Assert.Equal(1, controlFlowAnalysis.ExitPoints.Count())
Assert.Equal(0, controlFlowAnalysis.EntryPoints.Count())
Assert.True(controlFlowAnalysis.StartPointIsReachable)
Assert.False(controlFlowAnalysis.EndPointIsReachable)
End Sub
<WorkItem(542629, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542629")>
<Fact()>
Public Sub TestRegionControlFlowAnalysisInsideLambda3()
Dim controlFlowAnalysis = CompileAndAnalyzeControlFlow(
<compilation name="TestRegionControlFlowAnalysisInsideLambda3">
<file name="a.b">
Imports System
Module Module1
Sub Main()
Dim f1 As Object = Nothing
f1 = Function(lambdaParam As Integer)
[| Return lambdaParam + 1 |]
End Function
End Sub
End Module
</file>
</compilation>)
Assert.Equal(1, controlFlowAnalysis.ExitPoints.Count())
Assert.Equal(0, controlFlowAnalysis.EntryPoints.Count())
Assert.True(controlFlowAnalysis.StartPointIsReachable)
Assert.False(controlFlowAnalysis.EndPointIsReachable)
End Sub
<Fact()>
Public Sub DoLoopInLambdaBody()
Dim analysisResults = CompileAndAnalyzeControlAndDataFlow(
<compilation name="DoLoopWithContinue">
<file name="a.b">
Class A
Function Test1() As Integer
Dim x As Integer = 5
Console.Write(x)
dim x as System.Action(of Integer) = Sub(i)
[|
Do
Console.Write(i)
i = i + 1
Continue Do
'Blah
Loop Until i > 5 |]
end sub
Return x
End Function
End Class
</file>
</compilation>)
Dim controlFlowAnalysisResults = analysisResults.Item1
Dim dataFlowAnalysisResults = analysisResults.Item2
Assert.Equal(0, controlFlowAnalysisResults.EntryPoints.Count())
Assert.Equal(0, controlFlowAnalysisResults.ExitPoints.Count())
Assert.True(controlFlowAnalysisResults.StartPointIsReachable)
Assert.True(controlFlowAnalysisResults.EndPointIsReachable)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared))
Assert.Equal("i", GetSymbolNamesJoined(dataFlowAnalysisResults.AlwaysAssigned))
Assert.Equal("i", GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysisResults.DataFlowsOut))
Assert.Equal("i", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysisResults.ReadOutside))
Assert.Equal("i", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenInside))
Assert.Equal("Me, x, x, i", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside))
End Sub
<Fact()>
Public Sub AnonymousTypeAsLambdaLocal()
Dim analysisResults = CompileAndAnalyzeControlAndDataFlow(
<compilation>
<file name="a.vb">
Option Infer On
Imports System
Public Class Test
delegate R Func(OfT, R)(ref T t);
Public Shared Sub Main()
Dim local(3) As String
[|
Dim lambda As Func(Of Integer, Integer) =
Function(ByRef p As Integer) As Integer
p = p * 2
Dim at = New With {New C(Of Integer)().F, C(Of String).SF, .L = local.Length + p}
Console.Write("{0}, {1}, {2}", at.F, at.SF)
Return at.L
End Function
|]
End Sub
Class C(Of T)
Public Function F() As T
Return Nothing
End Function
Shared Public Function SF() As T
Return Nothing
End Function
End Class
End Class
</file>
</compilation>)
Dim controlFlowResults = analysisResults.Item1
Dim dataFlowResults = analysisResults.Item2
Assert.True(controlFlowResults.Succeeded)
Assert.True(dataFlowResults.Succeeded)
Assert.Equal("lambda", GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal("local", GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal("local", GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal("lambda, p, at", GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal("local", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal("p", GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal("local, p, at", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal("lambda, p, at", GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("local", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub AnonymousTypeAsNewInLocalContext()
Dim analysisResults = CompileAndAnalyzeControlAndDataFlow(
<compilation>
<file name="a.vb">
Imports System
Interface IGoo
Delegate Sub DS(ByRef p As Char)
End Interface
Class CGoo
Implements IGoo
End Class
Friend Module AM
Sub Main(args As String())
Dim igoo As IGoo = New CGoo()
Dim at1 As New With {.if = igoo}
[|
Dim at2 As New With {.if = at1, igoo,
.friend = New With {Key args, .lambda = DirectCast(Sub(ByRef p As Char)
args(0) = p & p
p = "Q"c
End Sub, IGoo.DS)}}
|]
Console.Write(args(0))
End Sub
End Module
</file>
</compilation>)
Dim controlFlowResults = analysisResults.Item1
Dim dataFlowResults = analysisResults.Item2
Assert.True(controlFlowResults.Succeeded)
Assert.True(dataFlowResults.Succeeded)
Assert.Equal("at2", GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal("args", GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal("args", GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal("at2, p", GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal("args, igoo, at1", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal("p", GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal("args, igoo, at1, p", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal("at2, p", GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal("args, igoo", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("args, igoo, at1", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub AnonymousTypeAsExpression()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Interface IGoo
Delegate Sub DS(ByRef p As Char)
End Interface
Friend Module AM
Sub Main(args As String())
Dim at1 As New With {.friend = New With {args, Key.lambda = DirectCast(Sub(ByRef p As Char)
args(0) = p & p
p = "Q"c
End Sub, IGoo.DS) }
}
Dim at2 As New With { Key .a= at1, .friend = New With { [| at1 |] }}
Console.Write(args(0))
End Sub
End Module
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal("args", GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal("args", GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal("at1", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal("at1", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal("args, at1, p", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("args, at1, p, at2", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub AnonymousTypeAccessInstanceMember()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Class AM
Dim field = 123
Sub M(args As String())
Dim at1 As New With {.friend = [| New With {args, Key.lambda = Sub(ByRef ary As Char())
Field = ary.Length
End Sub } |]
}
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal("ary", GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal("Me, args", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal("ary", GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal("Me, args, ary", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal("ary", GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("Me, args, at1", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub AnonymousTypeFieldInitializerWithLeftOmitted()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Class AM
Dim field = 123
Sub M(args As String())
Dim var1 As New AM
Dim at1 As New With { var1, .friend = [| .var1 |] }
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Null(GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Null(GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Null(GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Null(GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Null(GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Null(GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Null(GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Null(GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Null(GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal("var1", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("Me, args, var1, at1", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub AnonymousTypeUsingMe()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Class Base
Protected Function F1() As Long
Return 123
End Function
Friend Overridable Function F2(n As Integer) As Integer
Return 456
End Function
End Class
Class Derived
Inherits Base
Friend Overrides Function F2(n As Integer) As Integer
Return 789
End Function
Sub M()
Dim func = Function(x)
Dim at = [| New With {.dim = New With {Key .nested = Me.F2(x * x)}} |]
Return at.dim.nested
End Function
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal("Me, x", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal("Me, x", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal("at", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("Me, func, x, at", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub AnonymousTypeAccessMyBase()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Class Base
Protected Overridable Function F1() As Long
Return 123
End Function
End Class
Class Derived
Inherits Base
Protected Overrides Function F1() As Long
Return 789
End Function
Sub M()
Dim func = Function(x)
Dim at = [| New With {Key .dim = New With {MyBase.F1()}} |]
Return at.dim.F1
End Function
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal("at", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("Me, func, x, at", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub AnonymousTypeAccessMyClass()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Module M1
Class B1
Public Overridable Function F() As String
Return "B1::F_"
End Function
End Class
Class B2
Inherits B1
Public Overrides Function F() As String
Return "B2::F_"
End Function
Public Sub TestMMM()
Dim an = [| New With {.an = Function(s) As String
Return s + Me.F() + MyBase.F() + MyClass.F()
End Function
} |]
Console.WriteLine(an.an("R="))
End Sub
End Class
Class D
Inherits B2
Public Overrides Function F() As String
Return "D::F_"
End Function
End Class
Public Sub Main()
Call (New D()).TestMMM()
End Sub
End Module
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal("s", GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal("Me, s", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal("s", GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal("an", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("Me, an", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<WorkItem(543046, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543046")>
<Fact()>
Public Sub Lambda()
' The region is not correct and it is not clear if there is a way to fix the test
Assert.Throws(Of ArgumentException)(
Sub()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Option Strict On
Imports System
Imports System.Runtime.InteropServices
Public Class S1
[|Const str As String = "" < MyAttribute(Me.color.blue) >
Sub goo()
End Sub|]
Shared Sub main()
End Sub
Enum color
blue
End Enum
End Class
Class MyAttribute
Inherits Attribute
Sub New(str As S1.color)
End Sub
End Class
</file>
</compilation>)
Assert.False(dataFlowResults.Succeeded)
End Sub)
End Sub
<WorkItem(543684, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543684")>
<Fact()>
Public Sub AddressOfExpr()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Module Program
Sub Main()
Dim x5 = Function() AddressOf [|Main|]
End Sub
End Module
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
End Sub
<WorkItem(543741, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543741")>
<Fact()>
Public Sub AddressOfExpr2()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Module Program
Public Event Ev1
Public Sub Handler1()
End Sub
Public Sub AddFirstHandler()
AddHandler Ev1, AddressOf [|Handler1|]
End Sub
End Module
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
End Sub
<Fact()>
Public Sub XmlEmbeddedExpression()
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntimeAndReferences(
<compilation>
<file name="c.vb"><![CDATA[
Option Strict On
Imports System.Xml.Linq
Module M
Function F() As Object
Dim v0 = "v0"
Dim v1 = XName.Get("v1", "")
Dim v2 = XName.Get("v2", "")
Dim v3 = "v3"
Dim v4 = New XAttribute(XName.Get("v4", ""), "v4")
Dim v5 = "v5"
Return <?xml version="1.0"?><<%= v1 %> <%= v2 %>="v2" v3=<%= v3 %> <%= v4 %>><%= v5 %></>
End Function
End Module
]]></file>
</compilation>, references:=XmlReferences)
Dim tree = compilation.SyntaxTrees.First()
Dim model = compilation.GetSemanticModel(tree)
Dim root = tree.GetCompilationUnitRoot()
Dim node = DirectCast(root.FindToken(root.ToFullString().IndexOf("Return", StringComparison.Ordinal)).Parent, StatementSyntax)
Dim dataFlowAnalysis = model.AnalyzeDataFlow(node, node)
Assert.True(dataFlowAnalysis.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.AlwaysAssigned))
Assert.Equal("v1, v2, v3, v4, v5", GetSymbolNamesJoined(dataFlowAnalysis.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.DataFlowsOut))
Assert.Equal("v1, v2, v3, v4, v5", GetSymbolNamesJoined(dataFlowAnalysis.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.WrittenInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.ReadOutside))
Assert.Equal("v0, v1, v2, v3, v4, v5", GetSymbolNamesJoined(dataFlowAnalysis.WrittenOutside))
End Sub
<Fact()>
Public Sub XmlMemberAccess()
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntimeAndReferences(
<compilation>
<file name="c.vb"><![CDATA[
Option Strict On
Imports System.Xml.Linq
Module M
Function F() As Object
Dim x = <a><b><c d="e"/></b></a>
Return x.<b>...<c>.@<d>
End Function
End Module
]]></file>
</compilation>, references:=XmlReferences)
Dim tree = compilation.SyntaxTrees.First()
Dim model = compilation.GetSemanticModel(tree)
Dim root = tree.GetCompilationUnitRoot()
Dim node = DirectCast(root.FindToken(root.ToFullString().IndexOf("Return", StringComparison.Ordinal)).Parent, StatementSyntax)
Dim dataFlowAnalysis = model.AnalyzeDataFlow(node, node)
Assert.True(dataFlowAnalysis.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.AlwaysAssigned))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysis.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.DataFlowsOut))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysis.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.WrittenInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.ReadOutside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowAnalysis.WrittenOutside))
End Sub
<Fact()>
Public Sub GenericStructureCycle()
Dim source =
<compilation>
<file name="c.vb"><![CDATA[
Structure S(Of T)
Public F As S(Of S(Of T))
End Structure
Module M
Sub M()
Dim o As S(Of Object)
End Sub
End Module
]]></file>
</compilation>
Dim compilation = CreateCompilationWithMscorlib40(source)
Dim tree = compilation.SyntaxTrees.First()
Dim model = compilation.GetSemanticModel(tree)
Dim root = tree.GetCompilationUnitRoot()
Dim node = DirectCast(root.FindToken(root.ToFullString().IndexOf("Dim", StringComparison.Ordinal)).Parent, StatementSyntax)
Dim dataFlowAnalysis = model.AnalyzeDataFlow(node, node)
Assert.True(dataFlowAnalysis.Succeeded)
Assert.Equal("o", GetSymbolNamesJoined(dataFlowAnalysis.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.DataFlowsOut))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.WrittenInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.ReadOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowAnalysis.WrittenOutside))
End Sub
#End Region
#Region "With Statement"
<Fact()>
Public Sub WithStatement_Expression_RValue_1()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Structure SSS
Public A As String
Public B As Integer
Public Sub New(_a As String, _b As Integer)
End Sub
End Structure
Class Clazz
Sub TEST(i As Integer)
With [| New SSS(Me.ToString(), i) |]
End With
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal("Me, i", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal("Me, i", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("Me, i", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub WithStatement_Expression_RValue_2()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Structure SSS
Public A As String
Public B As Integer
Public Sub New(_a As String, _b As Integer)
End Sub
End Structure
Class Clazz
Sub TEST(i As Integer)
With [| New SSS(Me.ToString(), i) |]
.A = ""
End With
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal("Me, i", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal("Me, i", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("Me, i", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub WithStatement_Expression_RValue_3()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Structure SSS
Public A As String
Public B As Integer
Public Sub New(_a As String, _b As Integer)
End Sub
End Structure
Class Clazz
Sub TEST(i As Integer)
With [| New SSS(Me.ToString(), i) |]
Dim s As Action = Sub()
.A = ""
End Sub
End With
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal("Me, i", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal("Me, i", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("Me, i, s", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub WithStatement_Expression_LValue_1()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Structure SSS
Public A As String
Public B As Integer
Public Sub New(_a As String, _b As Integer)
End Sub
End Structure
Class Clazz
Sub TEST(i As Integer)
Dim x As New SSS(Me.ToString(), i)
With [| x |]
End With
End Sub
End Class
</file>
</compilation>)
Assert.False(dataFlowResults.Succeeded)
End Sub
<Fact()>
Public Sub WithStatement_Expression_LValue_2()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Structure SSS
Public A As String
Public B As Integer
Public Sub New(_a As String, _b As Integer)
End Sub
End Structure
Class Clazz
Sub TEST(i As Integer)
Dim x As New SSS(Me.ToString(), i)
With [| x |]
.A = ""
End With
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal("Me, i", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("Me, i, x", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub WithStatement_Expression_LValue_2_()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Structure SSS
Public A As String
Public B As Integer
Public Sub New(_a As String, _b As Integer)
End Sub
End Structure
Class Clazz
Sub TEST(i As Integer)
Dim x As New SSS(Me.ToString(), i)
With [| x |]
.A = ""
Dim a = .A
Dim b = .B
.B = 1
End With
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal("Me, i, x", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("Me, i, x, a, b", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub WithStatement_Expression_LValue_2a()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Structure SSS
Public A As String
Public B As Integer
Public Sub New(_a As String, _b As Integer)
End Sub
End Structure
Class Clazz
Sub TEST(i As Integer)
Dim x As New SSS(Me.ToString(), i)
With x
[| .A = "" |]
End With
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal("Me, i", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("Me, i, x", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub WithStatement_Expression_LValue_2b()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Structure SSS
Public A As String
Public B As Integer
Public Sub New(_a As String, _b As Integer)
End Sub
End Structure
Class Clazz
Sub TEST(i As Integer)
Dim x As New SSS(Me.ToString(), i)
With x
[| .B = "" |]
End With
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal("Me, i", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("Me, i, x", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub WithStatement_Expression_LValue_3()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Structure SSS
Public A As String
Public B As Integer
Public Sub New(_a As String, _b As Integer)
End Sub
End Structure
Class Clazz
Sub TEST(i As Integer)
Dim x As New SSS(Me.ToString(), i)
With [| x |]
Dim s As Action = Sub()
.A = ""
End Sub
End With
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal("Me, i", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("Me, i, x, s", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub WithStatement_Expression_LValue_4()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Structure SSSS
Public A As String
Public B As Integer
End Structure
Structure SSS
Public S As SSSS
nd Structure
Class Clazz
Sub TEST()
Dim x As New SSS()
With [| x.S |]
Dim s As Action = Sub()
.A = ""
End Sub
End With
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("Me, x, s", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub WithStatement_Expression_LValue_4a()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Structure SSSS
Public A As String
Public B As Integer
End Structure
Structure SSS
Public S As SSSS
nd Structure
Class Clazz
Sub TEST()
Dim x As New SSS()
With [| x |] .S
Dim s As Action = Sub()
.A = ""
End Sub
End With
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("Me, x, s", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub WithStatement_Expression_LValue_4b()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Structure SSSS
Public A As String
Public B As Integer
End Structure
Structure SSS
Public S As SSSS
nd Structure
Class Clazz
Sub TEST()
Dim x As New SSS()
With x.S
Dim s As Action = Sub()
[| .A = "" |]
End Sub
End With
x.ToString()
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("Me, x, s", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub WithStatement_Expression_LValue_4c()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Structure SSSS
Public A As String
Public B As Integer
End Structure
Structure SSS
Public S As SSSS
nd Structure
Class Clazz
Sub TEST()
Dim x As New SSS()
With x.S
Dim s As Action = Sub()
[| .A |] = ""
End Sub
End With
x.ToString()
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("Me, x, s", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub WithStatement_Expression_LValue_4d()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Structure SSSS3
Public A As String
Public B As Integer
End Structure
Structure SSSS2
Public S3 As SSSS3
End Structure
Structure SSSS
Public S2 As SSSS2
End Structure
Structure SSS
Public S As SSSS
End Structure
Class Clazz
Sub TEST()
Dim x As New SSS()
With x.S
With .S2
With .S3
Dim s As Action = Sub()
[| .A = "" |]
End Sub
End With
End With
End With
x.ToString()
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("Me, x, s", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub WithStatement_Expression_LValue_4e()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Structure SSSS3
Public A As String
Public B As Integer
End Structure
Structure SSSS2
Public S3 As SSSS3
End Structure
Structure SSSS
Public S2 As SSSS2
End Structure
Structure SSS
Public S As SSSS
End Structure
Class Clazz
Sub TEST()
Dim x As New SSS()
With x.S
With .S2
With .S3
Dim s As Action = Sub()
Dim xyz = [| .A |]
End Sub
End With
End With
End With
x.ToString()
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("Me, x, s, xyz", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub WithStatement_Expression_LValue_4f()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Structure SSSS3
Public A As String
Public B As Integer
End Structure
Structure SSSS2
Public S3 As SSSS3
End Structure
Structure SSSS
Public S2 As SSSS2
End Structure
Structure SSS
Public S As SSSS
End Structure
Class Clazz
Sub TEST()
Dim x As New SSS()
With [| x.S.S2 |].S3
Dim s As Action = Sub()
.A = ""
End Sub
End With
x.ToString()
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("Me, x, s", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub WithStatement_Expression_LValue_4g()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Structure SSSS3
Public A As String
Public B As Integer
End Structure
Structure SSSS2
Public S3 As SSSS3
End Structure
Structure SSSS
Public S2 As SSSS2
End Structure
Class SSS
Public S As SSSS
End Class
Class Clazz
Sub TEST()
Dim x As New SSS()
With [| x.S.S2 |].S3
Dim s As Action = Sub()
.A = ""
End Sub
End With
x.ToString()
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("Me, x, s", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub WithStatement_MeReference_1()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Structure SSSS3
Public A As String
Public B As Integer
End Structure
Structure SSSS2
Public S3 As SSSS3
End Structure
Structure SSSS
Public S2 As SSSS2
End Structure
Structure SSS
Public S As SSSS
End Structure
Class Clazz
Public x As New SSS()
Sub TEST()
With [| x.S.S2 |].S3
Dim s As Action = Sub()
.A = ""
End Sub
End With
x.ToString()
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("Me, s", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub WithStatement_MeReference_2()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Structure SSSS3
Public A As String
Public B As Integer
End Structure
Structure SSSS2
Public S3 As SSSS3
End Structure
Structure SSSS
Public S2 As SSSS2
End Structure
Structure SSS
Public S As SSSS
End Structure
Structure Clazz
Public x As New SSS()
Sub TEST()
With [| x.S |].S2
With .S3
.A = ""
End With
End With
x.ToString()
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub WithStatement_MeReference_3()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Structure SSSS3
Public A As String
Public B As Integer
End Structure
Structure SSSS2
Public S3 As SSSS3
End Structure
Structure SSSS
Public S2 As SSSS2
End Structure
Structure SSS
Public S As SSSS
End Structure
Structure Clazz
Public x As New SSS()
Sub TEST()
With x.S.S2
With .S3
[| .A = "" |]
End With
End With
x.ToString()
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub WithStatement_ComplexExpression_1()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Structure SSSS3
Public A As String
Public B As Integer
End Structure
Structure SSSS2
Public S3 As SSSS3
End Structure
Structure SSSS
Public S2 As SSSS2
End Structure
Structure SSS
Public S As SSSS
End Structure
Class Clazz
Public x As New SSS()
Sub TEST()
With DirectCast(Function()
Return [| Me.x |]
End Function, Func(Of SSS))()
With .S.S2
Dim a = .S3.A
End With
End With
x.ToString()
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("Me, a", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub WithStatement_ComplexExpression_2()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation>
<file name="a.vb">
Imports System
Structure SSSS3
Public A As String
Public B As Integer
End Structure
Structure SSSS2
Public S3 As SSSS3
End Structure
Structure SSSS
Public S2 As SSSS2
End Structure
Structure SSS
Public S As SSSS
End Structure
Class Clazz
Public x As New SSS()
Sub TEST()
Dim arr(,) As SSS
With arr(1,
[| DirectCast(Function()
Return x
End Function, Func(Of SSS)) |] ().S.S2.S3.B).S
Dim a = .S2.S3.A
End With
x.ToString()
End Sub
End Class
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal("Me", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal("Me, arr", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("Me, a", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
#End Region
#Region "Select Statement"
<Fact()>
Public Sub TestSelectCase_Empty()
Dim analysis = CompileAndAnalyzeControlAndDataFlow(
<compilation name="TestSelectCase_Empty">
<file name="a.b">
Module Program
Sub Main()
Dim obj As Object = 0
[|
Select Case obj
End Select
|]
End Sub
End Module
</file>
</compilation>)
Dim controlFlowResults = analysis.Item1
Assert.True(controlFlowResults.Succeeded)
Assert.Equal(0, controlFlowResults.ExitPoints.Count())
Assert.Equal(0, controlFlowResults.EntryPoints.Count())
Assert.True(controlFlowResults.EndPointIsReachable)
Dim dataFlowResults = analysis.Item2
Assert.True(dataFlowResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal("obj", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal("obj", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("obj", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub TestSelectCase_SingleCaseBlock_01()
Dim analysis = CompileAndAnalyzeControlAndDataFlow(
<compilation name="TestSelectCase_SingleCaseBlock_01">
<file name="a.b">
Module Program
Sub Main()
Dim obj1 As Object = 0
Dim obj2 As Object = 0
Dim obj3 As Object
[|
Select Case obj1
Case obj2
Dim obj4 = 1
obj3 = obj4
End Select
|]
End Sub
End Module
</file>
</compilation>)
Dim controlFlowResults = analysis.Item1
Assert.True(controlFlowResults.Succeeded)
Assert.Equal(0, controlFlowResults.ExitPoints.Count())
Assert.Equal(0, controlFlowResults.EntryPoints.Count())
Assert.True(controlFlowResults.EndPointIsReachable)
Dim dataFlowResults = analysis.Item2
Assert.True(dataFlowResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal("obj4", GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal("obj1, obj2", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal("obj1, obj2, obj4", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal("obj3, obj4", GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("obj1, obj2", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub TestSelectCase_SingleCaseBlock_02()
Dim analysis = CompileAndAnalyzeControlAndDataFlow(
<compilation name="TestSelectCase_SingleCaseBlock_02">
<file name="a.b">
Module Program
Sub Main()
Dim obj1 As Object = 0
Dim obj2 As Object = 0
Dim obj3 As Object
Select Case obj1
Case obj2
[|
Dim obj4 = 1
obj3 = obj4
|]
End Select
End Sub
End Module
</file>
</compilation>)
Dim controlFlowResults = analysis.Item1
Assert.True(controlFlowResults.Succeeded)
Assert.Equal(0, controlFlowResults.ExitPoints.Count())
Assert.Equal(0, controlFlowResults.EntryPoints.Count())
Assert.True(controlFlowResults.EndPointIsReachable)
Dim dataFlowResults = analysis.Item2
Assert.True(dataFlowResults.Succeeded)
Assert.Equal("obj3, obj4", GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal("obj4", GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal("obj4", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal("obj3, obj4", GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal("obj1, obj2", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("obj1, obj2", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub TestSelectCase_CaseBlocksWithCaseElse_01()
Dim analysis = CompileAndAnalyzeControlAndDataFlow(
<compilation name="TestSelectCase_CaseBlocksWithCaseElse_01">
<file name="a.b">
Module Program
Sub Main()
Dim obj1 As Object = 0
Dim obj2 As Object = 0
Dim obj3 As Object
Dim obj4 As Object
[|
Select Case obj1
Case obj2
Dim obj5 = 1
obj3 = obj5
obj4 = obj5
Case Else
Dim obj5 = 2
obj2 = obj5
obj4 = obj5
End Select
|]
obj1 = obj3 + obj4
End Sub
End Module
</file>
</compilation>)
Dim controlFlowResults = analysis.Item1
Assert.True(controlFlowResults.Succeeded)
Assert.Equal(0, controlFlowResults.ExitPoints.Count())
Assert.Equal(0, controlFlowResults.EntryPoints.Count())
Assert.True(controlFlowResults.EndPointIsReachable)
Dim dataFlowResults = analysis.Item2
Assert.True(dataFlowResults.Succeeded)
Assert.Equal("obj4", GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal("obj5, obj5", GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal("obj1, obj2", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal("obj3, obj4", GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal("obj1, obj2, obj5, obj5", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal("obj2, obj3, obj4, obj5, obj5", GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal("obj3, obj4", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("obj1, obj2", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub TestSelectCase_CaseBlocksWithCaseElse_01_CaseElseRegion()
Dim analysis = CompileAndAnalyzeControlAndDataFlow(
<compilation name="TestSelectCase_CaseBlocksWithCaseElse_01_CaseElseRegion">
<file name="a.b">
Module Program
Sub Main()
Dim obj1 As Object = 0
Dim obj2 As Object = 0
Dim obj3 As Object
Dim obj4 As Object
Select Case obj1
Case obj2
Dim obj5 = 1
obj3 = obj5
obj4 = obj5
Case Else
[|
Dim obj5 = 2
obj2 = obj5
obj4 = obj5
|]
End Select
obj1 = obj3 + obj4
End Sub
End Module
</file>
</compilation>)
Dim controlFlowResults = analysis.Item1
Assert.True(controlFlowResults.Succeeded)
Assert.Equal(0, controlFlowResults.ExitPoints.Count())
Assert.Equal(0, controlFlowResults.EntryPoints.Count())
Assert.True(controlFlowResults.EndPointIsReachable)
Dim dataFlowResults = analysis.Item2
Assert.True(dataFlowResults.Succeeded)
Assert.Equal("obj2, obj4, obj5", GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal("obj5", GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal("obj4", GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal("obj5", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal("obj2, obj4, obj5", GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal("obj1, obj2, obj3, obj4, obj5", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("obj1, obj2, obj3, obj4, obj5", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub TestSelectCase_CaseBlocksWithCaseElse_02()
Dim analysis = CompileAndAnalyzeControlAndDataFlow(
<compilation name="TestSelectCase_CaseBlocksWithCaseElse_02">
<file name="a.b">
Module Program
Sub Main()
Dim obj1 As Object = 0
Dim obj2 As Object = 0
Dim obj3 As Object
[|
Select Case obj1
Case obj2
Dim obj4 = 1
obj3 = obj4
Case Else
End Select
|]
End Sub
End Module
</file>
</compilation>)
Dim controlFlowResults = analysis.Item1
Assert.True(controlFlowResults.Succeeded)
Assert.Equal(0, controlFlowResults.ExitPoints.Count())
Assert.Equal(0, controlFlowResults.EntryPoints.Count())
Assert.True(controlFlowResults.EndPointIsReachable)
Dim dataFlowResults = analysis.Item2
Assert.True(dataFlowResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal("obj4", GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal("obj1, obj2", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal("obj1, obj2, obj4", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal("obj3, obj4", GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("obj1, obj2", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub TestSelectCase_CaseBlockWithCaseElse_03()
Dim analysis = CompileAndAnalyzeControlAndDataFlow(
<compilation name="TestSelectCase_CaseBlockWithCaseElse_03">
<file name="a.b">
Module Program
Sub Main()
Dim obj1 As Object = 0
Dim obj2 As Object = 0
Dim obj3 As Object
[|
Select Case obj1
Case obj2
LabelCase:
Dim obj4 = 1
obj3 = obj4
Case Else
Goto LabelCase
End Select
|]
End Sub
End Module
</file>
</compilation>)
Dim controlFlowResults = analysis.Item1
Assert.True(controlFlowResults.Succeeded)
Assert.Equal(0, controlFlowResults.ExitPoints.Count())
Assert.Equal(0, controlFlowResults.EntryPoints.Count())
Assert.True(controlFlowResults.EndPointIsReachable)
Dim dataFlowResults = analysis.Item2
Assert.True(dataFlowResults.Succeeded)
Assert.Equal("obj3, obj4", GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal("obj4", GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal("obj1, obj2", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal("obj1, obj2, obj4", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal("obj3, obj4", GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("obj1, obj2", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub TestSelectCase_CaseBlocksWithoutCaseElse_01()
Dim analysis = CompileAndAnalyzeControlAndDataFlow(
<compilation name="TestSelectCase_CaseBlocksWithoutCaseElse_01">
<file name="a.b">
Module Program
Sub Main()
Dim obj1 As Object = 0
Dim obj2 As Object = 0
Dim obj3 As Object
Dim obj4 As Object
[|
Select Case obj1
Case obj2
Dim obj5 = 1
obj3 = obj5
obj4 = obj5
Case obj3
Dim obj5 = 2
obj2 = obj5
obj4 = obj5
End Select
|]
obj1 = obj3 + obj4
End Sub
End Module
</file>
</compilation>)
Dim controlFlowResults = analysis.Item1
Assert.True(controlFlowResults.Succeeded)
Assert.Equal(0, controlFlowResults.ExitPoints.Count())
Assert.Equal(0, controlFlowResults.EntryPoints.Count())
Assert.True(controlFlowResults.EndPointIsReachable)
Dim dataFlowResults = analysis.Item2
Assert.True(dataFlowResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal("obj5, obj5", GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal("obj1, obj2, obj3", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal("obj3, obj4", GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal("obj1, obj2, obj3, obj5, obj5", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal("obj2, obj3, obj4, obj5, obj5", GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal("obj3, obj4", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("obj1, obj2", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub TestSelectCase_CaseBlockWithoutCaseElse_02()
Dim analysis = CompileAndAnalyzeControlAndDataFlow(
<compilation name="TestSelectCase_CaseBlockWithoutCaseElse_02">
<file name="a.b">
Module Program
Sub Main()
Dim obj1 As Object = 0
Dim obj2 As Object = 0
Dim obj3 As Object
[|
Select Case obj1
Case obj2
LabelCase:
Dim obj4 = 1
obj3 = obj4
Case obj3
Goto LabelCase
End Select
|]
End Sub
End Module
</file>
</compilation>)
Dim controlFlowResults = analysis.Item1
Assert.True(controlFlowResults.Succeeded)
Assert.Equal(0, controlFlowResults.ExitPoints.Count())
Assert.Equal(0, controlFlowResults.EntryPoints.Count())
Assert.True(controlFlowResults.EndPointIsReachable)
Dim dataFlowResults = analysis.Item2
Assert.True(dataFlowResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal("obj4", GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal("obj1, obj2, obj3", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal("obj1, obj2, obj3, obj4", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal("obj3, obj4", GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("obj1, obj2", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub TestSelectCase_CaseStatementRegion()
Dim dataFlowResults = CompileAndAnalyzeDataFlow(
<compilation name="TestSelectCase_CaseStatementRegion">
<file name="a.b">
Module Program
Sub Main()
Dim obj1 As Object = 0
Dim obj2 As Object = 0
Dim obj3 As Object
Select Case obj1
Case [|obj2|]
obj3 = 0
End Select
End Sub
End Module
</file>
</compilation>)
Assert.True(dataFlowResults.Succeeded)
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal("obj2", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal("obj1", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("obj1, obj2, obj3", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<Fact()>
Public Sub TestSelectCase_Error_CaseElseBeforeCaseBlock()
Dim analysis = CompileAndAnalyzeControlAndDataFlow(
<compilation name="TestSelectCase_Error_CaseElseBeforeCaseBlock">
<file name="a.b">
Module Program
Sub Main()
Dim obj1 As Object = 0
Dim obj2 As Object = 0
Dim obj3 As Object
Dim obj4 As Object
Select Case obj1
Case Else
[|
Dim obj5 = 2
obj2 = obj5
obj4 = obj5
|]
Case obj2
Dim obj5 = 1
obj3 = obj5
obj4 = obj5
End Select
obj1 = obj3 + obj4
End Sub
End Module
</file>
</compilation>)
Dim controlFlowResults = analysis.Item1
Assert.True(controlFlowResults.Succeeded)
Assert.Equal(0, controlFlowResults.ExitPoints.Count())
Assert.Equal(0, controlFlowResults.EntryPoints.Count())
Assert.True(controlFlowResults.EndPointIsReachable)
Dim dataFlowResults = analysis.Item2
Assert.True(dataFlowResults.Succeeded)
Assert.Equal("obj2, obj4, obj5", GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal("obj5", GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal("obj4", GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal("obj5", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal("obj2, obj4, obj5", GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal("obj1, obj2, obj3, obj4, obj5", GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("obj1, obj2, obj3, obj4, obj5", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<WorkItem(529089, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/529089")>
<Fact>
Public Sub CaseClauseNotReachable()
Dim analysis = CompileAndAnalyzeControlAndDataFlow(
<compilation name="TestSelectCase_Error_CaseElseBeforeCaseBlock">
<file name="a.b">
Module Program
Sub Main(args As String())
Dim x = 10
Select Case 5
Case 10
[|x = x + 1|]
End Select
End Sub
End Module
</file>
</compilation>)
Dim controlFlowResults = analysis.Item1
Assert.True(controlFlowResults.Succeeded)
Assert.Equal(0, controlFlowResults.ExitPoints.Count())
Assert.Equal(0, controlFlowResults.EntryPoints.Count())
Assert.True(controlFlowResults.StartPointIsReachable)
Assert.True(controlFlowResults.EndPointIsReachable)
Dim dataFlowResults = analysis.Item2
Assert.True(dataFlowResults.Succeeded)
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.AlwaysAssigned))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.Captured))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.CapturedOutside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.VariablesDeclared))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.DataFlowsIn))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.DataFlowsOut))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.ReadInside))
Assert.Equal("x", GetSymbolNamesJoined(dataFlowResults.WrittenInside))
Assert.Equal(Nothing, GetSymbolNamesJoined(dataFlowResults.ReadOutside))
Assert.Equal("args, x", GetSymbolNamesJoined(dataFlowResults.WrittenOutside))
End Sub
<WorkItem(543402, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543402")>
<Fact()>
Public Sub EndSelectStatement()
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntime(
<compilation>
<file name="a.vb">
Module Program
Sub Main(args As String())
Select Case 99
End Select
End Sub
End Module
</file>
</compilation>)
Dim tree = compilation.SyntaxTrees.First()
Dim model = compilation.GetSemanticModel(tree)
Dim stmtNode = DirectCast(tree.GetCompilationUnitRoot().FindToken(tree.GetRoot.ToFullString().IndexOf("End Select", StringComparison.Ordinal)).Parent, StatementSyntax)
Dim analysis = model.AnalyzeControlFlow(stmtNode, stmtNode)
Assert.False(analysis.Succeeded)
End Sub
<WorkItem(543434, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543434")>
<Fact()>
Public Sub SelectCaseStatement()
Dim compilation = CreateCompilationWithMscorlib40AndVBRuntime(
<compilation>
<file name="a.vb">
Module Program
Sub Main(args As String())
Select Case 99
End Select
End Sub
End Module
</file>
</compilation>)
Dim tree = compilation.SyntaxTrees.First()
Dim model = compilation.GetSemanticModel(tree)
Dim stmtNode = DirectCast(tree.GetCompilationUnitRoot().FindToken(tree.GetRoot.ToFullString().IndexOf("Select Case", StringComparison.Ordinal)).Parent, StatementSyntax)
Dim analysis = model.AnalyzeControlFlow(stmtNode, stmtNode)
Assert.False(analysis.Succeeded)
End Sub
<Fact, WorkItem(543492, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543492")>
Public Sub MyBaseExpressionSyntax()
Dim source =
<compilation>
<file name="a.vb">
Imports System
Public Class BaseClass
Public Overridable Sub MyMeth()
End Sub
End Class
Public Class MyClass : Inherits BaseClass
Public Overrides Sub MyMeth()
MyBase.MyMeth()
End Sub
Public Sub OtherMeth()
Dim f = Function() MyBase
End Sub
End Class
</file>
</compilation>
Dim comp = CreateCompilationWithMscorlib40(source)
Dim tree = comp.SyntaxTrees.Single()
Dim model = comp.GetSemanticModel(tree)
Dim invocation = tree.GetCompilationUnitRoot().DescendantNodes().OfType(Of InvocationExpressionSyntax)().Single()
Dim flowAnalysis = model.AnalyzeDataFlow(invocation)
Assert.Empty(flowAnalysis.Captured)
Assert.Empty(flowAnalysis.CapturedInside)
Assert.Empty(flowAnalysis.CapturedOutside)
Assert.Equal("Me As [MyClass]", flowAnalysis.DataFlowsIn.Single().ToTestDisplayString())
Assert.Empty(flowAnalysis.DataFlowsOut)
Assert.Equal("Me As [MyClass]", flowAnalysis.ReadInside.Single().ToTestDisplayString())
Assert.Empty(flowAnalysis.WrittenInside)
Assert.Equal("Me As [MyClass]", flowAnalysis.WrittenOutside.Single().ToTestDisplayString())
Dim lambda = tree.GetCompilationUnitRoot().DescendantNodes().OfType(Of LambdaExpressionSyntax)().Single()
flowAnalysis = model.AnalyzeDataFlow(lambda)
Assert.Equal("Me As [MyClass]", flowAnalysis.Captured.Single().ToTestDisplayString())
Assert.Equal("Me As [MyClass]", flowAnalysis.CapturedInside.Single().ToTestDisplayString())
Assert.Empty(flowAnalysis.CapturedOutside)
Assert.Equal("Me As [MyClass]", flowAnalysis.DataFlowsIn.Single().ToTestDisplayString())
Assert.Empty(flowAnalysis.DataFlowsOut)
Assert.Equal("Me As [MyClass]", flowAnalysis.ReadInside.Single().ToTestDisplayString())
Assert.Empty(flowAnalysis.WrittenInside)
Assert.Equal("Me, f", GetSymbolNamesJoined(flowAnalysis.WrittenOutside))
End Sub
#End Region
#Region "Helpers"
Private Shared Function GetSourceXElementFromTemplate(code As XCData) As XElement
Return <compilation>
<file name="a.vb">
Option Infer On
Option Explicit Off
Option Strict Off
Imports System
Imports System.Collections.Generic
Imports System.Linq
Module Module1
Sub Main()
<%= code.Value %>
End Sub
End Module
</file>
</compilation>
End Function
Private Sub VerifyReDimDataFlowAnalysis(
code As XCData,
Optional alwaysAssigned() As String = Nothing,
Optional captured() As String = Nothing,
Optional dataFlowsIn() As String = Nothing,
Optional dataFlowsOut() As String = Nothing,
Optional definitelyAssignedOnEntry() As String = Nothing,
Optional definitelyAssignedOnExit() As String = Nothing,
Optional readInside() As String = Nothing,
Optional readOutside() As String = Nothing,
Optional variablesDeclared() As String = Nothing,
Optional writtenInside() As String = Nothing,
Optional writtenOutside() As String = Nothing,
Optional capturedInside() As String = Nothing,
Optional capturedOutside() As String = Nothing)
VerifyDataFlowAnalysis(GetSourceXElementFromTemplate(code),
alwaysAssigned,
captured,
dataFlowsIn,
dataFlowsOut,
definitelyAssignedOnEntry,
definitelyAssignedOnExit,
readInside,
readOutside,
variablesDeclared,
writtenInside,
writtenOutside,
capturedInside,
capturedOutside)
End Sub
#End Region
End Class
End Namespace
|
aelij/roslyn
|
src/Compilers/VisualBasic/Test/Semantic/FlowAnalysis/RegionAnalysisTests.vb
|
Visual Basic
|
apache-2.0
| 384,868
|
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.CodeActions
Imports Microsoft.CodeAnalysis.CodeFixes
Imports Microsoft.CodeAnalysis.Formatting
Imports Microsoft.CodeAnalysis.VisualBasic
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports System.Collections.Immutable
Imports System.Threading
Namespace Performance
<ExportCodeFixProvider("CodeCrackerMakeLocalVariableConstWhenItIsPossibleCodeFixProvider", LanguageNames.VisualBasic), Composition.Shared>
Public Class MakeLocalVariableConstWhenPossibleCodeFixProvider
Inherits CodeFixProvider
Public Overrides Function GetFixableDiagnosticIds() As ImmutableArray(Of String)
Return ImmutableArray.Create(MakeLocalVariableConstWhenPossibleAnalyzer.Id)
End Function
Public Overrides Function GetFixAllProvider() As FixAllProvider
Return WellKnownFixAllProviders.BatchFixer
End Function
Public Overrides Async Function ComputeFixesAsync(context As CodeFixContext) As Task
Dim root = Await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(False)
Dim diagnostic = context.Diagnostics.First()
Dim diagnosticSpan = diagnostic.Location.SourceSpan
Dim localDeclaration = root.FindToken(diagnosticSpan.Start).Parent.AncestorsAndSelf().OfType(Of LocalDeclarationStatementSyntax).First()
Const message = "Make constant"
context.RegisterFix(CodeAction.Create(message, Function(c) MakeConstantAsync(context.Document, localDeclaration, c)), diagnostic)
End Function
Public Async Function MakeConstantAsync(document As Document, localDeclaration As LocalDeclarationStatementSyntax, cancellationToken As CancellationToken) As Task(Of Document)
Dim declaration = localDeclaration.Declarators.First
Dim dimModifier = localDeclaration.Modifiers.First()
Dim constant = SyntaxFactory.Token(SyntaxKind.ConstKeyword).
WithLeadingTrivia(dimModifier.LeadingTrivia).
WithTrailingTrivia(dimModifier.TrailingTrivia).
WithAdditionalAnnotations(Formatter.Annotation)
Dim modifiers = localDeclaration.Modifiers.Replace(dimModifier, constant)
Dim newLocalDeclaration = localDeclaration.
WithModifiers(modifiers).
WithLeadingTrivia(localDeclaration.GetLeadingTrivia()).
WithTrailingTrivia(localDeclaration.GetTrailingTrivia()).
WithAdditionalAnnotations(Formatter.Annotation)
Dim root = Await document.GetSyntaxRootAsync(cancellationToken)
Dim newRoot = root.ReplaceNode(localDeclaration, newLocalDeclaration)
Return document.WithSyntaxRoot(newRoot)
End Function
End Class
End Namespace
|
f14n/code-cracker
|
src/VisualBasic/CodeCracker/Performance/MakeLocalVariableConstWhenPossibleCodeFixProvider.vb
|
Visual Basic
|
apache-2.0
| 2,822
|
' Copyright (c) 2015 ZZZ Projects. All rights reserved
' Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods)
' Website: http://www.zzzprojects.com/
' Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927
' All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library
Public Module Extensions_67
''' <summary>
''' A bool extension method that execute an Action if the value is true.
''' </summary>
''' <param name="this">The @this to act on.</param>
''' <param name="action">The action to execute.</param>
<System.Runtime.CompilerServices.Extension> _
Public Sub IfTrue(this As Boolean, action As Action)
If this Then
action()
End If
End Sub
End Module
|
mario-loza/Z.ExtensionMethods
|
src (VB.NET)/Z.ExtensionMethods.VB/Z.Core/System.Boolean/Boolean.IfTrue.vb
|
Visual Basic
|
mit
| 788
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Threading
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.Editor.Completion.FileSystem
Imports Microsoft.VisualStudio.InteractiveWindow
Imports Microsoft.VisualStudio.Text.Editor
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Completion.CompletionProviders
#If TODO Then ' VB doesn't have LoadDirectiveTrivia defined yet
<ExportCompletionProviderMef1("LoadDirectiveCompletionProvider", LanguageNames.VisualBasic)>
<TextViewRole(PredefinedInteractiveTextViewRoles.InteractiveTextViewRole)>
Friend NotInheritable Class LoadDirectiveCompletionProvider : Inherits AbstractReferenceDirectiveCompletionProvider
Protected Overrides Function TryGetStringLiteralToken(tree As SyntaxTree, position As Integer, ByRef stringLiteral As SyntaxToken, cancellationToken As CancellationToken) As Boolean
Return DirectiveCompletionProviderUtilities.TryGetStringLiteralToken(tree, position, SyntaxKind.LoadDirectiveTrivia, stringLiteral, cancellationToken)
End Function
End Class
#End If
End Namespace
|
amcasey/roslyn
|
src/Interactive/EditorFeatures/VisualBasic/Interactive/FileSystem/LoadDirectiveCompletionProvider.vb
|
Visual Basic
|
apache-2.0
| 1,225
|
'------------------------------------------------------------------------------
' <auto-generated>
' 此代码由工具生成。
' 运行时版本:4.0.30319.42000
'
' 对此文件的更改可能会导致不正确的行为,并且如果
' 重新生成代码,这些更改将会丢失。
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Imports System
Namespace My.Resources
'此类是由 StronglyTypedResourceBuilder
'类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
'若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
'(以 /str 作为命令选项),或重新生成 VS 项目。
'''<summary>
''' 一个强类型的资源类,用于查找本地化的字符串等。
'''</summary>
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0"), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
Friend Module Resources
Private resourceMan As Global.System.Resources.ResourceManager
Private resourceCulture As Global.System.Globalization.CultureInfo
'''<summary>
''' 返回此类使用的缓存的 ResourceManager 实例。
'''</summary>
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
Get
If Object.ReferenceEquals(resourceMan, Nothing) Then
Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("ConsoleApp.Test.Resources", GetType(Resources).Assembly)
resourceMan = temp
End If
Return resourceMan
End Get
End Property
'''<summary>
''' 使用此强类型资源类,为所有资源查找
''' 重写当前线程的 CurrentUICulture 属性。
'''</summary>
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Friend Property Culture() As Global.System.Globalization.CultureInfo
Get
Return resourceCulture
End Get
Set
resourceCulture = value
End Set
End Property
End Module
End Namespace
|
xieguigang/spectrum
|
src/visualize/test/My Project/Resources.Designer.vb
|
Visual Basic
|
mit
| 2,734
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System
Imports System.Collections
Imports System.Collections.Generic
Imports System.Linq
Imports System.Runtime.CompilerServices
Imports System.Text
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax
Partial Class SyntaxList
Friend Class WeakWithManyChildren
Inherits SyntaxList
Private ReadOnly _children As ArrayElement(Of WeakReference(Of SyntaxNode))()
Friend Sub New(green As InternalSyntax.SyntaxList, parent As SyntaxNode, position As Integer)
MyBase.New(green, parent, position)
Me._children = New ArrayElement(Of WeakReference(Of SyntaxNode))(green.SlotCount - 1) {}
End Sub
Friend Overrides Function GetNodeSlot(index As Integer) As SyntaxNode
Return GetWeakRedElement(Me._children(index).Value, index)
End Function
Friend Overrides Function GetCachedSlot(i As Integer) As SyntaxNode
Dim result As SyntaxNode = Nothing
Dim weak = Me._children(i).Value
If weak IsNot Nothing Then
weak.TryGetTarget(result)
End If
Return result
End Function
End Class
End Class
End Namespace
|
ManishJayaswal/roslyn
|
src/Compilers/VisualBasic/Portable/Syntax/SyntaxList.WeakWithManyChildren.vb
|
Visual Basic
|
apache-2.0
| 1,570
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.IO
Imports System.Reflection.Metadata
Imports System.Security.Cryptography
Imports Microsoft.Cci
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.VisualBasic
Imports Microsoft.CodeAnalysis.VisualBasic.UnitTests
Imports Roslyn.Test.Utilities.SigningTestHelpers
Partial Public Class InternalsVisibleToAndStrongNameTests
Inherits BasicTestBase
Private Class StrongNameProviderWithBadInputStream
Inherits StrongNameProvider
Private _underlyingProvider As StrongNameProvider
Public Property ThrownException As Exception
Friend Overrides ReadOnly Property Capability As SigningCapability = SigningCapability.SignsStream
Public Sub New(underlyingProvider As StrongNameProvider)
_underlyingProvider = underlyingProvider
End Sub
Public Overrides Function Equals(other As Object) As Boolean
Return Me Is other
End Function
Public Overrides Function GetHashCode() As Integer
Return _underlyingProvider.GetHashCode()
End Function
Friend Overrides Function CreateInputStream() As Stream
ThrownException = New IOException("This is a test IOException")
Throw ThrownException
End Function
Friend Overrides Function CreateKeys(keyFilePath As String, keyContainerName As String, messageProvider As CommonMessageProvider) As StrongNameKeys
Return _underlyingProvider.CreateKeys(keyFilePath, keyContainerName, messageProvider)
End Function
Friend Overrides Sub SignStream(keys As StrongNameKeys, inputStream As Stream, outputStream As Stream)
_underlyingProvider.SignStream(keys, inputStream, outputStream)
End Sub
Friend Overrides Sub SignPeBuilder(peWriter As ExtendedPEBuilder, peBlob As BlobBuilder, privkey As RSAParameters)
Throw ThrownException
End Sub
End Class
<Fact>
Public Sub BadInputStream()
Dim testProvider = New StrongNameProviderWithBadInputStream(s_defaultDesktopProvider)
Dim options = TestOptions.DebugDll.WithStrongNameProvider(testProvider).WithCryptoKeyContainer("RoslynTestContainer")
Dim comp = CreateCompilationWithMscorlib40(
<compilation>
<file name="a.vb"><![CDATA[
Public Class C
Public Sub M()
End Sub
End Class
]]>
</file>
</compilation>, options:=options)
comp.Emit(New MemoryStream()).Diagnostics.Verify(
Diagnostic(ERRID.ERR_PeWritingFailure).WithArguments(testProvider.ThrownException.ToString()).WithLocation(1, 1))
End Sub
End Class
|
OmarTawfik/roslyn
|
src/Compilers/VisualBasic/Test/Emit/Attributes/EmitTestStrongNameProvider.vb
|
Visual Basic
|
apache-2.0
| 2,831
|
' Licensed to the .NET Foundation under one or more agreements.
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.
Imports System.Collections.Immutable
Imports System.Threading
Imports Microsoft.CodeAnalysis.PooledObjects
Namespace Microsoft.CodeAnalysis.VisualBasic
''' <summary>
''' This class implements the region data flow analysis operations. Region data flow analysis provides information
''' how data flows into and out of a region. The analysis is done lazily. When created, it performs no analysis, but
''' simply caches the arguments. Then, the first time one of the analysis results is used it computes that one
''' result and caches it. Each result is computed using a custom algorithm.
''' </summary>
Friend Class VisualBasicDataFlowAnalysis
Inherits DataFlowAnalysis
Private ReadOnly _context As RegionAnalysisContext
Private _variablesDeclared As ImmutableArray(Of ISymbol)
Private _unassignedVariables As HashSet(Of Symbol)
Private _dataFlowsIn As ImmutableArray(Of ISymbol)
Private _definitelyAssignedOnEntry As ImmutableArray(Of ISymbol)
Private _definitelyAssignedOnExit As ImmutableArray(Of ISymbol)
Private _dataFlowsOut As ImmutableArray(Of ISymbol)
Private _alwaysAssigned As ImmutableArray(Of ISymbol)
Private _readInside As ImmutableArray(Of ISymbol)
Private _writtenInside As ImmutableArray(Of ISymbol)
Private _readOutside As ImmutableArray(Of ISymbol)
Private _writtenOutside As ImmutableArray(Of ISymbol)
Private _captured As ImmutableArray(Of ISymbol)
Private _capturedInside As ImmutableArray(Of ISymbol)
Private _capturedOutside As ImmutableArray(Of ISymbol)
Private _succeeded As Boolean?
Private _invalidRegionDetected As Boolean
Friend Sub New(_context As RegionAnalysisContext)
Me._context = _context
End Sub
''' <summary>
''' A collection of the local variables that are declared within the region. Note that the region must be
''' bounded by a method's body or a field's initializer, so parameter symbols are never included in the result.
''' </summary>
Public Overrides ReadOnly Property VariablesDeclared As ImmutableArray(Of ISymbol)
Get
If _variablesDeclared.IsDefault Then
Dim result = If(Me._context.Failed, ImmutableArray(Of ISymbol).Empty,
Normalize(VariablesDeclaredWalker.Analyze(_context.AnalysisInfo, _context.RegionInfo)))
ImmutableInterlocked.InterlockedCompareExchange(_variablesDeclared, result, Nothing)
End If
Return _variablesDeclared
End Get
End Property
Private ReadOnly Property UnassignedVariables As HashSet(Of Symbol)
Get
If _unassignedVariables Is Nothing Then
Dim result = If(Me._context.Failed, New HashSet(Of Symbol)(),
UnassignedVariablesWalker.Analyze(_context.AnalysisInfo))
Interlocked.CompareExchange(_unassignedVariables, result, Nothing)
End If
Return _unassignedVariables
End Get
End Property
''' <summary>
''' A collection of the local variables for which a value assigned outside the region may be used inside the region.
''' </summary>
Public Overrides ReadOnly Property DataFlowsIn As ImmutableArray(Of ISymbol)
Get
If _dataFlowsIn.IsDefault Then
Me._succeeded = Not Me._context.Failed
Dim result = If(Me._context.Failed, ImmutableArray(Of ISymbol).Empty,
Normalize(DataFlowsInWalker.Analyze(_context.AnalysisInfo, _context.RegionInfo, UnassignedVariables, _succeeded, _invalidRegionDetected)))
ImmutableInterlocked.InterlockedCompareExchange(_dataFlowsIn, result, Nothing)
End If
Return _dataFlowsIn
End Get
End Property
Public Overrides ReadOnly Property DefinitelyAssignedOnEntry As ImmutableArray(Of ISymbol)
Get
Return ComputeDefinitelyAssignedValues().onEntry
End Get
End Property
Public Overrides ReadOnly Property DefinitelyAssignedOnExit As ImmutableArray(Of ISymbol)
Get
Return ComputeDefinitelyAssignedValues().onExit
End Get
End Property
Private Function ComputeDefinitelyAssignedValues() As (onEntry As ImmutableArray(Of ISymbol), onExit As ImmutableArray(Of ISymbol))
' Check for _definitelyAssignedOnExit as that's the last thing we write to. If it's not
' Default, then we'll have written to both variables and can safely read from either of
' them.
If _definitelyAssignedOnExit.IsDefault Then
Dim entry = ImmutableArray(Of ISymbol).Empty
Dim ex = ImmutableArray(Of ISymbol).Empty
Dim discarded = DataFlowsIn
If Not Me._context.Failed Then
Dim tuple = DefinitelyAssignedWalker.Analyze(_context.AnalysisInfo, _context.RegionInfo)
entry = Normalize(tuple.entry)
ex = Normalize(tuple.ex)
End If
ImmutableInterlocked.InterlockedInitialize(_definitelyAssignedOnEntry, entry)
ImmutableInterlocked.InterlockedInitialize(_definitelyAssignedOnExit, ex)
End If
Return (_definitelyAssignedOnEntry, _definitelyAssignedOnExit)
End Function
''' <summary>
''' A collection of the local variables for which a value assigned inside the region may be used outside the region.
''' </summary>
Public Overrides ReadOnly Property DataFlowsOut As ImmutableArray(Of ISymbol)
Get
Dim discarded = DataFlowsIn
If _dataFlowsOut.IsDefault Then
Dim result = If(Me._context.Failed, ImmutableArray(Of ISymbol).Empty,
Normalize(DataFlowsOutWalker.Analyze(_context.AnalysisInfo, _context.RegionInfo, UnassignedVariables, _dataFlowsIn)))
ImmutableInterlocked.InterlockedCompareExchange(_dataFlowsOut, result, Nothing)
End If
Return _dataFlowsOut
End Get
End Property
''' <summary>
''' A collection of the local variables for which a value is always assigned inside the region.
''' </summary>
Public Overrides ReadOnly Property AlwaysAssigned As ImmutableArray(Of ISymbol)
Get
If _alwaysAssigned.IsDefault Then
Dim result = If(Me._context.Failed, ImmutableArray(Of ISymbol).Empty,
Normalize(AlwaysAssignedWalker.Analyze(_context.AnalysisInfo, _context.RegionInfo)))
ImmutableInterlocked.InterlockedCompareExchange(_alwaysAssigned, result, Nothing)
End If
Return _alwaysAssigned
End Get
End Property
''' <summary>
''' A collection of the local variables that are read inside the region.
''' </summary>
Public Overrides ReadOnly Property ReadInside As ImmutableArray(Of ISymbol)
Get
If _readInside.IsDefault Then
AnalyzeReadWrite()
End If
Return _readInside
End Get
End Property
''' <summary>
''' A collection of local variables that are written inside the region.
''' </summary>
Public Overrides ReadOnly Property WrittenInside As ImmutableArray(Of ISymbol)
Get
If _writtenInside.IsDefault Then
AnalyzeReadWrite()
End If
Return _writtenInside
End Get
End Property
''' <summary>
''' A collection of the local variables that are read outside the region.
''' </summary>
Public Overrides ReadOnly Property ReadOutside As ImmutableArray(Of ISymbol)
Get
If _readOutside.IsDefault Then
AnalyzeReadWrite()
End If
Return _readOutside
End Get
End Property
''' <summary>
''' A collection of local variables that are written inside the region.
''' </summary>
Public Overrides ReadOnly Property WrittenOutside As ImmutableArray(Of ISymbol)
Get
If _writtenOutside.IsDefault Then
AnalyzeReadWrite()
End If
Return _writtenOutside
End Get
End Property
Private Sub AnalyzeReadWrite()
Dim readInside As IEnumerable(Of Symbol) = Nothing
Dim writtenInside As IEnumerable(Of Symbol) = Nothing
Dim readOutside As IEnumerable(Of Symbol) = Nothing
Dim writtenOutside As IEnumerable(Of Symbol) = Nothing
Dim captured As IEnumerable(Of Symbol) = Nothing
Dim capturedInside As IEnumerable(Of Symbol) = Nothing
Dim capturedOutside As IEnumerable(Of Symbol) = Nothing
If Not Me.Succeeded Then
readInside = Enumerable.Empty(Of Symbol)()
writtenInside = readInside
readOutside = readInside
writtenOutside = readInside
captured = readInside
Else
ReadWriteWalker.Analyze(
_context.AnalysisInfo, _context.RegionInfo,
readInside:=readInside,
writtenInside:=writtenInside,
readOutside:=readOutside,
writtenOutside:=writtenOutside,
captured:=captured,
capturedInside:=capturedInside,
capturedOutside:=capturedOutside)
End If
ImmutableInterlocked.InterlockedCompareExchange(Me._readInside, Normalize(readInside), Nothing)
ImmutableInterlocked.InterlockedCompareExchange(Me._writtenInside, Normalize(writtenInside), Nothing)
ImmutableInterlocked.InterlockedCompareExchange(Me._readOutside, Normalize(readOutside), Nothing)
ImmutableInterlocked.InterlockedCompareExchange(Me._writtenOutside, Normalize(writtenOutside), Nothing)
ImmutableInterlocked.InterlockedCompareExchange(Me._captured, Normalize(captured), Nothing)
ImmutableInterlocked.InterlockedCompareExchange(Me._capturedInside, Normalize(capturedInside), Nothing)
ImmutableInterlocked.InterlockedCompareExchange(Me._capturedOutside, Normalize(capturedOutside), Nothing)
End Sub
''' <summary>
''' A collection of the local variables that have been referenced in anonymous functions
''' and therefore must be moved to a field of a frame class.
''' </summary>
Public Overrides ReadOnly Property Captured As ImmutableArray(Of ISymbol)
Get
If Me._captured.IsDefault Then
AnalyzeReadWrite()
End If
Return Me._captured
End Get
End Property
Public Overrides ReadOnly Property CapturedInside As ImmutableArray(Of ISymbol)
Get
If Me._capturedInside.IsDefault Then
AnalyzeReadWrite()
End If
Return Me._capturedInside
End Get
End Property
Public Overrides ReadOnly Property CapturedOutside As ImmutableArray(Of ISymbol)
Get
If Me._capturedOutside.IsDefault Then
AnalyzeReadWrite()
End If
Return Me._capturedOutside
End Get
End Property
Friend ReadOnly Property InvalidRegionDetectedInternal As Boolean
Get
Return If(Me.Succeeded, False, Me._invalidRegionDetected)
End Get
End Property
Public NotOverridable Overrides ReadOnly Property Succeeded As Boolean
Get
If Me._succeeded Is Nothing Then
Dim discarded = DataFlowsIn
End If
Return Me._succeeded.Value
End Get
End Property
Public Overrides ReadOnly Property UnsafeAddressTaken As ImmutableArray(Of ISymbol)
Get
Return ImmutableArray(Of ISymbol).Empty
End Get
End Property
Public Overrides ReadOnly Property UsedLocalFunctions As ImmutableArray(Of IMethodSymbol)
Get
Return ImmutableArray(Of IMethodSymbol).Empty
End Get
End Property
Friend Function Normalize(data As IEnumerable(Of Symbol)) As ImmutableArray(Of ISymbol)
Dim builder = ArrayBuilder(Of Symbol).GetInstance()
builder.AddRange(data.Where(Function(s) s.CanBeReferencedByName))
builder.Sort(LexicalOrderSymbolComparer.Instance)
Return builder.ToImmutableAndFree().As(Of ISymbol)()
End Function
End Class
End Namespace
|
AmadeusW/roslyn
|
src/Compilers/VisualBasic/Portable/Analysis/FlowAnalysis/VisualBasicDataFlowAnalysis.vb
|
Visual Basic
|
apache-2.0
| 13,563
|
' Licensed to the .NET Foundation under one or more agreements.
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.
Imports System.Collections.Immutable
Imports System.Collections.ObjectModel
Imports System.IO
Imports Microsoft.CodeAnalysis.CodeGen
Imports Microsoft.CodeAnalysis.ExpressionEvaluator
Imports Microsoft.CodeAnalysis.ExpressionEvaluator.UnitTests
Imports Microsoft.CodeAnalysis.PooledObjects
Imports Microsoft.CodeAnalysis.Test.Utilities
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.UnitTests
Imports Microsoft.VisualStudio.Debugger.Clr
Imports Microsoft.VisualStudio.Debugger.Evaluation
Imports Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation
Imports Roslyn.Test.Utilities
Imports Xunit
Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator.UnitTests
Public Class TupleTests
Inherits ExpressionCompilerTestBase
<Fact>
Public Sub Literal()
Const source =
"Class C
Shared Sub M()
Dim o As (Integer, Integer)
End Sub
End Class"
Dim comp = CreateCompilationWithMscorlib40({source}, references:={ValueTupleRef, SystemRuntimeFacadeRef}, options:=TestOptions.DebugDll)
WithRuntimeInstance(comp, {MscorlibRef, ValueTupleRef, SystemRuntimeFacadeRef},
Sub(runtime)
Dim context = CreateMethodContext(runtime, "C.M")
Dim errorMessage As String = Nothing
Dim testData = New CompilationTestData()
Dim result = context.CompileExpression(
"(A:=1, B:=2)",
DkmEvaluationFlags.TreatAsExpression,
NoAliases,
errorMessage,
testData)
Assert.Null(errorMessage)
Dim typeInfo As ReadOnlyCollection(Of Byte) = Nothing
Dim typeInfoId = result.GetCustomTypeInfo(typeInfo)
Assert.NotNull(typeInfo)
Dim dynamicFlags As ReadOnlyCollection(Of Byte) = Nothing
Dim tupleElementNames As ReadOnlyCollection(Of String) = Nothing
CustomTypeInfo.Decode(typeInfoId, typeInfo, dynamicFlags, tupleElementNames)
Assert.Equal({"A", "B"}, tupleElementNames)
Dim methodData = testData.GetMethodData("<>x.<>m0")
Dim method = methodData.Method
Assert.True(method.ReturnType.IsTupleType)
CheckAttribute(result.Assembly, method, AttributeDescription.TupleElementNamesAttribute, expected:=True)
methodData.VerifyIL(
"{
// Code size 8 (0x8)
.maxstack 2
.locals init (System.ValueTuple(Of Integer, Integer) V_0) //o
IL_0000: ldc.i4.1
IL_0001: ldc.i4.2
IL_0002: newobj ""Sub System.ValueTuple(Of Integer, Integer)..ctor(Integer, Integer)""
IL_0007: ret
}")
End Sub)
End Sub
<Fact>
Public Sub DuplicateValueTupleBetweenMscorlibAndLibrary()
Const versionTemplate = "<Assembly: System.Reflection.AssemblyVersion(""{0}.0.0.0"")>"
Const corlib_vb = "
Namespace System
Public Class [Object]
End Class
Public Structure Void
End Structure
Public Class ValueType
End Class
Public Structure IntPtr
End Structure
Public Structure Int32
End Structure
Public Class [String]
End Class
Public Class Attribute
End Class
End Namespace
Namespace System.Reflection
Public Class AssemblyVersionAttribute
Inherits Attribute
Public Sub New(version As String)
End Sub
End Class
End Namespace
"
Dim corlibWithoutVT = CreateEmptyCompilation({String.Format(versionTemplate, "1") + corlib_vb}, options:=TestOptions.DebugDll, assemblyName:="corlib")
corlibWithoutVT.AssertTheseDiagnostics()
Dim corlibWithoutVTRef = corlibWithoutVT.EmitToImageReference()
Const valuetuple_vb As String = "
Namespace System
Public Structure ValueTuple(Of T1, T2)
Public Dim Item1 As T1
Public Dim Item2 As T2
Public Sub New(item1 As T1, item2 As T2)
End Sub
End Structure
End Namespace
"
Dim corlibWithVT = CreateEmptyCompilation({String.Format(versionTemplate, "2") + corlib_vb + valuetuple_vb}, options:=TestOptions.DebugDll, assemblyName:="corlib")
corlibWithVT.AssertTheseDiagnostics()
Const source As String =
"Class C
Shared Function M() As (Integer, Integer)
Dim o = (1, 2)
Return o
End Function
End Class"
Dim app = CreateEmptyCompilation(source + valuetuple_vb, references:={corlibWithoutVTRef}, options:=TestOptions.DebugDll)
app.AssertTheseDiagnostics()
Dim runtime = CreateRuntimeInstance({app.ToModuleInstance(), corlibWithVT.ToModuleInstance()})
' Create EE context with app assembly (including ValueTuple) and a more recent corlib (also including ValueTuple)
Dim evalContext = CreateMethodContext(runtime, "C.M")
Dim errorMessage As String = Nothing
Dim testData = New CompilationTestData()
Dim compileResult = evalContext.CompileExpression("(1, 2)", errorMessage, testData)
Assert.Null(errorMessage)
Using block As ModuleMetadata = ModuleMetadata.CreateFromStream(New MemoryStream(compileResult.Assembly))
Dim reader = block.MetadataReader
Dim appRef = app.Assembly.Identity.Name
AssertEx.SetEqual({"corlib 2.0", appRef + " 0.0"}, reader.DumpAssemblyReferences())
AssertEx.SetEqual({"Object, System, AssemblyReference:corlib",
"ValueTuple`2, System, AssemblyReference:" + appRef}, ' ValueTuple comes from app, not corlib
reader.DumpTypeReferences())
End Using
End Sub
<Fact>
Public Sub TupleElementNamesAttribute_NotAvailable()
Const source =
"Namespace System
Public Structure ValueTuple(Of T1, T2)
Public Item1 As T1
Public Item2 As T2
Public Sub New(_1 As T1, _2 As T2)
Item1 = _1
Item2 = _2
End Sub
End Structure
End Namespace
Class C
Shared Sub M()
Dim o As (Integer, Integer)
End Sub
End Class"
Dim comp = CreateCompilationWithMscorlib40({source}, options:=TestOptions.DebugDll)
WithRuntimeInstance(comp,
Sub(runtime)
Dim context = CreateMethodContext(runtime, "C.M")
Dim errorMessage As String = Nothing
Dim testData = New CompilationTestData()
Dim result = context.CompileExpression(
"(A:=1, B:=2)",
DkmEvaluationFlags.TreatAsExpression,
NoAliases,
errorMessage,
testData)
Assert.Null(errorMessage)
Dim typeInfo As ReadOnlyCollection(Of Byte) = Nothing
Dim typeInfoId = result.GetCustomTypeInfo(typeInfo)
Assert.Null(typeInfo)
Dim methodData = testData.GetMethodData("<>x.<>m0")
Dim method = methodData.Method
Assert.True(method.ReturnType.IsTupleType)
CheckAttribute(result.Assembly, method, AttributeDescription.TupleElementNamesAttribute, expected:=False)
methodData.VerifyIL(
"{
// Code size 8 (0x8)
.maxstack 2
.locals init (System.ValueTuple(Of Integer, Integer) V_0) //o
IL_0000: ldc.i4.1
IL_0001: ldc.i4.2
IL_0002: newobj ""Sub System.ValueTuple(Of Integer, Integer)..ctor(Integer, Integer)""
IL_0007: ret
}")
End Sub)
End Sub
<WorkItem(13948, "https://github.com/dotnet/roslyn/issues/13948")>
<Fact>
Public Sub Local()
Const source =
"class C
{
static void M()
{
(int A, int B) o = (1, 2);
}
}"
Dim comp = CreateCSharpCompilation(source, referencedAssemblies:={MscorlibRef, ValueTupleRef, SystemRuntimeFacadeRef})
WithRuntimeInstance(comp, {MscorlibRef, ValueTupleRef, SystemRuntimeFacadeRef},
Sub(runtime)
Dim context = CreateMethodContext(runtime, "C.M")
Dim testData = New CompilationTestData()
Dim locals = ArrayBuilder(Of LocalAndMethod).GetInstance()
Dim typeName As String = Nothing
Dim assembly = context.CompileGetLocals(locals, argumentsOnly:=False, typeName:=typeName, testData:=testData)
Assert.Equal(1, locals.Count)
Dim typeInfo As ReadOnlyCollection(Of Byte) = Nothing
Dim typeInfoId = locals(0).GetCustomTypeInfo(typeInfo)
Dim dynamicFlags As ReadOnlyCollection(Of Byte) = Nothing
Dim tupleElementNames As ReadOnlyCollection(Of String) = Nothing
CustomTypeInfo.Decode(typeInfoId, typeInfo, dynamicFlags, tupleElementNames)
Assert.Equal({"A", "B"}, tupleElementNames)
Dim method = testData.Methods.Single().Value.Method
CheckAttribute(assembly, method, AttributeDescription.TupleElementNamesAttribute, expected:=True)
Assert.True(method.ReturnType.IsTupleType)
VerifyLocal(testData, typeName, locals(0), "<>m0", "o", expectedILOpt:=
"{
// Code size 2 (0x2)
.maxstack 1
.locals init (System.ValueTuple(Of Integer, Integer) V_0) //o
IL_0000: ldloc.0
IL_0001: ret
}")
locals.Free()
End Sub)
End Sub
<WorkItem(13948, "https://github.com/dotnet/roslyn/issues/13948")>
<Fact>
Public Sub Constant()
Const source =
"class A<T>
{
internal class B<U>
{
}
}
class C
{
static (object, object) F;
static void M()
{
const A<(int, int A)>.B<(object B, object)>[] c = null;
}
}"
Dim comp = CreateCSharpCompilation(source, referencedAssemblies:={MscorlibRef, ValueTupleRef, SystemRuntimeFacadeRef})
WithRuntimeInstance(comp, {MscorlibRef, ValueTupleRef, SystemRuntimeFacadeRef},
Sub(runtime)
Dim context = CreateMethodContext(runtime, "C.M")
Dim testData = New CompilationTestData()
Dim locals = ArrayBuilder(Of LocalAndMethod).GetInstance()
Dim typeName As String = Nothing
Dim assembly = context.CompileGetLocals(locals, argumentsOnly:=False, typeName:=typeName, testData:=testData)
Assert.Equal(1, locals.Count)
Dim typeInfo As ReadOnlyCollection(Of Byte) = Nothing
Dim typeInfoId = locals(0).GetCustomTypeInfo(typeInfo)
Dim dynamicFlags As ReadOnlyCollection(Of Byte) = Nothing
Dim tupleElementNames As ReadOnlyCollection(Of String) = Nothing
CustomTypeInfo.Decode(typeInfoId, typeInfo, dynamicFlags, tupleElementNames)
Assert.Equal({Nothing, "A", "B", Nothing}, tupleElementNames)
Dim method = DirectCast(testData.Methods.Single().Value.Method, MethodSymbol)
CheckAttribute(assembly, method, AttributeDescription.TupleElementNamesAttribute, expected:=True)
Dim returnType = method.ReturnType
Assert.False(returnType.IsTupleType)
Assert.True(returnType.ContainsTuple())
VerifyLocal(testData, typeName, locals(0), "<>m0", "c", expectedFlags:=DkmClrCompilationResultFlags.ReadOnlyResult, expectedILOpt:=
"{
// Code size 2 (0x2)
.maxstack 1
IL_0000: ldnull
IL_0001: ret
}")
locals.Free()
End Sub)
End Sub
<WorkItem(13803, "https://github.com/dotnet/roslyn/issues/13803")>
<Fact>
Public Sub LongTupleLocalElement_NoNames()
Const source =
"Class C
Shared Sub M()
Dim x = (1, 2, 3, 4, 5, 6, 7, 8)
End Sub
End Class"
Dim comp = CreateCompilationWithMscorlib40({source}, references:={SystemRuntimeFacadeRef, ValueTupleRef}, options:=TestOptions.DebugDll)
WithRuntimeInstance(comp,
{MscorlibRef, SystemCoreRef, SystemRuntimeFacadeRef, ValueTupleRef},
Sub(runtime)
Dim context = CreateMethodContext(runtime, "C.M")
Dim errorMessage As String = Nothing
Dim testData = New CompilationTestData()
context.CompileExpression(
"x.Item4 + x.Item8",
DkmEvaluationFlags.TreatAsExpression,
NoAliases,
errorMessage,
testData)
testData.GetMethodData("<>x.<>m0").VerifyIL(
"{
// Code size 19 (0x13)
.maxstack 2
.locals init (System.ValueTuple(Of Integer, Integer, Integer, Integer, Integer, Integer, Integer, ValueTuple(Of Integer)) V_0) //x
IL_0000: ldloc.0
IL_0001: ldfld ""System.ValueTuple(Of Integer, Integer, Integer, Integer, Integer, Integer, Integer, ValueTuple(Of Integer)).Item4 As Integer""
IL_0006: ldloc.0
IL_0007: ldfld ""System.ValueTuple(Of Integer, Integer, Integer, Integer, Integer, Integer, Integer, ValueTuple(Of Integer)).Rest As ValueTuple(Of Integer)""
IL_000c: ldfld ""System.ValueTuple(Of Integer).Item1 As Integer""
IL_0011: add.ovf
IL_0012: ret
}")
End Sub)
End Sub
<Fact>
Public Sub LongTupleLocalElement_Names()
Const source =
"Class C
Shared Sub M()
Dim x = (1, 2, Three:=3, Four:=4, 5, 6, 7, Eight:=8)
End Sub
End Class"
Dim comp = CreateCompilationWithMscorlib40({source}, references:={SystemRuntimeFacadeRef, ValueTupleRef}, options:=TestOptions.DebugDll)
WithRuntimeInstance(comp,
{MscorlibRef, SystemCoreRef, SystemRuntimeFacadeRef, ValueTupleRef},
Sub(runtime)
Dim context = CreateMethodContext(runtime, "C.M")
Dim errorMessage As String = Nothing
Dim testData = New CompilationTestData()
context.CompileExpression(
"x.Item8 + x.Eight",
DkmEvaluationFlags.TreatAsExpression,
NoAliases,
errorMessage,
testData)
testData.GetMethodData("<>x.<>m0").VerifyIL(
"{
// Code size 24 (0x18)
.maxstack 2
.locals init (System.ValueTuple(Of Integer, Integer, Integer, Integer, Integer, Integer, Integer, ValueTuple(Of Integer)) V_0) //x
IL_0000: ldloc.0
IL_0001: ldfld ""System.ValueTuple(Of Integer, Integer, Integer, Integer, Integer, Integer, Integer, ValueTuple(Of Integer)).Rest As ValueTuple(Of Integer)""
IL_0006: ldfld ""System.ValueTuple(Of Integer).Item1 As Integer""
IL_000b: ldloc.0
IL_000c: ldfld ""System.ValueTuple(Of Integer, Integer, Integer, Integer, Integer, Integer, Integer, ValueTuple(Of Integer)).Rest As ValueTuple(Of Integer)""
IL_0011: ldfld ""System.ValueTuple(Of Integer).Item1 As Integer""
IL_0016: add.ovf
IL_0017: ret
}")
End Sub)
End Sub
''' <summary>
''' Locals declared in the VB EE do not have an explicit
''' type and are statically typed to Object, so tuple
''' element names on the value are not preserved.
''' </summary>
<Fact>
Public Sub DeclareLocal()
Const source =
"Class C
Shared Sub M()
Dim x = (1, 2)
End Sub
End Class"
Dim comp = CreateCompilationWithMscorlib40({source}, references:={ValueTupleRef, SystemRuntimeFacadeRef}, options:=TestOptions.DebugDll)
WithRuntimeInstance(comp, references:={MscorlibRef, ValueTupleRef, SystemRuntimeFacadeRef},
validator:=Sub(runtime)
Dim context = CreateMethodContext(runtime, "C.M")
Dim errorMessage As String = Nothing
Dim testData = New CompilationTestData()
Dim result = context.CompileExpression(
"y = DirectCast(x, (A As Integer, B As Integer))",
DkmEvaluationFlags.None,
NoAliases,
errorMessage,
testData)
Assert.Null(errorMessage)
Dim typeInfo As ReadOnlyCollection(Of Byte) = Nothing
Dim typeInfoId = result.GetCustomTypeInfo(typeInfo)
Assert.Null(typeInfo)
Dim methodData = testData.GetMethodData("<>x.<>m0")
Dim method = methodData.Method
CheckAttribute(result.Assembly, method, AttributeDescription.TupleElementNamesAttribute, expected:=False)
methodData.VerifyIL(
"{
// Code size 48 (0x30)
.maxstack 4
.locals init (System.ValueTuple(Of Integer, Integer) V_0, //x
System.Guid V_1)
IL_0000: ldtoken ""Object""
IL_0005: call ""Function System.Type.GetTypeFromHandle(System.RuntimeTypeHandle) As System.Type""
IL_000a: ldstr ""y""
IL_000f: ldloca.s V_1
IL_0011: initobj ""System.Guid""
IL_0017: ldloc.1
IL_0018: ldnull
IL_0019: call ""Sub Microsoft.VisualStudio.Debugger.Clr.IntrinsicMethods.CreateVariable(System.Type, String, System.Guid, Byte())""
IL_001e: ldstr ""y""
IL_0023: call ""Function Microsoft.VisualStudio.Debugger.Clr.IntrinsicMethods.GetVariableAddress(Of Object)(String) As Object""
IL_0028: ldloc.0
IL_0029: box ""System.ValueTuple(Of Integer, Integer)""
IL_002e: stind.ref
IL_002f: ret
}")
End Sub)
End Sub
<WorkItem(13589, "https://github.com/dotnet/roslyn/issues/13589")>
<Fact>
Public Sub [Alias]()
Const source =
"Class C
Shared F As (Integer, Integer)
Shared Sub M()
End Sub
End Class"
Dim comp = CreateCompilationWithMscorlib40({source}, references:={ValueTupleRef, SystemRuntimeFacadeRef}, options:=TestOptions.DebugDll)
WithRuntimeInstance(comp, {MscorlibRef, ValueTupleRef, SystemRuntimeFacadeRef},
Sub(runtime)
Dim context = CreateMethodContext(runtime, "C.M")
Dim locals = ArrayBuilder(Of LocalAndMethod).GetInstance()
Dim typeName As String = Nothing
Dim aliasElementNames = New ReadOnlyCollection(Of String)({"A", "B", Nothing, "D"})
Dim [alias] = New [Alias](
DkmClrAliasKind.Variable,
"t",
"t",
"System.ValueTuple`2[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.ValueTuple`2[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51]][], System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51",
CustomTypeInfo.PayloadTypeId,
CustomTypeInfo.Encode(Nothing, aliasElementNames))
Dim diagnostics = DiagnosticBag.GetInstance()
Dim testData = New CompilationTestData()
Dim assembly = context.CompileGetLocals(
locals,
argumentsOnly:=False,
aliases:=ImmutableArray.Create([alias]),
diagnostics:=diagnostics,
typeName:=typeName,
testData:=testData)
diagnostics.Verify()
diagnostics.Free()
Assert.Equal(1, locals.Count)
Dim typeInfo As ReadOnlyCollection(Of Byte) = Nothing
Dim typeInfoId = locals(0).GetCustomTypeInfo(typeInfo)
Dim dynamicFlags As ReadOnlyCollection(Of Byte) = Nothing
Dim tupleElementNames As ReadOnlyCollection(Of String) = Nothing
CustomTypeInfo.Decode(typeInfoId, typeInfo, dynamicFlags, tupleElementNames)
Assert.Equal(aliasElementNames, tupleElementNames)
Dim method = testData.Methods.Single().Value.Method
CheckAttribute(assembly, method, AttributeDescription.TupleElementNamesAttribute, expected:=True)
Dim returnType = DirectCast(method.ReturnType, TypeSymbol)
Assert.False(returnType.IsTupleType)
Assert.True(DirectCast(returnType, ArrayTypeSymbol).ElementType.IsTupleType)
VerifyLocal(testData, typeName, locals(0), "<>m0", "t", expectedILOpt:=
"{
// Code size 16 (0x10)
.maxstack 1
IL_0000: ldstr ""t""
IL_0005: call ""Function Microsoft.VisualStudio.Debugger.Clr.IntrinsicMethods.GetObjectByAlias(String) As Object""
IL_000a: castclass ""(A As Integer, B As (Integer, D As Integer))()""
IL_000f: ret
}")
locals.Free()
End Sub)
End Sub
<WorkItem(13803, "https://github.com/dotnet/roslyn/issues/13803")>
<Fact>
Public Sub AliasElement_NoNames()
Const source =
"Class C
Shared F As (Integer, Integer)
Shared Sub M()
End Sub
End Class"
Dim comp = CreateCompilationWithMscorlib40({source}, references:={SystemRuntimeFacadeRef, ValueTupleRef}, options:=TestOptions.DebugDll)
WithRuntimeInstance(comp,
{MscorlibRef, SystemCoreRef, SystemRuntimeFacadeRef, ValueTupleRef},
Sub(runtime)
Dim context = CreateMethodContext(runtime, "C.M")
Dim [alias] = New [Alias](
DkmClrAliasKind.Variable,
"x",
"x",
"System.ValueTuple`8[" +
"[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]," +
"[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]," +
"[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]," +
"[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]," +
"[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]," +
"[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]," +
"[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]," +
"[System.ValueTuple`2[" +
"[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]," +
"[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], " +
"System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51]], " +
"System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51",
Guid.Empty,
Nothing)
Dim errorMessage As String = Nothing
Dim testData = New CompilationTestData()
context.CompileExpression(
"x.Item4 + x.Item8",
DkmEvaluationFlags.TreatAsExpression,
ImmutableArray.Create([alias]),
errorMessage,
testData)
Assert.Null(errorMessage)
testData.GetMethodData("<>x.<>m0").VerifyIL(
"{
// Code size 47 (0x2f)
.maxstack 2
IL_0000: ldstr ""x""
IL_0005: call ""Function Microsoft.VisualStudio.Debugger.Clr.IntrinsicMethods.GetObjectByAlias(String) As Object""
IL_000a: unbox.any ""System.ValueTuple(Of Integer, Integer, Integer, Integer, Integer, Integer, Integer, (Integer, Integer))""
IL_000f: ldfld ""System.ValueTuple(Of Integer, Integer, Integer, Integer, Integer, Integer, Integer, (Integer, Integer)).Item4 As Integer""
IL_0014: ldstr ""x""
IL_0019: call ""Function Microsoft.VisualStudio.Debugger.Clr.IntrinsicMethods.GetObjectByAlias(String) As Object""
IL_001e: unbox.any ""System.ValueTuple(Of Integer, Integer, Integer, Integer, Integer, Integer, Integer, (Integer, Integer))""
IL_0023: ldfld ""System.ValueTuple(Of Integer, Integer, Integer, Integer, Integer, Integer, Integer, (Integer, Integer)).Rest As (Integer, Integer)""
IL_0028: ldfld ""System.ValueTuple(Of Integer, Integer).Item1 As Integer""
IL_002d: add.ovf
IL_002e: ret
}")
End Sub)
End Sub
End Class
End Namespace
|
AmadeusW/roslyn
|
src/ExpressionEvaluator/VisualBasic/Test/ExpressionCompiler/TupleTests.vb
|
Visual Basic
|
apache-2.0
| 26,133
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Threading
Imports System.Threading.Tasks
Imports Microsoft.CodeAnalysis
Imports Microsoft.VisualStudio.GraphModel
Imports Microsoft.VisualStudio.LanguageServices.Implementation.Progression
Imports Microsoft.VisualStudio.LanguageServices.Progression
Imports Roslyn.Test.Utilities
Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression
Public Class GraphNodeCreationTests
Private Async Function AssertCreatedNodeIsAsync(code As String, expectedId As String, xml As XElement, Optional language As String = "C#") As Task
Using testState = Await ProgressionTestState.CreateAsync(
<Workspace>
<Project Language=<%= language %> CommonReferences="true" FilePath="Z:\Project.csproj">
<Document FilePath="Z:\Project.cs">
<%= code %>
</Document>
</Project>
</Workspace>)
Dim symbol = Await testState.GetMarkedSymbolAsync()
Dim node = GraphNodeCreation.CreateNodeIdAsync(symbol, testState.GetSolution(), CancellationToken.None).Result
Assert.Equal(expectedId, node.ToString())
Dim graph = New Graph()
Await graph.CreateNodeAsync(symbol, testState.GetSolution(), CancellationToken.None)
AssertSimplifiedGraphIs(graph, xml)
End Using
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Progression)>
Public Async Function TestSimpleType() As Task
Await AssertCreatedNodeIsAsync("namespace N { class $$C { } }", "(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=C)",
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="(@1 Namespace=N Type=C)" Category="CodeSchema_Class" CodeSchemaProperty_IsInternal="True" CommonLabel="C" Icon="Microsoft.VisualStudio.Class.Internal" Label="C"/>
</Nodes>
<Links/>
<IdentifierAliases>
<Alias n="1" Uri="Assembly=file:///Z:/CSharpAssembly1.dll"/>
</IdentifierAliases>
</DirectedGraph>)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Progression)>
Public Async Function TestNamespaceType() As Task
Await AssertCreatedNodeIsAsync("namespace $$N { class C { } }", "(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N)",
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="(@1 Namespace=N)" Category="CodeSchema_Namespace" CodeSchemaProperty_IsPublic="True" CodeSchemaProperty_IsStatic="True" CommonLabel="N" Label="N"/>
</Nodes>
<Links/>
<IdentifierAliases>
<Alias n="1" Uri="Assembly=file:///Z:/CSharpAssembly1.dll"/>
</IdentifierAliases>
</DirectedGraph>)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Progression)>
Public Async Function TestLongNamespaceType() As Task
Await AssertCreatedNodeIsAsync("namespace N.$$N1.N11 { class C { } }", "(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N.N1)",
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="(@1 Namespace=N.N1)" Category="CodeSchema_Namespace" CodeSchemaProperty_IsPublic="True" CodeSchemaProperty_IsStatic="True" CommonLabel="N.N1" Label="N.N1"/>
</Nodes>
<Links/>
<IdentifierAliases>
<Alias n="1" Uri="Assembly=file:///Z:/CSharpAssembly1.dll"/>
</IdentifierAliases>
</DirectedGraph>)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Progression)>
Public Async Function TestSimpleParameterType() As Task
Await AssertCreatedNodeIsAsync("namespace N { class C { void M(int $$x) { } } }",
"(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=C Member=(Name=M OverloadingParameters=[(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System Type=Int32)]) ParameterIdentifier=x)",
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="(@1 Namespace=N Type=C Member=(Name=M OverloadingParameters=[(@2 Namespace=System Type=Int32)]) ParameterIdentifier=x)" Category="CodeSchema_Parameter" CodeSchemaProperty_IsByReference="False" CodeSchemaProperty_IsOut="False" CodeSchemaProperty_IsParameterArray="False" CommonLabel="x" Label="x"/>
</Nodes>
<Links/>
<IdentifierAliases>
<Alias n="1" Uri="Assembly=file:///Z:/CSharpAssembly1.dll"/>
<Alias n="2" Uri="Assembly=file:///Z:/FxReferenceAssembliesUri"/>
</IdentifierAliases>
</DirectedGraph>)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Progression)>
Public Async Function TestDelegateType() As Task
Await AssertCreatedNodeIsAsync("namespace N { delegate void D(string $$m); }",
"(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=D Member=(Name=Invoke OverloadingParameters=[(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System Type=String)]) ParameterIdentifier=m)",
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="(@1 Namespace=N Type=D Member=(Name=Invoke OverloadingParameters=[(@2 Namespace=System Type=String)]) ParameterIdentifier=m)" Category="CodeSchema_Parameter" CodeSchemaProperty_IsByReference="False" CodeSchemaProperty_IsOut="False" CodeSchemaProperty_IsParameterArray="False" CommonLabel="m" Label="m"/>
</Nodes>
<Links/>
<IdentifierAliases>
<Alias n="1" Uri="Assembly=file:///Z:/CSharpAssembly1.dll"/>
<Alias n="2" Uri="Assembly=file:///Z:/FxReferenceAssembliesUri"/>
</IdentifierAliases>
</DirectedGraph>)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Progression)>
Public Async Function TestLambdaParameterType() As Task
Await AssertCreatedNodeIsAsync("namespace N { class C { void M(Func<int,int> $$x) { } } }",
"(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=C Member=(Name=M OverloadingParameters=[(Assembly=file:///Z:/CSharpAssembly1.dll Type=(Name=Func GenericParameterCount=2 GenericArguments=[(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System Type=Int32),(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System Type=Int32)]))]) ParameterIdentifier=x)",
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="(@1 Namespace=N Type=C Member=(Name=M OverloadingParameters=[(@1 Type=(Name=Func GenericParameterCount=2 GenericArguments=[(@2 Namespace=System Type=Int32),(@2 Namespace=System Type=Int32)]))]) ParameterIdentifier=x)" Category="CodeSchema_Parameter" CodeSchemaProperty_IsByReference="False" CodeSchemaProperty_IsOut="False" CodeSchemaProperty_IsParameterArray="False" CommonLabel="x" Label="x"/>
</Nodes>
<Links/>
<IdentifierAliases>
<Alias n="1" Uri="Assembly=file:///Z:/CSharpAssembly1.dll"/>
<Alias n="2" Uri="Assembly=file:///Z:/FxReferenceAssembliesUri"/>
</IdentifierAliases>
</DirectedGraph>)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Progression)>
Public Async Function TestLocalType() As Task
Await AssertCreatedNodeIsAsync("namespace N { class C { int M() { int $$y = 0; return y; } } }", "(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=C Member=M LocalVariable=y)",
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="(@1 Namespace=N Type=C Member=M LocalVariable=y)" Category="CodeSchema_LocalExpression" CommonLabel="y" Label="y"/>
</Nodes>
<Links/>
<IdentifierAliases>
<Alias n="1" Uri="Assembly=file:///Z:/CSharpAssembly1.dll"/>
</IdentifierAliases>
</DirectedGraph>)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Progression)>
Public Async Function TestFirstLocalWithSameNameType() As Task
Await AssertCreatedNodeIsAsync("namespace N { class C { int M() { { int $$y = 0; } { int y = 1;} } } }", "(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=C Member=M LocalVariable=y)",
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="(@1 Namespace=N Type=C Member=M LocalVariable=y)" Category="CodeSchema_LocalExpression" CommonLabel="y" Label="y"/>
</Nodes>
<Links/>
<IdentifierAliases>
<Alias n="1" Uri="Assembly=file:///Z:/CSharpAssembly1.dll"/>
</IdentifierAliases>
</DirectedGraph>)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Progression)>
Public Async Function TestSecondLocalWithSameNameType() As Task
Await AssertCreatedNodeIsAsync("namespace N { class C { int M() { { int y = 0; } { int $$y = 1;} } } }",
"(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=C Member=M LocalVariable=y LocalVariableIndex=1)",
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="(@1 Namespace=N Type=C Member=M LocalVariable=y LocalVariableIndex=1)" Category="CodeSchema_LocalExpression" CommonLabel="y" Label="y"/>
</Nodes>
<Links/>
<IdentifierAliases>
<Alias n="1" Uri="Assembly=file:///Z:/CSharpAssembly1.dll"/>
</IdentifierAliases>
</DirectedGraph>)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Progression)>
Public Async Function TestErrorType() As Task
Await AssertCreatedNodeIsAsync(
"Class $$C : Inherits D : End Class",
"(Assembly=file:///Z:/VisualBasicAssembly1.dll Type=C)",
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="(@1 Type=C)" Category="CodeSchema_Class" CodeSchemaProperty_IsInternal="True" CommonLabel="C" Icon="Microsoft.VisualStudio.Class.Internal" Label="C"/>
</Nodes>
<Links/>
<IdentifierAliases>
<Alias n="1" Uri="Assembly=file:///Z:/VisualBasicAssembly1.dll"/>
</IdentifierAliases>
</DirectedGraph>,
LanguageNames.VisualBasic)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Progression)>
Public Async Function TestSimpleMethodSymbolTest() As Task
Using testState = Await ProgressionTestState.CreateAsync(
<Workspace>
<Project Language="C#" CommonReferences="true" FilePath="Z:\Project.csproj">
<Document FilePath="Z:\Project.cs"><![CDATA[[
class C {
static void $$Foo(string[] args) {}
}
]]></Document>
</Project>
</Workspace>)
Dim graphNode = (Await testState.GetGraphWithMarkedSymbolNodeAsync()).Nodes.Single()
Dim formattedLabelExtension As New GraphFormattedLabelExtension()
Assert.Equal("Foo(string[]) : void", formattedLabelExtension.Label(graphNode, GraphCommandDefinition.Contains.Id))
Assert.Equal("Foo", graphNode.Label)
End Using
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Progression)>
Public Async Function TestReferenceParameterSymbolTest() As Task
Await AssertCreatedNodeIsAsync("namespace N { class C { void $$Foo(ref int i) { i = i + 1; } } }",
"(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=C Member=(Name=Foo OverloadingParameters=[(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System Type=Int32 ParamKind=Ref)]))",
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="(@1 Namespace=N Type=C Member=(Name=Foo OverloadingParameters=[(@2 Namespace=System Type=Int32 ParamKind=Ref)]))" Category="CodeSchema_Method" CodeSchemaProperty_IsPrivate="True" CommonLabel="Foo" Icon="Microsoft.VisualStudio.Method.Private" Label="Foo"/>
</Nodes>
<Links/>
<IdentifierAliases>
<Alias n="1" Uri="Assembly=file:///Z:/CSharpAssembly1.dll"/>
<Alias n="2" Uri="Assembly=file:///Z:/FxReferenceAssembliesUri"/>
</IdentifierAliases>
</DirectedGraph>)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Progression)>
Public Async Function TestReferenceOutParameterSymbolTest() As Task
Await AssertCreatedNodeIsAsync("namespace N { class C { void $$Foo(out int i) { i = 1; } } }",
"(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=C Member=(Name=Foo OverloadingParameters=[(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System Type=Int32 ParamKind=Ref)]))",
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="(@1 Namespace=N Type=C Member=(Name=Foo OverloadingParameters=[(@2 Namespace=System Type=Int32 ParamKind=Ref)]))" Category="CodeSchema_Method" CodeSchemaProperty_IsPrivate="True" CommonLabel="Foo" Icon="Microsoft.VisualStudio.Method.Private" Label="Foo"/>
</Nodes>
<Links/>
<IdentifierAliases>
<Alias n="1" Uri="Assembly=file:///Z:/CSharpAssembly1.dll"/>
<Alias n="2" Uri="Assembly=file:///Z:/FxReferenceAssembliesUri"/>
</IdentifierAliases>
</DirectedGraph>)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Progression)>
Public Async Function TestSimpleIndexerTest() As Task
Using testState = Await ProgressionTestState.CreateAsync(
<Workspace>
<Project Language="C#" CommonReferences="true" FilePath="Z:\Project.csproj">
<Document FilePath="Z:\Project.cs"><![CDATA[[
namespace N
{
class A {
public string $$this[int i, int j, int k]
{
get { return ""; }
set { }
}
}
}
]]></Document>
</Project>
</Workspace>)
Dim symbol = Await testState.GetMarkedSymbolAsync()
Dim graph = New Graph()
Await graph.CreateNodeAsync(symbol, testState.GetSolution(), CancellationToken.None)
AssertSimplifiedGraphIs(graph,
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="(@1 Namespace=N Type=A Member=(Name=Item OverloadingParameters=[(@2 Namespace=System Type=Int32),(@2 Namespace=System Type=Int32),(@2 Namespace=System Type=Int32)]))" Category="CodeSchema_Property" CodeSchemaProperty_IsPublic="True" CommonLabel="this" Icon="Microsoft.VisualStudio.Property.Public" Label="this"/>
</Nodes>
<Links/>
<IdentifierAliases>
<Alias n="1" Uri="Assembly=file:///Z:/CSharpAssembly1.dll"/>
<Alias n="2" Uri="Assembly=file:///Z:/FxReferenceAssembliesUri"/>
</IdentifierAliases>
</DirectedGraph>)
End Using
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Progression)>
Public Async Function TestAttributedIndexerTest() As Task
Using testState = Await ProgressionTestState.CreateAsync(
<Workspace>
<Project Language="C#" CommonReferences="true" FilePath="Z:\Project.csproj">
<Document FilePath="Z:\Project.cs"><![CDATA[[
namespace N
{
class A {
[System.Runtime.CompilerServices.IndexerNameAttribute("AAA")]
public string $$this[int i, int j, int k]
{
get { return ""; }
set { }
}
}
}
]]></Document>
</Project>
</Workspace>)
Dim symbol = Await testState.GetMarkedSymbolAsync()
Dim graph = New Graph()
Await graph.CreateNodeAsync(symbol, testState.GetSolution(), CancellationToken.None)
AssertSimplifiedGraphIs(graph,
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="(@1 Namespace=N Type=A Member=(Name=AAA OverloadingParameters=[(@2 Namespace=System Type=Int32),(@2 Namespace=System Type=Int32),(@2 Namespace=System Type=Int32)]))" Category="CodeSchema_Property" CodeSchemaProperty_IsPublic="True" CommonLabel="this" Icon="Microsoft.VisualStudio.Property.Public" Label="this"/>
</Nodes>
<Links/>
<IdentifierAliases>
<Alias n="1" Uri="Assembly=file:///Z:/CSharpAssembly1.dll"/>
<Alias n="2" Uri="Assembly=file:///Z:/FxReferenceAssembliesUri"/>
</IdentifierAliases>
</DirectedGraph>)
End Using
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Progression)>
Public Async Function TestParameterWithConversionOperatorTest() As Task
Using testState = Await ProgressionTestState.CreateAsync(
<Workspace>
<Project Language="C#" CommonReferences="true" FilePath="Z:\Project.csproj">
<Document FilePath="Z:\Project.cs"><![CDATA[[
namespace N
{
class A {
public static explicit operator $$int(int x) { return x; }
}
}
]]></Document>
</Project>
</Workspace>)
Dim symbol = Await testState.GetMarkedSymbolAsync()
Dim graph = New Graph()
Await graph.CreateNodeAsync(symbol, testState.GetSolution(), CancellationToken.None)
AssertSimplifiedGraphIs(graph,
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="(@1 Namespace=N Type=A Member=(Name=op_Explicit OverloadingParameters=[(@2 Namespace=System Type=Int32),(@2 Namespace=System Type=Int32 ParamKind=Return)]))" Category="CodeSchema_Method" CodeSchemaProperty_IsOperator="True" CodeSchemaProperty_IsPublic="True" CodeSchemaProperty_IsStatic="True" CommonLabel="op_Explicit" Icon="Microsoft.VisualStudio.Operator.Public" Label="op_Explicit"/>
</Nodes>
<Links/>
<IdentifierAliases>
<Alias n="1" Uri="Assembly=file:///Z:/CSharpAssembly1.dll"/>
<Alias n="2" Uri="Assembly=file:///Z:/FxReferenceAssembliesUri"/>
</IdentifierAliases>
</DirectedGraph>)
End Using
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Progression)>
Public Async Function TestLocalVBVariableType() As Task
Using testState = Await ProgressionTestState.CreateAsync(
<Workspace>
<Project Language="Visual Basic" CommonReferences="true" FilePath="Z:\Project.vbproj">
<Document FilePath="Z:\Project.vb"><![CDATA[[
Module Module1
Sub Main()
Dim $$x As Integer = 3
End Sub
End Module
]]></Document>
</Project>
</Workspace>)
Dim symbol = Await testState.GetMarkedSymbolAsync()
Dim graph = New Graph()
Await graph.CreateNodeAsync(symbol, testState.GetSolution(), CancellationToken.None)
AssertSimplifiedGraphIs(graph,
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="(@1 Type=Module1 Member=Main LocalVariable=x)" Category="CodeSchema_LocalExpression" CommonLabel="x" Label="x"/>
</Nodes>
<Links/>
<IdentifierAliases>
<Alias n="1" Uri="Assembly=file:///Z:/VisualBasicAssembly1.dll"/>
</IdentifierAliases>
</DirectedGraph>)
End Using
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Progression)>
Public Async Function TestLocalVBRangeTypeVariable() As Task
Using testState = Await ProgressionTestState.CreateAsync(
<Workspace>
<Project Language="Visual Basic" CommonReferences="true" FilePath="Z:\Project.vbproj">
<Document FilePath="Z:\Project.vb"><![CDATA[[
Module Module1
Sub Main()
Dim wordQuery = From $$word In New List(Of Integer)() Select word
End Sub
End Module
]]></Document>
</Project>
</Workspace>)
Dim symbol = Await testState.GetMarkedSymbolAsync()
Dim graph = New Graph()
Await graph.CreateNodeAsync(symbol, testState.GetSolution(), CancellationToken.None)
AssertSimplifiedGraphIs(graph,
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="(@1 Type=Module1 Member=Main LocalVariable=word)" Category="CodeSchema_LocalExpression" CommonLabel="word" Label="word"/>
</Nodes>
<Links/>
<IdentifierAliases>
<Alias n="1" Uri="Assembly=file:///Z:/VisualBasicAssembly1.dll"/>
</IdentifierAliases>
</DirectedGraph>)
End Using
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Progression)>
Public Async Function TestLocalVBVariableWithinBlockType() As Task
Using testState = Await ProgressionTestState.CreateAsync(
<Workspace>
<Project Language="Visual Basic" CommonReferences="true" FilePath="Z:\Project.vbproj">
<Document FilePath="Z:\Project.vb"><![CDATA[[
Module Module1
Sub Main()
if true then
Dim $$x As Integer = 3
else
Dim x as Integer = 4
endif
End Sub
End Module
]]></Document>
</Project>
</Workspace>)
Dim symbol = Await testState.GetMarkedSymbolAsync()
Dim graph = New Graph()
Await graph.CreateNodeAsync(symbol, testState.GetSolution(), CancellationToken.None)
AssertSimplifiedGraphIs(graph,
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="(@1 Type=Module1 Member=Main LocalVariable=x)" Category="CodeSchema_LocalExpression" CommonLabel="x" Label="x"/>
</Nodes>
<Links/>
<IdentifierAliases>
<Alias n="1" Uri="Assembly=file:///Z:/VisualBasicAssembly1.dll"/>
</IdentifierAliases>
</DirectedGraph>)
End Using
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Progression)>
Public Async Function TestLocalVariableIndexTest() As Task
Using testState = Await ProgressionTestState.CreateAsync(
<Workspace>
<Project Language="Visual Basic" CommonReferences="true" FilePath="Z:\Project.vbproj">
<Document FilePath="Z:\Project.vb"><![CDATA[[
Module Module1
Sub Main()
if true then
Dim x As Integer = 3
else
Dim $$x as Integer = 4
endif
End Sub
End Module
]]></Document>
</Project>
</Workspace>)
Dim symbol = Await testState.GetMarkedSymbolAsync()
Dim graph = New Graph()
Await graph.CreateNodeAsync(symbol, testState.GetSolution(), CancellationToken.None)
AssertSimplifiedGraphIs(graph,
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="(@1 Type=Module1 Member=Main LocalVariable=x LocalVariableIndex=1)" Category="CodeSchema_LocalExpression" CommonLabel="x" Label="x"/>
</Nodes>
<Links/>
<IdentifierAliases>
<Alias n="1" Uri="Assembly=file:///Z:/VisualBasicAssembly1.dll"/>
</IdentifierAliases>
</DirectedGraph>)
End Using
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Progression)>
Public Async Function TestGenericArgumentsTest() As Task
Using testState = Await ProgressionTestState.CreateAsync(
<Workspace>
<Project Language="C#" CommonReferences="true" FilePath="Z:\Project.csproj">
<Document FilePath="Z:\Project.cs"><![CDATA[[
namespace N
{
public class MgtpTestOuterClass<T1, T2>
{
public class MgtpTestInnerClass<T3, T4>
{
public void MgtpTestMethod<T5, T6>(
T1 p1,
T2[][,] p2,
T3 p3,
T4[][,] p4,
T5 p5,
MgtpTestOuterClass<T3, $$MgtpTestInnerClass<T1, T6[][,]>> p6)
{
}
public void MgtpTestMethod2<T5, T6>(
T1 p1,
T2[][,] p2,
T3 p3,
T4[][,] p4,
T5 p5,
MgtpTestOuterClass<T3, MgtpTestInnerClass<T3, T4>> p6)
{
}
}
}
}
]]></Document>
</Project>
</Workspace>)
Dim symbol = Await testState.GetMarkedSymbolAsync()
Dim graph = New Graph()
Await graph.CreateNodeAsync(symbol, testState.GetSolution(), CancellationToken.None)
AssertSimplifiedGraphIs(graph,
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="(@1 Namespace=N Type=(Name=MgtpTestInnerClass GenericParameterCount=2 GenericArguments=[(@1 Namespace=N Type=(Name=MgtpTestOuterClass GenericParameterCount=2) ParameterIdentifier=0),(@1 Namespace=N Type=(ArrayRank=1 ParentType=(ArrayRank=2 ParentType=(ParameterIdentifier=1))))] ParentType=(Name=MgtpTestOuterClass GenericParameterCount=2 GenericArguments=[(@1 Namespace=N Type=(Name=MgtpTestOuterClass GenericParameterCount=2) ParameterIdentifier=0),(@1 Namespace=N Type=(Name=MgtpTestOuterClass GenericParameterCount=2) ParameterIdentifier=1)])))" Category="CodeSchema_Class" CodeSchemaProperty_IsPublic="True" CommonLabel="MgtpTestInnerClass<T3, T4>" Icon="Microsoft.VisualStudio.Class.Public" Label="MgtpTestInnerClass<T1, T6[][,]>"/>
</Nodes>
<Links/>
<IdentifierAliases>
<Alias n="1" Uri="Assembly=file:///Z:/CSharpAssembly1.dll"/>
</IdentifierAliases>
</DirectedGraph>)
End Using
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Progression)>
Public Async Function TestGenericArgumentsTest2() As Task
Using testState = Await ProgressionTestState.CreateAsync(
<Workspace>
<Project Language="C#" CommonReferences="true" FilePath="Z:\Project.csproj">
<Document FilePath="Z:\Project.cs"><![CDATA[[
namespace N
{
public class MgtpTestOuterClass<T1, T2>
{
public class MgtpTestInnerClass<T3, T4>
{
public void MgtpTestMethod<T5, T6>(
T1 p1,
T2[][,] p2,
T3 p3,
T4[][,] p4,
T5 p5,
MgtpTestOuterClass<T3, MgtpTestInnerClass<T1, T6[][,]>> p6)
{
}
public void MgtpTestMethod2<T5, T6>(
T1 p1,
T2[][,] p2,
T3 p3,
T4[][,] p4,
T5 p5,
MgtpTestOuterClass<T3, $$MgtpTestInnerClass<T3, T4>> p6)
{
}
}
}
}
]]></Document>
</Project>
</Workspace>)
Dim symbol = Await testState.GetMarkedSymbolAsync()
Dim graph = New Graph()
Await graph.CreateNodeAsync(symbol, testState.GetSolution(), CancellationToken.None)
AssertSimplifiedGraphIs(graph,
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="(@1 Namespace=N Type=(Name=MgtpTestInnerClass GenericParameterCount=2 ParentType=(Name=MgtpTestOuterClass GenericParameterCount=2)))" Category="CodeSchema_Class" CodeSchemaProperty_IsPublic="True" CommonLabel="MgtpTestInnerClass<T3, T4>" Icon="Microsoft.VisualStudio.Class.Public" Label="MgtpTestInnerClass<T3, T4>"/>
</Nodes>
<Links/>
<IdentifierAliases>
<Alias n="1" Uri="Assembly=file:///Z:/CSharpAssembly1.dll"/>
</IdentifierAliases>
</DirectedGraph>)
End Using
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Progression)>
Public Async Function TestGenericCSharpMethodSymbolTest() As Task
Using testState = Await ProgressionTestState.CreateAsync(
<Workspace>
<Project Language="C#" CommonReferences="true" FilePath="Z:\Project.csproj">
<Document FilePath="Z:\Project.cs"><![CDATA[[
class C<T,K> {
void $$Foo<T,K>() {}
}
]]></Document>
</Project>
</Workspace>)
Dim graphNode = (Await testState.GetGraphWithMarkedSymbolNodeAsync()).Nodes.Single()
Dim formattedLabelExtension As New GraphFormattedLabelExtension()
Assert.Equal("Foo<T, K>() : void", formattedLabelExtension.Label(graphNode, GraphCommandDefinition.Contains.Id))
Assert.Equal("Foo", graphNode.Label)
End Using
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Progression)>
Public Async Function TestGenericCSharpTypeSymbolTest() As Task
Using testState = Await ProgressionTestState.CreateAsync(
<Workspace>
<Project Language="C#" CommonReferences="true" FilePath="Z:\Project.csproj">
<Document FilePath="Z:\Project.cs"><![CDATA[[
class $$C<T> {
}
]]></Document>
</Project>
</Workspace>)
Dim graphNode = (Await testState.GetGraphWithMarkedSymbolNodeAsync()).Nodes.Single()
Dim formattedLabelExtension As New GraphFormattedLabelExtension()
Assert.Equal("C<T>", formattedLabelExtension.Label(graphNode, GraphCommandDefinition.Contains.Id))
Assert.Equal("C<T>", graphNode.Label)
Dim symbol = Await testState.GetMarkedSymbolAsync()
Dim graph = New Graph()
Await graph.CreateNodeAsync(symbol, testState.GetSolution(), CancellationToken.None)
AssertSimplifiedGraphIs(graph,
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="(@1 Type=(Name=C GenericParameterCount=1))" Category="CodeSchema_Class" CodeSchemaProperty_IsInternal="True" CommonLabel="C<T>" Icon="Microsoft.VisualStudio.Class.Internal" Label="C<T>"/>
</Nodes>
<Links/>
<IdentifierAliases>
<Alias n="1" Uri="Assembly=file:///Z:/CSharpAssembly1.dll"/>
</IdentifierAliases>
</DirectedGraph>)
End Using
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Progression)>
Public Async Function TestGenericCSharpMethodTypeSymbolTest() As Task
Using testState = Await ProgressionTestState.CreateAsync(
<Workspace>
<Project Language="C#" CommonReferences="true" FilePath="Z:\Project.csproj">
<Document FilePath="Z:\Project.cs"><![CDATA[[
class C {
public delegate T $$SomeDelegate<T>(T param);
}
]]></Document>
</Project>
</Workspace>)
Dim symbol = Await testState.GetMarkedSymbolAsync()
Dim graph = New Graph()
Await graph.CreateNodeAsync(symbol, testState.GetSolution(), CancellationToken.None)
AssertSimplifiedGraphIs(graph,
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="(@1 Type=(Name=SomeDelegate GenericParameterCount=1 ParentType=C))" Category="CodeSchema_Delegate" CodeSchemaProperty_IsFinal="True" CodeSchemaProperty_IsPublic="True" CommonLabel="SomeDelegate<T>" Icon="Microsoft.VisualStudio.Delegate.Public" Label="SomeDelegate<T>(T) : T"/>
</Nodes>
<Links/>
<IdentifierAliases>
<Alias n="1" Uri="Assembly=file:///Z:/CSharpAssembly1.dll"/>
</IdentifierAliases>
</DirectedGraph>)
End Using
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Progression)>
Public Async Function TestGenericVBMethodSymbolTest() As Task
Using testState = Await ProgressionTestState.CreateAsync(
<Workspace>
<Project Language="Visual Basic" CommonReferences="true" FilePath="Z:\Project.vbproj">
<Document FilePath="Z:\Project.vb">
Module Module1
Public Class Foo(Of T)
Public Sub $$Foo(ByVal x As T)
End Sub
End Class
End Module
</Document>
</Project>
</Workspace>)
Dim graphNode = (Await testState.GetGraphWithMarkedSymbolNodeAsync()).Nodes.Single()
Dim formattedLabelExtension As New GraphFormattedLabelExtension()
Assert.Equal("Foo(T)", formattedLabelExtension.Label(graphNode, GraphCommandDefinition.Contains.Id))
Assert.Equal("Foo", graphNode.Label)
End Using
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Progression)>
Public Async Function TestGenericVBTypeSymbolTest() As Task
Using testState = Await ProgressionTestState.CreateAsync(
<Workspace>
<Project Language="Visual Basic" CommonReferences="true" FilePath="Z:\Project.vbproj">
<Document FilePath="Z:\Project.vb">
Module Module1
Public Class $$Foo(Of T)
End Class
End Module
</Document>
</Project>
</Workspace>)
Dim graphNode = (Await testState.GetGraphWithMarkedSymbolNodeAsync()).Nodes.Single()
Dim formattedLabelExtension As New GraphFormattedLabelExtension()
Assert.Equal("Foo(Of T)", formattedLabelExtension.Label(graphNode, GraphCommandDefinition.Contains.Id))
Assert.Equal("Foo(Of T)", graphNode.Label)
Dim symbol = Await testState.GetMarkedSymbolAsync()
Dim graph = New Graph()
Await graph.CreateNodeAsync(symbol, testState.GetSolution(), CancellationToken.None)
AssertSimplifiedGraphIs(graph,
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="(@1 Type=(Name=Foo GenericParameterCount=1 ParentType=Module1))" Category="CodeSchema_Class" CodeSchemaProperty_IsPublic="True" CommonLabel="Foo<T>" Icon="Microsoft.VisualStudio.Class.Public" Label="Foo(Of T)"/>
</Nodes>
<Links/>
<IdentifierAliases>
<Alias n="1" Uri="Assembly=file:///Z:/VisualBasicAssembly1.dll"/>
</IdentifierAliases>
</DirectedGraph>)
End Using
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Progression)>
Public Async Function TestMultiGenericVBTypeSymbolTest() As Task
Using testState = Await ProgressionTestState.CreateAsync(
<Workspace>
<Project Language="Visual Basic" CommonReferences="true" FilePath="Z:\Project.vbproj">
<Document FilePath="Z:\Project.vb">
Module Module1
Public Class $$Foo(Of T, X)
End Class
End Module
</Document>
</Project>
</Workspace>)
Dim graphNode = (Await testState.GetGraphWithMarkedSymbolNodeAsync()).Nodes.Single()
Dim formattedLabelExtension As New GraphFormattedLabelExtension()
Assert.Equal("Foo(Of T, X)", formattedLabelExtension.Label(graphNode, GraphCommandDefinition.Contains.Id))
Assert.Equal("Foo(Of T, X)", graphNode.Label)
Dim symbol = Await testState.GetMarkedSymbolAsync()
Dim graph = New Graph()
Await graph.CreateNodeAsync(symbol, testState.GetSolution(), CancellationToken.None)
AssertSimplifiedGraphIs(graph,
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="(@1 Type=(Name=Foo GenericParameterCount=2 ParentType=Module1))" Category="CodeSchema_Class" CodeSchemaProperty_IsPublic="True" CommonLabel="Foo<T, X>" Icon="Microsoft.VisualStudio.Class.Public" Label="Foo(Of T, X)"/>
</Nodes>
<Links/>
<IdentifierAliases>
<Alias n="1" Uri="Assembly=file:///Z:/VisualBasicAssembly1.dll"/>
</IdentifierAliases>
</DirectedGraph>)
End Using
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Progression)>
Public Async Function TestFilteringPropertiesTest() As Task
Using testState = Await ProgressionTestState.CreateAsync(
<Workspace>
<Project Language="Visual Basic" CommonReferences="true" FilePath="Z:\Project.vbproj">
<Document FilePath="Z:\Project.vb">
Public Class TestEvents
Public Custom Event CustomEvent As EventHandler(Of Object)
AddHandler($$value As EventHandler(Of Object))
End AddHandler
RemoveHandler(value As EventHandler(Of Object))
End RemoveHandler
RaiseEvent(sender As Object, e As Object)
End RaiseEvent
End Event
End Class
</Document>
</Project>
</Workspace>)
Dim symbol = Await testState.GetMarkedSymbolAsync()
Dim graph = New Graph()
Await graph.CreateNodeAsync(symbol, testState.GetSolution(), CancellationToken.None)
AssertSimplifiedGraphIs(graph,
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="(@1 Type=TestEvents Member=(Name=add_CustomEvent OverloadingParameters=[(@2 Namespace=System Type=(Name=EventHandler GenericParameterCount=1 GenericArguments=[(@2 Namespace=System Type=Object)]))]) ParameterIdentifier=value)" Category="CodeSchema_Parameter" CodeSchemaProperty_IsByReference="False" CodeSchemaProperty_IsOut="False" CodeSchemaProperty_IsParameterArray="False" CommonLabel="value" Label="value"/>
</Nodes>
<Links/>
<IdentifierAliases>
<Alias n="1" Uri="Assembly=file:///Z:/VisualBasicAssembly1.dll"/>
<Alias n="2" Uri="Assembly=file:///Z:/FxReferenceAssembliesUri"/>
</IdentifierAliases>
</DirectedGraph>)
End Using
End Function
End Class
End Namespace
|
bbarry/roslyn
|
src/VisualStudio/Core/Test/Progression/GraphNodeCreationTests.vb
|
Visual Basic
|
apache-2.0
| 47,391
|
'Public Class OscopeForm
' Private _aOscopeController As OscopeController
' Public IsInitialized As Boolean = False
' Private _maxOnText As String = "Turn Max Traces On"
' Private _maxOffText As String = "Turn Max Traces Off"
' Public Sub New(ByRef oscopeController As OscopeController)
' Me._aOscopeController = OscopeController
' InitializeComponent()
' Me.isInitialized = True
' Me.Visible = True
' End Sub
' Private Sub TryEditConnectionToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles TryEditConnectionToolStripMenuItem.Click
' Try
' Me._aOscopeController.tryConnection()
' Catch ex As Exception
' MsgBox("Unable to try/edit Oscope IP connection: " & ex.Message)
' End Try
' End Sub
' Private Sub btnGetSearchTrace_Click(sender As System.Object, e As System.EventArgs) Handles btnGetSearchTrace.Click
' Me._aOscopeController.updatePlot()
' End Sub
' Private Sub btnExit_Click(sender As System.Object, e As System.EventArgs) Handles btnExit.Click
' Me._aOscopeController.exitCall()
' Me.Close()
' End Sub
' Private Sub btnClrPlot_Click(sender As System.Object, e As System.EventArgs) Handles btnClrPlot.Click
' Try
' Me.ScatterPlot1.ClearData()
' Me.ScatterPlot2.ClearData()
' Catch ex As Exception
' MsgBox("Cannot clear plot: " & ex.Message)
' End Try
' End Sub
' Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
' Try
' Me._aOscopeController.clearMaxHoldTraces()
' Catch ex As Exception
' MsgBox("Cannot clear FFT max hold traces" & ex.Message)
' End Try
' End Sub
' Private Sub btnReplayTrace_Click(sender As System.Object, e As System.EventArgs) Handles btnReplayTrace.Click
' Try
' Me._aOscopeController.replay()
' Catch ex As Exception
' MsgBox("Unable to start replay thread: " & ex.Message)
' End Try
' End Sub
' Private Sub btnMaxOnOff_Click(sender As System.Object, e As System.EventArgs) Handles btnMaxOnOff.Click
' Try
' If Me.btnMaxOnOff.Text.ToUpper.Contains("OFF") Then
' Try
' Me._aOscopeController.turnOffMax()
' Me.btnMaxOnOff.Text = Me._maxOnText
' Catch ex As Exception
' End Try
' ElseIf Me.btnMaxOnOff.Text.ToUpper.Contains("ON") Then
' Me._aOscopeController.turnOnMaxTraces()
' Me.btnMaxOnOff.Text = Me._maxOffText
' End If
' Catch ex As Exception
' MsgBox("Unable to toggle max function display on/off: " & ex.Message)
' End Try
' End Sub
' Private Sub UpdateToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles UpdateFunc2Ant.Click, UpdateFunc4Ant.Click
' Try
' Me._aOscopeController.updateCalFile(sender, "antenna")
' Catch ex As Exception
' MsgBox("Unable to update antenna cal file: " & ex.Message)
' End Try
' End Sub
' Private Sub UpdateToolStripMenuItem1_Click(sender As System.Object, e As System.EventArgs) Handles UpdateFunc2Cable.Click, UpdateFunc4Cable.Click
' Try
' Me._aOscopeController.updateCalFile(sender, "cable")
' Catch ex As Exception
' MsgBox("Unable to update cable cal file: " & ex.Message)
' End Try
' End Sub
' Private Sub cmboDisplayUnits_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles cmboDisplayUnits.SelectedIndexChanged
' If Me.IsInitialized <> False Then
' Select Case cmboDisplayUnits.Text
' Case "V/m"
' Me.YAxis1.Range = New NationalInstruments.UI.Range(-0.000001, 10)
' XyCursor1.YPosition = (0.001)
' Me.YAxis1.Caption = "Amplitude (V/m)"
' Me._aOscopeController.LoadLimit()
' Case "dBuV"
' Me.YAxis1.Range = New NationalInstruments.UI.Range(-70, 50)
' XyCursor1.YPosition = (20)
' Me.YAxis1.Caption = "Amplitude (dBuV)"
' Me.CheckBox1.Checked = False
' Case "dBuV/m"
' Me.YAxis1.Range = New NationalInstruments.UI.Range(-10, 200)
' XyCursor1.YPosition = (20)
' Me.YAxis1.Caption = "Amplitude (dBuV/m)"
' Me._aOscopeController.LoadLimit()
' Me.CheckBox1.Checked = False
' Case "dBm"
' Me.YAxis1.Range = New NationalInstruments.UI.Range(-100, -20)
' XyCursor1.YPosition = (20)
' Me.YAxis1.Caption = "Amplitude (dBm)"
' Me.CheckBox1.Checked = False
' Case "dBm/Hz"
' Me.YAxis1.Range = New NationalInstruments.UI.Range(-170, -30)
' XyCursor1.YPosition = (-100)
' Me.YAxis1.Caption = "Amplitude (dBm/Hz)"
' Me.CheckBox1.Checked = False
' Case "W/m2"
' Me.YAxis1.Range = New NationalInstruments.UI.Range(0, 5)
' Me.XyCursor1.YPosition = (2.5)
' Me.YAxis1.Caption = "Amplitude (W/m2)"
' Case "mW/cm2"
' Me.YAxis1.Range = New NationalInstruments.UI.Range(0, 5)
' Me.XyCursor1.YPosition = (2.5)
' Me.YAxis1.Caption = "Amplitude (mW/cm2)"
' End Select
' End If
' Me.OscopeScatterGraph.Refresh()
' End Sub
' Private Sub XyCursor1_AfterMove(ByVal sender As Object, ByVal e As NationalInstruments.UI.AfterMoveXYCursorEventArgs) Handles XyCursor1.AfterMove
' Dim proxyCursor As NationalInstruments.UI.XYCursor = CType(sender, NationalInstruments.UI.XYCursor)
' If ProxyCursor.Tag Is "XYCursor1" Then
' lblCursor1yaxis.Text = System.Math.Round(XyCursor1.YPosition, 2).ToString() : lblCursor1yaxis.Refresh()
' lblCursor1xaxis.Text = System.Math.Round(XyCursor1.XPosition, 8).ToString() : lblCursor1xaxis.Refresh()
' End If
' End Sub
' Private Sub XyCursor2_AfterMove(ByVal sender As Object, ByVal e As NationalInstruments.UI.AfterMoveXYCursorEventArgs) Handles XyCursor1.AfterMove, XyCursor2.AfterMove
' Dim proxyCursor As NationalInstruments.UI.XYCursor = CType(sender, NationalInstruments.UI.XYCursor)
' If ProxyCursor.Tag Is "XYCursor2" Then
' lblCursor2yaxis.Text = System.Math.Round(XyCursor2.YPosition, 2).ToString() : lblCursor2yaxis.Refresh()
' lblCursor2xaxis.Text = System.Math.Round(XyCursor2.XPosition, 8).ToString() : lblCursor2xaxis.Refresh()
' End If
' End Sub
' Private Sub updateOscopeLimFile1_Click(sender As System.Object, e As System.EventArgs) Handles updateOscopeLimFile1.Click
' 'prompt to get user input directory
' Try
' Me.OpenFileDialog1.Title = "Select a file for Limit File 1: "
' Me.OpenFileDialog1.InitialDirectory = Environment.SpecialFolder.MyComputer
' If Me.OpenFileDialog1.ShowDialog(Me) = Windows.Forms.DialogResult.Cancel Then
' Else
' Me._aOscopeController.oscopeObj.getlimitFile1 = Me.OpenFileDialog1.FileName
' Me.limitFile1.Text = Me.OpenFileDialog1.FileName
' End If
' Me._aOscopeController.LoadLimit()
' Catch ex As Exception
' MsgBox("Unable to load limit file 1: " & ex.Message)
' End Try
' End Sub
' Private Sub updateOscopeLimitFile2_Click(sender As System.Object, e As System.EventArgs) Handles updateOscopeLimitFile2.Click
' 'prompt to get user input directory
' Try
' Me.OpenFileDialog1.Title = "Select a file for Limit File 2: "
' Me.OpenFileDialog1.InitialDirectory = Environment.SpecialFolder.MyComputer
' If Me.OpenFileDialog1.ShowDialog(Me) = Windows.Forms.DialogResult.Cancel Then
' Else
' Me._aOscopeController.oscopeObj.getlimitFile2 = Me.OpenFileDialog1.FileName
' Me.limFile2.Text = Me.OpenFileDialog1.FileName
' End If
' Me._aOscopeController.LoadLimit()
' Catch ex As Exception
' MsgBox("Unable to load limit file 2: " & ex.Message)
' End Try
' End Sub
' Private Sub updateOscopeLimitFile3_Click(sender As System.Object, e As System.EventArgs) Handles updateOscopeLimitFile3.Click
' 'prompt to get user input directory
' Try
' Me.OpenFileDialog1.Title = "Select a file for Limit File 3: "
' Me.OpenFileDialog1.InitialDirectory = Environment.SpecialFolder.MyComputer
' If Me.OpenFileDialog1.ShowDialog(Me) = Windows.Forms.DialogResult.Cancel Then
' Else
' Me._aOscopeController.oscopeObj.getlimitFile3 = Me.OpenFileDialog1.FileName
' Me.limFile3.Text = Me.OpenFileDialog1.FileName
' End If
' Me._aOscopeController.LoadLimit()
' Catch ex As Exception
' MsgBox("Unable to load limit file 3: " & ex.Message)
' End Try
' End Sub
' Private Sub removeLimitFile1_Click(sender As System.Object, e As System.EventArgs) Handles removeLimit1.Click
' Try
' Me.limitFile1.Text = ""
' Me.Limit1.ClearData()
' Catch ex As Exception
' End Try
' End Sub
' Private Sub removeLimitFile2_Click(sender As System.Object, e As System.EventArgs) Handles removeLimit2.Click
' Try
' Me.limFile2.Text = ""
' Me.Limit2.ClearData()
' Catch ex As Exception
' End Try
' End Sub
' Private Sub removeLimitFile3_Click(sender As System.Object, e As System.EventArgs) Handles removeLimit3.Click
' Try
' Me.limFile3.Text = ""
' Me.Limit3.ClearData()
' Catch ex As Exception
' End Try
' End Sub
' Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
' Try
' Dim startPoint As Double = Me.XAxis1.Range.Minimum
' Dim endPoint As Double = Me.XAxis1.Range.Maximum
' Dim centerPoint As Double = (startPoint + endPoint) / 2
' Dim topPoint As Double = Me.YAxis1.Range.Maximum
' Dim bottomPoint As Double = Me.YAxis1.Range.Maximum
' Dim middlePoint As Double = (topPoint + bottomPoint) / 2
' Me.XyCursor1.SnapMode = CursorSnapMode.Floating
' Me.XyCursor2.SnapMode = CursorSnapMode.Floating
' Me.XyCursor1.XPosition = centerPoint
' Me.XyCursor1.YPosition = middlePoint
' Me.XyCursor2.XPosition = centerPoint
' Me.XyCursor2.YPosition = middlePoint
' Threading.Thread.Sleep(100)
' Me.XyCursor1.SnapMode = CursorSnapMode.NearestPoint
' Me.XyCursor2.SnapMode = CursorSnapMode.NearestPoint
' Threading.Thread.Sleep(100)
' Me.OscopeScatterGraph.Refresh()
' Me.Update()
' Catch ex As Exception
' MsgBox("Unable to center cursors: " & ex.Message)
' End Try
' End Sub
' Private Sub chkLogFreq_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles chkLogFreq.CheckedChanged
' If chkLogFreq.Checked = True Then Me.XAxis1.ScaleType = ScaleType.Logarithmic Else XAxis1.ScaleType = ScaleType.Linear
' End Sub
' Private Sub CheckBox1_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles CheckBox1.CheckedChanged
' If CheckBox1.Checked = True Then Me.YAxis1.ScaleType = ScaleType.Logarithmic Else YAxis1.ScaleType = ScaleType.Linear
' End Sub
' Private Sub btnUpdateOscopeParams_Click(sender As System.Object, e As System.EventArgs) Handles btnUpdateOscopeParams.Click
' Me._aOscopeController.updateOscopeParameters()
' End Sub
' Private Sub CheckBox2_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles CheckBox2.CheckedChanged
' If Me.isInitialized = True Then
' Try
' Me._aOscopeController.toggleStateFunction1and2(Me.CheckBox2.Checked)
' Catch ex As Exception
' MsgBox("Unable to change state of channel 1: " & ex.Message)
' End Try
' End If
' End Sub
' Private Sub CheckBox4_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles CheckBox4.CheckedChanged
' If Me.isInitialized = True Then
' Try
' Me._aOscopeController.toggleStateFunction3and4(Me.CheckBox4.Checked)
' Catch ex As Exception
' MsgBox("Unable to change state of channel 2: " & ex.Message)
' End Try
' End If
' End Sub
' Private Sub btnSaveToCSV_Click(sender As System.Object, e As System.EventArgs) Handles btnSaveToCSV.Click
' Try
' Me._aOscopeController.saveToCSV()
' Catch ex As Exception
' MsgBox("Unable to save data to CSV file: " & ex.Message)
' End Try
' End Sub
' Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles btnUpdateFunction.Click
' Try
' Me._aOscopeController.updateOscopeFunctions()
' Catch ex As Exception
' MsgBox("Error updating oscope mission function(s): " & ex.Message)
' End Try
' End Sub
' Private Sub cmbBxExistingMissions_Click(sender As System.Object, e As System.EventArgs) Handles cmbBxExistingMissions.SelectedIndexChanged
' Try
' If Me.cmbBxExistingMissions.SelectedItem = "" Then
' Return
' End If
' Me._aOscopeController.editMission(Me.cmbBxExistingMissions.SelectedItem)
' Me.cmbBxExistingMissions.Text = ""
' Catch ex As Exception
' MsgBox("error updating existing mission: " & ex.Message)
' End Try
' End Sub
' Private Sub cmbBxMeas_Click(sender As System.Object, e As System.EventArgs) Handles cmbBxMeas.SelectedIndexChanged
' Try
' If Me.cmbBxMeas.SelectedItem = "" Then
' Return
' End If
' Me._aOscopeController.editMeasState(Me.cmbBxMeas.SelectedItem)
' Me.cmbBxMeas.SelectedItem = ""
' Catch ex As Exception
' MsgBox("error updating existing measurment: " & ex.Message)
' End Try
' End Sub
' Private Sub cmbBxMeasName_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles cmbBxMeasName.SelectedIndexChanged
' Try
' If Me.cmbBxMeasName.Text = "" Then
' Return
' End If
' 'load the last meas state
' For Each measState In Me._aOscopeController.oscopeMeas.getMeasState
' If measState Is Nothing Then
' Exit For
' End If
' If Me.cmbBxMeasName.Text = measState.getName Then
' Me._aOscopeController.currentMeasState = measState
' End If
' Next
' Me.txtBxmemoryDepth.Text = Me._aOscopeController.currentMeasState.getmemoryDepth
' Me.txtBxtimeRange.Text = Me._aOscopeController.currentMeasState.gettime
' Me.txtBxSampleRate.Text = Me._aOscopeController.currentMeasState.getsampleRate
' Catch ex As Exception
' MsgBox("error loading measurement state: " & ex.Message)
' End Try
' End Sub
'End Class
|
wboxx1/85-EIS-PUMA
|
puma/src/Supporting Forms/OscopeForm.vb
|
Visual Basic
|
mit
| 15,720
|
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated by a tool.
' Runtime Version:4.0.30319.239
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Imports System
Namespace My.Resources
'This class was auto-generated by the StronglyTypedResourceBuilder
'class via a tool like ResGen or Visual Studio.
'To add or remove a member, edit your .ResX file then rerun ResGen
'with the /str option, or rebuild your VS project.
'''<summary>
''' A strongly-typed resource class, for looking up localized strings, etc.
'''</summary>
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0"),
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(),
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(),
Global.Microsoft.VisualBasic.HideModuleNameAttribute>
Friend Module Resources
Private resourceMan As Global.System.Resources.ResourceManager
Private resourceCulture As Global.System.Globalization.CultureInfo
'''<summary>
''' Returns the cached ResourceManager instance used by this class.
'''</summary>
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)>
Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
Get
If Object.ReferenceEquals(resourceMan, Nothing) Then
Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("LTR.IO.ImDisk.Devio.DiscUtilsDevio.Resources", GetType(Resources).Assembly)
resourceMan = temp
End If
Return resourceMan
End Get
End Property
'''<summary>
''' Overrides the current thread's CurrentUICulture property for all
''' resource lookups using this strongly typed resource class.
'''</summary>
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)>
Friend Property Culture() As Global.System.Globalization.CultureInfo
Get
Return resourceCulture
End Get
Set(value As Global.System.Globalization.CultureInfo)
resourceCulture = value
End Set
End Property
End Module
End Namespace
|
nnaabbcc/exercise
|
windows/tools/imdisk/ImDiskNet/DiscUtilsDevio/My Project/Resources.Designer.vb
|
Visual Basic
|
mit
| 2,799
|
Namespace Ribbons.Tools.Documents
Public Class ReLocate
Inherits RibbonButtonBase
Public Sub New()
_Image = ""
_Order = 1
_Text = "Re-Locate"
_ToolTip = ""
End Sub
Protected Friend Overrides Sub OnClick()
End Sub
Protected Friend Overrides Sub OnIsEnabled()
End Sub
End Class
End Namespace
|
nublet/DMS
|
DMS.Forms/Ribbons/Items/Tools/Documents/ReLocate.vb
|
Visual Basic
|
mit
| 411
|
Namespace Security.Search_User
Public Class Createdbyme
Inherits SecurityItemBase
Public Sub New()
_ConceptItemName = "Created by me"
_ConceptName = "Search_User"
_Description = "Enable 'Created by Me' button"
_IsEnterprise = True
_IsSmallBusiness = True
_IsViewer = True
_IsWeb = True
_IsWebPlus = True
End Sub
End Class
End Namespace
|
nublet/DMS
|
DMS.Forms.Shared/Security/Items/Search/User/Createdbyme.vb
|
Visual Basic
|
mit
| 473
|
Public Class Form3
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Label2.Text = Form1.TextBox9.Text
Button1.Hide()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Close()
End Sub
End Class
|
vineetkumardoshi/Cubic-EoS-Solver
|
WindowsApplication3/Form3.vb
|
Visual Basic
|
mit
| 369
|
Imports Athena.Analysis
Imports Athena.Core
Imports Leviathan.Commands
Imports Leviathan.Commands.StringCommands
Imports Leviathan.Configuration
Imports Leviathan.Visualisation
Imports IT = Leviathan.Visualisation.InformationType
Imports VL = Leviathan.Commands.VerbosityLevel
Imports System.Collections.Generic
Imports System.Data
Imports System.Data.SqlClient
Imports System.Linq
Imports System.Text
Imports C = System.Data.CommandType
Partial Public Class AnalysisCommands
#Region " Private Variables "
#End Region
#Region " Private Properties "
Private ReadOnly Property Enforce_Restrictions As Boolean
Get
Return Not Restrict_Days Is Nothing AndAlso Restrict_Days.Length > 0
End Get
End Property
Private ReadOnly Property Enforce_Ignoring As Boolean
Get
Return Not Ignore_Options Is Nothing AndAlso Ignore_Options.Length > 0
End Get
End Property
#End Region
#Region " Private Methods "
Private Function Is_Option_Restricted( _
ByVal value As [Option] _
) As Boolean
For i As Integer = 0 To Ignore_Options.Length - 1
If value.Name.ToLower().IndexOf(Ignore_Options(i).ToLower()) >= 0 Then Return True
Next
Return False
End Function
Private Function Is_Action_Restricted( _
ByVal value As Action _
) As Boolean
Dim check_Time As Boolean = False
Select Case value.Created.DayOfWeek
Case DayOfWeek.Monday
If Array.IndexOf(Restrict_Days, "Mon") > =0 OrElse Array.IndexOf(Restrict_Days, "MON") >= 0 OrElse Array.IndexOf(Restrict_Days, "mon") >= 0 Then check_Time = True
Case DayOfWeek.Tuesday
If Array.IndexOf(Restrict_Days, "Tue") > =0 OrElse Array.IndexOf(Restrict_Days, "TUE") >= 0 OrElse Array.IndexOf(Restrict_Days, "tue") >= 0 Then check_Time = True
Case DayOfWeek.Wednesday
If Array.IndexOf(Restrict_Days, "Wed") > =0 OrElse Array.IndexOf(Restrict_Days, "WED") >= 0 OrElse Array.IndexOf(Restrict_Days, "wed") >= 0 Then check_Time = True
Case DayOfWeek.Thursday
If Array.IndexOf(Restrict_Days, "Thu") > =0 OrElse Array.IndexOf(Restrict_Days, "THU") >= 0 OrElse Array.IndexOf(Restrict_Days, "thu") >= 0 Then check_Time = True
Case DayOfWeek.Friday
If Array.IndexOf(Restrict_Days, "Fri") > =0 OrElse Array.IndexOf(Restrict_Days, "FRI") >= 0 OrElse Array.IndexOf(Restrict_Days, "fri") >= 0 Then check_Time = True
Case DayOfWeek.Saturday
If Array.IndexOf(Restrict_Days, "Sat") > =0 OrElse Array.IndexOf(Restrict_Days, "SAT") >= 0 OrElse Array.IndexOf(Restrict_Days, "sat") >= 0 Then check_Time = True
Case DayOfWeek.Sunday
If Array.IndexOf(Restrict_Days, "Sun") > =0 OrElse Array.IndexOf(Restrict_Days, "SUN") >= 0 OrElse Array.IndexOf(Restrict_Days, "sun") >= 0 Then check_Time = True
End Select
If check_Time Then
If value.Created.TimeOfDay >= Time_Start.TimeOfDay AndAlso value.Created.TimeOfDay <= Time_End.TimeOfDay Then
Return True
Else
Return False
End If
Else
Return False
End If
End Function
Private Function Get_Actions( _
ByVal for_Instance As Instance _
) As List(Of Action)
Dim actions As List(Of Action) = Action.All.Filter( _
Data.Connection(Athena_Source), Action.All.Filters.INSTANCE, for_Instance.Id).ToList()
If Enforce_Restrictions Then
Dim last As Integer = actions.Count - 1
For i As Integer = 0 To last
If i > last Then Exit For
If Is_Action_Restricted(actions(i)) Then
actions.RemoveAt(i)
i -= 1
last -= 1
End If
Next
End If
actions.Sort()
Return actions
End Function
Private Sub Analyse_Actions( _
ByVal actions As List(Of Action), _
ByRef results As SortedDictionary(Of Int64, SortedDictionary(Of Int64, List(Of Timespan))) _
)
If Host.Available(VL.Debug) Then
Dim str_Events As String = Nothing
For i As Integer = 0 To actions.Count - 1
If Not String.IsNullOrEmpty(str_Events) Then str_Events = str_Events & " "
str_Events = str_Events & actions(i).Event
Next
Host.Debug(str_Events)
End If
Dim processed_Parent_Events As New List(of Int64)
For i As Integer = 0 To actions.Count - 1
If Not processed_Parent_Events.Contains(actions(i).Event) Then
processed_Parent_Events.Add(actions(i).Event)
Dim processed_Child_Events As New List(of Int64)
For j As Integer = (i + 1) To actions.Count - 1
If actions(i).Event <> actions(j).Event AndAlso Not processed_Child_Events.Contains(actions(j).Event) _
AndAlso actions(j).Created > actions(i).Created AndAlso Not processed_Parent_Events.Contains(actions(j).Event) Then
processed_Child_Events.Add(actions(j).Event)
If Not results.ContainsKey(actions(i).Event) Then _
results.Add(actions(i).Event, New SortedDictionary(Of Int64, List(Of Timespan)))
If Not results(actions(i).Event).ContainsKey(actions(j).Event) Then _
results(actions(i).Event).Add(actions(j).Event, New List(Of Timespan))
results(actions(i).Event)(actions(j).Event).Add(actions(j).Created.Subtract(actions(i).Created))
End If
Next
End If
Next
End Sub
Private Function Analyse_Exercise( _
ByVal value As Exercise, _
Optional ByVal completion_Weighting As Integer = -1 _
) As IFixedWidthWriteable()
Dim all_Results As New List(Of Result)
Dim results_Rows As New List(Of Row)
Dim summary_Rows As New List(Of Row)
Dim differencing_Rows As New List(Of Row)
Dim all_Events As New Dictionary(Of Int64, [Event])
Dim final_Events As New Dictionary(Of Int64, Int32)
Dim final_Event_Count As Int32 = 0
Dim final_Event As Int64 = -1
Dim edge_List As New List(of String)
Dim value_List As New List(Of List(Of Double))
Dim it_List As New List(Of List(Of Leviathan.Visualisation.InformationType))
Dim potential_Weighting As Integer = 0
Dim actual_Weighting As Integer = 0
Dim display_Round As Integer = 2
Dim analysis_Span As SpanType = SpanType.Hours
For Each single_Option As [Option] In [Option].All.Filter( _
Data.Connection(Athena_Source), [Option].All.Filters.EXERCISE, value.Id).ToList()
If Not Enforce_Ignoring OrElse Not Is_Option_Restricted(single_Option) Then
Dim new_Result As New Result()
new_Result.Name = single_Option.Name
Dim option_Results As New SortedDictionary(Of Int64, SortedDictionary(Of Int64, List(Of Timespan)))
Dim event_Count As New SortedDictionary(Of Int64, Integer)
Dim event_Earliest As New SortedDictionary(Of Int64, DateTime)
Dim event_Latest As New SortedDictionary(Of Int64, DateTime)
Dim event_Totals As New SortedDictionary(Of Int64, Double)
Dim all_Instances As List(Of Instance) = Instance.All.Filter( _
Data.Connection(Athena_Source), Instance.All.Filters.OPTION, single_Option.Id).ToList()
For Each single_Instance As Instance In all_Instances
Dim actions As List(Of Action) = Get_Actions(single_Instance)
Dim processed_Events As New List(of Int64)
For Each act As Action In actions
If Not all_Events.ContainsKey(act.Event) Then
Dim single_Event As [Event] = [Event].All.One(Data.Connection(Athena_Source), act.Event)
all_Events.Add(single_Event.Id, single_Event)
event_Count.Add(single_Event.Id, 0)
End If
If Not event_Count.ContainsKey(act.Event) Then event_Count.Add(act.Event, 1) Else event_Count(act.Event) += 1
If Not processed_Events.Contains(act.Event) Then
If Not event_Earliest.ContainsKey(act.Event) Then
event_Earliest.Add(act.Event, act.Created)
event_Latest.Add(act.Event, act.Created)
Else
If event_Earliest(act.Event) > act.Created Then event_Earliest(act.Event) = act.Created
If event_Latest(act.Event) < act.Created Then event_Latest(act.Event) = act.Created
End If
processed_Events.Add(act.Event)
End If
If Not event_Totals.ContainsKey(act.Event) Then
event_Totals.Add(act.Event, act.Created.Ticks)
Else
event_Totals(act.Event) += act.Created.Ticks
End If
Next
If processed_Events.Count > 0 Then
If Not final_Events.ContainsKey(processed_Events(processed_Events.Count - 1)) Then _
final_Events.Add(processed_Events(processed_Events.Count - 1), 0)
final_Events(processed_Events(processed_Events.Count - 1)) += 1
Analyse_Actions(actions, option_Results)
End If
Next
For Each key As Int64 In final_Events.Keys
If final_Events(key) >= final_Event_Count Then
final_Event_Count = final_Events(key)
final_Event = key
End If
Next
For i As Integer = 0 To event_Count.Keys.Count - 1
Dim new_Node As New Node()
new_Node.Name = all_Events(event_Count.Keys(i)).Name
If final_Event = event_Count.Keys(i) Then new_Node.Name = new_Node.Name & "*"
new_Node.Count = event_Count(event_Count.Keys(i))
new_Node.Completion = Math.Min(new_Node.Count / all_Instances.Count, 1)
new_Node.Earliest = event_Earliest(event_Count.Keys(i))
new_Node.Latest = event_Latest(event_Count.Keys(i))
new_Node.Average = New System.DateTime(Convert.ToInt64(event_Totals(event_Count.Keys(i)) / new_Node.Count))
' Work Out Best Timespan to Use!
If final_Event = event_Count.Keys(i) AndAlso i > 0 Then
Dim analysis_TS As Timespan = new_Node.Average - new_Result.Nodes(0).Average
If (analysis_TS.TotalDays > 5 Or analysis_TS.TotalDays < -5) Then
analysis_Span = SpanType.Days
ElseIf (analysis_TS.TotalHours > 5 Or analysis_TS.TotalHours < -5) Then
analysis_Span = SpanType.Hours
ElseIf (analysis_TS.TotalMinutes > 5 Or analysis_TS.TotalMinutes < -5) Then
analysis_Span = SpanType.Minutes
ElseIf (analysis_TS.TotalSeconds > 5 Or analysis_TS.TotalSeconds < -5) Then
analysis_Span = SpanType.Seconds
ElseIf (analysis_TS.TotalMilliseconds > 5 Or analysis_TS.TotalMilliseconds < -5) Then
analysis_Span = SpanType.Milliseconds
Else
analysis_Span = SpanType.Ticks
End If
End If
new_Result.Nodes.Add(new_Node)
Next
For Each from_Event As Int64 In option_Results.Keys
For Each to_Event As Int64 In option_Results(from_Event).Keys
Dim new_Edge As New Edge()
new_Edge.Name = all_Events(from_Event).Name & " > " & all_Events(to_Event).Name
If to_Event = final_Event Then new_Edge.Name = new_Edge.Name + "*"
Dim min_ts As Timespan = Nothing
Dim max_ts As Timespan = Nothing
Dim total_ts As Double = 0
For Each ts As Timespan In option_Results(from_Event)(to_Event)
If min_ts = Nothing OrElse ts < min_ts Then min_ts = ts
If max_ts = Nothing OrElse ts > max_ts Then max_ts = ts
total_ts += ts.Ticks
Next
Dim average_ts As New Timespan(Convert.ToInt64(total_ts/option_Results(from_Event)(to_Event).Count))
new_Edge.Count = option_Results(from_Event)(to_Event).Count
Select Case analysis_Span
Case SpanType.Days
new_Edge.Average = average_ts.TotalDays
new_Edge.Min = min_ts.TotalDays
new_Edge.Max = max_ts.TotalDays
Case SpanType.Hours
new_Edge.Average = average_ts.TotalHours
new_Edge.Min = min_ts.TotalHours
new_Edge.Max = max_ts.TotalHours
Case SpanType.Minutes
new_Edge.Average = average_ts.TotalMinutes
new_Edge.Min = min_ts.TotalMinutes
new_Edge.Max = max_ts.TotalMinutes
Case SpanType.Seconds
new_Edge.Average = average_ts.TotalSeconds
new_Edge.Min = min_ts.TotalSeconds
new_Edge.Max = max_ts.TotalSeconds
Case SpanType.Milliseconds
new_Edge.Average = average_ts.TotalMilliseconds
new_Edge.Min = min_ts.TotalMilliseconds
new_Edge.Max = max_ts.TotalMilliseconds
Case SpanType.Ticks
new_Edge.Average = average_ts.Ticks
new_Edge.Min = min_ts.Ticks
new_Edge.Max = max_ts.Ticks
End Select
new_Result.Edges.Add(new_Edge)
Next
Next
all_Results.Add(new_Result)
End If
Next ' Option'
If Host.Available(VL.Verbose) Then Host.Log("Assuming Event: " & all_Events(final_Event).Name & " is the completion event.")
' -- Compute Averages/Standard Deviation --
Dim node_Totals As New Dictionary(Of String, List(Of Double))
Dim node_Averages As New Dictionary(Of String, Double)
Dim edges_Totals As New Dictionary(Of String, List(Of Double))
Dim edge_Averages As New Dictionary(Of String, Double)
For Each single_Result As Result in all_Results
For Each single_Node As Node In single_Result.Nodes
If Not node_Totals.ContainsKey(single_Node.Name) Then _
node_Totals.Add(single_Node.Name, New List(Of Double))
node_Totals(single_Node.Name).Add(single_Node.Completion)
Next
For Each single_Edge As Edge In single_Result.Edges
If Not edges_Totals.ContainsKey(single_Edge.Name) Then _
edges_Totals.Add(single_Edge.Name, New List(Of Double))
edges_Totals(single_Edge.Name).Add(single_Edge.Average)
Next
Next
For Each node_Name As String In node_Totals.Keys
Dim node_Total As Double = 0
For i As Integer = 0 To node_Totals(node_Name).Count - 1
node_Total += node_Totals(node_Name)(i)
Next
node_Averages.Add(node_Name, (node_Total / node_Totals(node_Name).Count))
Next
For Each edge_Name As String In edges_Totals.Keys
Dim edge_Total As Double = 0
For i As Integer = 0 To edges_Totals(edge_Name).Count - 1
edge_Total += edges_Totals(edge_Name)(i)
Next
edge_Averages.Add(edge_Name, (edge_Total / edges_Totals(edge_Name).Count))
Next
Dim node_Devations As New Dictionary(Of String, List(Of Double))
Dim node_SDs As New Dictionary(Of String, Double)
Dim edges_Devations As New Dictionary(Of String, List(Of Double))
Dim edge_SDs As New Dictionary(Of String, Double)
For Each single_Result As Result in all_Results
For Each single_Node As Node In single_Result.Nodes
If Not node_Devations.ContainsKey(single_Node.Name) Then _
node_Devations.Add(single_Node.Name, New List(Of Double))
node_Devations(single_Node.Name).Add((single_Node.Completion - node_Averages(single_Node.Name)) ^ 2)
Next
For Each single_Edge As Edge In single_Result.Edges
If Not edges_Devations.ContainsKey(single_Edge.Name) Then _
edges_Devations.Add(single_Edge.Name, New List(Of Double))
If Host.Available(VL.Debug) Then Host.Debug("Average for Edge: " & single_Edge.Name & " [" & single_Edge.Average & "]") ' -- DEBUG --
If Host.Available(VL.Debug) Then Host.Debug("Averages for Edge: " & single_Edge.Name & " [" & edge_Averages(single_Edge.Name) & "]") ' -- DEBUG --
Dim d As Double = ((single_Edge.Average - edge_Averages(single_Edge.Name)) ^ 2)
If Host.Available(VL.Debug) Then Host.Debug("Adding Devation for Edge: " & single_Edge.Name & " [" & d & "]") ' -- DEBUG --
edges_Devations(single_Edge.Name).Add(d)
Next
Next
If Host.Available(VL.Debug) Then Host.Debug("Node Devations: " & node_Devations.Count) ' -- DEBUG --
For Each node_Name As String In node_Devations.Keys
If Host.Available(VL.Debug) Then Host.Debug("Node Devations [" & node_Name & "]: " & node_Devations(node_Name).Count) ' -- DEBUG --
Dim node_Total As Double = 0
For i As Integer = 0 To node_Devations(node_Name).Count - 1
node_Total += node_Devations(node_Name)(i)
Next
node_SDs.Add(node_Name, Math.Sqrt(node_Total / node_Devations(node_Name).Count))
If Host.Available(VL.Debug) Then Host.Debug("Node Standard Devation [" & node_Name & "]: " & node_SDs(node_Name)) ' -- DEBUG --
Next
If Host.Available(VL.Debug) Then Host.Debug("Edge Devations: " & edges_Devations.Count) ' -- DEBUG --
For Each edge_Name As String In edges_Devations.Keys
If Host.Available(VL.Debug) Then Host.Debug("Edge Devations [" & edge_Name & "]: " & edges_Devations(edge_Name).Count) ' -- DEBUG --
Dim edge_Total As Double = 0
For i As Integer = 0 To edges_Devations(edge_Name).Count - 1
edge_Total += edges_Devations(edge_Name)(i)
Next
edge_SDs.Add(edge_Name, Math.Sqrt(edge_Total / edges_Devations(edge_Name).Count))
If Host.Available(VL.Debug) Then Host.Debug("Edge Standard Devation [" & edge_Name & "]: " & edge_SDs(edge_Name)) ' -- DEBUG --
Next
' --------------------- '
Dim edge_SD_Average As Double = 0
Dim edge_SD_SD As Double = 0
For Each sd As Double in edge_SDs.Values
edge_SD_Average += sd
Next
edge_SD_Average = edge_SD_Average / edge_SDs.Count
For Each sd As Double in edge_SDs.Values
edge_SD_SD += (sd - edge_SD_Average) ^ 2
Next
edge_SD_SD = Math.Sqrt(edge_SD_SD)
Dim aggregate_Results As New Dictionary(Of String, List(Of Double))
Dim aggregate_Completion As New Dictionary(Of String, Double)
Dim aggregate_Overall As New Dictionary(Of String, Double)
For Each single_Result As Result in all_Results
value_List.Add(New List(Of Double))
it_List.Add(New List(Of Leviathan.Visualisation.InformationType))
For i As Integer = 0 To single_Result.Nodes.Count - 1
Dim new_Row As New Row()
If i = 0 Then new_Row.Add(single_Result.Display_Name) Else new_Row.Add()
new_Row.Add(single_Result.Nodes(i).Name & " [" & Math.Round(single_Result.Nodes(i).Completion * 100, display_Round) & "%]").Add(single_Result.Nodes(i).Count).Add(single_Result.Nodes(i).Average) _
.Add(single_Result.Nodes(i).Earliest).Add(single_Result.Nodes(i).Latest).Add()
results_Rows.Add(new_Row)
Next
' -- Aggregate Record -- '
For j As Integer = 0 To single_Result.Names.Length - 1
If Not aggregate_Results.ContainsKey(single_Result.Names(j)) Then _
aggregate_Results.Add(single_Result.Names(j), New List(Of Double))
Next
' -- Aggregate Record -- '
Dim running_Count As Double = 0
For i As Integer = 0 To single_Result.Edges.Count - 1
' It's a proper edge!
If single_Result.Edges(i).Count >= (single_Result.Average_Edge_Count / 3) Then
Dim new_Row As New Row()
new_Row.Add().Add(single_Result.Edges(i).Name).Add(single_Result.Edges(i).Count)
Dim disp_Value As Double = 0
Dim displacement As Integer = 0
If edge_SDs(single_Result.Edges(i).Name) > 0 Then _
disp_Value = (edge_Averages(single_Result.Edges(i).Name) - single_Result.Edges(i).Average) / edge_SDs(single_Result.Edges(i).Name)
If disp_Value < 0 Then displacement = Math.Floor(disp_Value) Else displacement = Math.Ceiling(disp_Value)
Dim it_Type As Leviathan.Visualisation.InformationType
If displacement < -1 Then
it_Type = IT.Error
ElseIf displacement < 0 Then
it_Type = IT.Performance
ElseIf displacement > 1 Then
it_Type = IT.Success
ElseIf displacement > 0 Then
it_Type = IT.Question
Else
it_Type = IT.General
End If
Dim sd_Type As Leviathan.Visualisation.InformationType = IT.General
If edge_SDs(single_Result.Edges(i).Name) > 0 Then
Dim sd_disp_Value As Double = (edge_SDs(single_Result.Edges(i).Name) - edge_SD_Average) / edge_SD_SD
Dim sd_displacement As Integer = 0
If sd_disp_Value < 0 Then sd_displacement = Math.Floor(sd_disp_Value * 4) Else sd_displacement = Math.Ceiling(sd_disp_Value * 4)
If sd_displacement > 1 Then
sd_Type = IT.Error
ElseIf sd_displacement > 0 Then
sd_Type = IT.Performance
ElseIf sd_displacement < -1 Then
sd_Type = IT.Success
ElseIf sd_displacement < 0 Then
sd_Type = IT.Question
Else
sd_Type = IT.General
End If
End If
new_Row.Add(Math.Round(single_Result.Edges(i).Average, display_Round), it_Type) _
.Add(Math.Round(single_Result.Edges(i).Min, display_Round)) _
.Add(Math.Round(single_Result.Edges(i).Max, display_Round)) _
.Add(Math.Round(edge_SDs(single_Result.Edges(i).Name), display_Round), sd_Type)
results_Rows.Add(new_Row)
If single_Result.Edges(i).Name.EndsWith("*") Then
If Not edge_List.Contains(single_Result.Edges(i).Name) Then
edge_List.Add(single_Result.Edges(i).Name)
potential_Weighting += 1
End If
Dim edge_Index As Integer = edge_List.IndexOf(single_Result.Edges(i).Name)
If value_List(value_List.Count - 1).Count < edge_Index + 1 Then
For j As Integer = value_List(value_List.Count - 1).Count To edge_Index
value_List(value_List.Count - 1).Add(0)
it_List(it_List.Count - 1).Add(IT.General)
Next
End If
' -- Aggregate Record -- '
For j As Integer = 0 To single_Result.Names.Length - 1
If Not aggregate_Overall.ContainsKey(single_Result.Names(j)) Then _
aggregate_Overall.Add(single_Result.Names(j), 0)
If aggregate_Results(single_Result.Names(j)).Count < edge_Index + 1 Then
For k As Integer = aggregate_Results(single_Result.Names(j)).Count To edge_Index
aggregate_Results(single_Result.Names(j)).Add(0)
Next
End If
Next
' -- Aggregate Record -- '
' value_List(value_List.Count - 1).Item(edge_Index) = single_Result.Edges(i).Average ' -- REMOVED TO GIVE RELATIVE --
Dim val As Double = edge_Averages(single_Result.Edges(i).Name) - single_Result.Edges(i).Average
running_Count = running_Count + val
' -- Aggregate Record -- '
For j As Integer = 0 To single_Result.Names.Length - 1
' aggregate_Results(single_Result.Names(j))(edge_Index) = aggregate_Results(single_Result.Names(j))(edge_Index) + val
aggregate_Results(single_Result.Names(j))(edge_Index) = aggregate_Results(single_Result.Names(j))(edge_Index) + disp_Value
aggregate_Overall(single_Result.Names(j)) = aggregate_Overall(single_Result.Names(j)) + disp_Value
Next
' -- Aggregate Record -- '
value_List(value_List.Count - 1).Item(edge_Index) = val
it_List(it_List.Count - 1).Item(edge_Index) = it_Type
End If
End If
Next
' -- Set Weighting -- '
Dim l_Weighting As Integer = actual_Weighting
If completion_Weighting = -1 Then actual_Weighting = potential_Weighting Else actual_Weighting = completion_Weighting
If Host.Available(VL.Verbose) AndAlso actual_Weighting <> l_Weighting Then Host.Log("Changing Weighting Value from " & l_Weighting & " to " & actual_Weighting)
Dim summary_Row As New Row()
summary_Row.Add(single_Result.Display_Name)
For i As Integer = 0 To single_Result.Nodes.Count - 1
If single_Result.Nodes(i).Name.EndsWith("*") Then
Dim disp_Value As Double = 0
Dim displacement As Integer = 0
If node_SDs(single_Result.Nodes(i).Name) > 0 Then _
disp_Value = (single_Result.Nodes(i).Completion - node_Averages(single_Result.Nodes(i).Name)) / node_SDs(single_Result.Nodes(i).Name)
If disp_Value < 0 Then displacement = Math.Floor(disp_Value) Else displacement = Math.Ceiling(disp_Value)
Dim it_Type As Leviathan.Visualisation.InformationType
If displacement < -1 Then
it_Type = IT.Error
ElseIf displacement < 0 Then
it_Type = IT.Performance
ElseIf displacement > 1 Then
it_Type = IT.Success
ElseIf displacement > 0 Then
it_Type = IT.Question
Else
it_Type = IT.General
End If
'summary_Row.Add((single_Result.Nodes(i).Completion * 100) & "%", it_Type) ' -- REMOVED TO GIVE RELATIVE --
Dim val As Double = (single_Result.Nodes(i).Completion - node_Averages(single_Result.Nodes(i).Name)) * 100
running_Count = running_Count + (val * actual_Weighting) ' -- x to Weight in favour of completion! '
summary_Row.Add(Math.Round(val, display_Round), it_Type)
' -- Aggregate Record -- '
For j As Integer = 0 To single_Result.Names.Length - 1
If Not aggregate_Completion.ContainsKey(single_Result.Names(j)) Then _
aggregate_Completion.Add(single_Result.Names(j), 0)
If Not aggregate_Overall.ContainsKey(single_Result.Names(j)) Then _
aggregate_Overall.Add(single_Result.Names(j), 0)
'aggregate_Completion(single_Result.Names(j)) = aggregate_Completion(single_Result.Names(j)) + val
'aggregate_Overall(single_Result.Names(j)) = aggregate_Overall(single_Result.Names(j)) + running_Count
aggregate_Completion(single_Result.Names(j)) = aggregate_Completion(single_Result.Names(j)) + disp_Value
aggregate_Overall(single_Result.Names(j)) = aggregate_Overall(single_Result.Names(j)) + (disp_Value * actual_Weighting) ' -- x to Weight in favour of completion! '
Next
' -- Aggregate Record -- '
Exit For
End If
Next
If summary_Row.Count = 1 Then summary_Row.Add()
If running_Count > 0 Then
summary_Row.Insert(1, Math.Round(running_Count, display_Round), IT.Success)
Else
summary_Row.Insert(1, Math.Round(running_Count, display_Round), IT.Error)
End If
For i As Integer = 0 To edge_List.Count - 1
If value_List(value_List.Count - 1).Count < i + 1 Then
summary_Row.Add()
Else
summary_Row.Add(Math.Round(value_List(value_List.Count - 1).Item(i), display_Round), _
it_List(it_List.Count - 1).Item(i))
End If
Next
summary_Rows.Add(summary_Row)
Next ' Result '
summary_Rows.Add(New Row()) ' Spacing Row '
summary_Rows.Add(New Row().Add("-- Aggregates --", IT.Information)) ' Spacing Row '
' -- Aggregate Records -- '
Dim aggregate_Sort = aggregate_Overall.OrderByDescending(Function(p) p.Value).ToList()
For i As Integer = 0 To aggregate_Sort.Count - 1
Dim aggregate_Name = aggregate_Sort(i).Key
Dim aggregate_Row As New Row()
aggregate_Row.Add(aggregate_Name)
aggregate_Row.Add(Math.Round(aggregate_Overall(aggregate_Name), display_Round), _
Get_Display_Type(aggregate_Overall(aggregate_Name)))
aggregate_Row.Add(Math.Round(aggregate_Completion(aggregate_Name), display_Round), _
Get_Display_Type(aggregate_Completion(aggregate_Name)))
For j As Integer = 0 To edge_List.Count - 1
If j > aggregate_Results(aggregate_Name).Count - 1 Then
aggregate_Row.Add()
Else
aggregate_Row.Add(Math.Round(aggregate_Results(aggregate_Name)(j), display_Round), _
Get_Display_Type(aggregate_Results(aggregate_Name)(j)))
End If
Next
summary_Rows.Add(aggregate_Row)
Next
' -- Aggregate Records -- '
edge_List.Insert(0, "Completion")
edge_List.Insert(0, "Delta")
edge_List.Insert(0, "Option Name")
For i As Integer = 0 TO summary_Rows.Count - 1
If summary_Rows(i).Count < edge_List.Count Then
For j As Integer = summary_Rows(i).Count To edge_List.Count - 1
summary_Rows(i).Add()
Next
End If
Next
If Host.Available(VL.Verbose) Then
Dim units As String = Nothing
Select Case analysis_Span
Case SpanType.Days
units = "/d"
Case SpanType.Hours
units = "/hr"
Case SpanType.Minutes
units = "/mi"
Case SpanType.Seconds
units = "/s"
Case SpanType.Milliseconds
units = "/ms"
Case SpanType.Ticks
units = "/tk"
End Select
Return New IFixedWidthWriteable() { _
Cube.Create(IT.Information, String.Format("{0} [{1}] // Summary", value.Name, value.Code), _
FormatterProperty.Create(edge_List.ToArray())).Add(New Slice(summary_Rows)), _
Cube.Create(IT.Information, String.Format("{0} [{1}] // Raw Results", value.Name, value.Code), _
"Option Name", "Event", "Count", "Avg" + units, "Min" + units, "Max" + units, "SD" + units).Add(New Slice(results_Rows)) _
}
Else
Return New IFixedWidthWriteable() { _
Cube.Create(IT.Information, String.Format("{0} [{1}] // Summary", value.Name, value.Code), _
FormatterProperty.Create(edge_List.ToArray())).Add(New Slice(summary_Rows)) _
}
End If
End Function
Private Function Get_Display_Type( _
ByVal value As Double _
) As Leviathan.Visualisation.InformationType
If value > 2 Then
Return IT.Success
ElseIf value > 0 Then
Return IT.Question
ElseIf value < -2 Then
Return IT.Error
ElseIf value < 0 Then
Return IT.Performance
Else
Return IT.General
End If
End Function
#End Region
#Region " Public Command Methods "
<Command( _
Name:="all", _
Description:="Analyse All Exercises" _
)> _
Public Function Analyse_All(
) As IFixedWidthWriteable()
Return Analyse_All(-1)
End Function
<Command( _
Name:="all", _
Description:="Analyse All Exercises" _
)> _
Public Function Analyse_All(
<Configurable( _
Description:="Weight Completion by ..." _
)> _
ByVal completion_Weighting As Integer _
) As IFixedWidthWriteable()
Dim return_List As New List(Of IFixedWidthWriteable)
For Each single_Exercise As Exercise In Exercise.All.Get(Data.Connection(Athena_Source)).ToList()
return_List.AddRange(Analyse_Exercise(single_Exercise, completion_Weighting))
Next
Return return_List.ToArray()
End Function
<Command( _
Name:="exercise", _
Description:="Analyse Specific Exerise" _
)> _
Public Function Analyse_Exercise( _
<Configurable( _
Description:="Exercise Name or Code" _
)> _
ByVal name As String _
) As IFixedWidthWriteable()
Return Analyse_Exercise(name, -1)
End Function
<Command( _
Name:="exercise", _
Description:="Analyse Specific Exerise" _
)> _
Public Function Analyse_Exercise( _
<Configurable( _
Description:="Exercise Name or Code" _
)> _
ByVal name As String, _
<Configurable( _
Description:="Weight Completion by ..." _
)> _
ByVal completion_Weighting As Integer _
) As IFixedWidthWriteable()
Dim existing_Exercise As Exercise = Exercise.All.Filter( _
Data.Connection(Athena_Source), Exercise.All.Filters.NAME, name).FirstOrDefault()
If existing_Exercise Is Nothing Then existing_Exercise = Exercise.All.Filter( _
Data.Connection(Athena_Source), Exercise.All.Filters.CODE, name).FirstOrDefault()
If Not existing_Exercise Is Nothing Then
Return Analyse_Exercise(existing_Exercise, completion_Weighting)
Else
Return Nothing
End If
End Function
#End Region
End Class
|
thiscouldbejd/Athena
|
Athena.Commands/Partials/AnalysisCommands.vb
|
Visual Basic
|
mit
| 30,516
|
#Region "License"
' The MIT License (MIT)
'
' Copyright (c) 2018 Richard L King (TradeWright Software Systems)
'
' Permission is hereby granted, free of charge, to any person obtaining a copy
' of this software and associated documentation files (the "Software"), to deal
' in the Software without restriction, including without limitation the rights
' to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
' copies of the Software, and to permit persons to whom the Software is
' furnished to do so, subject to the following conditions:
'
' The above copyright notice and this permission notice shall be included in all
' copies or substantial portions of the Software.
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
' IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
' FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
' AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
' LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
' OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
' SOFTWARE.
#End Region
Public Class AccountUpdateMultiEventArgs
Inherits AbstractEventArgsWithTimestamp
Public Property Account As String
Public Property Currency As String
Public Property Key As String
Public Property ModelCode As String
Public Property ReqId As Integer
Public Property Value As String
Public Sub New(timestamp As DateTime, reqId As Integer, account As String, modelCode As String, key As String, value As String, currency As String)
MyBase.New()
Me._Timestamp = timestamp
Me.Account = account
Me.ModelCode = modelCode
Me.Key = key
Me.Value = value
Me.Currency = currency
End Sub
End Class
|
tradewright/tradewright-twsapi
|
src/IBApi/EventArgs/AccountUpdateMultiEventArgs.vb
|
Visual Basic
|
mit
| 1,871
|
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated by a tool.
' Runtime Version:4.0.30319.42000
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Namespace My.Resources
'This class was auto-generated by the StronglyTypedResourceBuilder
'class via a tool like ResGen or Visual Studio.
'To add or remove a member, edit your .ResX file then rerun ResGen
'with the /str option, or rebuild your VS project.
'''<summary>
''' A strongly-typed resource class, for looking up localized strings, etc.
'''</summary>
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0"), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
Friend Module Resources
Private resourceMan As Global.System.Resources.ResourceManager
Private resourceCulture As Global.System.Globalization.CultureInfo
'''<summary>
''' Returns the cached ResourceManager instance used by this class.
'''</summary>
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
Get
If Object.ReferenceEquals(resourceMan, Nothing) Then
Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("VBScaleImage.Resources", GetType(Resources).Assembly)
resourceMan = temp
End If
Return resourceMan
End Get
End Property
'''<summary>
''' Overrides the current thread's CurrentUICulture property for all
''' resource lookups using this strongly typed resource class.
'''</summary>
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Friend Property Culture() As Global.System.Globalization.CultureInfo
Get
Return resourceCulture
End Get
Set(ByVal value As Global.System.Globalization.CultureInfo)
resourceCulture = value
End Set
End Property
End Module
End Namespace
|
AndreKuzubov/Easy_Report
|
packages/Independentsoft.Office.Word.2.0.400/Tutorial/VBScaleImage/My Project/Resources.Designer.vb
|
Visual Basic
|
apache-2.0
| 2,721
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Globalization
Imports System.Threading
Imports System.Threading.Tasks
Imports System.Xml.Linq
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Imports Microsoft.CodeAnalysis.LanguageServices
Imports Microsoft.CodeAnalysis.Shared.Extensions
Imports Microsoft.CodeAnalysis.Text
Imports Roslyn.Test.Utilities
Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Public Class ISymbolExtensionsTests
Inherits TestBase
Private Async Function TestIsAccessibleWithinAsync(workspaceDefinition As XElement, expectedVisible As Boolean) As Tasks.Task
Using workspace = Await TestWorkspaceFactory.CreateWorkspaceAsync(workspaceDefinition)
Dim cursorDocument = workspace.Documents.First(Function(d) d.CursorPosition.HasValue)
Dim cursorPosition = cursorDocument.CursorPosition.Value
Dim document = workspace.CurrentSolution.GetDocument(cursorDocument.Id)
Dim commonSyntaxToken = (Await document.GetSyntaxTreeAsync()).GetTouchingToken(cursorPosition, Nothing)
Dim semanticModel = Await document.GetSemanticModelAsync()
Dim symbol = semanticModel.GetSymbols(commonSyntaxToken, document.Project.Solution.Workspace, bindLiteralsToUnderlyingType:=False, cancellationToken:=Nothing).First()
Dim namedTypeSymbol = semanticModel.GetEnclosingNamedType(cursorPosition, CancellationToken.None)
Dim actualVisible = symbol.IsAccessibleWithin(namedTypeSymbol)
Assert.Equal(expectedVisible, actualVisible)
End Using
End Function
<Fact>
Public Async Function TestIsAccessibleWithin_ProtectedInternal() As Task
Dim workspace =
<Workspace>
<Project Language="C#" AssemblyName="CSharpAssembly" CommonReferences="true">
<Document>
public class Program { protected internal void M() { } }
</Document>
</Project>
<Project Language="C#" CommonReferences="true">
<ProjectReference>CSharpAssembly</ProjectReference>
<Document>
class C { void M() { Program.$$M(); } }
</Document>
</Project>
</Workspace>
Await TestIsAccessibleWithinAsync(workspace, False)
End Function
<Fact>
Public Async Function TestIsAccessibleWithin_ProtectedInternal_InternalsVisibleTo() As Task
Dim workspace =
<Workspace>
<Project Language="C#" AssemblyName="CSharpAssembly" CommonReferences="true">
<Document>
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("CSharpAssembly2")]
public class Program { protected internal static int F; }
</Document>
</Project>
<Project Language="C#" AssemblyName="CSharpAssembly2" CommonReferences="true">
<ProjectReference>CSharpAssembly</ProjectReference>
<Document>
class C { void M() { var f = Program.$$F; } }
</Document>
</Project>
</Workspace>
Await TestIsAccessibleWithinAsync(workspace, True)
End Function
<Fact>
Public Async Function TestIsAccessibleWithin_ProtectedInternal_WrongInternalsVisibleTo() As Task
Dim workspace =
<Workspace>
<Project Language="C#" AssemblyName="CSharpAssembly" CommonReferences="true">
<Document>
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("NonExisting")]
public class Program { protected internal static int F; }
</Document>
</Project>
<Project Language="C#" CommonReferences="true">
<ProjectReference>CSharpAssembly</ProjectReference>
<Document>
class C { void M() { var f = Program.$$F; } }
</Document>
</Project>
</Workspace>
Await TestIsAccessibleWithinAsync(workspace, False)
End Function
<Fact>
Public Async Function TestIsAccessibleWithin_PrivateInsideNestedType() As Task
Dim workspace =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
class Outer
{
private static int field;
class Inner
{
private int consumer = $$field;
}
} </Document>
</Project>
</Workspace>
Await TestIsAccessibleWithinAsync(workspace, True)
End Function
<Fact>
Public Async Function TestIsAccessibleWithin_ProtectedInsideNestedType() As Task
Dim workspace =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
class Outer
{
protected static int field;
class Inner
{
private int consumer = $$field;
}
} </Document>
</Project>
</Workspace>
Await TestIsAccessibleWithinAsync(workspace, True)
End Function
End Class
End Namespace
|
HellBrick/roslyn
|
src/EditorFeatures/Test2/Extensions/ISymbolExtensionsTests.vb
|
Visual Basic
|
apache-2.0
| 5,014
|
' Copyright (c) Microsoft. All Rights Reserved. Licensedf under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Collections.Immutable
Imports Microsoft.CodeAnalysis.PooledObjects
Imports Microsoft.CodeAnalysis.Operations
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic
Partial Friend Class BoundNode
Implements IBoundNodeWithIOperationChildren
Public ReadOnly Property IBoundNodeWithIOperationChildren_Children As ImmutableArray(Of BoundNode) Implements IBoundNodeWithIOperationChildren.Children
Get
Return Me.Children
End Get
End Property
''' <summary>
''' Override this property to return the child nodes if the IOperation API corresponding to this bound node is not yet designed or implemented.
''' </summary>
''' <remarks>
''' Note that any of the child bound nodes may be null.
''' </remarks>
Protected Overridable ReadOnly Property Children As ImmutableArray(Of BoundNode)
Get
Return ImmutableArray(Of BoundNode).Empty
End Get
End Property
End Class
Partial Friend Class BoundCaseBlock
Protected Overrides ReadOnly Property Children As ImmutableArray(Of BoundNode)
Get
Return ImmutableArray.Create(Of BoundNode)(Me.CaseStatement, Me.Body)
End Get
End Property
End Class
Partial Friend Class BoundCaseStatement
Protected Overrides ReadOnly Property Children As ImmutableArray(Of BoundNode)
Get
Return StaticCast(Of BoundNode).From(Me.CaseClauses).Add(Me.ConditionOpt)
End Get
End Property
End Class
Partial Friend Class BoundBadStatement
Protected Overrides ReadOnly Property Children As ImmutableArray(Of BoundNode)
Get
Return Me.ChildBoundNodes
End Get
End Property
End Class
Partial Friend Class BoundEraseStatement
Protected Overrides ReadOnly Property Children As ImmutableArray(Of BoundNode)
Get
Return StaticCast(Of BoundNode).From(Me.Clauses)
End Get
End Property
End Class
Partial Friend Class BoundResumeStatement
Protected Overrides ReadOnly Property Children As ImmutableArray(Of BoundNode)
Get
Return ImmutableArray.Create(Of BoundNode)(Me.LabelExpressionOpt)
End Get
End Property
End Class
Partial Friend Class BoundOnErrorStatement
Protected Overrides ReadOnly Property Children As ImmutableArray(Of BoundNode)
Get
Return ImmutableArray.Create(Of BoundNode)(Me.LabelExpressionOpt)
End Get
End Property
End Class
Partial Friend Class BoundUnstructuredExceptionHandlingStatement
Protected Overrides ReadOnly Property Children As ImmutableArray(Of BoundNode)
Get
Return ImmutableArray.Create(Of BoundNode)(Me.Body)
End Get
End Property
End Class
End Namespace
|
xasx/roslyn
|
src/Compilers/VisualBasic/Portable/BoundTree/Statement.vb
|
Visual Basic
|
apache-2.0
| 3,277
|
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class login
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.btnLogin = New System.Windows.Forms.Button()
Me.Label1 = New System.Windows.Forms.Label()
Me.label2 = New System.Windows.Forms.Label()
Me.txtboxUsername = New System.Windows.Forms.TextBox()
Me.txtboxPassword = New System.Windows.Forms.TextBox()
Me.GroupBox1 = New System.Windows.Forms.GroupBox()
Me.Label3 = New System.Windows.Forms.Label()
Me.GroupBox1.SuspendLayout()
Me.SuspendLayout()
'
'btnLogin
'
Me.btnLogin.Location = New System.Drawing.Point(23, 64)
Me.btnLogin.Name = "btnLogin"
Me.btnLogin.Size = New System.Drawing.Size(75, 23)
Me.btnLogin.TabIndex = 0
Me.btnLogin.Text = "Login"
Me.btnLogin.UseVisualStyleBackColor = True
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(118, 41)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(53, 13)
Me.Label1.TabIndex = 1
Me.Label1.Text = "Password"
'
'label2
'
Me.label2.AutoSize = True
Me.label2.Location = New System.Drawing.Point(118, 15)
Me.label2.Name = "label2"
Me.label2.Size = New System.Drawing.Size(55, 13)
Me.label2.TabIndex = 2
Me.label2.Text = "Username"
'
'txtboxUsername
'
Me.txtboxUsername.Location = New System.Drawing.Point(12, 12)
Me.txtboxUsername.Name = "txtboxUsername"
Me.txtboxUsername.Size = New System.Drawing.Size(100, 20)
Me.txtboxUsername.TabIndex = 3
'
'txtboxPassword
'
Me.txtboxPassword.Location = New System.Drawing.Point(12, 38)
Me.txtboxPassword.Name = "txtboxPassword"
Me.txtboxPassword.Size = New System.Drawing.Size(100, 20)
Me.txtboxPassword.TabIndex = 4
'
'GroupBox1
'
Me.GroupBox1.Controls.Add(Me.Label3)
Me.GroupBox1.Location = New System.Drawing.Point(179, 12)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(145, 75)
Me.GroupBox1.TabIndex = 5
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "Info"
'
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.Location = New System.Drawing.Point(7, 20)
Me.Label3.MaximumSize = New System.Drawing.Size(135, 0)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(135, 39)
Me.Label3.TabIndex = 0
Me.Label3.Text = "We need to check your permission level to edit this information."
'
'login
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(336, 94)
Me.Controls.Add(Me.GroupBox1)
Me.Controls.Add(Me.txtboxPassword)
Me.Controls.Add(Me.txtboxUsername)
Me.Controls.Add(Me.label2)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.btnLogin)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "login"
Me.ShowInTaskbar = False
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
Me.Text = "Checking your permissions"
Me.GroupBox1.ResumeLayout(False)
Me.GroupBox1.PerformLayout()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents btnLogin As Button
Friend WithEvents Label1 As Label
Friend WithEvents label2 As Label
Friend WithEvents txtboxUsername As TextBox
Friend WithEvents txtboxPassword As TextBox
Friend WithEvents GroupBox1 As GroupBox
Friend WithEvents Label3 As Label
End Class
|
sethleedy/Educational-Resource
|
outlinevb/login.Designer.vb
|
Visual Basic
|
apache-2.0
| 4,803
|
' Licensed to the .NET Foundation under one or more agreements.
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.
Imports System.Collections.Immutable
Imports System.Threading
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.CodeGeneration
Imports Microsoft.CodeAnalysis.Editing
Imports Microsoft.CodeAnalysis.Editor.Shared.Utilities
Imports Microsoft.CodeAnalysis.Editor.VisualBasic.Utilities
Imports Microsoft.CodeAnalysis.Formatting
Imports Microsoft.CodeAnalysis.NavigationBar
Imports Microsoft.CodeAnalysis.NavigationBar.RoslynNavigationBarItem
Imports Microsoft.CodeAnalysis.PooledObjects
Imports Microsoft.CodeAnalysis.Simplification
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports Microsoft.VisualStudio.Text.Editor
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.NavigationBar
Partial Friend Class VisualBasicEditorNavigationBarItemService
Private Async Function GenerateCodeForItemAsync(document As Document, generateCodeItem As AbstractGenerateCodeItem, textView As ITextView, cancellationToken As CancellationToken) As Task
' We'll compute everything up front before we go mutate state
Dim text = Await document.GetTextAsync(cancellationToken).ConfigureAwait(False)
Dim newDocument = Await GetGeneratedDocumentAsync(document, generateCodeItem, cancellationToken).ConfigureAwait(False)
Dim generatedTree = Await newDocument.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(False)
Dim generatedNode = generatedTree.GetAnnotatedNodes(GeneratedSymbolAnnotation).Single().FirstAncestorOrSelf(Of MethodBlockBaseSyntax)
Dim documentOptions = Await document.GetOptionsAsync(cancellationToken).ConfigureAwait(False)
Dim indentSize = documentOptions.GetOption(FormattingOptions.IndentationSize)
Dim navigationPoint = NavigationPointHelpers.GetNavigationPoint(generatedTree.GetText(text.Encoding), indentSize, generatedNode)
' switch back to ui thread to actually perform the application and navigation
Await Me.ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken)
Using transaction = New CaretPreservingEditTransaction(VBEditorResources.Generate_Member, textView, _textUndoHistoryRegistry, _editorOperationsFactoryService)
newDocument.Project.Solution.Workspace.ApplyDocumentChanges(newDocument, cancellationToken)
NavigateToVirtualTreePoint(newDocument.Project.Solution, navigationPoint, cancellationToken)
transaction.Complete()
End Using
End Function
Public Shared Async Function GetGeneratedDocumentAsync(document As Document, generateCodeItem As RoslynNavigationBarItem, cancellationToken As CancellationToken) As Task(Of Document)
Dim syntaxTree = Await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(False)
Dim contextLocation = syntaxTree.GetLocation(New TextSpan(0, 0))
Dim codeGenerationOptions As New CodeGenerationOptions(contextLocation, generateMethodBodies:=True)
Dim newDocument = Await GetGeneratedDocumentCoreAsync(document, generateCodeItem, codeGenerationOptions, cancellationToken).ConfigureAwait(False)
If newDocument Is Nothing Then
Return document
End If
newDocument = Await Simplifier.ReduceAsync(newDocument, Simplifier.Annotation, Nothing, cancellationToken).ConfigureAwait(False)
Dim formatterRules = Formatter.GetDefaultFormattingRules(newDocument)
If ShouldApplyLineAdjustmentFormattingRule(generateCodeItem) Then
formatterRules = LineAdjustmentFormattingRule.Instance.Concat(formatterRules)
End If
Dim documentOptions = Await newDocument.GetOptionsAsync(cancellationToken).ConfigureAwait(False)
Return Await Formatter.FormatAsync(
newDocument,
Formatter.Annotation,
options:=documentOptions,
cancellationToken:=cancellationToken,
rules:=formatterRules).ConfigureAwait(False)
End Function
Private Shared Function ShouldApplyLineAdjustmentFormattingRule(generateCodeItem As RoslynNavigationBarItem) As Boolean
Return generateCodeItem.Kind <> RoslynNavigationBarItemKind.GenerateFinalizer
End Function
Private Shared Function GetGeneratedDocumentCoreAsync(document As Document, generateCodeItem As RoslynNavigationBarItem, codeGenerationOptions As CodeGenerationOptions, cancellationToken As CancellationToken) As Task(Of Document)
Select Case generateCodeItem.Kind
Case RoslynNavigationBarItemKind.GenerateDefaultConstructor
Return GenerateDefaultConstructorAsync(document, DirectCast(generateCodeItem, GenerateDefaultConstructor), codeGenerationOptions, cancellationToken)
Case RoslynNavigationBarItemKind.GenerateEventHandler
Return GenerateEventHandlerAsync(document, DirectCast(generateCodeItem, GenerateEventHandler), codeGenerationOptions, cancellationToken)
Case RoslynNavigationBarItemKind.GenerateFinalizer
Return GenerateFinalizerAsync(document, DirectCast(generateCodeItem, GenerateFinalizer), codeGenerationOptions, cancellationToken)
Case RoslynNavigationBarItemKind.GenerateMethod
Return GenerateMethodAsync(document, DirectCast(generateCodeItem, GenerateMethod), codeGenerationOptions, cancellationToken)
Case Else
Throw ExceptionUtilities.UnexpectedValue(generateCodeItem.Kind)
End Select
End Function
Private Shared Async Function GenerateDefaultConstructorAsync(document As Document, generateCodeItem As GenerateDefaultConstructor, codeGenerationOptions As CodeGenerationOptions, cancellationToken As CancellationToken) As Task(Of Document)
Dim compilation = Await document.Project.GetCompilationAsync(cancellationToken).ConfigureAwait(False)
Dim destinationType = TryCast(generateCodeItem.DestinationTypeSymbolKey.Resolve(compilation, cancellationToken:=cancellationToken).Symbol, INamedTypeSymbol)
If destinationType Is Nothing Then
Return Nothing
End If
Dim statements As New ArrayBuilder(Of SyntaxNode)
If destinationType.IsDesignerGeneratedTypeWithInitializeComponent(compilation) Then
Dim statement = SyntaxFactory.ExpressionStatement(SyntaxFactory.InvocationExpression(SyntaxFactory.IdentifierName("InitializeComponent"), SyntaxFactory.ArgumentList()))
Dim endOfLineTrivia = SyntaxFactory.EndOfLineTrivia(vbCrLf)
' When sticking on the comments, we don't want the ' in the localized string
' lest we try localizing the comment character itself
statement = statement.WithLeadingTrivia(endOfLineTrivia, SyntaxFactory.CommentTrivia("' " & VBEditorResources.This_call_is_required_by_the_designer), endOfLineTrivia)
statement = statement.WithTrailingTrivia(endOfLineTrivia, endOfLineTrivia, SyntaxFactory.CommentTrivia("' " & VBEditorResources.Add_any_initialization_after_the_InitializeComponent_call), endOfLineTrivia, endOfLineTrivia)
statements.Add(statement)
End If
Dim methodSymbol = CodeGenerationSymbolFactory.CreateConstructorSymbol(
attributes:=Nothing,
accessibility:=Accessibility.Public,
modifiers:=New DeclarationModifiers(),
typeName:=destinationType.Name,
parameters:=ImmutableArray(Of IParameterSymbol).Empty,
statements:=statements.ToImmutableAndFree())
methodSymbol = GeneratedSymbolAnnotation.AddAnnotationToSymbol(methodSymbol)
Return Await CodeGenerator.AddMethodDeclarationAsync(document.Project.Solution,
destinationType,
methodSymbol,
codeGenerationOptions,
cancellationToken).ConfigureAwait(False)
End Function
Private Shared Async Function GenerateEventHandlerAsync(document As Document, generateCodeItem As GenerateEventHandler, codeGenerationOptions As CodeGenerationOptions, cancellationToken As CancellationToken) As Task(Of Document)
Dim compilation = Await document.Project.GetCompilationAsync(cancellationToken).ConfigureAwait(False)
Dim eventSymbol = TryCast(generateCodeItem.EventSymbolKey.Resolve(compilation, cancellationToken:=cancellationToken).GetAnySymbol(), IEventSymbol)
Dim destinationType = TryCast(generateCodeItem.DestinationTypeSymbolKey.Resolve(compilation, cancellationToken:=cancellationToken).GetAnySymbol(), INamedTypeSymbol)
If eventSymbol Is Nothing OrElse destinationType Is Nothing Then
Return Nothing
End If
Dim delegateInvokeMethod = DirectCast(eventSymbol.Type, INamedTypeSymbol).DelegateInvokeMethod
If delegateInvokeMethod Is Nothing Then
Return Nothing
End If
Dim containerSyntax As ExpressionSyntax
Dim methodName As String
If generateCodeItem.ContainerName IsNot Nothing Then
containerSyntax = SyntaxFactory.IdentifierName(generateCodeItem.ContainerName)
methodName = generateCodeItem.ContainerName + "_" + eventSymbol.Name
Else
containerSyntax = SyntaxFactory.KeywordEventContainer(SyntaxFactory.Token(SyntaxKind.MeKeyword))
methodName = destinationType.Name + "_" + eventSymbol.Name
End If
Dim handlesSyntax = SyntaxFactory.SimpleMemberAccessExpression(containerSyntax, SyntaxFactory.Token(SyntaxKind.DotToken), eventSymbol.Name.ToIdentifierName())
Dim methodSymbol = CodeGenerationSymbolFactory.CreateMethodSymbol(
attributes:=Nothing,
accessibility:=Accessibility.Private,
modifiers:=New DeclarationModifiers(),
returnType:=delegateInvokeMethod.ReturnType,
refKind:=delegateInvokeMethod.RefKind,
explicitInterfaceImplementations:=Nothing,
name:=methodName,
typeParameters:=Nothing,
parameters:=delegateInvokeMethod.RemoveInaccessibleAttributesAndAttributesOfTypes(destinationType).Parameters,
handlesExpressions:=ImmutableArray.Create(Of SyntaxNode)(handlesSyntax))
methodSymbol = GeneratedSymbolAnnotation.AddAnnotationToSymbol(methodSymbol)
Return Await CodeGenerator.AddMethodDeclarationAsync(document.Project.Solution,
destinationType,
methodSymbol,
codeGenerationOptions,
cancellationToken).ConfigureAwait(False)
End Function
Private Shared Async Function GenerateFinalizerAsync(document As Document, generateCodeItem As GenerateFinalizer, codeGenerationOptions As CodeGenerationOptions, cancellationToken As CancellationToken) As Task(Of Document)
Dim compilation = Await document.Project.GetCompilationAsync(cancellationToken).ConfigureAwait(False)
Dim destinationType = TryCast(generateCodeItem.DestinationTypeSymbolKey.Resolve(compilation, cancellationToken:=cancellationToken).Symbol, INamedTypeSymbol)
If destinationType Is Nothing Then
Return Nothing
End If
Dim syntaxFactory = document.GetLanguageService(Of SyntaxGenerator)()
Dim finalizeCall =
syntaxFactory.ExpressionStatement(
syntaxFactory.InvocationExpression(
syntaxFactory.MemberAccessExpression(
syntaxFactory.BaseExpression(),
syntaxFactory.IdentifierName(WellKnownMemberNames.DestructorName))))
Dim finalizerMethodSymbol = CodeGenerationSymbolFactory.CreateMethodSymbol(
attributes:=Nothing,
accessibility:=Accessibility.Protected,
modifiers:=New DeclarationModifiers(isOverride:=True),
returnType:=compilation.GetSpecialType(SpecialType.System_Void),
refKind:=RefKind.None,
explicitInterfaceImplementations:=Nothing,
name:=WellKnownMemberNames.DestructorName,
typeParameters:=Nothing,
parameters:=ImmutableArray(Of IParameterSymbol).Empty,
statements:=ImmutableArray.Create(finalizeCall))
finalizerMethodSymbol = GeneratedSymbolAnnotation.AddAnnotationToSymbol(finalizerMethodSymbol)
Return Await CodeGenerator.AddMethodDeclarationAsync(document.Project.Solution,
destinationType,
finalizerMethodSymbol,
codeGenerationOptions,
cancellationToken).ConfigureAwait(False)
End Function
Private Shared Async Function GenerateMethodAsync(document As Document, generateCodeItem As GenerateMethod, codeGenerationOptions As CodeGenerationOptions, cancellationToken As CancellationToken) As Task(Of Document)
Dim compilation = Await document.Project.GetCompilationAsync(cancellationToken).ConfigureAwait(False)
Dim destinationType = TryCast(generateCodeItem.DestinationTypeSymbolKey.Resolve(compilation, cancellationToken:=cancellationToken).Symbol, INamedTypeSymbol)
Dim methodToReplicate = TryCast(generateCodeItem.MethodToReplicateSymbolKey.Resolve(compilation, cancellationToken:=cancellationToken).Symbol, IMethodSymbol)
If destinationType Is Nothing OrElse methodToReplicate Is Nothing Then
Return Nothing
End If
Dim codeGenerationSymbol = GeneratedSymbolAnnotation.AddAnnotationToSymbol(
CodeGenerationSymbolFactory.CreateMethodSymbol(
methodToReplicate.RemoveInaccessibleAttributesAndAttributesOfTypes(destinationType)))
Return Await CodeGenerator.AddMethodDeclarationAsync(document.Project.Solution,
destinationType,
codeGenerationSymbol,
codeGenerationOptions,
cancellationToken).ConfigureAwait(False)
End Function
End Class
End Namespace
|
AmadeusW/roslyn
|
src/EditorFeatures/VisualBasic/NavigationBar/VisualBasicEditorNavigationBarItemService_CodeGeneration.vb
|
Visual Basic
|
apache-2.0
| 15,457
|
'////////////////////////////////////////////////////////////////////////
' Copyright 2001-2015 Aspose Pty Ltd. All Rights Reserved.
'
' This file is part of Aspose.Imaging. The source code in this file
' is only intended as a supplement to the documentation, and is provided
' "as is", without warranty of any kind, either expressed or implied.
'////////////////////////////////////////////////////////////////////////
Imports Aspose.Cloud
Imports System
Namespace Aspose.Cells.Cloud.Examples.Text
Friend Class ReplaceTextWorksheet
Shared Sub Main()
Dim dataDir As String = Common.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)
Dim input As String = "sample1.xlsx"
Dim text As String = "aspose"
Dim newText As String = "updated"
Dim sheetName As String = "Sheet1"
Common.StorageService.File.UploadFile(dataDir & input, input, storage:= Common.STORAGE)
Dim apiResponse As CellsWorksheetMatchesResponse = Common.CellsService.Worksheets.ReplaceText(input, sheetName, text, newText, Common.FOLDER, storage:= Common.STORAGE)
Console.WriteLine(" Response Status: " & apiResponse.Status.ToString())
End Sub
End Class
End Namespace
|
farooqsheikhpk/Aspose.Cells-for-Cloud
|
Examples/DotNet/VisualBasic/Text/ReplaceTextWorksheet.vb
|
Visual Basic
|
mit
| 1,190
|
' Copyright 2015, Google Inc. All Rights Reserved.
'
' Licensed under the Apache License, Version 2.0 (the "License");
' you may not use this file except in compliance with the License.
' You may obtain a copy of the License at
'
' http://www.apache.org/licenses/LICENSE-2.0
'
' Unless required by applicable law or agreed to in writing, software
' distributed under the License is distributed on an "AS IS" BASIS,
' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
' See the License for the specific language governing permissions and
' limitations under the License.
' Author: api.anash@gmail.com (Anash P. Oommen)
Imports Google.Api.Ads.AdWords.Lib
Imports Google.Api.Ads.AdWords.v201506
Imports System
Imports System.Collections.Generic
Imports System.IO
Namespace Google.Api.Ads.AdWords.Examples.VB.v201506
''' <summary>
''' This code example pauses a given ad. To list all ads, run GetTextAds.cs.
'''
''' Tags: AdGroupAdService.mutate
''' </summary>
Public Class PauseAd
Inherits ExampleBase
''' <summary>
''' Main method, to run this code example as a standalone application.
''' </summary>
''' <param name="args">The command line arguments.</param>
Public Shared Sub Main(ByVal args As String())
Dim codeExample As New PauseAd
Console.WriteLine(codeExample.Description)
Try
Dim adGroupId As Long = Long.Parse("INSERT_ADGROUP_ID_HERE")
Dim adId As Long = Long.Parse("INSERT_AD_ID_HERE")
codeExample.Run(New AdWordsUser, adGroupId, adId)
Catch ex As Exception
Console.WriteLine("An exception occurred while running this code example. {0}", _
ExampleUtilities.FormatException(ex))
End Try
End Sub
''' <summary>
''' Returns a description about the code example.
''' </summary>
Public Overrides ReadOnly Property Description() As String
Get
Return "This code example pauses a given ad. To list all ads, run GetTextAds.cs."
End Get
End Property
''' <summary>
''' Runs the code example.
''' </summary>
''' <param name="user">The AdWords user.</param>
''' <param name="adGroupId">Id of the ad group that contains the ad.
''' </param>
''' <param name="adId">Id of the ad to be paused.</param>
Public Sub Run(ByVal user As AdWordsUser, ByVal adGroupId As Long, ByVal adId As Long)
' Get the AdGroupAdService.
Dim service As AdGroupAdService = CType(user.GetService( _
AdWordsService.v201506.AdGroupAdService), AdGroupAdService)
Dim status As AdGroupAdStatus = AdGroupAdStatus.PAUSED
' Create the ad group ad.
Dim adGroupAd As New AdGroupAd
adGroupAd.status = status
adGroupAd.adGroupId = adGroupId
adGroupAd.ad = New Ad
adGroupAd.ad.id = adId
' Create the operation.
Dim adGroupAdOperation As New AdGroupAdOperation
adGroupAdOperation.operator = [Operator].SET
adGroupAdOperation.operand = adGroupAd
Try
' Update the ad.
Dim retVal As AdGroupAdReturnValue = service.mutate( _
New AdGroupAdOperation() {adGroupAdOperation})
' Display the results.
If ((Not retVal Is Nothing) AndAlso (Not retVal.value Is Nothing) AndAlso _
(retVal.value.Length > 0)) Then
Dim pausedAdGroupAd As AdGroupAd = retVal.value(0)
Console.WriteLine("Ad with id ""{0}"" was paused.", pausedAdGroupAd.ad.id)
Else
Console.WriteLine("No ads were paused.")
End If
Catch ex As Exception
Throw New System.ApplicationException("Failed to pause ad.", ex)
End Try
End Sub
End Class
End Namespace
|
stevemanderson/googleads-dotnet-lib
|
examples/AdXBuyer/Vb/v201506/BasicOperations/PauseAd.vb
|
Visual Basic
|
apache-2.0
| 3,706
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Windows.Data
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.CodeStyle
Imports Microsoft.CodeAnalysis.Options
Imports Microsoft.CodeAnalysis.Simplification
Imports Microsoft.VisualStudio.LanguageServices.Implementation.Options
Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options
Friend Class StyleViewModel
Inherits AbstractOptionPreviewViewModel
#Region "Preview Text"
Private Shared s_fieldDeclarationPreviewTrue As String = "
Class C
Private capacity As Integer
Sub Method()
'//[
Me.capacity = 0
'//]
End Sub
End Class
"
Private Shared s_fieldDeclarationPreviewFalse As String = "
Class C
Private capacity As Integer
Sub Method()
'//[
capacity = 0
'//]
End Sub
End Class
"
Private Shared s_propertyDeclarationPreviewTrue As String = "
Class C
Public Property Id As Integer
Sub Method()
'//[
Me.Id = 0
'//]
End Sub
End Class
"
Private Shared s_propertyDeclarationPreviewFalse As String = "
Class C
Public Property Id As Integer
Sub Method()
'//[
Id = 0
'//]
End Sub
End Class
"
Private Shared s_methodDeclarationPreviewTrue As String = "
Class C
Sub Display()
'//[
Me.Display()
'//]
End Sub
End Class
"
Private Shared s_methodDeclarationPreviewFalse As String = "
Class C
Sub Display()
'//[
Display()
'//]
End Sub
End Class
"
Private Shared s_eventDeclarationPreviewTrue As String = "
Imports System
Class C
Public Event Elapsed As EventHandler
Sub Handler(sender As Object, args As EventArgs)
'//[
AddHandler Me.Elapsed, AddressOf Handler
'//]
End Sub
End Class
"
Private Shared s_eventDeclarationPreviewFalse As String = "
Imports System
Class C
Public Event Elapsed As EventHandler
Sub Handler(sender As Object, args As EventArgs)
'//[
AddHandler Elapsed, AddressOf Handler
'//]
End Sub
End Class
"
Private _intrinsicDeclarationPreviewTrue As String = <a><![CDATA[
Class Program
'//[
Private _member As Integer
Sub M(argument As Integer)
Dim local As Integer = 0
End Sub
'//]
End Class
]]></a>.Value
Private _intrinsicDeclarationPreviewFalse As String = <a><![CDATA[
Class Program
'//[
Private _member As Int32
Sub M(argument As Int32)
Dim local As Int32 = 0
End Sub
'//]
End Class
]]></a>.Value
Private _intrinsicMemberAccessPreviewTrue As String = <a><![CDATA[
Imports System
Class Program
'//[
Sub M()
Dim local = Integer.MaxValue
End Sub
'//]
End Class
]]></a>.Value
Private _intrinsicMemberAccessPreviewFalse As String = <a><![CDATA[
Imports System
Class Program
'//[
Sub M()
Dim local = Int32.MaxValue
End Sub
'//]
End Class
]]></a>.Value
Private Shared ReadOnly s_preferObjectInitializer As String = "
Imports System
Class Customer
Private Age As Integer
Sub New()
//[
' Prefer:
Dim c = New Customer() With {
.Age = 21
}
' Over:
Dim c = New Customer()
c.Age = 21
//]
End Sub
End Class"
Private Shared ReadOnly s_preferCollectionInitializer As String = "
Class Customer
Private Age As Integer
Sub New()
//[
' Prefer:
Dim list = New List(Of Integer) From {
1,
2,
3
}
' Over:
Dim list = New List(Of Integer)()
list.Add(1)
list.Add(2)
list.Add(3)
//]
End Sub
End Class"
Private Shared ReadOnly s_preferExplicitTupleName As String = "
Class Customer
Public Sub New()
//[
' Prefer:
Dim customer As (name As String, age As Integer)
Dim name = customer.name
Dim age = customer.age
' Over
Dim customer As (name As String, age As Integer)
Dim name = customer.Item1
Dim age = customer.Item2
//]
End Sub
end class
"
Private Shared ReadOnly s_preferCoalesceExpression As String = "
Imports System
Class Customer
Private Age As Integer
Sub New()
//[
' Prefer:
Dim v = If(x, y)
' Over:
Dim v = If(x Is Nothing, y, x) ' or
Dim v = If(x IsNot Nothing, x, y)
//]
End Sub
End Class"
Private Shared ReadOnly s_preferNullPropagation As String = "
Imports System
Class Customer
Private Age As Integer
Sub New()
//[
' Prefer:
Dim v = o?.ToString()
' Over:
Dim v = If(o Is Nothing, Nothing, o.ToString()) ' or
Dim v = If(o IsNot Nothing, o.ToString(), Nothing)
//]
End Sub
End Class"
#End Region
Public Sub New(optionSet As OptionSet, serviceProvider As IServiceProvider)
MyBase.New(optionSet, serviceProvider, LanguageNames.VisualBasic)
Dim collectionView = DirectCast(CollectionViewSource.GetDefaultView(CodeStyleItems), ListCollectionView)
collectionView.GroupDescriptions.Add(New PropertyGroupDescription(NameOf(AbstractCodeStyleOptionViewModel.GroupName)))
Dim qualifyGroupTitle = BasicVSResources.Me_preferences_colon
Dim qualifyMemberAccessPreferences = New List(Of CodeStylePreference) From
{
New CodeStylePreference(BasicVSResources.Prefer_Me, isChecked:=True),
New CodeStylePreference(BasicVSResources.Do_not_prefer_Me, isChecked:=False)
}
Dim predefinedTypesGroupTitle = BasicVSResources.Predefined_type_preferences_colon
Dim predefinedTypesPreferences = New List(Of CodeStylePreference) From
{
New CodeStylePreference(ServicesVSResources.Prefer_predefined_type, isChecked:=True),
New CodeStylePreference(ServicesVSResources.Prefer_framework_type, isChecked:=False)
}
Dim expressionPreferencesGroupTitle = ServicesVSResources.Expression_preferences_colon
Dim nothingPreferencesGroupTitle = BasicVSResources.nothing_checking_colon
' qualify with Me. group
Me.CodeStyleItems.Add(New SimpleCodeStyleOptionViewModel(CodeStyleOptions.QualifyFieldAccess, BasicVSResources.Qualify_field_access_with_Me, s_fieldDeclarationPreviewTrue, s_fieldDeclarationPreviewFalse, Me, optionSet, qualifyGroupTitle, qualifyMemberAccessPreferences))
Me.CodeStyleItems.Add(New SimpleCodeStyleOptionViewModel(CodeStyleOptions.QualifyPropertyAccess, BasicVSResources.Qualify_property_access_with_Me, s_propertyDeclarationPreviewTrue, s_propertyDeclarationPreviewFalse, Me, optionSet, qualifyGroupTitle, qualifyMemberAccessPreferences))
Me.CodeStyleItems.Add(New SimpleCodeStyleOptionViewModel(CodeStyleOptions.QualifyMethodAccess, BasicVSResources.Qualify_method_access_with_Me, s_methodDeclarationPreviewTrue, s_methodDeclarationPreviewFalse, Me, optionSet, qualifyGroupTitle, qualifyMemberAccessPreferences))
Me.CodeStyleItems.Add(New SimpleCodeStyleOptionViewModel(CodeStyleOptions.QualifyEventAccess, BasicVSResources.Qualify_event_access_with_Me, s_eventDeclarationPreviewTrue, s_eventDeclarationPreviewFalse, Me, optionSet, qualifyGroupTitle, qualifyMemberAccessPreferences))
' predefined or framework type group
Me.CodeStyleItems.Add(New SimpleCodeStyleOptionViewModel(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration, ServicesVSResources.For_locals_parameters_and_members, _intrinsicDeclarationPreviewTrue, _intrinsicDeclarationPreviewFalse, Me, optionSet, predefinedTypesGroupTitle, predefinedTypesPreferences))
Me.CodeStyleItems.Add(New SimpleCodeStyleOptionViewModel(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, ServicesVSResources.For_member_access_expressions, _intrinsicMemberAccessPreviewTrue, _intrinsicMemberAccessPreviewFalse, Me, optionSet, predefinedTypesGroupTitle, predefinedTypesPreferences))
' expression preferences
Me.CodeStyleItems.Add(New SimpleCodeStyleOptionViewModel(CodeStyleOptions.PreferObjectInitializer, ServicesVSResources.Prefer_object_initializer, s_preferObjectInitializer, s_preferObjectInitializer, Me, optionSet, expressionPreferencesGroupTitle))
Me.CodeStyleItems.Add(New SimpleCodeStyleOptionViewModel(CodeStyleOptions.PreferCollectionInitializer, ServicesVSResources.Prefer_collection_initializer, s_preferCollectionInitializer, s_preferCollectionInitializer, Me, optionSet, expressionPreferencesGroupTitle))
Me.CodeStyleItems.Add(New SimpleCodeStyleOptionViewModel(CodeStyleOptions.PreferExplicitTupleNames, ServicesVSResources.Prefer_explicit_tuple_name, s_preferExplicitTupleName, s_preferExplicitTupleName, Me, optionSet, expressionPreferencesGroupTitle))
' nothing preferences
Me.CodeStyleItems.Add(New SimpleCodeStyleOptionViewModel(CodeStyleOptions.PreferCoalesceExpression, ServicesVSResources.Prefer_coalesce_expression, s_preferCoalesceExpression, s_preferCoalesceExpression, Me, optionSet, nothingPreferencesGroupTitle))
Me.CodeStyleItems.Add(New SimpleCodeStyleOptionViewModel(CodeStyleOptions.PreferNullPropagation, ServicesVSResources.Prefer_null_propagation, s_preferNullPropagation, s_preferNullPropagation, Me, optionSet, nothingPreferencesGroupTitle))
End Sub
End Class
End Namespace
|
AArnott/roslyn
|
src/VisualStudio/VisualBasic/Impl/Options/StyleViewModel.vb
|
Visual Basic
|
apache-2.0
| 9,729
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports Microsoft.ApiDesignGuidelines.Analyzers
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.Diagnostics
Namespace Microsoft.ApiDesignGuidelines.VisualBasic.Analyzers
''' <summary>
''' Async001: Avoid Async Void
''' </summary>
<DiagnosticAnalyzer(LanguageNames.VisualBasic)>
Public NotInheritable Class BasicAvoidAsyncVoidAnalyzer
Inherits AvoidAsyncVoidAnalyzer
End Class
End Namespace
|
bkoelman/roslyn-analyzers
|
src/Microsoft.CodeQuality.Analyzers/VisualBasic/ApiDesignGuidelines/BasicAvoidAsyncVoid.vb
|
Visual Basic
|
apache-2.0
| 598
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Threading
Imports Microsoft.CodeAnalysis.Completion.Providers
Imports Microsoft.CodeAnalysis.VisualBasic.Extensions.ContextQuery
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic.Completion.KeywordRecommenders.Declarations
''' <summary>
''' Recommends the "Imports" keyword
''' </summary>
Friend Class ImportsKeywordRecommender
Inherits AbstractKeywordRecommender
Protected Overrides Function RecommendKeywords(context As VisualBasicSyntaxContext, cancellationToken As CancellationToken) As IEnumerable(Of RecommendedKeyword)
If context.IsPreProcessorDirectiveContext Then
Return SpecializedCollections.EmptyEnumerable(Of RecommendedKeyword)()
End If
Dim targetToken = context.TargetToken
If context.SyntaxTree.HasCompilationUnitRoot Then
' Make sure there isn't a Option statement after us
' TODO: does this break our rule of not looking forward?
Dim compilationUnit = DirectCast(context.SyntaxTree.GetRoot(cancellationToken), CompilationUnitSyntax)
If compilationUnit.Options.Count > 0 Then
If context.Position <= compilationUnit.Options.First().SpanStart Then
Return SpecializedCollections.EmptyEnumerable(Of RecommendedKeyword)()
End If
End If
End If
' If we have no left token, then we're at the start of the file
If targetToken.Kind = SyntaxKind.None Then
Return SpecializedCollections.SingletonEnumerable(New RecommendedKeyword("Imports", VBFeaturesResources.Imports_all_or_specified_elements_of_a_namespace_into_a_file))
End If
' Show if after an earlier option statement
If context.IsAfterStatementOfKind(SyntaxKind.OptionStatement, SyntaxKind.ImportsStatement) Then
Return SpecializedCollections.SingletonEnumerable(New RecommendedKeyword("Imports", VBFeaturesResources.Imports_all_or_specified_elements_of_a_namespace_into_a_file))
End If
Return SpecializedCollections.EmptyEnumerable(Of RecommendedKeyword)()
End Function
End Class
End Namespace
|
Pvlerick/roslyn
|
src/Features/VisualBasic/Portable/Completion/KeywordRecommenders/Declarations/ImportsKeywordRecommender.vb
|
Visual Basic
|
apache-2.0
| 2,466
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Threading
Imports Microsoft.CodeAnalysis.Completion.Providers
Imports Microsoft.CodeAnalysis.VisualBasic.Extensions.ContextQuery
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic.Completion.KeywordRecommenders.Statements
''' <summary>
''' Recommends the "While" and "Until" keywords as a part of a Do or Loop statements
''' </summary>
Friend Class UntilAndWhileKeywordRecommender
Inherits AbstractKeywordRecommender
Protected Overrides Function RecommendKeywords(context As VisualBasicSyntaxContext, cancellationToken As CancellationToken) As IEnumerable(Of RecommendedKeyword)
If context.FollowsEndOfStatement Then
Return SpecializedCollections.EmptyEnumerable(Of RecommendedKeyword)()
End If
Dim targetToken = context.TargetToken
If (targetToken.Kind = SyntaxKind.DoKeyword AndAlso TypeOf targetToken.Parent Is DoStatementSyntax) OrElse
(targetToken.Kind = SyntaxKind.LoopKeyword AndAlso
TypeOf targetToken.Parent Is LoopStatementSyntax AndAlso
targetToken.Parent.Parent.IsKind(SyntaxKind.SimpleDoLoopBlock, SyntaxKind.DoLoopWhileBlock, SyntaxKind.DoLoopUntilBlock)) Then
Return {New RecommendedKeyword("Until", If(targetToken.Kind = SyntaxKind.LoopKeyword,
VBFeaturesResources.Repeats_a_block_of_statements_until_a_Boolean_condition_becomes_true_Do_Loop_Until_condition,
VBFeaturesResources.Repeats_a_block_of_statements_until_a_Boolean_condition_becomes_true_Do_Until_condition_Loop)),
New RecommendedKeyword("While", If(targetToken.Kind = SyntaxKind.LoopKeyword,
VBFeaturesResources.Repeats_a_block_of_statements_while_a_Boolean_condition_is_true_Do_Loop_While_condition,
VBFeaturesResources.Repeats_a_block_of_statements_while_a_Boolean_condition_is_true_Do_While_condition_Loop))}
Else
Return SpecializedCollections.EmptyEnumerable(Of RecommendedKeyword)()
End If
End Function
End Class
End Namespace
|
mmitche/roslyn
|
src/Features/VisualBasic/Portable/Completion/KeywordRecommenders/Statements/UntilAndWhileKeywordRecommender.vb
|
Visual Basic
|
apache-2.0
| 2,551
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.Test.Utilities
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.SymbolId
Partial Public Class SymbolIdTest
Inherits SymbolKeyTestBase
#Region "No change to symbol"
<WorkItem(528864)>
<Fact>
Public Sub C2CTypeSymbolUnchanged01()
Dim src1 = <compilation name="C2CTypeSymbolUnchanged01">
<file name="a.vb">
Imports System
Public Delegate Sub DFoo(p1 As Integer, p2 As String)
Namespace N1.N2
Public Interface IFoo
End Interface
Namespace N3
Public Class CFoo
Public Structure SFoo
Public Enum EFoo
Zero
One
End Enum
End Structure
End Class
End Namespace
End Namespace
</file>
</compilation>
Dim src2 = <compilation name="C2CTypeSymbolUnchanged01">
<file name="b.vb">
Public Delegate Sub DFoo(p1 As Integer, p2 As String)
Namespace N1.N2
Public Interface IFoo
Function GetClass() As N3.CFoo
End Interface
Namespace N3
Public Class CFoo
Public Structure SFoo
' Update member
Public Enum EFoo
Zero
One
Two
End Enum
End Structure
' Add member
Public Sub M(n As Integer)
Console.WriteLine(n)
End Sub
End Class
End Namespace
End Namespace
</file>
</compilation>
Dim comp1 = CreateCompilationWithMscorlib(src1)
Dim comp2 = CreateCompilationWithMscorlib(src2)
Dim originalSymbols = GetSourceSymbols(comp1, SymbolCategory.DeclaredType Or SymbolCategory.DeclaredNamespace)
Dim newSymbols = GetSourceSymbols(comp2, SymbolCategory.DeclaredType Or SymbolCategory.DeclaredNamespace)
ResolveAndVerifySymbolList(newSymbols, comp2, originalSymbols, comp1)
End Sub
<Fact, WorkItem(530198)>
Public Sub C2CTypeSymbolCaseChangeOnly()
Dim src1 = <compilation name="C2CTypeSymbolCaseChangeOnly">
<file name="a.vb">
Imports System
Namespace NFOO
Public Interface IFOO
Delegate Sub DFOO(p As Integer)
End Interface
End Namespace
</file>
</compilation>
Dim src2 = <compilation name="C2CTypeSymbolCaseChangeOnly">
<file name="b.vb">
Imports System
Namespace nFOO
Public Interface IFoo ' case
Delegate Sub DfOO(p As Integer)
End Interface
End Namespace
</file>
</compilation>
Dim comp1 = CreateCompilationWithMscorlib(src1)
Dim comp2 = CreateCompilationWithMscorlib(src2)
Dim originalSymbols = GetSourceSymbols(comp1, SymbolCategory.DeclaredType Or SymbolCategory.DeclaredNamespace)
Dim newSymbols = GetSourceSymbols(comp2, SymbolCategory.DeclaredType Or SymbolCategory.DeclaredNamespace)
' case-insensitive
ResolveAndVerifySymbolList(newSymbols, comp2, originalSymbols, comp1)
Dim origlist = originalSymbols.OrderBy(Function(s) s.Name).ToList()
Dim newlist = newSymbols.OrderBy(Function(s) s.Name).ToList()
' case sensitive
For i = 0 To newlist.Count - 1 Step 1
Dim sym1 = origlist(i)
Dim sym2 = newlist(i)
AssertSymbolsIdsEqual(sym2, comp2, sym1, comp1, SymbolIdComparison.CaseSensitive, expectEqual:=False)
Dim resolvedSymbol = ResolveSymbol(sym2, comp2, comp1, SymbolIdComparison.CaseSensitive) ' ignored
Assert.NotNull(resolvedSymbol)
Assert.Equal(sym1, resolvedSymbol)
Next
End Sub
#End Region
#Region "Change to symbol but same ID"
<Fact>
Public Sub C2CTypeSymbolChanged01()
Dim src1 = <compilation name="C2CTypeSymbolChanged01">
<file name="a.vb">
Imports System
Public Delegate Sub DFoo(p As Integer)
Namespace N1.N2
Public Interface IBase
End Interface
Public Interface IFoo
End Interface
Namespace N3
Public Class CFoo
Public Structure SFoo
Public Enum EFoo
Zero
One
End Enum
End Structure
End Class
End Namespace
End Namespace
</file>
</compilation>
Dim src2 = <compilation name="C2CTypeSymbolChanged01">
<file name="a.vb">
Public Delegate Sub DFoo(p1 As Integer, p2 As String) ' One more param
Namespace N1.N2
Public Interface IBase
End Interface
Public Interface IFoo
Inherits IBase ' base
End Interface
Namespace N3
Public Class cFoo
Implements Ifoo ' impl
Private Structure SFOO ' modifier
Public Enum efoo As Long ' change base, case
Zero
ONE
End Enum
End Structure
End Class
End Namespace
End Namespace
</file>
</compilation>
Dim comp1 = CreateCompilationWithMscorlib(src1)
Dim comp2 = CreateCompilationWithMscorlib(src2)
Dim originalSymbols = GetSourceSymbols(comp1, SymbolCategory.DeclaredType)
Dim newSymbols = GetSourceSymbols(comp2, SymbolCategory.DeclaredType)
ResolveAndVerifySymbolList(newSymbols, comp2, originalSymbols, comp1)
End Sub
<Fact>
Public Sub C2CAssemblySymbolChanged01()
Dim src1 = <compilation name="C2CAssemblySymbolChanged01">
<file name="a.vb"><![CDATA[
<Assembly: System.Reflection.AssemblyVersion("1.2.3.4")>
Public Class C
End Class
]]>
</file>
</compilation>
Dim src2 = <compilation name="C2CAssemblySymbolChanged02">
<file name="b.vb"><![CDATA[
<Assembly: System.Reflection.AssemblyVersion("5.6.7.8")>
Public Class C
End Class
]]>
</file>
</compilation>
Dim comp1 = CreateCompilationWithMscorlib(src1)
Dim comp2 = CreateCompilationWithMscorlib(src2)
Dim sym1 = comp1.SourceModule.GlobalNamespace.GetMembers("C").FirstOrDefault()
Dim sym2 = comp2.SourceModule.GlobalNamespace.GetMembers("C").FirstOrDefault()
AssertSymbolsIdsEqual(sym2, comp2, sym1, comp1, SymbolIdComparison.CaseInsensitive, expectEqual:=False)
Assert.Null(ResolveSymbol(sym2, comp2, comp1, SymbolIdComparison.CaseInsensitive))
' ignore asm id
ResolveAndVerifySymbol(sym2, comp2, sym1, comp1, SymbolIdComparison.CaseInsensitive Or SymbolIdComparison.IgnoreAssemblyIds)
End Sub
<Fact, WorkItem(530170)>
Public Sub C2CAssemblySymbolChanged02()
Dim src1 = <compilation name="C2CAssemblySymbolChanged01">
<file name="a.vb"><![CDATA[
<Assembly: System.Reflection.AssemblyVersion("1.2.3.4")>
Public Class C
End Class
]]>
</file>
</compilation>
Dim src2 = <compilation name="C2CAssemblySymbolChanged02">
<file name="b.vb"><![CDATA[
<Assembly: System.Reflection.AssemblyVersion("1.2.3.4")>
Public Class C
End Class
]]>
</file>
</compilation>
Dim comp1 = CreateCompilationWithMscorlib(src1)
Dim comp2 = CreateCompilationWithMscorlib(src2)
Dim originalSymbols = GetSourceSymbols(comp1, SymbolCategory.DeclaredType)
Dim newSymbols = GetSourceSymbols(comp2, SymbolCategory.DeclaredType)
Dim sym1 As ISymbol = comp1.Assembly
Dim sym2 As ISymbol = comp2.Assembly
AssertSymbolsIdsEqual(sym2, comp2, sym1, comp1, SymbolIdComparison.CaseInsensitive, False)
Assert.Null(ResolveSymbol(sym2, comp2, comp1, SymbolIdComparison.CaseInsensitive))
' ignore asm id
' Same ID
AssertSymbolsIdsEqual(sym2, comp2, sym1, comp1, SymbolIdComparison.IgnoreAssemblyIds)
' but can NOT resolve
Assert.Null(ResolveSymbol(sym2, comp2, comp1, SymbolIdComparison.CaseInsensitive Or SymbolIdComparison.IgnoreAssemblyIds))
sym1 = comp1.Assembly.Modules(0)
sym2 = comp2.Assembly.Modules(0)
AssertSymbolsIdsEqual(sym2, comp2, sym1, comp1, SymbolIdComparison.CaseInsensitive, False)
Assert.Null(ResolveSymbol(sym2, comp2, comp1, SymbolIdComparison.CaseInsensitive))
AssertSymbolsIdsEqual(sym2, comp2, sym1, comp1, SymbolIdComparison.IgnoreAssemblyIds)
Assert.Null(ResolveSymbol(sym2, comp2, comp1, SymbolIdComparison.IgnoreAssemblyIds))
End Sub
#End Region
End Class
End Namespace
|
droyad/roslyn
|
src/EditorFeatures/VisualBasicTest/SymbolId/SymbolKeyCompilationsTests.vb
|
Visual Basic
|
apache-2.0
| 9,671
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Public Class ScanConditionalTests
<Fact>
Public Sub Scanner_ConditionalSkipEol()
Dim Str = <text>
#hi
</text>.Value
Using s As New InternalSyntax.Scanner(SourceText.From(Str), TestOptions.Regular)
Dim res = s.SkipToNextConditionalLine
Assert.Equal(0, res.Start)
Assert.Equal(1, res.Length)
Dim tk = s.GetCurrentToken
Assert.Equal(SyntaxKind.HashToken, tk.Kind)
End Using
End Sub
<Fact>
Public Sub Scanner_ConditionalSkipSomeText()
Dim Str = <text>
blah
blah
#hi
boo</text>.Value
Using s As New InternalSyntax.Scanner(SourceText.From(Str), TestOptions.Regular)
' grab the whole text (why not)
Dim disabled = s.GetDisabledTextAt(New TextSpan(0, Str.Length))
Assert.Equal(Str, disabled.ToFullString)
Dim res = s.SkipToNextConditionalLine
Assert.Equal(0, res.Start)
Assert.Equal(11, res.Length)
' grab skipped text.
disabled = s.GetDisabledTextAt(res)
Assert.Equal(vbLf & "blah" & vbLf & "blah" & vbLf, disabled.ToFullString)
Dim tk = s.GetCurrentToken
Assert.Equal(SyntaxKind.HashToken, tk.Kind)
s.GetNextTokenInState(InternalSyntax.ScannerState.VB) ' get off #
res = s.SkipToNextConditionalLine
Assert.Equal(12, res.Start)
Assert.Equal(6, res.Length)
disabled = s.GetDisabledTextAt(res)
Assert.Equal("hi" & vbLf & "boo", disabled.ToFullString)
s.GetNextTokenInState(InternalSyntax.ScannerState.VB)
tk = s.GetCurrentToken
Assert.Equal(SyntaxKind.EndOfFileToken, tk.Kind)
End Using
End Sub
<Fact>
Public Sub Scanner_ConditionalSkipTwice()
Dim Str = <text>
blah
blah
#hi
boo
#hi</text>.Value
Using s As New InternalSyntax.Scanner(SourceText.From(Str), TestOptions.Regular)
Dim res = s.SkipToNextConditionalLine
Assert.Equal(0, res.Start)
Assert.Equal(11, res.Length)
Dim tk = s.GetCurrentToken
Assert.Equal(SyntaxKind.HashToken, tk.Kind)
s.GetNextTokenInState(InternalSyntax.ScannerState.VB) ' skip #
res = s.SkipToNextConditionalLine
Assert.Equal(12, res.Start)
Assert.Equal(7, res.Length)
tk = s.GetCurrentToken
Assert.Equal(SyntaxKind.HashToken, tk.Kind)
s.GetNextTokenInState(InternalSyntax.ScannerState.VB) ' skip #
res = s.SkipToNextConditionalLine
Assert.Equal(20, res.Start)
Assert.Equal(2, res.Length)
tk = s.GetCurrentToken
Assert.Equal(SyntaxKind.EndOfFileToken, tk.Kind)
End Using
End Sub
<Fact>
Public Sub Scanner_ConditionalLineCont()
Dim Str = <text>blah _
# here
boo
#here _
_
_
#here _
#here _
_</text>.Value
Using s As New InternalSyntax.Scanner(SourceText.From(Str), TestOptions.Regular)
Dim res = s.SkipToNextConditionalLine
Assert.Equal(0, res.Start)
Assert.Equal(7, res.Length)
Dim tk = s.GetCurrentToken
Assert.Equal(SyntaxKind.HashToken, tk.Kind)
s.GetNextTokenInState(InternalSyntax.ScannerState.VB) ' skip #
res = s.SkipToNextConditionalLine
Assert.Equal(9, res.Start)
Assert.Equal(9, res.Length)
tk = s.GetCurrentToken
Assert.Equal(SyntaxKind.HashToken, tk.Kind)
s.GetNextTokenInState(InternalSyntax.ScannerState.VB) ' skip #
res = s.SkipToNextConditionalLine
Assert.Equal(19, res.Start)
Assert.Equal(11, res.Length)
tk = s.GetCurrentToken
Assert.Equal(SyntaxKind.HashToken, tk.Kind)
s.GetNextTokenInState(InternalSyntax.ScannerState.VB) ' skip #
res = s.SkipToNextConditionalLine
Assert.Equal(31, res.Start)
Assert.Equal(8, res.Length)
tk = s.GetCurrentToken
Assert.Equal(SyntaxKind.HashToken, tk.Kind)
s.GetNextTokenInState(InternalSyntax.ScannerState.VB) ' skip #
res = s.SkipToNextConditionalLine
Assert.Equal(40, res.Start)
Assert.Equal(8, res.Length)
tk = s.GetCurrentToken
Assert.Equal(SyntaxKind.EndOfFileToken, tk.Kind)
End Using
End Sub
End Class
|
mmitche/roslyn
|
src/Compilers/VisualBasic/Test/Syntax/Scanner/ScanConditionalTests.vb
|
Visual Basic
|
apache-2.0
| 4,908
|
'------------------------------------------------------------------------------
' <generado automáticamente>
' Este código fue generado por una herramienta.
'
' Los cambios en este archivo podrían causar un comportamiento incorrecto y se perderán si
' se vuelve a generar el código.
' </generado automáticamente>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Partial Public Class FrmProyectoCCosto
'''<summary>
'''Control RadCodeBlock1.
'''</summary>
'''<remarks>
'''Campo generado automáticamente.
'''Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente.
'''</remarks>
Protected WithEvents RadCodeBlock1 As Global.Telerik.Web.UI.RadCodeBlock
'''<summary>
'''Control LblProyecto.
'''</summary>
'''<remarks>
'''Campo generado automáticamente.
'''Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente.
'''</remarks>
Protected WithEvents LblProyecto As Global.System.Web.UI.WebControls.Label
'''<summary>
'''Control HFIdProyecto.
'''</summary>
'''<remarks>
'''Campo generado automáticamente.
'''Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente.
'''</remarks>
Protected WithEvents HFIdProyecto As Global.System.Web.UI.WebControls.HiddenField
'''<summary>
'''Control Menu1.
'''</summary>
'''<remarks>
'''Campo generado automáticamente.
'''Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente.
'''</remarks>
Protected WithEvents Menu1 As Global.System.Web.UI.WebControls.Menu
'''<summary>
'''Control RgGeneral.
'''</summary>
'''<remarks>
'''Campo generado automáticamente.
'''Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente.
'''</remarks>
Protected WithEvents RgGeneral As Global.Telerik.Web.UI.RadGrid
'''<summary>
'''Control OdsCCosto.
'''</summary>
'''<remarks>
'''Campo generado automáticamente.
'''Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente.
'''</remarks>
Protected WithEvents OdsCCosto As Global.System.Web.UI.WebControls.ObjectDataSource
'''<summary>
'''Control BtnBuscar.
'''</summary>
'''<remarks>
'''Campo generado automáticamente.
'''Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente.
'''</remarks>
Protected WithEvents BtnBuscar As Global.System.Web.UI.WebControls.Button
'''<summary>
'''Control RWMensajes.
'''</summary>
'''<remarks>
'''Campo generado automáticamente.
'''Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente.
'''</remarks>
Protected WithEvents RWMensajes As Global.Telerik.Web.UI.RadWindowManager
'''<summary>
'''Control AsignarElem.
'''</summary>
'''<remarks>
'''Campo generado automáticamente.
'''Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente.
'''</remarks>
Protected WithEvents AsignarElem As Global.Telerik.Web.UI.RadWindow
'''<summary>
'''Control AJAX_MANAGER.
'''</summary>
'''<remarks>
'''Campo generado automáticamente.
'''Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente.
'''</remarks>
Protected WithEvents AJAX_MANAGER As Global.Telerik.Web.UI.RadAjaxManager
'''<summary>
'''Control Panel1.
'''</summary>
'''<remarks>
'''Campo generado automáticamente.
'''Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente.
'''</remarks>
Protected WithEvents Panel1 As Global.System.Web.UI.WebControls.Panel
'''<summary>
'''Control TxtActividad.
'''</summary>
'''<remarks>
'''Campo generado automáticamente.
'''Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente.
'''</remarks>
Protected WithEvents TxtActividad As Global.System.Web.UI.WebControls.TextBox
'''<summary>
'''Control TxtElemGasto.
'''</summary>
'''<remarks>
'''Campo generado automáticamente.
'''Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente.
'''</remarks>
Protected WithEvents TxtElemGasto As Global.System.Web.UI.WebControls.TextBox
'''<summary>
'''Control TxtUnidad.
'''</summary>
'''<remarks>
'''Campo generado automáticamente.
'''Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente.
'''</remarks>
Protected WithEvents TxtUnidad As Global.System.Web.UI.WebControls.TextBox
'''<summary>
'''Control TxtPorcen.
'''</summary>
'''<remarks>
'''Campo generado automáticamente.
'''Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente.
'''</remarks>
Protected WithEvents TxtPorcen As Global.Telerik.Web.UI.RadNumericTextBox
'''<summary>
'''Control RequiredFieldValidator1.
'''</summary>
'''<remarks>
'''Campo generado automáticamente.
'''Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente.
'''</remarks>
Protected WithEvents RequiredFieldValidator1 As Global.System.Web.UI.WebControls.RequiredFieldValidator
'''<summary>
'''Control BtnAceptar.
'''</summary>
'''<remarks>
'''Campo generado automáticamente.
'''Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente.
'''</remarks>
Protected WithEvents BtnAceptar As Global.System.Web.UI.WebControls.ImageButton
'''<summary>
'''Control BtnCancelar.
'''</summary>
'''<remarks>
'''Campo generado automáticamente.
'''Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente.
'''</remarks>
Protected WithEvents BtnCancelar As Global.System.Web.UI.WebControls.ImageButton
'''<summary>
'''Control HFIdCCosto.
'''</summary>
'''<remarks>
'''Campo generado automáticamente.
'''Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente.
'''</remarks>
Protected WithEvents HFIdCCosto As Global.System.Web.UI.WebControls.HiddenField
'''<summary>
'''Control HFIdProyAct.
'''</summary>
'''<remarks>
'''Campo generado automáticamente.
'''Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente.
'''</remarks>
Protected WithEvents HFIdProyAct As Global.System.Web.UI.WebControls.HiddenField
'''<summary>
'''Control HFIdElemGasto.
'''</summary>
'''<remarks>
'''Campo generado automáticamente.
'''Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente.
'''</remarks>
Protected WithEvents HFIdElemGasto As Global.System.Web.UI.WebControls.HiddenField
'''<summary>
'''Control Panel2.
'''</summary>
'''<remarks>
'''Campo generado automáticamente.
'''Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente.
'''</remarks>
Protected WithEvents Panel2 As Global.System.Web.UI.WebControls.Panel
'''<summary>
'''Control BtnNueElem.
'''</summary>
'''<remarks>
'''Campo generado automáticamente.
'''Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente.
'''</remarks>
Protected WithEvents BtnNueElem As Global.System.Web.UI.WebControls.Button
'''<summary>
'''Control RadGrid1.
'''</summary>
'''<remarks>
'''Campo generado automáticamente.
'''Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente.
'''</remarks>
Protected WithEvents RadGrid1 As Global.Telerik.Web.UI.RadGrid
'''<summary>
'''Control OdsActividad.
'''</summary>
'''<remarks>
'''Campo generado automáticamente.
'''Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente.
'''</remarks>
Protected WithEvents OdsActividad As Global.System.Web.UI.WebControls.ObjectDataSource
'''<summary>
'''Control RadGrid2.
'''</summary>
'''<remarks>
'''Campo generado automáticamente.
'''Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente.
'''</remarks>
Protected WithEvents RadGrid2 As Global.Telerik.Web.UI.RadGrid
'''<summary>
'''Control OdsElementoGasto.
'''</summary>
'''<remarks>
'''Campo generado automáticamente.
'''Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente.
'''</remarks>
Protected WithEvents OdsElementoGasto As Global.System.Web.UI.WebControls.ObjectDataSource
End Class
|
crackper/SistFoncreagro
|
SistFoncreagro.WebSite/Monitoreo/Formularios/FrmProyectoCCosto.aspx.designer.vb
|
Visual Basic
|
mit
| 9,609
|
Option Infer On
Imports System
Imports System.Collections.Generic
Imports System.Runtime.InteropServices
Namespace Examples
Friend Class Program
<STAThread>
Shared Sub Main(ByVal args() As String)
Dim application As SolidEdgeFramework.Application = Nothing
Dim documents As SolidEdgeFramework.Documents = Nothing
Dim draftDocument As SolidEdgeDraft.DraftDocument = Nothing
Dim sheet As SolidEdgeDraft.Sheet = Nothing
Dim datumTargets As SolidEdgeFrameworkSupport.DatumTargets = Nothing
Dim datumTarget As SolidEdgeFrameworkSupport.DatumTarget = Nothing
Try
' See "Handling 'Application is Busy' and 'Call was Rejected By Callee' errors" topic.
OleMessageFilter.Register()
' Attempt to connect to a running instance of Solid Edge.
application = DirectCast(Marshal.GetActiveObject("SolidEdge.Application"), SolidEdgeFramework.Application)
documents = application.Documents
draftDocument = CType(documents.Add("SolidEdge.DraftDocument"), SolidEdgeDraft.DraftDocument)
sheet = draftDocument.ActiveSheet
datumTargets = CType(sheet.DatumTargets, SolidEdgeFrameworkSupport.DatumTargets)
datumTarget = datumTargets.Add(0.3, 0.25, 0.25)
' Add a Text to the Datum Target
datumTarget.DatumReference = "A"
Dim datumTargetType = datumTarget.Type
Catch ex As System.Exception
Console.WriteLine(ex)
Finally
OleMessageFilter.Unregister()
End Try
End Sub
End Class
End Namespace
|
SolidEdgeCommunity/docs
|
docfx_project/snippets/SolidEdgeFrameworkSupport.DatumTarget.Type.vb
|
Visual Basic
|
mit
| 1,747
|
Namespace Directories
''' <summary>
''' This Interface defines the Common Methods that should be implemented by a Principal Provider.
''' </summary>
''' <remarks>A Principal Provider is a class which can process IIdentities into CorePrincipals.
''' An Update method is also provided to allow updates without re-authentications.</remarks>
Public Interface IPrincipalProvider
''' <summary>
''' Creates a CorePrincipal Object for the given IIdentity.
''' </summary>
''' <param name="identity"></param>
''' <returns></returns>
''' <remarks></remarks>
Function CreateIPrincipal( _
ByVal identity As System.Security.Principal.IIdentity _
) As CorePrincipal
''' <summary>
''' Creates a CorePrincipal Object for the given IIdentity and Password
''' (should perform an Authentication to ensure password is correct).
''' </summary>
''' <param name="identity"></param>
''' <param name="password"></param>
''' <returns></returns>
''' <remarks></remarks>
Function CreateIPrincipal( _
ByVal identity As System.Security.Principal.IIdentity, _
ByVal password As String _
) As CorePrincipal
''' <summary>
''' Updates a CorePrincipal from the Provider.
''' </summary>
''' <param name="principle">The CorePrincipal to Update.</param>
''' <returns></returns>
''' <remarks></remarks>
Function UpdateIPrincipal( _
ByVal principle As CorePrincipal _
) As CorePrincipal
''' <summary>
''' Creates CorePrincipal Objects for the given Role.
''' </summary>
''' <param name="role"></param>
''' <returns></returns>
''' <remarks></remarks>
Function CreateIPrincipals( _
ByVal role As String _
) As CorePrincipal()
End Interface
End Namespace
|
thiscouldbejd/Caerus
|
_Directories/Interfaces/IPrincipalProvider.vb
|
Visual Basic
|
mit
| 1,845
|
Namespace Exterity
''' <summary>Class Representing an Exterity TV Decoder</summary>
''' <autogenerated>Generated from a T4 template. Modifications will be lost, if applicable use a partial class instead.</autogenerated>
''' <generator-date>08/02/2014 18:15:29</generator-date>
''' <generator-functions>1</generator-functions>
''' <generator-source>Caerus\_Exterity\Generated\TVDecoder.tt</generator-source>
''' <generator-template>Text-Templates\Classes\VB_Object.tt</generator-template>
''' <generator-version>1</generator-version>
<System.CodeDom.Compiler.GeneratedCode("Caerus\_Exterity\Generated\TVDecoder.tt", "1")> _
<System.Serializable()> _
Partial Public Class TVDecoder
Inherits System.Object
Implements System.IComparable
Implements System.IFormattable
Implements System.Xml.Serialization.IXmlSerializable
Implements Caerus.Snmp.ISnmpManageable
#Region " Public Constructors "
''' <summary>Default Constructor</summary>
Public Sub New()
MyBase.New()
End Sub
''' <summary>Parametered Constructor (1 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName _
)
MyBase.New()
Name = _Name
End Sub
''' <summary>Parametered Constructor (2 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
End Sub
''' <summary>Parametered Constructor (3 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
End Sub
''' <summary>Parametered Constructor (4 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
End Sub
''' <summary>Parametered Constructor (5 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
End Sub
''' <summary>Parametered Constructor (6 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
End Sub
''' <summary>Parametered Constructor (7 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64 _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
End Sub
''' <summary>Parametered Constructor (8 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64 _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
End Sub
''' <summary>Parametered Constructor (9 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64 _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
End Sub
''' <summary>Parametered Constructor (10 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64 _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
End Sub
''' <summary>Parametered Constructor (11 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64 _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
End Sub
''' <summary>Parametered Constructor (12 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64 _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
End Sub
''' <summary>Parametered Constructor (13 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64 _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
End Sub
''' <summary>Parametered Constructor (14 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
End Sub
''' <summary>Parametered Constructor (15 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
End Sub
''' <summary>Parametered Constructor (16 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
End Sub
''' <summary>Parametered Constructor (17 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
End Sub
''' <summary>Parametered Constructor (18 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType, _
ByVal _Stream As StreamType _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
Stream = _Stream
End Sub
''' <summary>Parametered Constructor (19 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType, _
ByVal _Stream As StreamType, _
ByVal _Version As System.Int32 _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
Stream = _Stream
Version = _Version
End Sub
''' <summary>Parametered Constructor (20 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType, _
ByVal _Stream As StreamType, _
ByVal _Version As System.Int32, _
ByVal _VersionName As System.String _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
Stream = _Stream
Version = _Version
VersionName = _VersionName
End Sub
''' <summary>Parametered Constructor (21 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType, _
ByVal _Stream As StreamType, _
ByVal _Version As System.Int32, _
ByVal _VersionName As System.String, _
ByVal _TotalResets As System.Int32 _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
Stream = _Stream
Version = _Version
VersionName = _VersionName
TotalResets = _TotalResets
End Sub
''' <summary>Parametered Constructor (22 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType, _
ByVal _Stream As StreamType, _
ByVal _Version As System.Int32, _
ByVal _VersionName As System.String, _
ByVal _TotalResets As System.Int32, _
ByVal _VideoInterface As VideoInterfaceType _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
Stream = _Stream
Version = _Version
VersionName = _VersionName
TotalResets = _TotalResets
VideoInterface = _VideoInterface
End Sub
''' <summary>Parametered Constructor (23 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType, _
ByVal _Stream As StreamType, _
ByVal _Version As System.Int32, _
ByVal _VersionName As System.String, _
ByVal _TotalResets As System.Int32, _
ByVal _VideoInterface As VideoInterfaceType, _
ByVal _VideoAspect As VideoAspectType _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
Stream = _Stream
Version = _Version
VersionName = _VersionName
TotalResets = _TotalResets
VideoInterface = _VideoInterface
VideoAspect = _VideoAspect
End Sub
''' <summary>Parametered Constructor (24 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType, _
ByVal _Stream As StreamType, _
ByVal _Version As System.Int32, _
ByVal _VersionName As System.String, _
ByVal _TotalResets As System.Int32, _
ByVal _VideoInterface As VideoInterfaceType, _
ByVal _VideoAspect As VideoAspectType, _
ByVal _CurrentChannelUri As System.String _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
Stream = _Stream
Version = _Version
VersionName = _VersionName
TotalResets = _TotalResets
VideoInterface = _VideoInterface
VideoAspect = _VideoAspect
CurrentChannelUri = _CurrentChannelUri
End Sub
''' <summary>Parametered Constructor (25 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType, _
ByVal _Stream As StreamType, _
ByVal _Version As System.Int32, _
ByVal _VersionName As System.String, _
ByVal _TotalResets As System.Int32, _
ByVal _VideoInterface As VideoInterfaceType, _
ByVal _VideoAspect As VideoAspectType, _
ByVal _CurrentChannelUri As System.String, _
ByVal _Groups As System.String _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
Stream = _Stream
Version = _Version
VersionName = _VersionName
TotalResets = _TotalResets
VideoInterface = _VideoInterface
VideoAspect = _VideoAspect
CurrentChannelUri = _CurrentChannelUri
Groups = _Groups
End Sub
''' <summary>Parametered Constructor (26 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType, _
ByVal _Stream As StreamType, _
ByVal _Version As System.Int32, _
ByVal _VersionName As System.String, _
ByVal _TotalResets As System.Int32, _
ByVal _VideoInterface As VideoInterfaceType, _
ByVal _VideoAspect As VideoAspectType, _
ByVal _CurrentChannelUri As System.String, _
ByVal _Groups As System.String, _
ByVal _Model As System.String _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
Stream = _Stream
Version = _Version
VersionName = _VersionName
TotalResets = _TotalResets
VideoInterface = _VideoInterface
VideoAspect = _VideoAspect
CurrentChannelUri = _CurrentChannelUri
Groups = _Groups
Model = _Model
End Sub
''' <summary>Parametered Constructor (27 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType, _
ByVal _Stream As StreamType, _
ByVal _Version As System.Int32, _
ByVal _VersionName As System.String, _
ByVal _TotalResets As System.Int32, _
ByVal _VideoInterface As VideoInterfaceType, _
ByVal _VideoAspect As VideoAspectType, _
ByVal _CurrentChannelUri As System.String, _
ByVal _Groups As System.String, _
ByVal _Model As System.String, _
ByVal _Speed As LineSpeed _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
Stream = _Stream
Version = _Version
VersionName = _VersionName
TotalResets = _TotalResets
VideoInterface = _VideoInterface
VideoAspect = _VideoAspect
CurrentChannelUri = _CurrentChannelUri
Groups = _Groups
Model = _Model
Speed = _Speed
End Sub
''' <summary>Parametered Constructor (28 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType, _
ByVal _Stream As StreamType, _
ByVal _Version As System.Int32, _
ByVal _VersionName As System.String, _
ByVal _TotalResets As System.Int32, _
ByVal _VideoInterface As VideoInterfaceType, _
ByVal _VideoAspect As VideoAspectType, _
ByVal _CurrentChannelUri As System.String, _
ByVal _Groups As System.String, _
ByVal _Model As System.String, _
ByVal _Speed As LineSpeed, _
ByVal _Duplex As LineDuplex _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
Stream = _Stream
Version = _Version
VersionName = _VersionName
TotalResets = _TotalResets
VideoInterface = _VideoInterface
VideoAspect = _VideoAspect
CurrentChannelUri = _CurrentChannelUri
Groups = _Groups
Model = _Model
Speed = _Speed
Duplex = _Duplex
End Sub
''' <summary>Parametered Constructor (29 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType, _
ByVal _Stream As StreamType, _
ByVal _Version As System.Int32, _
ByVal _VersionName As System.String, _
ByVal _TotalResets As System.Int32, _
ByVal _VideoInterface As VideoInterfaceType, _
ByVal _VideoAspect As VideoAspectType, _
ByVal _CurrentChannelUri As System.String, _
ByVal _Groups As System.String, _
ByVal _Model As System.String, _
ByVal _Speed As LineSpeed, _
ByVal _Duplex As LineDuplex, _
ByVal _AutoNegotiation As System.Boolean _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
Stream = _Stream
Version = _Version
VersionName = _VersionName
TotalResets = _TotalResets
VideoInterface = _VideoInterface
VideoAspect = _VideoAspect
CurrentChannelUri = _CurrentChannelUri
Groups = _Groups
Model = _Model
Speed = _Speed
Duplex = _Duplex
AutoNegotiation = _AutoNegotiation
End Sub
''' <summary>Parametered Constructor (30 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType, _
ByVal _Stream As StreamType, _
ByVal _Version As System.Int32, _
ByVal _VersionName As System.String, _
ByVal _TotalResets As System.Int32, _
ByVal _VideoInterface As VideoInterfaceType, _
ByVal _VideoAspect As VideoAspectType, _
ByVal _CurrentChannelUri As System.String, _
ByVal _Groups As System.String, _
ByVal _Model As System.String, _
ByVal _Speed As LineSpeed, _
ByVal _Duplex As LineDuplex, _
ByVal _AutoNegotiation As System.Boolean, _
ByVal _ScreenFormat As System.String _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
Stream = _Stream
Version = _Version
VersionName = _VersionName
TotalResets = _TotalResets
VideoInterface = _VideoInterface
VideoAspect = _VideoAspect
CurrentChannelUri = _CurrentChannelUri
Groups = _Groups
Model = _Model
Speed = _Speed
Duplex = _Duplex
AutoNegotiation = _AutoNegotiation
ScreenFormat = _ScreenFormat
End Sub
''' <summary>Parametered Constructor (31 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType, _
ByVal _Stream As StreamType, _
ByVal _Version As System.Int32, _
ByVal _VersionName As System.String, _
ByVal _TotalResets As System.Int32, _
ByVal _VideoInterface As VideoInterfaceType, _
ByVal _VideoAspect As VideoAspectType, _
ByVal _CurrentChannelUri As System.String, _
ByVal _Groups As System.String, _
ByVal _Model As System.String, _
ByVal _Speed As LineSpeed, _
ByVal _Duplex As LineDuplex, _
ByVal _AutoNegotiation As System.Boolean, _
ByVal _ScreenFormat As System.String, _
ByVal _AspectRatio As System.String _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
Stream = _Stream
Version = _Version
VersionName = _VersionName
TotalResets = _TotalResets
VideoInterface = _VideoInterface
VideoAspect = _VideoAspect
CurrentChannelUri = _CurrentChannelUri
Groups = _Groups
Model = _Model
Speed = _Speed
Duplex = _Duplex
AutoNegotiation = _AutoNegotiation
ScreenFormat = _ScreenFormat
AspectRatio = _AspectRatio
End Sub
''' <summary>Parametered Constructor (32 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType, _
ByVal _Stream As StreamType, _
ByVal _Version As System.Int32, _
ByVal _VersionName As System.String, _
ByVal _TotalResets As System.Int32, _
ByVal _VideoInterface As VideoInterfaceType, _
ByVal _VideoAspect As VideoAspectType, _
ByVal _CurrentChannelUri As System.String, _
ByVal _Groups As System.String, _
ByVal _Model As System.String, _
ByVal _Speed As LineSpeed, _
ByVal _Duplex As LineDuplex, _
ByVal _AutoNegotiation As System.Boolean, _
ByVal _ScreenFormat As System.String, _
ByVal _AspectRatio As System.String, _
ByVal _Mode As DisplayType _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
Stream = _Stream
Version = _Version
VersionName = _VersionName
TotalResets = _TotalResets
VideoInterface = _VideoInterface
VideoAspect = _VideoAspect
CurrentChannelUri = _CurrentChannelUri
Groups = _Groups
Model = _Model
Speed = _Speed
Duplex = _Duplex
AutoNegotiation = _AutoNegotiation
ScreenFormat = _ScreenFormat
AspectRatio = _AspectRatio
Mode = _Mode
End Sub
''' <summary>Parametered Constructor (33 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType, _
ByVal _Stream As StreamType, _
ByVal _Version As System.Int32, _
ByVal _VersionName As System.String, _
ByVal _TotalResets As System.Int32, _
ByVal _VideoInterface As VideoInterfaceType, _
ByVal _VideoAspect As VideoAspectType, _
ByVal _CurrentChannelUri As System.String, _
ByVal _Groups As System.String, _
ByVal _Model As System.String, _
ByVal _Speed As LineSpeed, _
ByVal _Duplex As LineDuplex, _
ByVal _AutoNegotiation As System.Boolean, _
ByVal _ScreenFormat As System.String, _
ByVal _AspectRatio As System.String, _
ByVal _Mode As DisplayType, _
ByVal _CurrentUrl As System.String _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
Stream = _Stream
Version = _Version
VersionName = _VersionName
TotalResets = _TotalResets
VideoInterface = _VideoInterface
VideoAspect = _VideoAspect
CurrentChannelUri = _CurrentChannelUri
Groups = _Groups
Model = _Model
Speed = _Speed
Duplex = _Duplex
AutoNegotiation = _AutoNegotiation
ScreenFormat = _ScreenFormat
AspectRatio = _AspectRatio
Mode = _Mode
CurrentUrl = _CurrentUrl
End Sub
''' <summary>Parametered Constructor (34 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType, _
ByVal _Stream As StreamType, _
ByVal _Version As System.Int32, _
ByVal _VersionName As System.String, _
ByVal _TotalResets As System.Int32, _
ByVal _VideoInterface As VideoInterfaceType, _
ByVal _VideoAspect As VideoAspectType, _
ByVal _CurrentChannelUri As System.String, _
ByVal _Groups As System.String, _
ByVal _Model As System.String, _
ByVal _Speed As LineSpeed, _
ByVal _Duplex As LineDuplex, _
ByVal _AutoNegotiation As System.Boolean, _
ByVal _ScreenFormat As System.String, _
ByVal _AspectRatio As System.String, _
ByVal _Mode As DisplayType, _
ByVal _CurrentUrl As System.String, _
ByVal _HomepageUrl As System.String _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
Stream = _Stream
Version = _Version
VersionName = _VersionName
TotalResets = _TotalResets
VideoInterface = _VideoInterface
VideoAspect = _VideoAspect
CurrentChannelUri = _CurrentChannelUri
Groups = _Groups
Model = _Model
Speed = _Speed
Duplex = _Duplex
AutoNegotiation = _AutoNegotiation
ScreenFormat = _ScreenFormat
AspectRatio = _AspectRatio
Mode = _Mode
CurrentUrl = _CurrentUrl
HomepageUrl = _HomepageUrl
End Sub
''' <summary>Parametered Constructor (35 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType, _
ByVal _Stream As StreamType, _
ByVal _Version As System.Int32, _
ByVal _VersionName As System.String, _
ByVal _TotalResets As System.Int32, _
ByVal _VideoInterface As VideoInterfaceType, _
ByVal _VideoAspect As VideoAspectType, _
ByVal _CurrentChannelUri As System.String, _
ByVal _Groups As System.String, _
ByVal _Model As System.String, _
ByVal _Speed As LineSpeed, _
ByVal _Duplex As LineDuplex, _
ByVal _AutoNegotiation As System.Boolean, _
ByVal _ScreenFormat As System.String, _
ByVal _AspectRatio As System.String, _
ByVal _Mode As DisplayType, _
ByVal _CurrentUrl As System.String, _
ByVal _HomepageUrl As System.String, _
ByVal _Proxy As ProxyType _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
Stream = _Stream
Version = _Version
VersionName = _VersionName
TotalResets = _TotalResets
VideoInterface = _VideoInterface
VideoAspect = _VideoAspect
CurrentChannelUri = _CurrentChannelUri
Groups = _Groups
Model = _Model
Speed = _Speed
Duplex = _Duplex
AutoNegotiation = _AutoNegotiation
ScreenFormat = _ScreenFormat
AspectRatio = _AspectRatio
Mode = _Mode
CurrentUrl = _CurrentUrl
HomepageUrl = _HomepageUrl
Proxy = _Proxy
End Sub
''' <summary>Parametered Constructor (36 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType, _
ByVal _Stream As StreamType, _
ByVal _Version As System.Int32, _
ByVal _VersionName As System.String, _
ByVal _TotalResets As System.Int32, _
ByVal _VideoInterface As VideoInterfaceType, _
ByVal _VideoAspect As VideoAspectType, _
ByVal _CurrentChannelUri As System.String, _
ByVal _Groups As System.String, _
ByVal _Model As System.String, _
ByVal _Speed As LineSpeed, _
ByVal _Duplex As LineDuplex, _
ByVal _AutoNegotiation As System.Boolean, _
ByVal _ScreenFormat As System.String, _
ByVal _AspectRatio As System.String, _
ByVal _Mode As DisplayType, _
ByVal _CurrentUrl As System.String, _
ByVal _HomepageUrl As System.String, _
ByVal _Proxy As ProxyType, _
ByVal _ProxyAddress As System.Net.IPAddress _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
Stream = _Stream
Version = _Version
VersionName = _VersionName
TotalResets = _TotalResets
VideoInterface = _VideoInterface
VideoAspect = _VideoAspect
CurrentChannelUri = _CurrentChannelUri
Groups = _Groups
Model = _Model
Speed = _Speed
Duplex = _Duplex
AutoNegotiation = _AutoNegotiation
ScreenFormat = _ScreenFormat
AspectRatio = _AspectRatio
Mode = _Mode
CurrentUrl = _CurrentUrl
HomepageUrl = _HomepageUrl
Proxy = _Proxy
ProxyAddress = _ProxyAddress
End Sub
''' <summary>Parametered Constructor (37 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType, _
ByVal _Stream As StreamType, _
ByVal _Version As System.Int32, _
ByVal _VersionName As System.String, _
ByVal _TotalResets As System.Int32, _
ByVal _VideoInterface As VideoInterfaceType, _
ByVal _VideoAspect As VideoAspectType, _
ByVal _CurrentChannelUri As System.String, _
ByVal _Groups As System.String, _
ByVal _Model As System.String, _
ByVal _Speed As LineSpeed, _
ByVal _Duplex As LineDuplex, _
ByVal _AutoNegotiation As System.Boolean, _
ByVal _ScreenFormat As System.String, _
ByVal _AspectRatio As System.String, _
ByVal _Mode As DisplayType, _
ByVal _CurrentUrl As System.String, _
ByVal _HomepageUrl As System.String, _
ByVal _Proxy As ProxyType, _
ByVal _ProxyAddress As System.Net.IPAddress, _
ByVal _ProxyPort As System.Int32 _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
Stream = _Stream
Version = _Version
VersionName = _VersionName
TotalResets = _TotalResets
VideoInterface = _VideoInterface
VideoAspect = _VideoAspect
CurrentChannelUri = _CurrentChannelUri
Groups = _Groups
Model = _Model
Speed = _Speed
Duplex = _Duplex
AutoNegotiation = _AutoNegotiation
ScreenFormat = _ScreenFormat
AspectRatio = _AspectRatio
Mode = _Mode
CurrentUrl = _CurrentUrl
HomepageUrl = _HomepageUrl
Proxy = _Proxy
ProxyAddress = _ProxyAddress
ProxyPort = _ProxyPort
End Sub
''' <summary>Parametered Constructor (38 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType, _
ByVal _Stream As StreamType, _
ByVal _Version As System.Int32, _
ByVal _VersionName As System.String, _
ByVal _TotalResets As System.Int32, _
ByVal _VideoInterface As VideoInterfaceType, _
ByVal _VideoAspect As VideoAspectType, _
ByVal _CurrentChannelUri As System.String, _
ByVal _Groups As System.String, _
ByVal _Model As System.String, _
ByVal _Speed As LineSpeed, _
ByVal _Duplex As LineDuplex, _
ByVal _AutoNegotiation As System.Boolean, _
ByVal _ScreenFormat As System.String, _
ByVal _AspectRatio As System.String, _
ByVal _Mode As DisplayType, _
ByVal _CurrentUrl As System.String, _
ByVal _HomepageUrl As System.String, _
ByVal _Proxy As ProxyType, _
ByVal _ProxyAddress As System.Net.IPAddress, _
ByVal _ProxyPort As System.Int32, _
ByVal _ProxyIgnoreList As System.String _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
Stream = _Stream
Version = _Version
VersionName = _VersionName
TotalResets = _TotalResets
VideoInterface = _VideoInterface
VideoAspect = _VideoAspect
CurrentChannelUri = _CurrentChannelUri
Groups = _Groups
Model = _Model
Speed = _Speed
Duplex = _Duplex
AutoNegotiation = _AutoNegotiation
ScreenFormat = _ScreenFormat
AspectRatio = _AspectRatio
Mode = _Mode
CurrentUrl = _CurrentUrl
HomepageUrl = _HomepageUrl
Proxy = _Proxy
ProxyAddress = _ProxyAddress
ProxyPort = _ProxyPort
ProxyIgnoreList = _ProxyIgnoreList
End Sub
''' <summary>Parametered Constructor (39 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType, _
ByVal _Stream As StreamType, _
ByVal _Version As System.Int32, _
ByVal _VersionName As System.String, _
ByVal _TotalResets As System.Int32, _
ByVal _VideoInterface As VideoInterfaceType, _
ByVal _VideoAspect As VideoAspectType, _
ByVal _CurrentChannelUri As System.String, _
ByVal _Groups As System.String, _
ByVal _Model As System.String, _
ByVal _Speed As LineSpeed, _
ByVal _Duplex As LineDuplex, _
ByVal _AutoNegotiation As System.Boolean, _
ByVal _ScreenFormat As System.String, _
ByVal _AspectRatio As System.String, _
ByVal _Mode As DisplayType, _
ByVal _CurrentUrl As System.String, _
ByVal _HomepageUrl As System.String, _
ByVal _Proxy As ProxyType, _
ByVal _ProxyAddress As System.Net.IPAddress, _
ByVal _ProxyPort As System.Int32, _
ByVal _ProxyIgnoreList As System.String, _
ByVal _BrowserToolbar As System.Boolean _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
Stream = _Stream
Version = _Version
VersionName = _VersionName
TotalResets = _TotalResets
VideoInterface = _VideoInterface
VideoAspect = _VideoAspect
CurrentChannelUri = _CurrentChannelUri
Groups = _Groups
Model = _Model
Speed = _Speed
Duplex = _Duplex
AutoNegotiation = _AutoNegotiation
ScreenFormat = _ScreenFormat
AspectRatio = _AspectRatio
Mode = _Mode
CurrentUrl = _CurrentUrl
HomepageUrl = _HomepageUrl
Proxy = _Proxy
ProxyAddress = _ProxyAddress
ProxyPort = _ProxyPort
ProxyIgnoreList = _ProxyIgnoreList
BrowserToolbar = _BrowserToolbar
End Sub
''' <summary>Parametered Constructor (40 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType, _
ByVal _Stream As StreamType, _
ByVal _Version As System.Int32, _
ByVal _VersionName As System.String, _
ByVal _TotalResets As System.Int32, _
ByVal _VideoInterface As VideoInterfaceType, _
ByVal _VideoAspect As VideoAspectType, _
ByVal _CurrentChannelUri As System.String, _
ByVal _Groups As System.String, _
ByVal _Model As System.String, _
ByVal _Speed As LineSpeed, _
ByVal _Duplex As LineDuplex, _
ByVal _AutoNegotiation As System.Boolean, _
ByVal _ScreenFormat As System.String, _
ByVal _AspectRatio As System.String, _
ByVal _Mode As DisplayType, _
ByVal _CurrentUrl As System.String, _
ByVal _HomepageUrl As System.String, _
ByVal _Proxy As ProxyType, _
ByVal _ProxyAddress As System.Net.IPAddress, _
ByVal _ProxyPort As System.Int32, _
ByVal _ProxyIgnoreList As System.String, _
ByVal _BrowserToolbar As System.Boolean, _
ByVal _StartupMode As DisplayType _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
Stream = _Stream
Version = _Version
VersionName = _VersionName
TotalResets = _TotalResets
VideoInterface = _VideoInterface
VideoAspect = _VideoAspect
CurrentChannelUri = _CurrentChannelUri
Groups = _Groups
Model = _Model
Speed = _Speed
Duplex = _Duplex
AutoNegotiation = _AutoNegotiation
ScreenFormat = _ScreenFormat
AspectRatio = _AspectRatio
Mode = _Mode
CurrentUrl = _CurrentUrl
HomepageUrl = _HomepageUrl
Proxy = _Proxy
ProxyAddress = _ProxyAddress
ProxyPort = _ProxyPort
ProxyIgnoreList = _ProxyIgnoreList
BrowserToolbar = _BrowserToolbar
StartupMode = _StartupMode
End Sub
''' <summary>Parametered Constructor (41 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType, _
ByVal _Stream As StreamType, _
ByVal _Version As System.Int32, _
ByVal _VersionName As System.String, _
ByVal _TotalResets As System.Int32, _
ByVal _VideoInterface As VideoInterfaceType, _
ByVal _VideoAspect As VideoAspectType, _
ByVal _CurrentChannelUri As System.String, _
ByVal _Groups As System.String, _
ByVal _Model As System.String, _
ByVal _Speed As LineSpeed, _
ByVal _Duplex As LineDuplex, _
ByVal _AutoNegotiation As System.Boolean, _
ByVal _ScreenFormat As System.String, _
ByVal _AspectRatio As System.String, _
ByVal _Mode As DisplayType, _
ByVal _CurrentUrl As System.String, _
ByVal _HomepageUrl As System.String, _
ByVal _Proxy As ProxyType, _
ByVal _ProxyAddress As System.Net.IPAddress, _
ByVal _ProxyPort As System.Int32, _
ByVal _ProxyIgnoreList As System.String, _
ByVal _BrowserToolbar As System.Boolean, _
ByVal _StartupMode As DisplayType, _
ByVal _Volume As System.Int32 _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
Stream = _Stream
Version = _Version
VersionName = _VersionName
TotalResets = _TotalResets
VideoInterface = _VideoInterface
VideoAspect = _VideoAspect
CurrentChannelUri = _CurrentChannelUri
Groups = _Groups
Model = _Model
Speed = _Speed
Duplex = _Duplex
AutoNegotiation = _AutoNegotiation
ScreenFormat = _ScreenFormat
AspectRatio = _AspectRatio
Mode = _Mode
CurrentUrl = _CurrentUrl
HomepageUrl = _HomepageUrl
Proxy = _Proxy
ProxyAddress = _ProxyAddress
ProxyPort = _ProxyPort
ProxyIgnoreList = _ProxyIgnoreList
BrowserToolbar = _BrowserToolbar
StartupMode = _StartupMode
Volume = _Volume
End Sub
''' <summary>Parametered Constructor (42 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType, _
ByVal _Stream As StreamType, _
ByVal _Version As System.Int32, _
ByVal _VersionName As System.String, _
ByVal _TotalResets As System.Int32, _
ByVal _VideoInterface As VideoInterfaceType, _
ByVal _VideoAspect As VideoAspectType, _
ByVal _CurrentChannelUri As System.String, _
ByVal _Groups As System.String, _
ByVal _Model As System.String, _
ByVal _Speed As LineSpeed, _
ByVal _Duplex As LineDuplex, _
ByVal _AutoNegotiation As System.Boolean, _
ByVal _ScreenFormat As System.String, _
ByVal _AspectRatio As System.String, _
ByVal _Mode As DisplayType, _
ByVal _CurrentUrl As System.String, _
ByVal _HomepageUrl As System.String, _
ByVal _Proxy As ProxyType, _
ByVal _ProxyAddress As System.Net.IPAddress, _
ByVal _ProxyPort As System.Int32, _
ByVal _ProxyIgnoreList As System.String, _
ByVal _BrowserToolbar As System.Boolean, _
ByVal _StartupMode As DisplayType, _
ByVal _Volume As System.Int32, _
ByVal _AudioLanguage As System.String _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
Stream = _Stream
Version = _Version
VersionName = _VersionName
TotalResets = _TotalResets
VideoInterface = _VideoInterface
VideoAspect = _VideoAspect
CurrentChannelUri = _CurrentChannelUri
Groups = _Groups
Model = _Model
Speed = _Speed
Duplex = _Duplex
AutoNegotiation = _AutoNegotiation
ScreenFormat = _ScreenFormat
AspectRatio = _AspectRatio
Mode = _Mode
CurrentUrl = _CurrentUrl
HomepageUrl = _HomepageUrl
Proxy = _Proxy
ProxyAddress = _ProxyAddress
ProxyPort = _ProxyPort
ProxyIgnoreList = _ProxyIgnoreList
BrowserToolbar = _BrowserToolbar
StartupMode = _StartupMode
Volume = _Volume
AudioLanguage = _AudioLanguage
End Sub
''' <summary>Parametered Constructor (43 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType, _
ByVal _Stream As StreamType, _
ByVal _Version As System.Int32, _
ByVal _VersionName As System.String, _
ByVal _TotalResets As System.Int32, _
ByVal _VideoInterface As VideoInterfaceType, _
ByVal _VideoAspect As VideoAspectType, _
ByVal _CurrentChannelUri As System.String, _
ByVal _Groups As System.String, _
ByVal _Model As System.String, _
ByVal _Speed As LineSpeed, _
ByVal _Duplex As LineDuplex, _
ByVal _AutoNegotiation As System.Boolean, _
ByVal _ScreenFormat As System.String, _
ByVal _AspectRatio As System.String, _
ByVal _Mode As DisplayType, _
ByVal _CurrentUrl As System.String, _
ByVal _HomepageUrl As System.String, _
ByVal _Proxy As ProxyType, _
ByVal _ProxyAddress As System.Net.IPAddress, _
ByVal _ProxyPort As System.Int32, _
ByVal _ProxyIgnoreList As System.String, _
ByVal _BrowserToolbar As System.Boolean, _
ByVal _StartupMode As DisplayType, _
ByVal _Volume As System.Int32, _
ByVal _AudioLanguage As System.String, _
ByVal _IRInputName As System.String _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
Stream = _Stream
Version = _Version
VersionName = _VersionName
TotalResets = _TotalResets
VideoInterface = _VideoInterface
VideoAspect = _VideoAspect
CurrentChannelUri = _CurrentChannelUri
Groups = _Groups
Model = _Model
Speed = _Speed
Duplex = _Duplex
AutoNegotiation = _AutoNegotiation
ScreenFormat = _ScreenFormat
AspectRatio = _AspectRatio
Mode = _Mode
CurrentUrl = _CurrentUrl
HomepageUrl = _HomepageUrl
Proxy = _Proxy
ProxyAddress = _ProxyAddress
ProxyPort = _ProxyPort
ProxyIgnoreList = _ProxyIgnoreList
BrowserToolbar = _BrowserToolbar
StartupMode = _StartupMode
Volume = _Volume
AudioLanguage = _AudioLanguage
IRInputName = _IRInputName
End Sub
''' <summary>Parametered Constructor (44 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType, _
ByVal _Stream As StreamType, _
ByVal _Version As System.Int32, _
ByVal _VersionName As System.String, _
ByVal _TotalResets As System.Int32, _
ByVal _VideoInterface As VideoInterfaceType, _
ByVal _VideoAspect As VideoAspectType, _
ByVal _CurrentChannelUri As System.String, _
ByVal _Groups As System.String, _
ByVal _Model As System.String, _
ByVal _Speed As LineSpeed, _
ByVal _Duplex As LineDuplex, _
ByVal _AutoNegotiation As System.Boolean, _
ByVal _ScreenFormat As System.String, _
ByVal _AspectRatio As System.String, _
ByVal _Mode As DisplayType, _
ByVal _CurrentUrl As System.String, _
ByVal _HomepageUrl As System.String, _
ByVal _Proxy As ProxyType, _
ByVal _ProxyAddress As System.Net.IPAddress, _
ByVal _ProxyPort As System.Int32, _
ByVal _ProxyIgnoreList As System.String, _
ByVal _BrowserToolbar As System.Boolean, _
ByVal _StartupMode As DisplayType, _
ByVal _Volume As System.Int32, _
ByVal _AudioLanguage As System.String, _
ByVal _IRInputName As System.String, _
ByVal _IROutputName As System.String _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
Stream = _Stream
Version = _Version
VersionName = _VersionName
TotalResets = _TotalResets
VideoInterface = _VideoInterface
VideoAspect = _VideoAspect
CurrentChannelUri = _CurrentChannelUri
Groups = _Groups
Model = _Model
Speed = _Speed
Duplex = _Duplex
AutoNegotiation = _AutoNegotiation
ScreenFormat = _ScreenFormat
AspectRatio = _AspectRatio
Mode = _Mode
CurrentUrl = _CurrentUrl
HomepageUrl = _HomepageUrl
Proxy = _Proxy
ProxyAddress = _ProxyAddress
ProxyPort = _ProxyPort
ProxyIgnoreList = _ProxyIgnoreList
BrowserToolbar = _BrowserToolbar
StartupMode = _StartupMode
Volume = _Volume
AudioLanguage = _AudioLanguage
IRInputName = _IRInputName
IROutputName = _IROutputName
End Sub
''' <summary>Parametered Constructor (45 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType, _
ByVal _Stream As StreamType, _
ByVal _Version As System.Int32, _
ByVal _VersionName As System.String, _
ByVal _TotalResets As System.Int32, _
ByVal _VideoInterface As VideoInterfaceType, _
ByVal _VideoAspect As VideoAspectType, _
ByVal _CurrentChannelUri As System.String, _
ByVal _Groups As System.String, _
ByVal _Model As System.String, _
ByVal _Speed As LineSpeed, _
ByVal _Duplex As LineDuplex, _
ByVal _AutoNegotiation As System.Boolean, _
ByVal _ScreenFormat As System.String, _
ByVal _AspectRatio As System.String, _
ByVal _Mode As DisplayType, _
ByVal _CurrentUrl As System.String, _
ByVal _HomepageUrl As System.String, _
ByVal _Proxy As ProxyType, _
ByVal _ProxyAddress As System.Net.IPAddress, _
ByVal _ProxyPort As System.Int32, _
ByVal _ProxyIgnoreList As System.String, _
ByVal _BrowserToolbar As System.Boolean, _
ByVal _StartupMode As DisplayType, _
ByVal _Volume As System.Int32, _
ByVal _AudioLanguage As System.String, _
ByVal _IRInputName As System.String, _
ByVal _IROutputName As System.String, _
ByVal _IRInput As System.Boolean _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
Stream = _Stream
Version = _Version
VersionName = _VersionName
TotalResets = _TotalResets
VideoInterface = _VideoInterface
VideoAspect = _VideoAspect
CurrentChannelUri = _CurrentChannelUri
Groups = _Groups
Model = _Model
Speed = _Speed
Duplex = _Duplex
AutoNegotiation = _AutoNegotiation
ScreenFormat = _ScreenFormat
AspectRatio = _AspectRatio
Mode = _Mode
CurrentUrl = _CurrentUrl
HomepageUrl = _HomepageUrl
Proxy = _Proxy
ProxyAddress = _ProxyAddress
ProxyPort = _ProxyPort
ProxyIgnoreList = _ProxyIgnoreList
BrowserToolbar = _BrowserToolbar
StartupMode = _StartupMode
Volume = _Volume
AudioLanguage = _AudioLanguage
IRInputName = _IRInputName
IROutputName = _IROutputName
IRInput = _IRInput
End Sub
''' <summary>Parametered Constructor (46 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType, _
ByVal _Stream As StreamType, _
ByVal _Version As System.Int32, _
ByVal _VersionName As System.String, _
ByVal _TotalResets As System.Int32, _
ByVal _VideoInterface As VideoInterfaceType, _
ByVal _VideoAspect As VideoAspectType, _
ByVal _CurrentChannelUri As System.String, _
ByVal _Groups As System.String, _
ByVal _Model As System.String, _
ByVal _Speed As LineSpeed, _
ByVal _Duplex As LineDuplex, _
ByVal _AutoNegotiation As System.Boolean, _
ByVal _ScreenFormat As System.String, _
ByVal _AspectRatio As System.String, _
ByVal _Mode As DisplayType, _
ByVal _CurrentUrl As System.String, _
ByVal _HomepageUrl As System.String, _
ByVal _Proxy As ProxyType, _
ByVal _ProxyAddress As System.Net.IPAddress, _
ByVal _ProxyPort As System.Int32, _
ByVal _ProxyIgnoreList As System.String, _
ByVal _BrowserToolbar As System.Boolean, _
ByVal _StartupMode As DisplayType, _
ByVal _Volume As System.Int32, _
ByVal _AudioLanguage As System.String, _
ByVal _IRInputName As System.String, _
ByVal _IROutputName As System.String, _
ByVal _IRInput As System.Boolean, _
ByVal _IROutput As System.Boolean _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
Stream = _Stream
Version = _Version
VersionName = _VersionName
TotalResets = _TotalResets
VideoInterface = _VideoInterface
VideoAspect = _VideoAspect
CurrentChannelUri = _CurrentChannelUri
Groups = _Groups
Model = _Model
Speed = _Speed
Duplex = _Duplex
AutoNegotiation = _AutoNegotiation
ScreenFormat = _ScreenFormat
AspectRatio = _AspectRatio
Mode = _Mode
CurrentUrl = _CurrentUrl
HomepageUrl = _HomepageUrl
Proxy = _Proxy
ProxyAddress = _ProxyAddress
ProxyPort = _ProxyPort
ProxyIgnoreList = _ProxyIgnoreList
BrowserToolbar = _BrowserToolbar
StartupMode = _StartupMode
Volume = _Volume
AudioLanguage = _AudioLanguage
IRInputName = _IRInputName
IROutputName = _IROutputName
IRInput = _IRInput
IROutput = _IROutput
End Sub
''' <summary>Parametered Constructor (47 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType, _
ByVal _Stream As StreamType, _
ByVal _Version As System.Int32, _
ByVal _VersionName As System.String, _
ByVal _TotalResets As System.Int32, _
ByVal _VideoInterface As VideoInterfaceType, _
ByVal _VideoAspect As VideoAspectType, _
ByVal _CurrentChannelUri As System.String, _
ByVal _Groups As System.String, _
ByVal _Model As System.String, _
ByVal _Speed As LineSpeed, _
ByVal _Duplex As LineDuplex, _
ByVal _AutoNegotiation As System.Boolean, _
ByVal _ScreenFormat As System.String, _
ByVal _AspectRatio As System.String, _
ByVal _Mode As DisplayType, _
ByVal _CurrentUrl As System.String, _
ByVal _HomepageUrl As System.String, _
ByVal _Proxy As ProxyType, _
ByVal _ProxyAddress As System.Net.IPAddress, _
ByVal _ProxyPort As System.Int32, _
ByVal _ProxyIgnoreList As System.String, _
ByVal _BrowserToolbar As System.Boolean, _
ByVal _StartupMode As DisplayType, _
ByVal _Volume As System.Int32, _
ByVal _AudioLanguage As System.String, _
ByVal _IRInputName As System.String, _
ByVal _IROutputName As System.String, _
ByVal _IRInput As System.Boolean, _
ByVal _IROutput As System.Boolean, _
ByVal _LedStatus As System.Boolean _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
Stream = _Stream
Version = _Version
VersionName = _VersionName
TotalResets = _TotalResets
VideoInterface = _VideoInterface
VideoAspect = _VideoAspect
CurrentChannelUri = _CurrentChannelUri
Groups = _Groups
Model = _Model
Speed = _Speed
Duplex = _Duplex
AutoNegotiation = _AutoNegotiation
ScreenFormat = _ScreenFormat
AspectRatio = _AspectRatio
Mode = _Mode
CurrentUrl = _CurrentUrl
HomepageUrl = _HomepageUrl
Proxy = _Proxy
ProxyAddress = _ProxyAddress
ProxyPort = _ProxyPort
ProxyIgnoreList = _ProxyIgnoreList
BrowserToolbar = _BrowserToolbar
StartupMode = _StartupMode
Volume = _Volume
AudioLanguage = _AudioLanguage
IRInputName = _IRInputName
IROutputName = _IROutputName
IRInput = _IRInput
IROutput = _IROutput
LedStatus = _LedStatus
End Sub
''' <summary>Parametered Constructor (48 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType, _
ByVal _Stream As StreamType, _
ByVal _Version As System.Int32, _
ByVal _VersionName As System.String, _
ByVal _TotalResets As System.Int32, _
ByVal _VideoInterface As VideoInterfaceType, _
ByVal _VideoAspect As VideoAspectType, _
ByVal _CurrentChannelUri As System.String, _
ByVal _Groups As System.String, _
ByVal _Model As System.String, _
ByVal _Speed As LineSpeed, _
ByVal _Duplex As LineDuplex, _
ByVal _AutoNegotiation As System.Boolean, _
ByVal _ScreenFormat As System.String, _
ByVal _AspectRatio As System.String, _
ByVal _Mode As DisplayType, _
ByVal _CurrentUrl As System.String, _
ByVal _HomepageUrl As System.String, _
ByVal _Proxy As ProxyType, _
ByVal _ProxyAddress As System.Net.IPAddress, _
ByVal _ProxyPort As System.Int32, _
ByVal _ProxyIgnoreList As System.String, _
ByVal _BrowserToolbar As System.Boolean, _
ByVal _StartupMode As DisplayType, _
ByVal _Volume As System.Int32, _
ByVal _AudioLanguage As System.String, _
ByVal _IRInputName As System.String, _
ByVal _IROutputName As System.String, _
ByVal _IRInput As System.Boolean, _
ByVal _IROutput As System.Boolean, _
ByVal _LedStatus As System.Boolean, _
ByVal _Subtitles As System.Boolean _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
Stream = _Stream
Version = _Version
VersionName = _VersionName
TotalResets = _TotalResets
VideoInterface = _VideoInterface
VideoAspect = _VideoAspect
CurrentChannelUri = _CurrentChannelUri
Groups = _Groups
Model = _Model
Speed = _Speed
Duplex = _Duplex
AutoNegotiation = _AutoNegotiation
ScreenFormat = _ScreenFormat
AspectRatio = _AspectRatio
Mode = _Mode
CurrentUrl = _CurrentUrl
HomepageUrl = _HomepageUrl
Proxy = _Proxy
ProxyAddress = _ProxyAddress
ProxyPort = _ProxyPort
ProxyIgnoreList = _ProxyIgnoreList
BrowserToolbar = _BrowserToolbar
StartupMode = _StartupMode
Volume = _Volume
AudioLanguage = _AudioLanguage
IRInputName = _IRInputName
IROutputName = _IROutputName
IRInput = _IRInput
IROutput = _IROutput
LedStatus = _LedStatus
Subtitles = _Subtitles
End Sub
''' <summary>Parametered Constructor (49 Parameters)</summary>
Public Sub New( _
ByVal _Name As DeviceName, _
ByVal _SnmpCommunity As System.String, _
ByVal _Description As System.String, _
ByVal _UpTime As TimePeriod, _
ByVal _Contact As System.String, _
ByVal _Location As Location, _
ByVal _Services As System.Int64, _
ByVal _TcpCurrentConnections As System.Int64, _
ByVal _InDatagramsDiscarded As System.Int64, _
ByVal _OutDatagramsDiscards As System.Int64, _
ByVal _InDatagramsDelivered As System.Int64, _
ByVal _OutDatagramsRequests As System.Int64, _
ByVal _InterfaceCount As System.Int64, _
ByVal _Interfaces As NetworkInterfaceCollection, _
ByVal _TFTPServer As System.Net.IPAddress, _
ByVal _SerialNumber As System.Net.NetworkInformation.PhysicalAddress, _
ByVal _Type As DeviceType, _
ByVal _Stream As StreamType, _
ByVal _Version As System.Int32, _
ByVal _VersionName As System.String, _
ByVal _TotalResets As System.Int32, _
ByVal _VideoInterface As VideoInterfaceType, _
ByVal _VideoAspect As VideoAspectType, _
ByVal _CurrentChannelUri As System.String, _
ByVal _Groups As System.String, _
ByVal _Model As System.String, _
ByVal _Speed As LineSpeed, _
ByVal _Duplex As LineDuplex, _
ByVal _AutoNegotiation As System.Boolean, _
ByVal _ScreenFormat As System.String, _
ByVal _AspectRatio As System.String, _
ByVal _Mode As DisplayType, _
ByVal _CurrentUrl As System.String, _
ByVal _HomepageUrl As System.String, _
ByVal _Proxy As ProxyType, _
ByVal _ProxyAddress As System.Net.IPAddress, _
ByVal _ProxyPort As System.Int32, _
ByVal _ProxyIgnoreList As System.String, _
ByVal _BrowserToolbar As System.Boolean, _
ByVal _StartupMode As DisplayType, _
ByVal _Volume As System.Int32, _
ByVal _AudioLanguage As System.String, _
ByVal _IRInputName As System.String, _
ByVal _IROutputName As System.String, _
ByVal _IRInput As System.Boolean, _
ByVal _IROutput As System.Boolean, _
ByVal _LedStatus As System.Boolean, _
ByVal _Subtitles As System.Boolean, _
ByVal _Channels As TVChannelCollection _
)
MyBase.New()
Name = _Name
SnmpCommunity = _SnmpCommunity
Description = _Description
UpTime = _UpTime
Contact = _Contact
Location = _Location
Services = _Services
TcpCurrentConnections = _TcpCurrentConnections
InDatagramsDiscarded = _InDatagramsDiscarded
OutDatagramsDiscards = _OutDatagramsDiscards
InDatagramsDelivered = _InDatagramsDelivered
OutDatagramsRequests = _OutDatagramsRequests
InterfaceCount = _InterfaceCount
Interfaces = _Interfaces
TFTPServer = _TFTPServer
SerialNumber = _SerialNumber
[Type] = _Type
Stream = _Stream
Version = _Version
VersionName = _VersionName
TotalResets = _TotalResets
VideoInterface = _VideoInterface
VideoAspect = _VideoAspect
CurrentChannelUri = _CurrentChannelUri
Groups = _Groups
Model = _Model
Speed = _Speed
Duplex = _Duplex
AutoNegotiation = _AutoNegotiation
ScreenFormat = _ScreenFormat
AspectRatio = _AspectRatio
Mode = _Mode
CurrentUrl = _CurrentUrl
HomepageUrl = _HomepageUrl
Proxy = _Proxy
ProxyAddress = _ProxyAddress
ProxyPort = _ProxyPort
ProxyIgnoreList = _ProxyIgnoreList
BrowserToolbar = _BrowserToolbar
StartupMode = _StartupMode
Volume = _Volume
AudioLanguage = _AudioLanguage
IRInputName = _IRInputName
IROutputName = _IROutputName
IRInput = _IRInput
IROutput = _IROutput
LedStatus = _LedStatus
Subtitles = _Subtitles
Channels = _Channels
End Sub
#End Region
#Region " Class Plumbing/Interface Code "
#Region " IComparable Implementation "
#Region " Public Methods "
''' <summary>Comparison Method</summary>
Public Overridable Function IComparable_CompareTo( _
ByVal value As System.Object _
) As System.Int32 Implements System.IComparable.CompareTo
Dim typed_Value As TVDecoder = TryCast(value, TVDecoder)
If typed_Value Is Nothing Then
Throw New ArgumentException(String.Format("Value is not of comparable type: {0}", value.GetType.Name), "Value")
Else
Dim return_Value As Integer = 0
If Not Name Is Nothing Then return_Value = DirectCast(Name, System.IComparable).CompareTo(typed_Value.Name)
If return_Value <> 0 Then Return return_Value
Return return_Value
End If
End Function
#End Region
#End Region
#Region " IFormattable Implementation "
#Region " Public Constants "
''' <summary>Public Shared Reference to the Name of the Property: AsString</summary>
''' <remarks></remarks>
Public Const PROPERTY_ASSTRING As String = "AsString"
#End Region
#Region " Public Properties "
''' <summary></summary>
''' <remarks></remarks>
Public ReadOnly Property AsString() As System.String
Get
Return Me.ToString()
End Get
End Property
#End Region
#Region " Public Shared Methods "
#End Region
#Region " Public Methods "
Public Overloads Overrides Function ToString() As String
Return Me.ToString(String.Empty, Nothing)
End Function
Public Overloads Function ToString( _
ByVal format As String _
) As String
Return String.Empty
End Function
Public Overloads Function ToString( _
ByVal format As String, _
ByVal formatProvider As System.IFormatProvider _
) As String Implements System.IFormattable.ToString
Return String.Empty
End Function
#End Region
#End Region
#Region " IXmlSerialisable Implementation "
#Region " Public Methods "
''' <summary>Method to Return Schema Depicting Object/Class</summary>
''' <remarks></remarks>
Public Function IXmlSerialisable_GetSchema() As System.Xml.Schema.XmlSchema Implements System.Xml.Serialization.IXmlSerializable.GetSchema
Return Leviathan.Configuration.XmlSerialiser.GenerateSchema(Me.GetType)
End Function
''' <summary></summary>
''' <remarks></remarks>
Public Sub IXmlSerialisable_ReadXml( _
ByVal reader As System.Xml.XmlReader _
) Implements System.Xml.Serialization.IXmlSerializable.ReadXml
Leviathan.Configuration.XmlSerialiser.ReadXml(Me, reader)
End Sub
''' <summary></summary>
''' <remarks></remarks>
Public Sub IXmlSerialisable_WriteXml( _
ByVal writer As System.Xml.XmlWriter _
) Implements System.Xml.Serialization.IXmlSerializable.WriteXml
Leviathan.Configuration.XmlSerialiser.WriteXml(Me, writer)
End Sub
#End Region
#End Region
#Region " ISnmpManageable Implementation "
#Region " Public Properties "
''' <summary></summary>
''' <remarks></remarks>
Public ReadOnly Property ISnmpManageable_Target() As System.Net.IPAddress() Implements Caerus.Snmp.ISnmpManageable.Target
Get
Return Name.IpAddresses
End Get
End Property
''' <summary></summary>
''' <remarks></remarks>
Public ReadOnly Property ISnmpManageable_Community() As System.String Implements Caerus.Snmp.ISnmpManageable.Community
Get
Return SnmpCommunity
End Get
End Property
#End Region
#End Region
#End Region
#Region " Public Constants "
''' <summary>Public Shared Reference to the Name of the Property: Name</summary>
''' <remarks></remarks>
Public Const PROPERTY_NAME As String = "Name"
''' <summary>Public Shared Reference to the Name of the Property: SnmpCommunity</summary>
''' <remarks></remarks>
Public Const PROPERTY_SNMPCOMMUNITY As String = "SnmpCommunity"
''' <summary>Public Shared Reference to the Name of the Property: Description</summary>
''' <remarks></remarks>
Public Const PROPERTY_DESCRIPTION As String = "Description"
''' <summary>Public Shared Reference to the Name of the Property: UpTime</summary>
''' <remarks></remarks>
Public Const PROPERTY_UPTIME As String = "UpTime"
''' <summary>Public Shared Reference to the Name of the Property: Contact</summary>
''' <remarks></remarks>
Public Const PROPERTY_CONTACT As String = "Contact"
''' <summary>Public Shared Reference to the Name of the Property: Location</summary>
''' <remarks></remarks>
Public Const PROPERTY_LOCATION As String = "Location"
''' <summary>Public Shared Reference to the Name of the Property: Services</summary>
''' <remarks></remarks>
Public Const PROPERTY_SERVICES As String = "Services"
''' <summary>Public Shared Reference to the Name of the Property: TcpCurrentConnections</summary>
''' <remarks></remarks>
Public Const PROPERTY_TCPCURRENTCONNECTIONS As String = "TcpCurrentConnections"
''' <summary>Public Shared Reference to the Name of the Property: InDatagramsDiscarded</summary>
''' <remarks></remarks>
Public Const PROPERTY_INDATAGRAMSDISCARDED As String = "InDatagramsDiscarded"
''' <summary>Public Shared Reference to the Name of the Property: OutDatagramsDiscards</summary>
''' <remarks></remarks>
Public Const PROPERTY_OUTDATAGRAMSDISCARDS As String = "OutDatagramsDiscards"
''' <summary>Public Shared Reference to the Name of the Property: InDatagramsDelivered</summary>
''' <remarks></remarks>
Public Const PROPERTY_INDATAGRAMSDELIVERED As String = "InDatagramsDelivered"
''' <summary>Public Shared Reference to the Name of the Property: OutDatagramsRequests</summary>
''' <remarks></remarks>
Public Const PROPERTY_OUTDATAGRAMSREQUESTS As String = "OutDatagramsRequests"
''' <summary>Public Shared Reference to the Name of the Property: InterfaceCount</summary>
''' <remarks></remarks>
Public Const PROPERTY_INTERFACECOUNT As String = "InterfaceCount"
''' <summary>Public Shared Reference to the Name of the Property: Interfaces</summary>
''' <remarks></remarks>
Public Const PROPERTY_INTERFACES As String = "Interfaces"
''' <summary>Public Shared Reference to the Name of the Property: TFTPServer</summary>
''' <remarks></remarks>
Public Const PROPERTY_TFTPSERVER As String = "TFTPServer"
''' <summary>Public Shared Reference to the Name of the Property: SerialNumber</summary>
''' <remarks></remarks>
Public Const PROPERTY_SERIALNUMBER As String = "SerialNumber"
''' <summary>Public Shared Reference to the Name of the Property: Type</summary>
''' <remarks></remarks>
Public Const PROPERTY_TYPE As String = "Type"
''' <summary>Public Shared Reference to the Name of the Property: Stream</summary>
''' <remarks></remarks>
Public Const PROPERTY_STREAM As String = "Stream"
''' <summary>Public Shared Reference to the Name of the Property: Version</summary>
''' <remarks></remarks>
Public Const PROPERTY_VERSION As String = "Version"
''' <summary>Public Shared Reference to the Name of the Property: VersionName</summary>
''' <remarks></remarks>
Public Const PROPERTY_VERSIONNAME As String = "VersionName"
''' <summary>Public Shared Reference to the Name of the Property: TotalResets</summary>
''' <remarks></remarks>
Public Const PROPERTY_TOTALRESETS As String = "TotalResets"
''' <summary>Public Shared Reference to the Name of the Property: VideoInterface</summary>
''' <remarks></remarks>
Public Const PROPERTY_VIDEOINTERFACE As String = "VideoInterface"
''' <summary>Public Shared Reference to the Name of the Property: VideoAspect</summary>
''' <remarks></remarks>
Public Const PROPERTY_VIDEOASPECT As String = "VideoAspect"
''' <summary>Public Shared Reference to the Name of the Property: CurrentChannelUri</summary>
''' <remarks></remarks>
Public Const PROPERTY_CURRENTCHANNELURI As String = "CurrentChannelUri"
''' <summary>Public Shared Reference to the Name of the Property: Groups</summary>
''' <remarks></remarks>
Public Const PROPERTY_GROUPS As String = "Groups"
''' <summary>Public Shared Reference to the Name of the Property: Model</summary>
''' <remarks></remarks>
Public Const PROPERTY_MODEL As String = "Model"
''' <summary>Public Shared Reference to the Name of the Property: Speed</summary>
''' <remarks></remarks>
Public Const PROPERTY_SPEED As String = "Speed"
''' <summary>Public Shared Reference to the Name of the Property: Duplex</summary>
''' <remarks></remarks>
Public Const PROPERTY_DUPLEX As String = "Duplex"
''' <summary>Public Shared Reference to the Name of the Property: AutoNegotiation</summary>
''' <remarks></remarks>
Public Const PROPERTY_AUTONEGOTIATION As String = "AutoNegotiation"
''' <summary>Public Shared Reference to the Name of the Property: ScreenFormat</summary>
''' <remarks></remarks>
Public Const PROPERTY_SCREENFORMAT As String = "ScreenFormat"
''' <summary>Public Shared Reference to the Name of the Property: AspectRatio</summary>
''' <remarks></remarks>
Public Const PROPERTY_ASPECTRATIO As String = "AspectRatio"
''' <summary>Public Shared Reference to the Name of the Property: Mode</summary>
''' <remarks></remarks>
Public Const PROPERTY_MODE As String = "Mode"
''' <summary>Public Shared Reference to the Name of the Property: CurrentUrl</summary>
''' <remarks></remarks>
Public Const PROPERTY_CURRENTURL As String = "CurrentUrl"
''' <summary>Public Shared Reference to the Name of the Property: HomepageUrl</summary>
''' <remarks></remarks>
Public Const PROPERTY_HOMEPAGEURL As String = "HomepageUrl"
''' <summary>Public Shared Reference to the Name of the Property: Proxy</summary>
''' <remarks></remarks>
Public Const PROPERTY_PROXY As String = "Proxy"
''' <summary>Public Shared Reference to the Name of the Property: ProxyAddress</summary>
''' <remarks></remarks>
Public Const PROPERTY_PROXYADDRESS As String = "ProxyAddress"
''' <summary>Public Shared Reference to the Name of the Property: ProxyPort</summary>
''' <remarks></remarks>
Public Const PROPERTY_PROXYPORT As String = "ProxyPort"
''' <summary>Public Shared Reference to the Name of the Property: ProxyIgnoreList</summary>
''' <remarks></remarks>
Public Const PROPERTY_PROXYIGNORELIST As String = "ProxyIgnoreList"
''' <summary>Public Shared Reference to the Name of the Property: BrowserToolbar</summary>
''' <remarks></remarks>
Public Const PROPERTY_BROWSERTOOLBAR As String = "BrowserToolbar"
''' <summary>Public Shared Reference to the Name of the Property: StartupMode</summary>
''' <remarks></remarks>
Public Const PROPERTY_STARTUPMODE As String = "StartupMode"
''' <summary>Public Shared Reference to the Name of the Property: Volume</summary>
''' <remarks></remarks>
Public Const PROPERTY_VOLUME As String = "Volume"
''' <summary>Public Shared Reference to the Name of the Property: AudioLanguage</summary>
''' <remarks></remarks>
Public Const PROPERTY_AUDIOLANGUAGE As String = "AudioLanguage"
''' <summary>Public Shared Reference to the Name of the Property: IRInputName</summary>
''' <remarks></remarks>
Public Const PROPERTY_IRINPUTNAME As String = "IRInputName"
''' <summary>Public Shared Reference to the Name of the Property: IROutputName</summary>
''' <remarks></remarks>
Public Const PROPERTY_IROUTPUTNAME As String = "IROutputName"
''' <summary>Public Shared Reference to the Name of the Property: IRInput</summary>
''' <remarks></remarks>
Public Const PROPERTY_IRINPUT As String = "IRInput"
''' <summary>Public Shared Reference to the Name of the Property: IROutput</summary>
''' <remarks></remarks>
Public Const PROPERTY_IROUTPUT As String = "IROutput"
''' <summary>Public Shared Reference to the Name of the Property: LedStatus</summary>
''' <remarks></remarks>
Public Const PROPERTY_LEDSTATUS As String = "LedStatus"
''' <summary>Public Shared Reference to the Name of the Property: Subtitles</summary>
''' <remarks></remarks>
Public Const PROPERTY_SUBTITLES As String = "Subtitles"
''' <summary>Public Shared Reference to the Name of the Property: Channels</summary>
''' <remarks></remarks>
Public Const PROPERTY_CHANNELS As String = "Channels"
#End Region
#Region " Private Variables "
''' <summary>Private Data Storage Variable for Property: Name</summary>
''' <remarks></remarks>
Private m_Name As DeviceName
''' <summary>Private Data Storage Variable for Property: SnmpCommunity</summary>
''' <remarks></remarks>
Private m_SnmpCommunity As System.String
''' <summary>Private Data Storage Variable for Property: Description</summary>
''' <remarks></remarks>
Private m_Description As System.String
''' <summary>Private Data Storage Variable for Property: UpTime</summary>
''' <remarks></remarks>
Private m_UpTime As TimePeriod
''' <summary>Private Data Storage Variable for Property: Contact</summary>
''' <remarks></remarks>
Private m_Contact As System.String
''' <summary>Private Data Storage Variable for Property: Location</summary>
''' <remarks></remarks>
Private m_Location As Location
''' <summary>Private Data Storage Variable for Property: Services</summary>
''' <remarks></remarks>
Private m_Services As System.Int64
''' <summary>Private Data Storage Variable for Property: TcpCurrentConnections</summary>
''' <remarks></remarks>
Private m_TcpCurrentConnections As System.Int64
''' <summary>Private Data Storage Variable for Property: InDatagramsDiscarded</summary>
''' <remarks></remarks>
Private m_InDatagramsDiscarded As System.Int64
''' <summary>Private Data Storage Variable for Property: OutDatagramsDiscards</summary>
''' <remarks></remarks>
Private m_OutDatagramsDiscards As System.Int64
''' <summary>Private Data Storage Variable for Property: InDatagramsDelivered</summary>
''' <remarks></remarks>
Private m_InDatagramsDelivered As System.Int64
''' <summary>Private Data Storage Variable for Property: OutDatagramsRequests</summary>
''' <remarks></remarks>
Private m_OutDatagramsRequests As System.Int64
''' <summary>Private Data Storage Variable for Property: InterfaceCount</summary>
''' <remarks></remarks>
Private m_InterfaceCount As System.Int64
''' <summary>Private Data Storage Variable for Property: Interfaces</summary>
''' <remarks></remarks>
Private m_Interfaces As NetworkInterfaceCollection
''' <summary>Private Data Storage Variable for Property: TFTPServer</summary>
''' <remarks></remarks>
Private m_TFTPServer As System.Net.IPAddress
''' <summary>Private Data Storage Variable for Property: SerialNumber</summary>
''' <remarks></remarks>
Private m_SerialNumber As System.Net.NetworkInformation.PhysicalAddress
''' <summary>Private Data Storage Variable for Property: Type</summary>
''' <remarks></remarks>
Private m_Type As DeviceType
''' <summary>Private Data Storage Variable for Property: Stream</summary>
''' <remarks></remarks>
Private m_Stream As StreamType
''' <summary>Private Data Storage Variable for Property: Version</summary>
''' <remarks></remarks>
Private m_Version As System.Int32
''' <summary>Private Data Storage Variable for Property: VersionName</summary>
''' <remarks></remarks>
Private m_VersionName As System.String
''' <summary>Private Data Storage Variable for Property: TotalResets</summary>
''' <remarks></remarks>
Private m_TotalResets As System.Int32
''' <summary>Private Data Storage Variable for Property: VideoInterface</summary>
''' <remarks></remarks>
Private m_VideoInterface As VideoInterfaceType
''' <summary>Private Data Storage Variable for Property: VideoAspect</summary>
''' <remarks></remarks>
Private m_VideoAspect As VideoAspectType
''' <summary>Private Data Storage Variable for Property: CurrentChannelUri</summary>
''' <remarks></remarks>
Private m_CurrentChannelUri As System.String
''' <summary>Private Data Storage Variable for Property: Groups</summary>
''' <remarks></remarks>
Private m_Groups As System.String
''' <summary>Private Data Storage Variable for Property: Model</summary>
''' <remarks></remarks>
Private m_Model As System.String
''' <summary>Private Data Storage Variable for Property: Speed</summary>
''' <remarks></remarks>
Private m_Speed As LineSpeed
''' <summary>Private Data Storage Variable for Property: Duplex</summary>
''' <remarks></remarks>
Private m_Duplex As LineDuplex
''' <summary>Private Data Storage Variable for Property: AutoNegotiation</summary>
''' <remarks></remarks>
Private m_AutoNegotiation As System.Boolean
''' <summary>Private Data Storage Variable for Property: ScreenFormat</summary>
''' <remarks></remarks>
Private m_ScreenFormat As System.String
''' <summary>Private Data Storage Variable for Property: AspectRatio</summary>
''' <remarks></remarks>
Private m_AspectRatio As System.String
''' <summary>Private Data Storage Variable for Property: Mode</summary>
''' <remarks></remarks>
Private m_Mode As DisplayType
''' <summary>Private Data Storage Variable for Property: CurrentUrl</summary>
''' <remarks></remarks>
Private m_CurrentUrl As System.String
''' <summary>Private Data Storage Variable for Property: HomepageUrl</summary>
''' <remarks></remarks>
Private m_HomepageUrl As System.String
''' <summary>Private Data Storage Variable for Property: Proxy</summary>
''' <remarks></remarks>
Private m_Proxy As ProxyType
''' <summary>Private Data Storage Variable for Property: ProxyAddress</summary>
''' <remarks></remarks>
Private m_ProxyAddress As System.Net.IPAddress
''' <summary>Private Data Storage Variable for Property: ProxyPort</summary>
''' <remarks></remarks>
Private m_ProxyPort As System.Int32
''' <summary>Private Data Storage Variable for Property: ProxyIgnoreList</summary>
''' <remarks></remarks>
Private m_ProxyIgnoreList As System.String
''' <summary>Private Data Storage Variable for Property: BrowserToolbar</summary>
''' <remarks></remarks>
Private m_BrowserToolbar As System.Boolean
''' <summary>Private Data Storage Variable for Property: StartupMode</summary>
''' <remarks></remarks>
Private m_StartupMode As DisplayType
''' <summary>Private Data Storage Variable for Property: Volume</summary>
''' <remarks></remarks>
Private m_Volume As System.Int32
''' <summary>Private Data Storage Variable for Property: AudioLanguage</summary>
''' <remarks></remarks>
Private m_AudioLanguage As System.String
''' <summary>Private Data Storage Variable for Property: IRInputName</summary>
''' <remarks></remarks>
Private m_IRInputName As System.String
''' <summary>Private Data Storage Variable for Property: IROutputName</summary>
''' <remarks></remarks>
Private m_IROutputName As System.String
''' <summary>Private Data Storage Variable for Property: IRInput</summary>
''' <remarks></remarks>
Private m_IRInput As System.Boolean
''' <summary>Private Data Storage Variable for Property: IROutput</summary>
''' <remarks></remarks>
Private m_IROutput As System.Boolean
''' <summary>Private Data Storage Variable for Property: LedStatus</summary>
''' <remarks></remarks>
Private m_LedStatus As System.Boolean
''' <summary>Private Data Storage Variable for Property: Subtitles</summary>
''' <remarks></remarks>
Private m_Subtitles As System.Boolean
''' <summary>Private Data Storage Variable for Property: Channels</summary>
''' <remarks></remarks>
Private m_Channels As TVChannelCollection
#End Region
#Region " Public Properties "
''' <summary>Provides Access to the Property: Name</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="Name")> _
Public Property Name() As DeviceName
Get
Return m_Name
End Get
Set(value As DeviceName)
m_Name = value
End Set
End Property
''' <summary>Provides Access to the Property: SnmpCommunity</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="SnmpCommunity")> _
Public Property SnmpCommunity() As System.String
Get
Return m_SnmpCommunity
End Get
Set(value As System.String)
m_SnmpCommunity = value
End Set
End Property
''' <summary>Provides Access to the Property: Description</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="Description")> _
Public Property Description() As System.String
Get
Return m_Description
End Get
Set(value As System.String)
m_Description = value
End Set
End Property
''' <summary>Provides Access to the Property: UpTime</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="UpTime")> _
Public Property UpTime() As TimePeriod
Get
Return m_UpTime
End Get
Set(value As TimePeriod)
m_UpTime = value
End Set
End Property
''' <summary>Provides Access to the Property: Contact</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="Contact")> _
Public Property Contact() As System.String
Get
Return m_Contact
End Get
Set(value As System.String)
m_Contact = value
End Set
End Property
''' <summary>Provides Access to the Property: Location</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="Location")> _
Public Property Location() As Location
Get
Return m_Location
End Get
Set(value As Location)
m_Location = value
End Set
End Property
''' <summary>Provides Access to the Property: Services</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="Services")> _
Public Property Services() As System.Int64
Get
Return m_Services
End Get
Set(value As System.Int64)
m_Services = value
End Set
End Property
''' <summary>Provides Access to the Property: TcpCurrentConnections</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="TcpCurrentConnections")> _
Public Property TcpCurrentConnections() As System.Int64
Get
Return m_TcpCurrentConnections
End Get
Set(value As System.Int64)
m_TcpCurrentConnections = value
End Set
End Property
''' <summary>Provides Access to the Property: InDatagramsDiscarded</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="InDatagramsDiscarded")> _
Public Property InDatagramsDiscarded() As System.Int64
Get
Return m_InDatagramsDiscarded
End Get
Set(value As System.Int64)
m_InDatagramsDiscarded = value
End Set
End Property
''' <summary>Provides Access to the Property: OutDatagramsDiscards</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="OutDatagramsDiscards")> _
Public Property OutDatagramsDiscards() As System.Int64
Get
Return m_OutDatagramsDiscards
End Get
Set(value As System.Int64)
m_OutDatagramsDiscards = value
End Set
End Property
''' <summary>Provides Access to the Property: InDatagramsDelivered</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="InDatagramsDelivered")> _
Public Property InDatagramsDelivered() As System.Int64
Get
Return m_InDatagramsDelivered
End Get
Set(value As System.Int64)
m_InDatagramsDelivered = value
End Set
End Property
''' <summary>Provides Access to the Property: OutDatagramsRequests</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="OutDatagramsRequests")> _
Public Property OutDatagramsRequests() As System.Int64
Get
Return m_OutDatagramsRequests
End Get
Set(value As System.Int64)
m_OutDatagramsRequests = value
End Set
End Property
''' <summary>Provides Access to the Property: InterfaceCount</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="InterfaceCount")> _
Public Property InterfaceCount() As System.Int64
Get
Return m_InterfaceCount
End Get
Set(value As System.Int64)
m_InterfaceCount = value
End Set
End Property
''' <summary>Provides Access to the Property: Interfaces</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="Interfaces")> _
Public Property Interfaces() As NetworkInterfaceCollection
Get
Return m_Interfaces
End Get
Set(value As NetworkInterfaceCollection)
m_Interfaces = value
End Set
End Property
''' <summary>Provides Access to the Property: TFTPServer</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="TFTPServer")> _
Public Property TFTPServer() As System.Net.IPAddress
Get
Return m_TFTPServer
End Get
Set(value As System.Net.IPAddress)
m_TFTPServer = value
End Set
End Property
''' <summary>Provides Access to the Property: SerialNumber</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="SerialNumber")> _
Public Property SerialNumber() As System.Net.NetworkInformation.PhysicalAddress
Get
Return m_SerialNumber
End Get
Set(value As System.Net.NetworkInformation.PhysicalAddress)
m_SerialNumber = value
End Set
End Property
''' <summary>Provides Access to the Property: Type</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="Type")> _
Public Property [Type]() As DeviceType
Get
Return m_Type
End Get
Set(value As DeviceType)
m_Type = value
End Set
End Property
''' <summary>Provides Access to the Property: Stream</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="Stream")> _
Public Property Stream() As StreamType
Get
Return m_Stream
End Get
Set(value As StreamType)
m_Stream = value
End Set
End Property
''' <summary>Provides Access to the Property: Version</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="Version")> _
Public Property Version() As System.Int32
Get
Return m_Version
End Get
Set(value As System.Int32)
m_Version = value
End Set
End Property
''' <summary>Provides Access to the Property: VersionName</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="VersionName")> _
Public Property VersionName() As System.String
Get
Return m_VersionName
End Get
Set(value As System.String)
m_VersionName = value
End Set
End Property
''' <summary>Provides Access to the Property: TotalResets</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="TotalResets")> _
Public Property TotalResets() As System.Int32
Get
Return m_TotalResets
End Get
Set(value As System.Int32)
m_TotalResets = value
End Set
End Property
''' <summary>Provides Access to the Property: VideoInterface</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="VideoInterface")> _
Public Property VideoInterface() As VideoInterfaceType
Get
Return m_VideoInterface
End Get
Set(value As VideoInterfaceType)
m_VideoInterface = value
End Set
End Property
''' <summary>Provides Access to the Property: VideoAspect</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="VideoAspect")> _
Public Property VideoAspect() As VideoAspectType
Get
Return m_VideoAspect
End Get
Set(value As VideoAspectType)
m_VideoAspect = value
End Set
End Property
''' <summary>Provides Access to the Property: CurrentChannelUri</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="CurrentChannelUri")> _
Public Property CurrentChannelUri() As System.String
Get
Return m_CurrentChannelUri
End Get
Set(value As System.String)
m_CurrentChannelUri = value
End Set
End Property
''' <summary>Provides Access to the Property: Groups</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="Groups")> _
Public Property Groups() As System.String
Get
Return m_Groups
End Get
Set(value As System.String)
m_Groups = value
End Set
End Property
''' <summary>Provides Access to the Property: Model</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="Model")> _
Public Property Model() As System.String
Get
Return m_Model
End Get
Set(value As System.String)
m_Model = value
End Set
End Property
''' <summary>Provides Access to the Property: Speed</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="Speed")> _
Public Property Speed() As LineSpeed
Get
Return m_Speed
End Get
Set(value As LineSpeed)
m_Speed = value
End Set
End Property
''' <summary>Provides Access to the Property: Duplex</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="Duplex")> _
Public Property Duplex() As LineDuplex
Get
Return m_Duplex
End Get
Set(value As LineDuplex)
m_Duplex = value
End Set
End Property
''' <summary>Provides Access to the Property: AutoNegotiation</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="AutoNegotiation")> _
Public Property AutoNegotiation() As System.Boolean
Get
Return m_AutoNegotiation
End Get
Set(value As System.Boolean)
m_AutoNegotiation = value
End Set
End Property
''' <summary>Provides Access to the Property: ScreenFormat</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="ScreenFormat")> _
Public Property ScreenFormat() As System.String
Get
Return m_ScreenFormat
End Get
Set(value As System.String)
m_ScreenFormat = value
End Set
End Property
''' <summary>Provides Access to the Property: AspectRatio</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="AspectRatio")> _
Public Property AspectRatio() As System.String
Get
Return m_AspectRatio
End Get
Set(value As System.String)
m_AspectRatio = value
End Set
End Property
''' <summary>Provides Access to the Property: Mode</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="Mode")> _
Public Property Mode() As DisplayType
Get
Return m_Mode
End Get
Set(value As DisplayType)
m_Mode = value
End Set
End Property
''' <summary>Provides Access to the Property: CurrentUrl</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="CurrentUrl")> _
Public Property CurrentUrl() As System.String
Get
Return m_CurrentUrl
End Get
Set(value As System.String)
m_CurrentUrl = value
End Set
End Property
''' <summary>Provides Access to the Property: HomepageUrl</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="HomepageUrl")> _
Public Property HomepageUrl() As System.String
Get
Return m_HomepageUrl
End Get
Set(value As System.String)
m_HomepageUrl = value
End Set
End Property
''' <summary>Provides Access to the Property: Proxy</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="Proxy")> _
Public Property Proxy() As ProxyType
Get
Return m_Proxy
End Get
Set(value As ProxyType)
m_Proxy = value
End Set
End Property
''' <summary>Provides Access to the Property: ProxyAddress</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="ProxyAddress")> _
Public Property ProxyAddress() As System.Net.IPAddress
Get
Return m_ProxyAddress
End Get
Set(value As System.Net.IPAddress)
m_ProxyAddress = value
End Set
End Property
''' <summary>Provides Access to the Property: ProxyPort</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="ProxyPort")> _
Public Property ProxyPort() As System.Int32
Get
Return m_ProxyPort
End Get
Set(value As System.Int32)
m_ProxyPort = value
End Set
End Property
''' <summary>Provides Access to the Property: ProxyIgnoreList</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="ProxyIgnoreList")> _
Public Property ProxyIgnoreList() As System.String
Get
Return m_ProxyIgnoreList
End Get
Set(value As System.String)
m_ProxyIgnoreList = value
End Set
End Property
''' <summary>Provides Access to the Property: BrowserToolbar</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="BrowserToolbar")> _
Public Property BrowserToolbar() As System.Boolean
Get
Return m_BrowserToolbar
End Get
Set(value As System.Boolean)
m_BrowserToolbar = value
End Set
End Property
''' <summary>Provides Access to the Property: StartupMode</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="StartupMode")> _
Public Property StartupMode() As DisplayType
Get
Return m_StartupMode
End Get
Set(value As DisplayType)
m_StartupMode = value
End Set
End Property
''' <summary>Provides Access to the Property: Volume</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="Volume")> _
Public Property Volume() As System.Int32
Get
Return m_Volume
End Get
Set(value As System.Int32)
m_Volume = value
End Set
End Property
''' <summary>Provides Access to the Property: AudioLanguage</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="AudioLanguage")> _
Public Property AudioLanguage() As System.String
Get
Return m_AudioLanguage
End Get
Set(value As System.String)
m_AudioLanguage = value
End Set
End Property
''' <summary>Provides Access to the Property: IRInputName</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="IRInputName")> _
Public Property IRInputName() As System.String
Get
Return m_IRInputName
End Get
Set(value As System.String)
m_IRInputName = value
End Set
End Property
''' <summary>Provides Access to the Property: IROutputName</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="IROutputName")> _
Public Property IROutputName() As System.String
Get
Return m_IROutputName
End Get
Set(value As System.String)
m_IROutputName = value
End Set
End Property
''' <summary>Provides Access to the Property: IRInput</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="IRInput")> _
Public Property IRInput() As System.Boolean
Get
Return m_IRInput
End Get
Set(value As System.Boolean)
m_IRInput = value
End Set
End Property
''' <summary>Provides Access to the Property: IROutput</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="IROutput")> _
Public Property IROutput() As System.Boolean
Get
Return m_IROutput
End Get
Set(value As System.Boolean)
m_IROutput = value
End Set
End Property
''' <summary>Provides Access to the Property: LedStatus</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="LedStatus")> _
Public Property LedStatus() As System.Boolean
Get
Return m_LedStatus
End Get
Set(value As System.Boolean)
m_LedStatus = value
End Set
End Property
''' <summary>Provides Access to the Property: Subtitles</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="Subtitles")> _
Public Property Subtitles() As System.Boolean
Get
Return m_Subtitles
End Get
Set(value As System.Boolean)
m_Subtitles = value
End Set
End Property
''' <summary>Provides Access to the Property: Channels</summary>
''' <remarks></remarks>
<System.Xml.Serialization.XmlElement(ElementName:="Channels")> _
Public Property Channels() As TVChannelCollection
Get
Return m_Channels
End Get
Set(value As TVChannelCollection)
m_Channels = value
End Set
End Property
#End Region
End Class
End Namespace
|
thiscouldbejd/Caerus
|
_Exterity/Generated/TVDecoder.vb
|
Visual Basic
|
mit
| 136,228
|
' This file was generated by CSLA Object Generator - CslaGenFork v4.5
'
' Filename: DocStatusEditDyna
' ObjectType: DocStatusEditDyna
' CSLAType: DynamicEditableRoot
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports Csla
Imports Csla.Data
Imports DocStore.Business.Util
Imports DocStore.Business.Security
Imports UsingLibrary
Namespace DocStore.Business
''' <summary>
''' DocStatusEditDyna (dynamic root object).<br/>
''' This is a generated base class of <see cref="DocStatusEditDyna"/> business object.
''' </summary>
''' <remarks>
''' This class is an item of <see cref="DocStatusEditDynaColl"/> collection.
''' </remarks>
<Serializable>
Public Partial Class DocStatusEditDyna
Inherits BusinessBase(Of DocStatusEditDyna)
Implements IHaveInterface, IHaveGenericInterface(Of DocStatusEditDyna)
#Region " Static Fields "
Private Shared _lastId As Integer
#End Region
#Region " Business Properties "
''' <summary>
''' Maintains metadata about <see cref="DocStatusID"/> property.
''' </summary>
<NotUndoable>
Public Shared ReadOnly DocStatusIDProperty As PropertyInfo(Of Integer) = RegisterProperty(Of Integer)(Function(p) p.DocStatusID, "Doc Status ID")
''' <summary>
''' Row version counter for concurrency control
''' </summary>
''' <value>The Doc Status ID.</value>
Public ReadOnly Property DocStatusID As Integer
Get
Return GetProperty(DocStatusIDProperty)
End Get
End Property
''' <summary>
''' Maintains metadata about <see cref="DocStatusName"/> property.
''' </summary>
Public Shared ReadOnly DocStatusNameProperty As PropertyInfo(Of String) = RegisterProperty(Of String)(Function(p) p.DocStatusName, "Doc Status Name")
''' <summary>
''' Gets or sets the Doc Status Name.
''' </summary>
''' <value>The Doc Status Name.</value>
Public Property DocStatusName As String
Get
Return GetProperty(DocStatusNameProperty)
End Get
Set(ByVal value As String)
SetProperty(DocStatusNameProperty, value)
End Set
End Property
''' <summary>
''' Maintains metadata about <see cref="CreateDate"/> property.
''' </summary>
Public Shared ReadOnly CreateDateProperty As PropertyInfo(Of SmartDate) = RegisterProperty(Of SmartDate)(Function(p) p.CreateDate, "Create Date")
''' <summary>
''' Gets the Create Date.
''' </summary>
''' <value>The Create Date.</value>
Public ReadOnly Property CreateDate As SmartDate
Get
Return GetProperty(CreateDateProperty)
End Get
End Property
''' <summary>
''' Maintains metadata about <see cref="CreateUserID"/> property.
''' </summary>
Public Shared ReadOnly CreateUserIDProperty As PropertyInfo(Of Integer) = RegisterProperty(Of Integer)(Function(p) p.CreateUserID, "Create User ID")
''' <summary>
''' Gets the Create User ID.
''' </summary>
''' <value>The Create User ID.</value>
Public ReadOnly Property CreateUserID As Integer
Get
Return GetProperty(CreateUserIDProperty)
End Get
End Property
''' <summary>
''' Maintains metadata about <see cref="ChangeDate"/> property.
''' </summary>
Public Shared ReadOnly ChangeDateProperty As PropertyInfo(Of SmartDate) = RegisterProperty(Of SmartDate)(Function(p) p.ChangeDate, "Change Date")
''' <summary>
''' Gets the Change Date.
''' </summary>
''' <value>The Change Date.</value>
Public ReadOnly Property ChangeDate As SmartDate
Get
Return GetProperty(ChangeDateProperty)
End Get
End Property
''' <summary>
''' Maintains metadata about <see cref="ChangeUserID"/> property.
''' </summary>
Public Shared ReadOnly ChangeUserIDProperty As PropertyInfo(Of Integer) = RegisterProperty(Of Integer)(Function(p) p.ChangeUserID, "Change User ID")
''' <summary>
''' Gets the Change User ID.
''' </summary>
''' <value>The Change User ID.</value>
Public ReadOnly Property ChangeUserID As Integer
Get
Return GetProperty(ChangeUserIDProperty)
End Get
End Property
''' <summary>
''' Maintains metadata about <see cref="RowVersion"/> property.
''' </summary>
<NotUndoable>
Public Shared ReadOnly RowVersionProperty As PropertyInfo(Of Byte()) = RegisterProperty(Of Byte())(Function(p) p.RowVersion, "Row Version")
''' <summary>
''' Gets the Row Version.
''' </summary>
''' <value>The Row Version.</value>
Public ReadOnly Property RowVersion As Byte()
Get
Return GetProperty(RowVersionProperty)
End Get
End Property
#End Region
#Region " Factory Methods "
''' <summary>
''' Factory method. Creates a new <see cref="DocStatusEditDyna"/> object.
''' </summary>
''' <returns>A reference to the created <see cref="DocStatusEditDyna"/> object.</returns>
Friend Shared Function NewDocStatusEditDyna() As DocStatusEditDyna
Return DataPortal.Create(Of DocStatusEditDyna)()
End Function
''' <summary>
''' Factory method. Loads a <see cref="DocStatusEditDyna"/> object from the given SafeDataReader.
''' </summary>
''' <param name="dr">The SafeDataReader to use.</param>
''' <returns>A reference to the fetched <see cref="DocStatusEditDyna"/> object.</returns>
Friend Shared Function GetDocStatusEditDyna(dr As SafeDataReader) As DocStatusEditDyna
Dim obj As DocStatusEditDyna = New DocStatusEditDyna()
obj.Fetch(dr)
obj.MarkOld()
' check all object rules and property rules
obj.BusinessRules.CheckRules()
Return obj
End Function
''' <summary>
''' Factory method. Deletes a <see cref="DocStatusEditDyna"/> object, based on given parameters.
''' </summary>
''' <param name="docStatusID">The DocStatusID of the DocStatusEditDyna to delete.</param>
Friend Shared Sub DeleteDocStatusEditDyna(docStatusID As Integer)
DataPortal.Delete(Of DocStatusEditDyna)(docStatusID)
End Sub
''' <summary>
''' Factory method. Asynchronously creates a new <see cref="DocStatusEditDyna"/> object.
''' </summary>
''' <param name="callback">The completion callback method.</param>
Friend Shared Sub NewDocStatusEditDyna(callback As EventHandler(Of DataPortalResult(Of DocStatusEditDyna)))
DataPortal.BeginCreate(Of DocStatusEditDyna)(callback)
End Sub
''' <summary>
''' Factory method. Asynchronously deletes a <see cref="DocStatusEditDyna"/> object, based on given parameters.
''' </summary>
''' <param name="docStatusID">The DocStatusID of the DocStatusEditDyna to delete.</param>
''' <param name="callback">The completion callback method.</param>
Friend Shared Sub DeleteDocStatusEditDyna(docStatusID As Integer, callback As EventHandler(Of DataPortalResult(Of DocStatusEditDyna)))
DataPortal.BeginDelete(Of DocStatusEditDyna)(docStatusID, callback)
End Sub
#End Region
#Region " Constructor "
''' <summary>
''' Initializes a new instance of the <see cref="DocStatusEditDyna"/> class.
''' </summary>
''' <remarks> Do not use to create a Csla object. Use factory methods instead.</remarks>
<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)>
Public Sub New()
' Use factory methods and do not use direct creation.
End Sub
#End Region
#Region " Data Access "
''' <summary>
''' Loads default values for the <see cref="DocStatusEditDyna"/> object properties.
''' </summary>
<RunLocal>
Protected Overrides Sub DataPortal_Create()
LoadProperty(DocStatusIDProperty, System.Threading.Interlocked.Decrement(_lastId))
LoadProperty(CreateDateProperty, new SmartDate(Date.Now))
LoadProperty(CreateUserIDProperty, UserInformation.UserId)
LoadProperty(ChangeDateProperty, ReadProperty(CreateDateProperty))
LoadProperty(ChangeUserIDProperty, ReadProperty(CreateUserIDProperty))
Dim args As New DataPortalHookArgs()
OnCreate(args)
MyBase.DataPortal_Create()
End Sub
''' <summary>
''' Loads a <see cref="DocStatusEditDyna"/> object from the given SafeDataReader.
''' </summary>
''' <param name="dr">The SafeDataReader to use.</param>
Private Sub Fetch(dr As SafeDataReader)
' Value properties
LoadProperty(DocStatusIDProperty, dr.GetInt32("DocStatusID"))
LoadProperty(DocStatusNameProperty, dr.GetString("DocStatusName"))
LoadProperty(CreateDateProperty, dr.GetSmartDate("CreateDate", True))
LoadProperty(CreateUserIDProperty, dr.GetInt32("CreateUserID"))
LoadProperty(ChangeDateProperty, dr.GetSmartDate("ChangeDate", True))
LoadProperty(ChangeUserIDProperty, dr.GetInt32("ChangeUserID"))
LoadProperty(RowVersionProperty, TryCast(dr.GetValue("RowVersion"), Byte()))
Dim args As New DataPortalHookArgs(dr)
OnFetchRead(args)
End Sub
''' <summary>
''' Inserts a new <see cref="DocStatusEditDyna"/> object in the database.
''' </summary>
Protected Overrides Sub DataPortal_Insert()
SimpleAuditTrail()
Using ctx = TransactionManager(Of SqlConnection, SqlTransaction).GetManager(Database.DocStoreConnection, False)
Using cmd = New SqlCommand("AddDocStatusEditDyna", ctx.Connection)
cmd.Transaction = ctx.Transaction
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@DocStatusID", ReadProperty(DocStatusIDProperty)).Direction = ParameterDirection.Output
cmd.Parameters.AddWithValue("@DocStatusName", ReadProperty(DocStatusNameProperty)).DbType = DbType.String
cmd.Parameters.AddWithValue("@CreateDate", ReadProperty(CreateDateProperty).DBValue).DbType = DbType.DateTime2
cmd.Parameters.AddWithValue("@CreateUserID", ReadProperty(CreateUserIDProperty)).DbType = DbType.Int32
cmd.Parameters.AddWithValue("@ChangeDate", ReadProperty(ChangeDateProperty).DBValue).DbType = DbType.DateTime2
cmd.Parameters.AddWithValue("@ChangeUserID", ReadProperty(ChangeUserIDProperty)).DbType = DbType.Int32
cmd.Parameters.Add("@NewRowVersion", SqlDbType.Timestamp).Direction = ParameterDirection.Output
Dim args As New DataPortalHookArgs(cmd)
OnInsertPre(args)
cmd.ExecuteNonQuery()
OnInsertPost(args)
LoadProperty(DocStatusIDProperty, DirectCast(cmd.Parameters("@DocStatusID").Value, Integer))
LoadProperty(RowVersionProperty, DirectCast(cmd.Parameters("@NewRowVersion").Value, Byte()))
End Using
ctx.Commit()
End Using
End Sub
''' <summary>
''' Updates in the database all changes made to the <see cref="DocStatusEditDyna"/> object.
''' </summary>
Protected Overrides Sub DataPortal_Update()
SimpleAuditTrail()
Using ctx = TransactionManager(Of SqlConnection, SqlTransaction).GetManager(Database.DocStoreConnection, False)
Using cmd = New SqlCommand("UpdateDocStatusEditDyna", ctx.Connection)
cmd.Transaction = ctx.Transaction
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@DocStatusID", ReadProperty(DocStatusIDProperty)).DbType = DbType.Int32
cmd.Parameters.AddWithValue("@DocStatusName", ReadProperty(DocStatusNameProperty)).DbType = DbType.String
cmd.Parameters.AddWithValue("@ChangeDate", ReadProperty(ChangeDateProperty).DBValue).DbType = DbType.DateTime2
cmd.Parameters.AddWithValue("@ChangeUserID", ReadProperty(ChangeUserIDProperty)).DbType = DbType.Int32
cmd.Parameters.AddWithValue("@RowVersion", ReadProperty(RowVersionProperty)).DbType = DbType.Binary
cmd.Parameters.Add("@NewRowVersion", SqlDbType.Timestamp).Direction = ParameterDirection.Output
Dim args As New DataPortalHookArgs(cmd)
OnUpdatePre(args)
cmd.ExecuteNonQuery()
OnUpdatePost(args)
LoadProperty(RowVersionProperty, DirectCast(cmd.Parameters("@NewRowVersion").Value, Byte()))
End Using
ctx.Commit()
End Using
End Sub
Private Sub SimpleAuditTrail()
LoadProperty(ChangeDateProperty, Date.Now)
LoadProperty(ChangeUserIDProperty, UserInformation.UserId)
If IsNew Then
LoadProperty(CreateDateProperty, ReadProperty(ChangeDateProperty))
LoadProperty(CreateUserIDProperty, ReadProperty(ChangeUserIDProperty))
End If
End Sub
''' <summary>
''' Self deletes the <see cref="DocStatusEditDyna"/> object.
''' </summary>
Protected Overrides Sub DataPortal_DeleteSelf()
DataPortal_Delete(DocStatusID)
End Sub
''' <summary>
''' Deletes the <see cref="DocStatusEditDyna"/> object from database.
''' </summary>
''' <param name="docStatusID">The delete criteria.</param>
Protected Sub DataPortal_Delete(docStatusID As Integer)
' audit the object, just in case soft delete is used on this object
SimpleAuditTrail()
Using ctx = TransactionManager(Of SqlConnection, SqlTransaction).GetManager(Database.DocStoreConnection, False)
Using cmd = New SqlCommand("DeleteDocStatusEditDyna", ctx.Connection)
cmd.Transaction = ctx.Transaction
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@DocStatusID", docStatusID).DbType = DbType.Int32
Dim args As New DataPortalHookArgs(cmd, docStatusID)
OnDeletePre(args)
cmd.ExecuteNonQuery()
OnDeletePost(args)
End Using
ctx.Commit()
End Using
End Sub
#End Region
#Region " DataPortal Hooks "
''' <summary>
''' Occurs after setting all defaults for object creation.
''' </summary>
Partial Private Sub OnCreate(args As DataPortalHookArgs)
End Sub
''' <summary>
''' Occurs in DataPortal_Delete, after setting query parameters and before the delete operation.
''' </summary>
Partial Private Sub OnDeletePre(args As DataPortalHookArgs)
End Sub
''' <summary>
''' Occurs in DataPortal_Delete, after the delete operation, before Commit().
''' </summary>
Partial Private Sub OnDeletePost(args As DataPortalHookArgs)
End Sub
''' <summary>
''' Occurs after setting query parameters and before the fetch operation.
''' </summary>
Partial Private Sub OnFetchPre(args As DataPortalHookArgs)
End Sub
''' <summary>
''' Occurs after the fetch operation (object or collection is fully loaded and set up).
''' </summary>
Partial Private Sub OnFetchPost(args As DataPortalHookArgs)
End Sub
''' <summary>
''' Occurs after the low level fetch operation, before the data reader is destroyed.
''' </summary>
Partial Private Sub OnFetchRead(args As DataPortalHookArgs)
End Sub
''' <summary>
''' Occurs after setting query parameters and before the update operation.
''' </summary>
Partial Private Sub OnUpdatePre(args As DataPortalHookArgs)
End Sub
''' <summary>
''' Occurs in DataPortal_Insert, after the update operation, before setting back row identifiers (RowVersion) and Commit().
''' </summary>
Partial Private Sub OnUpdatePost(args As DataPortalHookArgs)
End Sub
''' <summary>
''' Occurs in DataPortal_Insert, after setting query parameters and before the insert operation.
''' </summary>
Partial Private Sub OnInsertPre(args As DataPortalHookArgs)
End Sub
''' <summary>
''' Occurs in DataPortal_Insert, after the insert operation, before setting back row identifiers (ID and RowVersion) and Commit().
''' </summary>
Partial Private Sub OnInsertPost(args As DataPortalHookArgs)
End Sub
#End Region
End Class
End Namespace
|
CslaGenFork/CslaGenFork
|
trunk/CoverageTest/Inherits/Inherits-WIN-VB/DocStore.Business/DocStatusEditDyna.Designer.vb
|
Visual Basic
|
mit
| 18,021
|
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class DockWindow
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.pnlTiles = New System.Windows.Forms.Panel()
Me.picBoarder = New System.Windows.Forms.PictureBox()
CType(Me.picBoarder, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'pnlTiles
'
Me.pnlTiles.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.pnlTiles.BackColor = System.Drawing.Color.Transparent
Me.pnlTiles.Location = New System.Drawing.Point(-1, 0)
Me.pnlTiles.Name = "pnlTiles"
Me.pnlTiles.Size = New System.Drawing.Size(125, 112)
Me.pnlTiles.TabIndex = 3
'
'picBoarder
'
Me.picBoarder.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.picBoarder.BackColor = System.Drawing.Color.Gray
Me.picBoarder.Location = New System.Drawing.Point(-1, 107)
Me.picBoarder.Name = "picBoarder"
Me.picBoarder.Size = New System.Drawing.Size(125, 21)
Me.picBoarder.TabIndex = 2
Me.picBoarder.TabStop = False
'
'DockWindow
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.BackColor = System.Drawing.Color.FromArgb(CType(CType(1, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(1, Byte), Integer))
Me.ClientSize = New System.Drawing.Size(124, 149)
Me.Controls.Add(Me.pnlTiles)
Me.Controls.Add(Me.picBoarder)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
Me.Name = "DockWindow"
Me.Text = "Dock"
Me.TransparencyKey = System.Drawing.Color.FromArgb(CType(CType(1, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(1, Byte), Integer))
CType(Me.picBoarder, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
Friend WithEvents pnlTiles As System.Windows.Forms.Panel
Friend WithEvents picBoarder As System.Windows.Forms.PictureBox
End Class
|
TheUltimateHacker/ShiftOS
|
ShiftOS/DockWindow.Designer.vb
|
Visual Basic
|
apache-2.0
| 3,197
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.