Skip to content

Commit 123aeca

Browse files
промежукточный для переноса
1 parent 8fe5063 commit 123aeca

17 files changed

+1675
-117
lines changed

Diff for: CodeAnalysisUnitTests/Class1.cs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace CodeAnalysisUnitTests
8+
{
9+
public class Class1
10+
{
11+
}
12+
}

Diff for: CodeAnalysisUnitTests/CodeAnalysisUnitTests.csproj

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{FBE7EFCC-57BC-4D67-820C-55422C15C8F8}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>CodeAnalysisUnitTests</RootNamespace>
11+
<AssemblyName>CodeAnalysisUnitTests</AssemblyName>
12+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<DebugSymbols>true</DebugSymbols>
17+
<DebugType>full</DebugType>
18+
<Optimize>false</Optimize>
19+
<OutputPath>bin\Debug\</OutputPath>
20+
<DefineConstants>DEBUG;TRACE</DefineConstants>
21+
<ErrorReport>prompt</ErrorReport>
22+
<WarningLevel>4</WarningLevel>
23+
</PropertyGroup>
24+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25+
<DebugType>pdbonly</DebugType>
26+
<Optimize>true</Optimize>
27+
<OutputPath>bin\Release\</OutputPath>
28+
<DefineConstants>TRACE</DefineConstants>
29+
<ErrorReport>prompt</ErrorReport>
30+
<WarningLevel>4</WarningLevel>
31+
</PropertyGroup>
32+
<ItemGroup>
33+
<Reference Include="nunit.framework, Version=3.6.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
34+
<HintPath>..\packages\NUnit.3.6.0\lib\net45\nunit.framework.dll</HintPath>
35+
<Private>True</Private>
36+
</Reference>
37+
<Reference Include="System" />
38+
<Reference Include="System.Core" />
39+
<Reference Include="System.Xml.Linq" />
40+
<Reference Include="System.Data.DataSetExtensions" />
41+
<Reference Include="Microsoft.CSharp" />
42+
<Reference Include="System.Data" />
43+
<Reference Include="System.Net.Http" />
44+
<Reference Include="System.Xml" />
45+
</ItemGroup>
46+
<ItemGroup>
47+
<Compile Include="Class1.cs" />
48+
<Compile Include="Properties\AssemblyInfo.cs" />
49+
<Compile Include="SecondLevelCSharpTests.cs" />
50+
</ItemGroup>
51+
<ItemGroup>
52+
<ProjectReference Include="..\VisualBasicCodeAnalysis\VisualBasicCodeAnalysis.csproj">
53+
<Project>{30919ef3-518b-4e94-b738-0b6c593d9767}</Project>
54+
<Name>VisualBasicCodeAnalysis</Name>
55+
</ProjectReference>
56+
</ItemGroup>
57+
<ItemGroup>
58+
<None Include="packages.config" />
59+
</ItemGroup>
60+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
61+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
62+
Other similar extension points exist, see Microsoft.Common.targets.
63+
<Target Name="BeforeBuild">
64+
</Target>
65+
<Target Name="AfterBuild">
66+
</Target>
67+
-->
68+
</Project>

Diff for: CodeAnalysisUnitTests/Properties/AssemblyInfo.cs

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("CodeAnalysisUnitTests")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("Microsoft")]
12+
[assembly: AssemblyProduct("CodeAnalysisUnitTests")]
13+
[assembly: AssemblyCopyright("Copyright © Microsoft 2017")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("fbe7efcc-57bc-4d67-820c-55422c15c8f8")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

Diff for: CodeAnalysisUnitTests/SecondLevelCSharpTests.cs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using NUnit.Framework;
7+
using VisualBasicCodeAnalysis.Analyzer;
8+
9+
namespace CodeAnalysisUnitTests
10+
{
11+
[TestFixture]
12+
public class SecondLevelCSharpTests
13+
{
14+
[Test]
15+
public void GetMethodList_BadExtension_ReturnNull()
16+
{
17+
SecondLevelCSharp secondLevelCSharp = new SecondLevelCSharp();
18+
19+
}
20+
}
21+
}

Diff for: CodeAnalysisUnitTests/packages.config

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="NUnit" version="3.6.0" targetFramework="net452" />
4+
</packages>

Diff for: VisualBasicCodeAnalysis.sln

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ VisualStudioVersion = 14.0.25420.1
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisualBasicCodeAnalysis", "VisualBasicCodeAnalysis\VisualBasicCodeAnalysis.csproj", "{30919EF3-518B-4E94-B738-0B6C593D9767}"
77
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeAnalysisUnitTests", "CodeAnalysisUnitTests\CodeAnalysisUnitTests.csproj", "{FBE7EFCC-57BC-4D67-820C-55422C15C8F8}"
9+
EndProject
810
Global
911
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1012
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +17,10 @@ Global
1517
{30919EF3-518B-4E94-B738-0B6C593D9767}.Debug|Any CPU.Build.0 = Debug|Any CPU
1618
{30919EF3-518B-4E94-B738-0B6C593D9767}.Release|Any CPU.ActiveCfg = Release|Any CPU
1719
{30919EF3-518B-4E94-B738-0B6C593D9767}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{FBE7EFCC-57BC-4D67-820C-55422C15C8F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{FBE7EFCC-57BC-4D67-820C-55422C15C8F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{FBE7EFCC-57BC-4D67-820C-55422C15C8F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{FBE7EFCC-57BC-4D67-820C-55422C15C8F8}.Release|Any CPU.Build.0 = Release|Any CPU
1824
EndGlobalSection
1925
GlobalSection(SolutionProperties) = preSolution
2026
HideSolutionNode = FALSE

Diff for: VisualBasicCodeAnalysis/Analyzer/DatabaseConnection.cs

+101-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public void CreateOrUpdateDatabase()
5353
"CREATE TABLE Function (id INTEGER PRIMARY KEY, name TEXT, ret_type TEXT, type_param TEXT, count_line INTEGER," +
5454
"def_file TEXT, def_offset INTEGER, dec_file TEXT, is_useful INTEGER, udb_id INTEGER);");
5555
NonExecuteQuery("CREATE TABLE gVar (id INTEGER PRIMARY KEY, name TEXT, type TEXT, def_file TEXT, def_offset INTEGER);");
56+
NonExecuteQuery("CREATE TABLE Func_Func_Link (id_parent INGETER, id_child INTEGER);");
5657
connection.Close();
5758
}
5859
}
@@ -74,7 +75,7 @@ public int NonExecuteQuery(string query)
7475
}
7576
}
7677

