Skip to content

Commit 0fd86a4

Browse files
committed
Initial code commit, forked from: https://github.com/LinksPlatform/Helpers
1 parent 97c0502 commit 0fd86a4

14 files changed

+356
-1
lines changed

.travis.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
language: csharp
2+
sudo: required
3+
dist: xenial
4+
mono: latest
5+
dotnet: 2.2
6+
before_install:
7+
- sudo apt-get install -y texlive texlive-lang-cyrillic texlive-latex-extra python-pygments ghostscript
8+
- export TRAVIS_REPO_NAME=$(echo "${TRAVIS_REPO_SLUG#*/}" | sed 's/.*/\u&/')
9+
- export SOURCE_BRANCH="master"
10+
script:
11+
- dotnet build -c Release
12+
after_success:
13+
- bash ./generate-pdf.sh
14+
- bash ./publish-docs.sh

Counter.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System.Runtime.CompilerServices;
2+
3+
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
4+
5+
namespace Platform.Counters
6+
{
7+
/// <remarks>
8+
/// Must be class, not struct (in order to persist access to Count field value).
9+
/// </remarks>
10+
public class Counter
11+
{
12+
protected ulong _count;
13+
public ulong Count => _count;
14+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
15+
public void Increment() => _count++;
16+
}
17+
}

Counter[TValue, TDecision].cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System.Runtime.CompilerServices;
2+
3+
#pragma warning disable IDE0060 // Remove unused parameter
4+
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
5+
6+
namespace Platform.Counters
7+
{
8+
public class Counter<TValue, TDecision> : Counter
9+
{
10+
private readonly TDecision _trueValue;
11+
12+
public Counter(TDecision trueValue) => _trueValue = trueValue;
13+
14+
public Counter() { }
15+
16+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
17+
public TDecision IncrementAndReturnTrue()
18+
{
19+
_count++;
20+
return _trueValue;
21+
}
22+
23+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
24+
public TDecision IncrementAndReturnTrue(TValue value)
25+
{
26+
_count++;
27+
return _trueValue;
28+
}
29+
}
30+
}

Counter[TValue].cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System.Runtime.CompilerServices;
2+
3+
#pragma warning disable IDE0060 // Remove unused parameter
4+
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
5+
6+
namespace Platform.Counters
7+
{
8+
public class Counter<TValue> : Counter
9+
{
10+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
11+
public bool IncrementAndReturnTrue()
12+
{
13+
_count++;
14+
return true;
15+
}
16+
17+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
18+
public bool IncrementAndReturnTrue(TValue value)
19+
{
20+
_count++;
21+
return true;
22+
}
23+
}
24+
}

Platform.Counters.csproj

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<Description>LinksPlatform's Platform.Counters Class Library</Description>
5+
<Copyright>Konstantin Diachenko</Copyright>
6+
<AssemblyTitle>Platform.Counters</AssemblyTitle>
7+
<VersionPrefix>0.0.1</VersionPrefix>
8+
<Authors>Konstantin Diachenko</Authors>
9+
<TargetFramework>netstandard2.0</TargetFramework>
10+
<AssemblyName>Platform.Counters</AssemblyName>
11+
<PackageId>Platform.Counters</PackageId>
12+
<PackageTags>LinksPlatform;Counters;</PackageTags>
13+
<PackageIconUrl>https://raw.githubusercontent.com/linksplatform/Documentation/18469f4d033ee9a5b7b84caab9c585acab2ac519/doc/Avatar-rainbow-icon-64x64.png</PackageIconUrl>
14+
<PackageProjectUrl>https://linksplatform.github.io/Counters</PackageProjectUrl>
15+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
16+
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
17+
<RepositoryType>git</RepositoryType>
18+
<RepositoryUrl>git://github.com/linksplatform/Counters</RepositoryUrl>
19+
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
20+
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
21+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
22+
<IncludeSymbols>true</IncludeSymbols>
23+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
24+
<PackageReleaseNotes>Initial release.</PackageReleaseNotes>
25+
</PropertyGroup>
26+
27+
</Project>

