Skip to content

Commit 9b6aa64

Browse files
ptupitsynMmuzaf
authored andcommitted
IGNITE-13979 .NET: Modernize examples
* Target .NET Core 2.1 * Every example resides in a separate project for better CLI and IDE experience * NuGet-based: `examples` folder can be downloaded independently and everything just works * Easy standalone node startup with `ServerNode` project * More Thin Client examples * Deliver examples as a project template with `dotnet new`: Apache.Ignite.Examples NuGet package added * Nicer README with screenshots
1 parent 681a64f commit 9b6aa64

175 files changed

Lines changed: 5245 additions & 3098 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/_config.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ attrs: &asciidoc_attributes
2424
javaCodeDir: code-snippets/java/src/main/java/org/apache/ignite/snippets
2525
csharpCodeDir: code-snippets/dotnet
2626
githubUrl: https://github.com/apache/ignite/tree/master
27+
githubVersionUrl: https://github.com/apache/ignite/tree/ignite-{version}
2728
docSourceUrl: https://github.com/apache/ignite/tree/IGNITE-7595/docs
2829
collections:
2930
docs:
@@ -39,8 +40,8 @@ defaults:
3940
scope:
4041
path: '_docs'
4142
values:
42-
toc: ignite
43+
toc: ignite
4344
asciidoctor:
44-
base_dir: _docs/
45+
base_dir: _docs/
4546
attributes: *asciidoc_attributes
46-
47+

docs/_docs/quick-start/dotnet.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ From here, you may want to:
8888

8989
* Check out the link:thin-clients/dotnet-thin-client[.NET thin client] that provides a lightweight form of connectivity
9090
to Ignite clusters
91-
* Explore the link:{githubUrl}/modules/platforms/dotnet/examples[additional examples] included with Ignite
91+
* Explore the link:{githubVersionUrl}/modules/platforms/dotnet/examples[additional examples] included with Ignite
9292
* Refer to the link:net-specific[NET-specific section] of the documentation to learn more about capabilities
9393
that are available for C# and .NET applications.
9494

modules/platforms/dotnet/examples/dotnetcore/Organization.cs renamed to modules/platforms/dotnet/Apache.Ignite.Core.Tests.TestDll2/Account.cs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* Licensed to the Apache Software Foundation (ASF) under one or more
33
* contributor license agreements. See the NOTICE file distributed with
44
* this work for additional information regarding copyright ownership.
@@ -15,44 +15,43 @@
1515
* limitations under the License.
1616
*/
1717

18-
namespace Apache.Ignite.Examples
18+
namespace Apache.Ignite.Core.Tests.TestDll2
1919
{
20-
using System;
21-
using Core.Cache.Configuration;
22-
2320
/// <summary>
24-
/// Organization.
21+
/// Test account.
2522
/// </summary>
26-
public class Organization
23+
public class Account
2724
{
2825
/// <summary>
2926
/// Constructor.
3027
/// </summary>
31-
/// <param name="name">Name.</param>
32-
public Organization(string name)
28+
/// <param name="id">Account ID.</param>
29+
/// <param name="balance">Account balance.</param>
30+
public Account(int id, decimal balance)
3331
{
34-
Name = name;
35-
LastUpdated = DateTime.UtcNow;
32+
Id = id;
33+
Balance = balance;
3634
}
3735

3836
/// <summary>
39-
/// Name.
37+
/// Account ID.
4038
/// </summary>
41-
[QuerySqlField(IsIndexed = true)]
42-
public string Name { get; set; }
39+
public int Id { get; set; }
4340

4441
/// <summary>
45-
/// Last update time.
42+
/// Account balance.
4643
/// </summary>
47-
[QuerySqlField]
48-
public DateTime LastUpdated { get; set; }
44+
public decimal Balance { get; set; }
4945

5046
/// <summary>
5147
/// Returns a string that represents the current object.
5248
/// </summary>
49+
/// <returns>
50+
/// A string that represents the current object.
51+
/// </returns>
5352
public override string ToString()
5453
{
55-
return $"{typeof(Organization).Name} [{nameof(Name)}={Name}, {nameof(LastUpdated)}={LastUpdated}]";
54+
return string.Format("{0} [id={1}, balance={2}]", typeof(Account).Name, Id, Balance);
5655
}
5756
}
5857
}

modules/platforms/dotnet/examples/dotnetcore/Employee.cs renamed to modules/platforms/dotnet/Apache.Ignite.Core.Tests.TestDll2/Address.cs

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,53 +15,43 @@
1515
* limitations under the License.
1616
*/
1717