77-
public void NonExecuteQueryForInsert(List<VisualBasicAnalysis.FuncStruct> functionStruct)
78+
public void NonExecuteQueryForInsertFunc(List<VisualBasicAnalysis.FuncStruct> functionStruct)
7879
{
7980
try
8081
{
@@ -122,6 +123,105 @@ public void NonExecuteQueryForInsert(List<VisualBasicAnalysis.FuncStruct> functi
122123
}
123124
}
124125

126+
public void NonExecuteQueryForInsertFuncToFunc(List<VisualBasicAnalysis.FuncToFuncLinkStruct> funcToFunc)
127+
{
128+
try
129+
{
130+
dbFileName = @"E:\testdb.db";
131+
SQLiteConnection con = new SQLiteConnection();
132+
if (!File.Exists(dbFileName))
133+
{
134+
// SQLiteConnection.CreateFile(dbFileName);
135+
}
136+
sqlFactory = (SQLiteFactory)DbProviderFactories.GetFactory("System.Data.SQLite");
137+
using (connection = (SQLiteConnection)sqlFactory.CreateConnection())
138+
{
139+
connection.ConnectionString = "Data Source = " + dbFileName;
140+
connection.Open();
141+
142+
143+
144+
foreach (var func in funcToFunc)
145+
{
146+
SQLiteCommand command = new SQLiteCommand(connection)
147+
{
148+
CommandText = "INSERT INTO Func_Func_Link (id_parent, id_child ) VALUES (@id_parent,@id_child)"
149+
};
150+
command.Parameters.Add(new SQLiteParameter("@id_parent", func.ParentFuncId ));
151+
command.Parameters.Add(new SQLiteParameter("@id_child", func.ChildFuncId));
152+
command.CommandType = CommandType.Text;
153+
command.ExecuteNonQuery();
154+
155+
}
156+
157+
foreach (var function in VisualBasicAnalysis.FunctionList)
158+
{
159+
SQLiteCommand command = new SQLiteCommand(connection)
160+
{
161+
CommandText = "INSERT INTO Function (id, name) VALUES (@id,@name)"
162+
};
163+
command.Parameters.Add(new SQLiteParameter("@id", function.Key));
164+
command.Parameters.Add(new SQLiteParameter("@name", function.Value.Name));
165+
command.CommandType = CommandType.Text;
166+
command.ExecuteNonQuery();
167+
}
168+
169+
connection.Close();
170+
}
171+
172+
}
173+
catch (Exception e)
174+
{
175+
176+
177+
}
178+
}
179+
180+
public void NonExecuteQueryForInsertVar(List<VisualBasicAnalysis.VarStruct> varStruct)
181+
{
182+
try
183+
{
184+
dbFileName = @"E:\testdb.db";
185+
SQLiteConnection con = new SQLiteConnection();
186+
if (!File.Exists(dbFileName))
187+
{
188+
// SQLiteConnection.CreateFile(dbFileName);
189+
}
190+
sqlFactory = (SQLiteFactory)DbProviderFactories.GetFactory("System.Data.SQLite");
191+
using (connection = (SQLiteConnection)sqlFactory.CreateConnection())
192+
{
193+
connection.ConnectionString = "Data Source = " + dbFileName;
194+
connection.Open();
195+
196+
197+
int i = 1;
198+
foreach (var varS in varStruct)
199+
{
200+
SQLiteCommand command = new SQLiteCommand(connection)
201+
{
202+
CommandText = "INSERT INTO gVar (id, name, type, def_file," +
203+
" def_offset) VALUES (@id,@name,@type,@def_file,@def_offset)"
204+
};
205+
command.Parameters.Add(new SQLiteParameter("@id", varS.Id));
206+
command.Parameters.Add(new SQLiteParameter("@name", varS.Name));
207+
command.Parameters.Add(new SQLiteParameter("@type", varS.Type));
208+
command.Parameters.Add(new SQLiteParameter("@def_file", varS.DefFile));
209+
command.Parameters.Add(new SQLiteParameter("@def_offset", varS.DefOffset));
210+
command.CommandType = CommandType.Text;
211+
command.ExecuteNonQuery();
212+
i++;
213+
}
214+
connection.Close();
215+
}
216+
217+
}
218+
catch (Exception e)
219+
{
220+
221+
222+
}
223+
}
224+
125225
public SQLiteDataReader Query(string query)
126226
{
127227
SQLiteCommand command = new SQLiteCommand(this.connection);

0 commit comments

Comments
 (0)