Platform.Counters.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29209.62
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Platform.Counters", "Platform.Counters.csproj", "{33387358-3CDE-4A70-84F8-4C7E5E2DC42B}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{33387358-3CDE-4A70-84F8-4C7E5E2DC42B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{33387358-3CDE-4A70-84F8-4C7E5E2DC42B}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{33387358-3CDE-4A70-84F8-4C7E5E2DC42B}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{33387358-3CDE-4A70-84F8-4C7E5E2DC42B}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {B5D9906D-4D99-4755-8DAB-A1770E132736}
24+
EndGlobalSection
25+
EndGlobal

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,25 @@
1-
# Counters
1+
[![Build Status](https://travis-ci.com/linksplatform/Counters.svg?branch=master)](https://travis-ci.com/linksplatform/Counters)
2+
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/f095ae6c0742405399a34ad50ec6ab8d)](https://app.codacy.com/app/drakonard/Counters?utm_source=github.com&utm_medium=referral&utm_content=linksplatform/Counters&utm_campaign=Badge_Grade_Dashboard)
3+
[![CodeFactor](https://www.codefactor.io/repository/github/linksplatform/Counters/badge)](https://www.codefactor.io/repository/github/linksplatform/Counters)
4+
5+
# [Counters](https://github.com/linksplatform/Counters)
6+
7+
LinksPlatform's Platform.Counters Class Library.
8+
9+
Namespace: [Platform.Counters](https://linksplatform.github.io/Counters/api/Platform.Counters.html)
10+
11+
Forked from: [LinksPlatform/Helpers/Counters](https://github.com/linksplatform/Helpers/tree/e27f7586f8015cad596b6aa3c2df2ac2a3dadb60/Counters)
12+
13+
NuGet package: [Platform.Counters](https://www.nuget.org/packages/Platform.Counters)
14+
15+
## [Documentation](https://linksplatform.github.io/Counters)
16+
[PDF file](https://linksplatform.github.io/Counters/Platform.Counters.pdf) with code for e-readers.
17+
18+
## Mystery files
19+
* [.travis.yml](https://github.com/linksplatform/Counters/blob/master/.travis.yml) - Travis CI build configuration.
20+
* [docfx.json](https://github.com/linksplatform/Counters/blob/master/docfx.json) and [toc.yml](https://github.com/linksplatform/Counters/blob/master/toc.yml) - DocFX build configuration.
21+
* [format-document.sh](https://github.com/linksplatform/Counters/blob/master/format-document.sh) - script for formating `tex` file for generating PDF from it.
22+
* [format-csharp-files.py](https://github.com/linksplatform/Counters/blob/master/format-csharp-files.py) - script for formating single `.cs` file as a part of `tex` file.
23+
* [generate-pdf.sh](https://github.com/linksplatform/Counters/blob/master/generate-pdf.sh) - script that generates PDF with code for e-readers.
24+
* [publish-docs.sh](https://github.com/linksplatform/Counters/blob/master/publish-docs.sh) - script that publishes generated documentation and PDF with code for e-readers to `gh-pages` branch.
25+
* [push-nuget.bat](https://github.com/linksplatform/Counters/blob/master/push-nuget.bat) - Windows script for publishing current version of NuGet package.

docfx.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"metadata": [
3+
{
4+
"src": [
5+
{
6+
"files": [ "**/*.sln" ],
7+
"exclude": [ "**/bin/**", "**/obj/**" ],
8+
"src": ""
9+
}
10+
],
11+
"dest": "obj/api"
12+
}
13+
],
14+
"build": {
15+
"content": [
16+
{
17+
"files": [ "**/*.yml" ],
18+
"src": "obj/api",
19+
"dest": "api"
20+
},
21+
{
22+
"files": [ "*.md", "toc.yml" ]
23+
}
24+
],
25+
"globalMetadata": {
26+
"_appTitle": "LinksPlatform's Platform.$TRAVIS_REPO_NAME Library",
27+
"_enableSearch": true,
28+
"_gitContribute": {
29+
"branch": "master"
30+
},
31+
"_gitUrlPattern": "github"
32+
},
33+
"markdownEngineName": "markdig",
34+
"dest": "_site",
35+
"xrefService": [ "https://xref.docs.microsoft.com/query?uid={uid}" ]
36+
}
37+
}

format-csharp-files.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/python
2+
# -*- coding: utf-8 -*-
3+
import sys
4+
reload(sys)
5+
sys.setdefaultencoding('utf-8')
6+
for line in sys.stdin.readlines():
7+
line = line.strip()
8+
print "\\index{%s}" % (line.replace('_','\\_'))
9+
print "\\begin{section}{%s}" % (line.replace('_','\\_'))
10+
#print "\\inputminted[tabsize=2,breaklines,linenos=true]{csharp}{%s}" % (line)
11+
print "\\begin{minted}[tabsize=2,breaklines,breakanywhere,linenos=true,xleftmargin=7mm,framesep=4mm]{csharp}"
12+
f = open(line,"rt")
13+
c = "\n".join([x.strip("\n") for x in f.readlines()])
14+
f.close()
15+
c = c.replace(u'\ufeff','')
16+
print c
17+
print "\\end{minted}"
18+
print "\\end{section}"
19+
print

format-document.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
set -e # Exit with nonzero exit code if anything fails
3+
4+
# Download fvextra package
5+
wget https://raw.githubusercontent.com/gpoore/fvextra/cc1c0c5f7b92023cfec67084e2a87bdac520414c/fvextra/fvextra.sty
6+
7+
echo """
8+
\\documentclass[11pt,a4paper,fleqn]{report}
9+
\\usepackage[left=5mm,top=5mm,right=5mm,bottom=5mm]{geometry}
10+
\\textwidth=200mm
11+
\\usepackage[utf8]{inputenc}
12+
\\usepackage[T1]{fontenc}
13+
\\usepackage[T2A]{fontenc}
14+
\\usepackage{fvextra}
15+
\\usepackage{minted}
16+
\\usemintedstyle{vs}
17+
\\usepackage{makeidx}
18+
\\usepackage[columns=1]{idxlayout}
19+
\\makeindex
20+
\\renewcommand{\\thesection}{\\arabic{chapter}.\\arabic{section}}
21+
\\setcounter{chapter}{1}
22+
\\setcounter{section}{0}
23+
\\usepackage[tiny]{titlesec}
24+
\\titlespacing\\chapter{0mm}{0mm}{0mm}
25+
\\titlespacing\\section{0mm}{0mm}{0mm}
26+
\\DeclareUnicodeCharacter{221E}{\\ensuremath{\\infty}}
27+
\\DeclareUnicodeCharacter{FFFD}{\\ensuremath{ }}
28+
\\usepackage{fancyhdr}
29+
\\pagestyle{fancy}
30+
\\fancyhf{}
31+
\\fancyfoot[C]{\\thepage}
32+
\\renewcommand{\\headrulewidth}{0mm}
33+
\\renewcommand{\\footrulewidth}{0mm}
34+
\\renewcommand{\\baselinestretch}{0.7}
35+
\\begin{document}
36+
\\sf
37+
\\noindent{\\Large LinksPlatform's Platform.${TRAVIS_REPO_NAME} Class Library}
38+
"""
39+
40+
# Remove auto-generated code files
41+
find ./obj -type f -iname "*.cs" -delete
42+
43+
# CSharp files
44+
#find * -type f -iname '*.cs' -exec sh -c 'enconv "{}"' \;
45+
find . -type f -iname '*.cs' | sort -b | python format-csharp-files.py
46+
47+
echo """
48+
\\printindex
49+
\\end{document}
50+
"""

0 commit comments

Comments
 (0)