18-
namespace Apache.Ignite.Examples
18+
namespace Apache.Ignite.Core.Tests.TestDll2
1919
{
20-
using Core.Cache.Configuration;
21-
2220
/// <summary>
23-
/// Employee.
21+
/// Address.
2422
/// </summary>
25-
public class Employee
23+
public class Address
2624
{
2725
/// <summary>
2826
/// Constructor.
2927
/// </summary>
30-
/// <param name="name">Name.</param>
31-
/// <param name="salary">Salary.</param>
32-
/// <param name="organizationId">The organization identifier.</param>
33-
public Employee(string name, long salary, int organizationId = 0)
28+
/// <param name="street">Street.</param>
29+
/// <param name="zip">ZIP code.</param>
30+
public Address(string street, int zip)
3431
{
35-
Name = name;
36-
Salary = salary;
37-
OrganizationId = organizationId;
32+
Street = street;
33+
Zip = zip;
3834
}
3935

4036
/// <summary>
41-
/// Name.
37+
/// Street.
4238
/// </summary>
43-
[QuerySqlField]
44-
public string Name { get; set; }
39+
public string Street { get; set; }
4540

4641
/// <summary>
47-
/// Organization id.
42+
/// ZIP code.
4843
/// </summary>
49-
[QuerySqlField(IsIndexed = true)]
50-
public int OrganizationId { get; set; }
44+
public int Zip { get; set; }
5145

52-
/// <summary>
53-
/// Salary.
54-
/// </summary>
55-
[QuerySqlField]
56-
public long Salary { get; set; }
57-
58-
/// <summary>
46+
/// <summary>
5947
/// Returns a string that represents the current object.
6048
/// </summary>
49+
/// <returns>
50+
/// A string that represents the current object.
51+
/// </returns>
6152
public override string ToString()
6253
{
63-
return $"{typeof(Employee).Name} [{nameof(Name)}={Name}, {nameof(Salary)}={Salary}, " +
64-
$"{nameof(OrganizationId)}={OrganizationId}]";
54+
return string.Format("{0} [street={1}, zip={2}]", typeof(Address).Name, Street, Zip);
6555
}
6656
}
6757
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.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>{4D8DDA6D-4616-4DF1-A2DA-22FB3A5EC817}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>Apache.Ignite.Core.Tests.TestDll2</RootNamespace>
11+
<AssemblyName>Apache.Ignite.Core.Tests.TestDll2</AssemblyName>
12+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup>
16+
<SignAssembly>true</SignAssembly>
17+
</PropertyGroup>
18+
<PropertyGroup>
19+
<AssemblyOriginatorKeyFile>Apache.Ignite.Core.Tests.TestDll2.snk</AssemblyOriginatorKeyFile>
20+
</PropertyGroup>
21+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
22+
<DebugSymbols>true</DebugSymbols>
23+
<OutputPath>bin\Debug\</OutputPath>
24+
<PlatformTarget>AnyCPU</PlatformTarget>
25+
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
26+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
27+
</PropertyGroup>
28+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
29+
<OutputPath>bin\Release\</OutputPath>
30+
<Optimize>true</Optimize>
31+
<PlatformTarget>AnyCPU</PlatformTarget>
32+
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
33+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
34+
</PropertyGroup>
35+
<PropertyGroup>
36+
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
37+
</PropertyGroup>
38+
<ItemGroup>
39+
<Reference Include="System" />
40+
<Reference Include="System.Core" />
41+
</ItemGroup>
42+
<ItemGroup>
43+
<Compile Include="Account.cs" />
44+
<Compile Include="Address.cs" />
45+
<Compile Include="Properties\AssemblyInfo.cs" />
46+
</ItemGroup>
47+
<ItemGroup>
48+
<None Include="Apache.Ignite.Core.Tests.TestDll2.snk" />
49+
</ItemGroup>
50+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
51+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
52+
Other similar extension points exist, see Microsoft.Common.targets.
53+
<Target Name="BeforeBuild">
54+
</Target>
55+
<Target Name="AfterBuild">
56+
</Target>
57+
-->
58+
</Project>
Binary file not shown.

modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs renamed to modules/platforms/dotnet/Apache.Ignite.Core.Tests.TestDll2/Properties/AssemblyInfo.cs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,25 @@
1818
using System.Reflection;
1919
using System.Runtime.InteropServices;
2020

21-
[assembly: AssemblyTitle("Apache Ignite.NET Examples Library")]
22-
[assembly: AssemblyDescription("")]
21+
[assembly: AssemblyTitle("Apache.Ignite.Core.Tests.TestDll2")]
22+
[assembly: AssemblyDescription("Apache Ignite.NET Tests Library 2")]
2323
[assembly: AssemblyConfiguration("")]
2424
[assembly: AssemblyCompany("Apache Software Foundation")]
2525
[assembly: AssemblyProduct("Apache Ignite.NET")]
2626
[assembly: AssemblyCopyright("Copyright 2021")]
2727
[assembly: AssemblyTrademark("")]
2828
[assembly: AssemblyCulture("")]
2929

30-
[assembly: ComVisible(false)]
31-
32-
[assembly: Guid("ce65ec7c-d3cf-41ad-8f45-f90d5af68d77")]
33-
34-
[assembly: AssemblyVersion("1.0.*")]
30+
// Version information for an assembly consists of the following four values:
31+
//
32+
// Major Version
33+
// Minor Version
34+
// Build Number
35+
// Revision
36+
//
37+
// You can specify all the values or you can default the Build and Revision Numbers
38+
// by using the '*' as shown below:
39+
// [assembly: AssemblyVersion("1.0.*")]
40+
[assembly: AssemblyVersion("2.11.0.51807")]
41+
[assembly: AssemblyFileVersion("2.11.0.51807")]
42+
[assembly: AssemblyInformationalVersion("2.11.0")]

modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.DotNetCore.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
4242
</None>
4343
<None Remove="Deployment\**" />
44-
<None Remove="Examples\**" />
4544

4645
<None Update="Config\ignite-halthandler-dotnet-cfg.xml" CopyToOutputDirectory="PreserveNewest" />
4746
<None Update="Config\native-client-test-cache-affinity.xml" CopyToOutputDirectory="PreserveNewest" />
@@ -102,13 +101,11 @@
102101

103102
<ItemGroup>
104103
<Compile Remove="Deployment\**" />
105-
<Compile Remove="Examples\**" />
106104
<Compile Remove="Compute\Forked\**" />
107105
</ItemGroup>
108106

109107
<ItemGroup>
110108
<EmbeddedResource Remove="Deployment\**" />
111-
<EmbeddedResource Remove="Examples\**" />
112109
<EmbeddedResource Remove="Compute\Forked\**" />
113110
</ItemGroup>
114111

modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -360,10 +360,6 @@
360360
<Compile Include="DataStructures\AtomicSequenceTest.cs" />
361361
<Compile Include="DeploymentTest.cs" />
362362
<Compile Include="EventsTest.cs" />
363-
<Compile Include="Examples\Example.cs" />
364-
<Compile Include="Examples\ExamplesTest.cs" />
365-
<Compile Include="Examples\PathUtil.cs" />
366-
<Compile Include="Examples\ProjectFilesTest.cs" />
367363
<Compile Include="ExceptionsTest.cs" />
368364
<Compile Include="ExecutableTest.cs" />
369365
<Compile Include="FutureTest.cs" />
@@ -411,6 +407,11 @@
411407
<Compile Include="WindowsServiceTest.cs" />
412408
</ItemGroup>
413409
<ItemGroup>
410+
<ProjectReference Include="..\Apache.Ignite.Core.Tests.TestDll2\Apache.Ignite.Core.Tests.TestDll2.csproj">
411+
<Project>{f4a69e2d-908e-4f0f-a794-84d508d60e5f}</Project>
412+
<Name>Apache.Ignite.Core.Tests.TestDll2</Name>
413+
<Aliases>TestDll2</Aliases>
414+
</ProjectReference>
414415
<ProjectReference Include="..\Apache.Ignite.Core\Apache.Ignite.Core.csproj">
415416
<Project>{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}</Project>
416417
<Name>Apache.Ignite.Core</Name>
@@ -431,15 +432,6 @@
431432
<Project>{27F7F3C6-BDDE-43A9-B565-856F8395A04B}</Project>
432433
<Name>Apache.Ignite</Name>
433434
</ProjectReference>
434-
<ProjectReference Include="..\examples\Apache.Ignite.ExamplesDll\Apache.Ignite.ExamplesDll.csproj">
435-
<Project>{dfb08363-202e-412d-8812-349ef10a8702}</Project>
436-
<Name>Apache.Ignite.ExamplesDll</Name>
437-
<Aliases>ExamplesDll</Aliases>
438-
</ProjectReference>
439-
<ProjectReference Include="..\examples\Apache.Ignite.Examples\Apache.Ignite.Examples.csproj">
440-
<Project>{069fa680-3c4d-43a9-b84f-e67513b87827}</Project>
441-
<Name>Apache.Ignite.Examples</Name>
442-
</ProjectReference>
443435
<ProjectReference Include="..\Apache.Ignite.Core.Tests.TestDll\Apache.Ignite.Core.Tests.TestDll.csproj">
444436
<Project>{F4A69E2D-908E-4F0F-A794-84D508D60E5F}</Project>
445437
<Name>Apache.Ignite.Core.Tests.TestDll</Name>
@@ -623,4 +615,4 @@
623615
<Target Name="AfterBuild">
624616
</Target>
625617
-->
626-
</Project>
618+
</Project>

modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryDynamicRegistrationTest.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
namespace Apache.Ignite.Core.Tests.Binary
2020
{
2121
#if !NETCOREAPP
22-
extern alias ExamplesDll;
23-
using Apache.Ignite.ExamplesDll.Binary;
24-
using ExamplesAccount = ExamplesDll::Apache.Ignite.ExamplesDll.Binary.Account;
22+
extern alias TestDll2;
23+
using Apache.Ignite.Core.Tests.TestDll2;
24+
using ExamplesAccount = TestDll2.Apache.Ignite.Core.Tests.TestDll2.Account;
2525
#endif
2626

2727
using System;
@@ -596,10 +596,10 @@ public DateTime Invoke()
596596
}
597597

598598
#if !NETCOREAPP
599-
namespace Apache.Ignite.ExamplesDll.Binary
599+
namespace Apache.Ignite.Core.Tests.TestDll2
600600
{
601601
/// <summary>
602-
/// Copy of Account class in ExamplesDll. Same name and namespace, different assembly.
602+
/// Copy of Account class in TestDll2. Same name and namespace, different assembly.
603603
/// </summary>
604604
public class Account
605605
{

0 commit comments

Comments
 (0)