├── tools
├── app-version-number.txt
├── Install-DotNet.sh
└── Install-DotNet.ps1
├── screenshot.png
├── .nuke
└── parameters.json
├── src
├── build
│ ├── PlatformTarget.cs
│ ├── Directory.Build.targets
│ ├── AppVersion
│ │ ├── CSharpVersionUpdateRule.cs
│ │ ├── AppVersion.cs
│ │ ├── VersionString.cs
│ │ ├── VersionUpdateRule.cs
│ │ ├── CSharpUpdater.cs
│ │ └── AppxManifestUpdater.cs
│ ├── Configuration.cs
│ ├── .editorconfig
│ ├── _build.csproj
│ ├── DotnetParameters.cs
│ └── Directory.Build.props
├── app
│ ├── dev
│ │ ├── NotepadBasedCalculator.Desktop.Mac
│ │ │ ├── Assets.xcassets
│ │ │ │ ├── Contents.json
│ │ │ │ └── AppIcon.appiconset
│ │ │ │ │ ├── AppIcon-16.png
│ │ │ │ │ ├── AppIcon-32.png
│ │ │ │ │ ├── AppIcon-128.png
│ │ │ │ │ ├── AppIcon-256.png
│ │ │ │ │ ├── AppIcon-512.png
│ │ │ │ │ ├── AppIcon-128@2x.png
│ │ │ │ │ ├── AppIcon-16@2x.png
│ │ │ │ │ ├── AppIcon-256@2x.png
│ │ │ │ │ ├── AppIcon-32@2x.png
│ │ │ │ │ ├── AppIcon-512@2x.png
│ │ │ │ │ └── Contents.json
│ │ │ ├── Properties
│ │ │ │ └── AssemblyInfo.cs
│ │ │ ├── Entitlements.plist
│ │ │ ├── PlatformInitializer.cs
│ │ │ ├── Info.plist
│ │ │ ├── AppDelegate.cs
│ │ │ ├── NotepadBasedCalculator.Desktop.Mac.csproj
│ │ │ └── Program.cs
│ │ ├── NotepadBasedCalculator.Desktop.Windows
│ │ │ ├── Properties
│ │ │ │ └── AssemblyInfo.cs
│ │ │ ├── PlatformInitializer.cs
│ │ │ ├── NotepadBasedCalculator.Desktop.Windows.csproj
│ │ │ └── Program.cs
│ │ ├── Directory.Build.targets
│ │ ├── NotepadBasedCalculator.Api
│ │ │ ├── Lexer
│ │ │ │ ├── ITokenEnumerator.cs
│ │ │ │ ├── ILexer.cs
│ │ │ │ ├── LinkedToken.cs
│ │ │ │ └── TokenizedTextLine.cs
│ │ │ ├── Data
│ │ │ │ ├── IDecimal.cs
│ │ │ │ ├── ISupportMultipleDataTypeForArithmeticOperation.cs
│ │ │ │ ├── IValueRelativeToOtherData.cs
│ │ │ │ ├── Definition
│ │ │ │ │ └── CurrencyValue.cs
│ │ │ │ ├── IDataParser.cs
│ │ │ │ ├── IData.cs
│ │ │ │ ├── INumericData.cs
│ │ │ │ └── Data.cs
│ │ │ ├── Metadata
│ │ │ │ ├── IOrderableMetadata.cs
│ │ │ │ ├── NameAttribute.cs
│ │ │ │ ├── FunctionInterpreterMetadata.cs
│ │ │ │ ├── CultureAttribute.cs
│ │ │ │ ├── CultureCodeMetadata.cs
│ │ │ │ ├── SupportedCultures.cs
│ │ │ │ ├── OrderAttribute.cs
│ │ │ │ └── ParserAndInterpreterMetadata.cs
│ │ │ ├── DataOperationException.cs
│ │ │ ├── AbstractSyntaxTree
│ │ │ │ ├── Statement.cs
│ │ │ │ ├── Expression.cs
│ │ │ │ ├── ReferenceExpression.cs
│ │ │ │ ├── DataExpression.cs
│ │ │ │ ├── FunctionExpression.cs
│ │ │ │ ├── VariableReferenceExpression.cs
│ │ │ │ ├── AbstractSyntaxTreeBase.cs
│ │ │ │ ├── GroupExpression.cs
│ │ │ │ ├── VariableDeclarationStatement.cs
│ │ │ │ ├── BinaryOperatorExpression.cs
│ │ │ │ └── BinaryOperatorType.cs
│ │ │ ├── Grammar
│ │ │ │ ├── IGrammarProvider.cs
│ │ │ │ ├── IFunctionDefinitionProvider.cs
│ │ │ │ ├── TokenDefinitionGrammar.cs
│ │ │ │ └── FunctionDefinition.cs
│ │ │ ├── IncompatibleUnitsException.cs
│ │ │ ├── Core
│ │ │ │ ├── DictionaryExtensions.cs
│ │ │ │ ├── CultureHelper.cs
│ │ │ │ ├── Threading
│ │ │ │ │ ├── CancellationTokenExtension.cs
│ │ │ │ │ ├── AsyncLazy.cs
│ │ │ │ │ ├── DisposableSempahore.cs
│ │ │ │ │ └── TaskExtension.cs
│ │ │ │ ├── DictionaryWithSpecialEnumValueConverter.cs
│ │ │ │ └── EnumExtension.cs
│ │ │ ├── UnsupportedArithmeticOperationException.cs
│ │ │ ├── IMefProvider.cs
│ │ │ ├── NotepadBasedCalculator.Api.csproj
│ │ │ ├── ILogger.cs
│ │ │ ├── ParserAndInterpreter
│ │ │ │ ├── PredefinedExpressionParserAndInterpreterNames.cs
│ │ │ │ ├── PredefinedStatementParserAndInterpreterNames.cs
│ │ │ │ ├── IVariableService.cs
│ │ │ │ ├── StatementParserAndInterpreterResult.cs
│ │ │ │ ├── ExpressionParserAndInterpreterResult.cs
│ │ │ │ ├── IFunctionInterpreter.cs
│ │ │ │ ├── IParserAndInterpretersRepository.cs
│ │ │ │ ├── IStatementParserAndInterpreter.cs
│ │ │ │ └── IExpressionParserAndInterpreter.cs
│ │ │ ├── ICurrencyService.cs
│ │ │ └── IArithmeticAndRelationOperationService.cs
│ │ ├── NotepadBasedCalculator.Desktop
│ │ │ ├── Platform
│ │ │ │ ├── Services
│ │ │ │ │ ├── Theme
│ │ │ │ │ │ ├── UserPreferredTheme.cs
│ │ │ │ │ │ ├── AppTheme.cs
│ │ │ │ │ │ └── IThemeService.cs
│ │ │ │ │ └── IUiService.cs
│ │ │ │ └── IPlatformInitializer.cs
│ │ │ ├── App.axaml
│ │ │ ├── App.axaml.cs
│ │ │ ├── NotepadBasedCalculator.Desktop.csproj
│ │ │ ├── MainWindow.axaml.cs
│ │ │ └── MainWindow.axaml
│ │ ├── NotepadBasedCalculator.BuiltInPlugins
│ │ │ ├── Grammars
│ │ │ │ ├── SpecialTokenDefinition.json
│ │ │ │ ├── en-us
│ │ │ │ │ ├── TokenDefinition.json
│ │ │ │ │ └── FunctionDefinition.json
│ │ │ │ ├── UnitMapProvider.cs
│ │ │ │ ├── GrammarProvider.cs
│ │ │ │ ├── FunctionDefinitionProvider.cs
│ │ │ │ └── fr-fr
│ │ │ │ │ └── UnitNames.json
│ │ │ ├── StatementParsersAndInterpreters
│ │ │ │ ├── Header
│ │ │ │ │ ├── HeaderStatement.cs
│ │ │ │ │ └── HeaderStatementParserAndInterpreter.cs
│ │ │ │ ├── Comment
│ │ │ │ │ ├── CommentStatement.cs
│ │ │ │ │ └── CommentStatementParserAndInterpreter.cs
│ │ │ │ ├── Condition
│ │ │ │ │ └── ConditionStatement.cs
│ │ │ │ ├── NumericalExpression
│ │ │ │ │ ├── NumericalCalculusStatement.cs
│ │ │ │ │ └── NumericalExpressionStatementParserAndInterpreter.cs
│ │ │ │ └── Function
│ │ │ │ │ └── FunctionExpressionStatementParserAndInterpreter.cs
│ │ │ ├── Functions
│ │ │ │ ├── General
│ │ │ │ │ ├── RemainderInterpreter.cs
│ │ │ │ │ ├── MidpointInterpreter.cs
│ │ │ │ │ └── RandomNumberInterpreter.cs
│ │ │ │ └── Percentage
│ │ │ │ │ ├── PercentOfInterpreter.cs
│ │ │ │ │ ├── PercentOnInterpreter.cs
│ │ │ │ │ ├── PercentOffInterpreter.cs
│ │ │ │ │ ├── IsWhatPercentOffInterpreter.cs
│ │ │ │ │ ├── IsPercentOnWhatInterpreter.cs
│ │ │ │ │ ├── IsPercentOfWhatInterpreter.cs
│ │ │ │ │ ├── IsWhatPercentOfInterpreter.cs
│ │ │ │ │ └── IsWhatPercentOnInterpreter.cs
│ │ │ ├── Data
│ │ │ │ ├── BooleanDataParser.cs
│ │ │ │ ├── UnitMap.cs
│ │ │ │ ├── OrdinalDataParser.cs
│ │ │ │ ├── TemperatureDataParser.cs
│ │ │ │ ├── NumberDataParser.cs
│ │ │ │ └── CurrencyDataParser.cs
│ │ │ └── NotepadBasedCalculator.BuiltInPlugins.csproj
│ │ ├── NotepadBasedCalculator.Core
│ │ │ ├── Core
│ │ │ │ └── DescendingComparer.cs
│ │ │ ├── ParserAndInterpreterResultUpdatedEventArgs.cs
│ │ │ ├── TextDocument.cs
│ │ │ ├── Mef
│ │ │ │ ├── MefProvider.cs
│ │ │ │ └── MefComposer.cs
│ │ │ ├── Logger.cs
│ │ │ ├── ParserAndInterpreterFactory.cs
│ │ │ └── NotepadBasedCalculator.Core.csproj
│ │ ├── shared
│ │ │ ├── GlobalUsings.cs
│ │ │ ├── SharedAssemblyVersion.cs
│ │ │ └── SharedAssemblyInfo.cs
│ │ └── Directory.Build.props
│ ├── tools
│ │ ├── NotepadBasedCalculator.Benchmark
│ │ │ ├── Program.cs
│ │ │ ├── NotepadBasedCalculator.Benchmark.csproj
│ │ │ └── CalculatorBenchmarks.cs
│ │ └── Directory.Build.props
│ └── tests
│ │ ├── NotepadBasedCalculator.Core.Tests
│ │ ├── TestHelper.cs
│ │ ├── NotepadBasedCalculator.Core.Tests.csproj
│ │ └── MefBaseTest.cs
│ │ └── NotepadBasedCalculator.StandaloneConsoleTestApp
│ │ └── NotepadBasedCalculator.StandaloneConsoleTestApp.csproj
├── Directory.Build.targets
├── Environment.props
└── Directory.Build.props
├── init.cmd
├── .vscode
├── tasks.json
└── launch.json
├── nuget.config
├── LICENSE.md
├── init.sh
├── init.ps1
└── .gitattributes
/tools/app-version-number.txt:
--------------------------------------------------------------------------------
1 | 0.0.0.0
--------------------------------------------------------------------------------
/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/veler/notepad-based-calculator/HEAD/screenshot.png
--------------------------------------------------------------------------------
/.nuke/parameters.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./build.schema.json",
3 | "Solution": "src/NotepadBasedCalculator.App.sln"
4 | }
--------------------------------------------------------------------------------
/src/build/PlatformTarget.cs:
--------------------------------------------------------------------------------
1 | enum PlatformTarget
2 | {
3 | Windows,
4 | MacOS,
5 | Linux,
6 | iOS,
7 | Android
8 | }
9 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Desktop.Mac/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Desktop.Mac/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Versioning;
2 |
3 | [assembly: SupportedOSPlatform("macos10.14")]
4 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Desktop.Windows/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Versioning;
2 |
3 | [assembly: SupportedOSPlatform("windows10.0.17763.0")]
4 |
--------------------------------------------------------------------------------
/src/app/dev/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/src/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Api/Lexer/ITokenEnumerator.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Api
2 | {
3 | internal interface ITokenEnumerator : IEnumerator
4 | {
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/init.cmd:
--------------------------------------------------------------------------------
1 | :; set -eo pipefail
2 | :; SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
3 | :; ${SCRIPT_DIR}/init.sh "$@"
4 | :; exit $?
5 |
6 | @ECHO OFF
7 | powershell -ExecutionPolicy ByPass -NoProfile -File "%~dp0init.ps1" %*
8 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Desktop.Mac/Assets.xcassets/AppIcon.appiconset/AppIcon-16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/veler/notepad-based-calculator/HEAD/src/app/dev/NotepadBasedCalculator.Desktop.Mac/Assets.xcassets/AppIcon.appiconset/AppIcon-16.png
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Desktop.Mac/Assets.xcassets/AppIcon.appiconset/AppIcon-32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/veler/notepad-based-calculator/HEAD/src/app/dev/NotepadBasedCalculator.Desktop.Mac/Assets.xcassets/AppIcon.appiconset/AppIcon-32.png
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Desktop.Mac/Assets.xcassets/AppIcon.appiconset/AppIcon-128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/veler/notepad-based-calculator/HEAD/src/app/dev/NotepadBasedCalculator.Desktop.Mac/Assets.xcassets/AppIcon.appiconset/AppIcon-128.png
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Desktop.Mac/Assets.xcassets/AppIcon.appiconset/AppIcon-256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/veler/notepad-based-calculator/HEAD/src/app/dev/NotepadBasedCalculator.Desktop.Mac/Assets.xcassets/AppIcon.appiconset/AppIcon-256.png
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Desktop.Mac/Assets.xcassets/AppIcon.appiconset/AppIcon-512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/veler/notepad-based-calculator/HEAD/src/app/dev/NotepadBasedCalculator.Desktop.Mac/Assets.xcassets/AppIcon.appiconset/AppIcon-512.png
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Desktop.Mac/Assets.xcassets/AppIcon.appiconset/AppIcon-128@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/veler/notepad-based-calculator/HEAD/src/app/dev/NotepadBasedCalculator.Desktop.Mac/Assets.xcassets/AppIcon.appiconset/AppIcon-128@2x.png
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Desktop.Mac/Assets.xcassets/AppIcon.appiconset/AppIcon-16@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/veler/notepad-based-calculator/HEAD/src/app/dev/NotepadBasedCalculator.Desktop.Mac/Assets.xcassets/AppIcon.appiconset/AppIcon-16@2x.png
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Desktop.Mac/Assets.xcassets/AppIcon.appiconset/AppIcon-256@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/veler/notepad-based-calculator/HEAD/src/app/dev/NotepadBasedCalculator.Desktop.Mac/Assets.xcassets/AppIcon.appiconset/AppIcon-256@2x.png
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Desktop.Mac/Assets.xcassets/AppIcon.appiconset/AppIcon-32@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/veler/notepad-based-calculator/HEAD/src/app/dev/NotepadBasedCalculator.Desktop.Mac/Assets.xcassets/AppIcon.appiconset/AppIcon-32@2x.png
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Desktop.Mac/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/veler/notepad-based-calculator/HEAD/src/app/dev/NotepadBasedCalculator.Desktop.Mac/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Desktop.Mac/Entitlements.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Desktop/Platform/Services/Theme/UserPreferredTheme.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Desktop.Platform.Services.Theme
2 | {
3 | internal enum UserPreferredTheme
4 | {
5 | Light,
6 | Dark,
7 | Auto
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Desktop/Platform/Services/Theme/AppTheme.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Desktop.Platform.Services.Theme
2 | {
3 | internal enum AppTheme
4 | {
5 | Light,
6 | Dark,
7 | LightHighContrast,
8 | DarkHighContrast
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Api/Data/IDecimal.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Api
2 | {
3 | ///
4 | /// Indicates whether the current data's value is a generic number without unit.
5 | ///
6 | public interface IDecimal : INumericData
7 | {
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Api/Metadata/IOrderableMetadata.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Api
2 | {
3 | public interface IOrderableMetadata
4 | {
5 | IReadOnlyList Before { get; }
6 |
7 | IReadOnlyList After { get; }
8 |
9 | string Name { get; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.BuiltInPlugins/Grammars/SpecialTokenDefinition.json:
--------------------------------------------------------------------------------
1 | {
2 | "common_tokens": {
3 | "comment_operators": [
4 | "//"
5 | ],
6 | "header_operators": [
7 | "#",
8 | "##",
9 | "###",
10 | "####",
11 | "#####",
12 | "######"
13 | ]
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Core/Core/DescendingComparer.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Core
2 | {
3 | internal sealed class DescendingComparer : IComparer where T : IComparable
4 | {
5 | public int Compare(T? x, T? y)
6 | {
7 | return y!.CompareTo(x!);
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/app/tools/NotepadBasedCalculator.Benchmark/Program.cs:
--------------------------------------------------------------------------------
1 | using BenchmarkDotNet.Running;
2 |
3 | namespace NotepadBasedCalculator.Benchmark
4 | {
5 | internal class Program
6 | {
7 | public static void Main(string[] args)
8 | {
9 | new BenchmarkSwitcher(typeof(Program).Assembly).Run(args);
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Api/DataOperationException.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Api
2 | {
3 | public abstract class DataOperationException : Exception
4 | {
5 | public virtual string GetLocalizedMessage(string culture)
6 | {
7 | // TODO: Localize.
8 | return "Unknown error";
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/app/tests/NotepadBasedCalculator.Core.Tests/TestHelper.cs:
--------------------------------------------------------------------------------
1 | using NotepadBasedCalculator.Api;
2 |
3 | namespace NotepadBasedCalculator.Core.Tests
4 | {
5 | public static class TestHelper
6 | {
7 | public static string GetDataDisplayText(this IData data)
8 | {
9 | return data.GetDisplayText(SupportedCultures.English);
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/app/tools/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | enable
7 | disable
8 | false
9 |
10 |
--------------------------------------------------------------------------------
/src/Environment.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | $([MSBuild]::IsOSPlatform('Windows'))
4 | $([MSBuild]::IsOSPlatform('OSX'))
5 | $([MSBuild]::IsOSPlatform('Linux'))
6 |
7 |
8 |
9 | $(DefineConstants);MAC
10 |
11 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Desktop/App.axaml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0.0",
3 | "tasks": [
4 | {
5 | "label": "build",
6 | "type": "shell",
7 | "command": "${workspaceFolder}/build.sh Compile --incremental-build true --configuration Debug",
8 | "windows": {
9 | "command": "${workspaceFolder}\\build.cmd Compile --incremental-build true --configuration Debug"
10 | }
11 | }
12 | ]
13 | }
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Api/AbstractSyntaxTree/Statement.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Api
2 | {
3 | ///
4 | /// Basic class that represents a statement.
5 | ///
6 | public abstract class Statement : AbstractSyntaxTreeBase
7 | {
8 | protected Statement(LinkedToken firstToken, LinkedToken lastToken)
9 | : base(firstToken, lastToken)
10 | {
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Api/Data/ISupportMultipleDataTypeForArithmeticOperation.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Api
2 | {
3 | ///
4 | /// Indicates that the data can perform arithmeric operation with several type of data (not only the current one)
5 | /// and will handle incompatibility itself.
6 | ///
7 | public interface ISupportMultipleDataTypeForArithmeticOperation : INumericData
8 | {
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/app/dev/shared/GlobalUsings.cs:
--------------------------------------------------------------------------------
1 | global using global::CommunityToolkit.Common.Deferred;
2 | global using global::CommunityToolkit.Diagnostics;
3 | global using global::NotepadBasedCalculator.Api;
4 | global using global::System;
5 | global using global::System.ComponentModel;
6 | global using global::System.ComponentModel.Composition;
7 | global using global::System.Diagnostics;
8 | global using ExportAttribute = global::System.ComponentModel.Composition.ExportAttribute;
9 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Api/AbstractSyntaxTree/Expression.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Api
2 | {
3 | ///
4 | /// Basic class that represents an expression in a statement.
5 | ///
6 | public abstract class Expression : AbstractSyntaxTreeBase
7 | {
8 | protected Expression(LinkedToken firstToken, LinkedToken lastToken)
9 | : base(firstToken, lastToken)
10 | {
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Api/AbstractSyntaxTree/ReferenceExpression.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Api
2 | {
3 | ///
4 | /// Basic class for a reference to something.
5 | ///
6 | public abstract class ReferenceExpression : Expression
7 | {
8 | protected ReferenceExpression(LinkedToken firstToken, LinkedToken lastToken)
9 | : base(firstToken, lastToken)
10 | {
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/build/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Desktop/Platform/IPlatformInitializer.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Desktop.Platform
2 | {
3 | ///
4 | /// Provides an entry point for the app to start-up anything platform-specific.
5 | ///
6 | internal interface IPlatformInitializer
7 | {
8 | ///
9 | /// Initializes some platform-specific work.
10 | ///
11 | void Initialize();
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Api/Grammar/IGrammarProvider.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Api
2 | {
3 | ///
4 | /// Represents a grammar provider.
5 | ///
6 | public interface IGrammarProvider
7 | {
8 | ///
9 | /// Loads the token definition grammars for the given culture.
10 | ///
11 | IReadOnlyList? LoadTokenDefinitionGrammars(string culture);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/build/AppVersion/CSharpVersionUpdateRule.cs:
--------------------------------------------------------------------------------
1 | internal class CSharpVersionUpdateRule
2 | {
3 | private readonly VersionUpdateRule _updateRule;
4 | public CSharpVersionUpdateRule(string attributeName, string updateRule)
5 | {
6 | AttributeName = attributeName;
7 | _updateRule = new VersionUpdateRule(updateRule);
8 | }
9 | public string AttributeName { get; private set; }
10 | public string Update(VersionString v) { return _updateRule.Update(v); }
11 | }
12 |
--------------------------------------------------------------------------------
/nuget.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Api/IncompatibleUnitsException.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Api
2 | {
3 | ///
4 | /// Exception thrown when data have incompatible units during an arithmetic operation.
5 | ///
6 | public class IncompatibleUnitsException : DataOperationException
7 | {
8 | public override string GetLocalizedMessage(string culture)
9 | {
10 | // TODO: Localize.
11 | return "Incompatible units";
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/build/Configuration.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using Nuke.Common.Tooling;
3 |
4 | [TypeConverter(typeof(TypeConverter))]
5 | internal sealed class Configuration : Enumeration
6 | {
7 | public static readonly Configuration Debug = new() { Value = nameof(Debug) };
8 | public static readonly Configuration Release = new() { Value = nameof(Release) };
9 |
10 | public static implicit operator string(Configuration configuration)
11 | {
12 | return configuration.Value;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Api/Grammar/IFunctionDefinitionProvider.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Api
2 | {
3 | ///
4 | /// Represents a function definition provider.
5 | ///
6 | public interface IFunctionDefinitionProvider
7 | {
8 | ///
9 | /// Loads the function definitions for the given culture.
10 | ///
11 | IReadOnlyList>> LoadFunctionDefinitions(string culture);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Api/Core/DictionaryExtensions.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Api
2 | {
3 | public static class DictionaryExtensions
4 | {
5 | ///
6 | /// Gets the value at the given key, or a default value.
7 | ///
8 | public static TValue? GetValueOrDefault(this IDictionary dictionary, TKey key)
9 | {
10 | return dictionary.TryGetValue(key, out TValue? value) ? value : default;
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Desktop/Platform/Services/IUiService.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Styling;
2 | using NotepadBasedCalculator.Desktop.Platform.Services.Theme;
3 |
4 | namespace NotepadBasedCalculator.Desktop.Platform.Services
5 | {
6 | internal interface IUiService
7 | {
8 | ///
9 | /// Gets the list of UI styles to use on the platform, applying to the given .
10 | ///
11 | IEnumerable GetPlatformSpecificStyles(AppTheme theme);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Api/Data/IValueRelativeToOtherData.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Api
2 | {
3 | ///
4 | /// Indicates that a data is always relative to another one.
5 | ///
6 | public interface IValueRelativeToOtherData : INumericData
7 | {
8 | ///
9 | /// Gets the value, in standard unit, relative to the given data.
10 | ///
11 | double GetStandardUnitValueRelativeTo(INumericData other);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Api/UnsupportedArithmeticOperationException.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Api
2 | {
3 | ///
4 | /// Exception thrown when an arithmetic operation isn't supported.
5 | ///
6 | public class UnsupportedArithmeticOperationException : DataOperationException
7 | {
8 | public override string GetLocalizedMessage(string culture)
9 | {
10 | // TODO: Localize.
11 | return "Unsupported arithmetic operation";
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Api/Data/Definition/CurrencyValue.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Api
2 | {
3 | public struct CurrencyValue
4 | {
5 | public CurrencyValue(double value, string currency, string isoCurrency)
6 | {
7 | Value = value;
8 | Currency = currency;
9 | IsoCurrency = isoCurrency;
10 | }
11 |
12 | public double Value { get; }
13 |
14 | public string Currency { get; }
15 |
16 | public string IsoCurrency { get; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Core/ParserAndInterpreterResultUpdatedEventArgs.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Core
2 | {
3 | internal sealed class ParserAndInterpreterResultUpdatedEventArgs : DeferredCancelEventArgs
4 | {
5 | internal IReadOnlyList? ResultPerLines { get; }
6 |
7 | public ParserAndInterpreterResultUpdatedEventArgs(IReadOnlyList? resultPerLines)
8 | {
9 | ResultPerLines = resultPerLines;
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.BuiltInPlugins/StatementParsersAndInterpreters/Header/HeaderStatement.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.BuiltInPlugins.StatementParsersAndInterpreters.Header
2 | {
3 | internal sealed class HeaderStatement : Statement
4 | {
5 | internal HeaderStatement(LinkedToken firstToken, LinkedToken lastToken)
6 | : base(firstToken, lastToken)
7 | {
8 | }
9 |
10 | public override string ToString()
11 | {
12 | return "Header";
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Api/IMefProvider.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Api
2 | {
3 | ///
4 | /// Provides a way to import MEF components on the fly.
5 | ///
6 | public interface IMefProvider
7 | {
8 | ///
9 | /// Imports the given type.
10 | ///
11 | TExport Import();
12 |
13 | ///
14 | /// Imports the given type.
15 | ///
16 | IEnumerable ImportMany();
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.BuiltInPlugins/StatementParsersAndInterpreters/Comment/CommentStatement.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.BuiltInPlugins.StatementParsersAndInterpreters.Comment
2 | {
3 | internal sealed class CommentStatement : Statement
4 | {
5 | internal CommentStatement(LinkedToken firstToken, LinkedToken lastToken)
6 | : base(firstToken, lastToken)
7 | {
8 | }
9 |
10 | public override string ToString()
11 | {
12 | return "Comment";
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Desktop.Windows/PlatformInitializer.cs:
--------------------------------------------------------------------------------
1 | using NotepadBasedCalculator.Desktop.Platform;
2 |
3 | namespace NotepadBasedCalculator.Desktop.Windows
4 | {
5 | [Export(typeof(IPlatformInitializer))]
6 | internal sealed class PlatformInitializer : IPlatformInitializer
7 | {
8 | private bool _isInitialized;
9 |
10 | public void Initialize()
11 | {
12 | if (!_isInitialized)
13 | {
14 | _isInitialized = true;
15 | }
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/build/.editorconfig:
--------------------------------------------------------------------------------
1 | [*.cs]
2 | dotnet_style_qualification_for_field = false:warning
3 | dotnet_style_qualification_for_property = false:warning
4 | dotnet_style_qualification_for_method = false:warning
5 | dotnet_style_qualification_for_event = false:warning
6 | dotnet_style_require_accessibility_modifiers = never:warning
7 |
8 | csharp_style_expression_bodied_methods = true:silent
9 | csharp_style_expression_bodied_properties = true:warning
10 | csharp_style_expression_bodied_indexers = true:warning
11 | csharp_style_expression_bodied_accessors = true:warning
12 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Api/Data/IDataParser.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Api
2 | {
3 | ///
4 | /// Provides a way to extract a data out from a line of text such as a number or a date.
5 | ///
6 | public interface IDataParser
7 | {
8 | ///
9 | /// Parses the data in the given .
10 | ///
11 | IReadOnlyList? Parse(string culture, TokenizedTextLine tokenizedTextLine, CancellationToken cancellationToken);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Api/Grammar/TokenDefinitionGrammar.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 | using Newtonsoft.Json;
3 |
4 | namespace NotepadBasedCalculator.Api
5 | {
6 | [DataContract]
7 | public class TokenDefinitionGrammar
8 | {
9 | [DataMember(Name = "common_tokens")]
10 | public Dictionary? CommonTokens { get; set; }
11 |
12 | public static TokenDefinitionGrammar? Load(string json)
13 | {
14 | return JsonConvert.DeserializeObject(json);
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Desktop.Mac/PlatformInitializer.cs:
--------------------------------------------------------------------------------
1 | using NotepadBasedCalculator.Desktop.Platform;
2 |
3 | namespace NotepadBasedCalculator.Desktop.Mac
4 | {
5 | [Export(typeof(IPlatformInitializer))]
6 | internal sealed class PlatformInitializer : IPlatformInitializer
7 | {
8 | private bool _isInitialized;
9 |
10 | public void Initialize()
11 | {
12 | if (!_isInitialized)
13 | {
14 | _isInitialized = true;
15 | AppDelegate.Init();
16 | }
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Api/Lexer/ILexer.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Api
2 | {
3 | ///
4 | /// A service for tokenizing a text.
5 | ///
6 | public interface ILexer
7 | {
8 | ///
9 | /// Tokenize the given text, line by line.
10 | ///
11 | /// See .
12 | /// The text to tokenize.
13 | IReadOnlyList Tokenize(string culture, string? wholeDocument);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/build/_build.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | $(NetCore)
6 |
7 | CS0649;CS0169
8 | ..\..
9 | ..\..
10 | 1
11 | false
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Api/AbstractSyntaxTree/DataExpression.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Api
2 | {
3 | public class DataExpression : ReferenceExpression
4 | {
5 | public IData Data { get; }
6 |
7 | public DataExpression(LinkedToken firstToken, LinkedToken lastToken, IData data)
8 | : base(firstToken, lastToken)
9 | {
10 | Guard.IsNotNull(data);
11 | Data = data;
12 | }
13 |
14 | public override string ToString()
15 | {
16 | return Data.ToString() ?? string.Empty;
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Core/TextDocument.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Core
2 | {
3 | ///
4 | /// Represents a text document.
5 | ///
6 | internal sealed class TextDocument
7 | {
8 | private string _text = string.Empty;
9 |
10 | internal string Text
11 | {
12 | get => _text;
13 | set
14 | {
15 | _text = value ?? string.Empty;
16 | TextChanged?.Invoke(this, EventArgs.Empty);
17 | }
18 | }
19 |
20 | internal event EventHandler? TextChanged;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Api/Metadata/NameAttribute.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Api
2 | {
3 | ///
4 | /// Defines the internal name of this component. This name can be used to explicitly request this component to be invoked.
5 | ///
6 | [MetadataAttribute]
7 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
8 | public class NameAttribute : Attribute
9 | {
10 | public string Name { get; }
11 |
12 | public NameAttribute(string name)
13 | {
14 | Guard.IsNotEmpty(name);
15 | Name = name;
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Core/Mef/MefProvider.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.Composition.Hosting;
2 |
3 | namespace NotepadBasedCalculator.Core.Mef
4 | {
5 | [Export(typeof(IMefProvider))]
6 | internal sealed class MefProvider : IMefProvider
7 | {
8 | internal ExportProvider? ExportProvider { get; set; }
9 |
10 | public TExport Import()
11 | {
12 | return ExportProvider!.GetExport()!.Value;
13 | }
14 |
15 | public IEnumerable ImportMany()
16 | {
17 | return ExportProvider!.GetExports().Select(e => e.Value);
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Api/AbstractSyntaxTree/FunctionExpression.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Api
2 | {
3 | public sealed class FunctionExpression : Expression
4 | {
5 | public FunctionDefinition FunctionDefinition { get; }
6 |
7 | public FunctionExpression(FunctionDefinition functionDefinition, LinkedToken firstToken, LinkedToken lastToken)
8 | : base(firstToken, lastToken)
9 | {
10 | FunctionDefinition = functionDefinition;
11 | }
12 |
13 | public override string ToString()
14 | {
15 | return $"function {FunctionDefinition.FunctionFullName}()";
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Api/Core/CultureHelper.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Api
2 | {
3 | public static class CultureHelper
4 | {
5 | ///
6 | /// Determines whether the given is compatible with the .
7 | ///
8 | public static bool IsCultureApplicable(string culture, string targetCulture)
9 | {
10 | Guard.IsNotNull(culture);
11 | Guard.IsNotNull(targetCulture);
12 | return culture == SupportedCultures.Any || string.Equals(culture, targetCulture, StringComparison.OrdinalIgnoreCase);
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Api/NotepadBasedCalculator.Api.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(NetCoreAndStandard)
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Api/Metadata/FunctionInterpreterMetadata.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Api
2 | {
3 | public sealed class FunctionInterpreterMetadata : CultureCodeMetadata
4 | {
5 | public string Name { get; }
6 |
7 | public FunctionInterpreterMetadata(IDictionary metadata)
8 | : base(metadata)
9 | {
10 | if (metadata.TryGetValue(nameof(NameAttribute.Name), out object? value) && value is string name)
11 | {
12 | Name = name;
13 | }
14 | else
15 | {
16 | Name = string.Empty;
17 | }
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Api/ILogger.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Api
2 | {
3 | ///
4 | /// Provides a way to log information for debugging purpose.
5 | ///
6 | public interface ILogger
7 | {
8 | void Log(string logName, params ValueTuple[]? properties);
9 |
10 | void Log(string logName, string? description, params ValueTuple[]? properties);
11 |
12 | void LogFault(string logName, Exception ex, params ValueTuple[]? properties);
13 |
14 | void LogFault(string logName, Exception ex, string description, params ValueTuple[]? properties);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/build/DotnetParameters.cs:
--------------------------------------------------------------------------------
1 | using Nuke.Common.IO;
2 |
3 | internal sealed record DotnetParameters
4 | {
5 | internal readonly AbsolutePath ProjectOrSolutionPath;
6 |
7 | internal readonly string RuntimeIdentifier;
8 |
9 | internal readonly string TargetFramework;
10 |
11 | internal readonly bool PublishTrimmed;
12 |
13 | public DotnetParameters(AbsolutePath projectOrSolutionPath, string runtimeIdentifier, string targetFramework, bool publishTrimmed)
14 | {
15 | ProjectOrSolutionPath = projectOrSolutionPath;
16 | RuntimeIdentifier = runtimeIdentifier;
17 | TargetFramework = targetFramework;
18 | PublishTrimmed = publishTrimmed;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Api/ParserAndInterpreter/PredefinedExpressionParserAndInterpreterNames.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Api
2 | {
3 | ///
4 | /// Contains a list of pre-defined known expression parser and interpreter names.
5 | ///
6 | public static class PredefinedExpressionParserAndInterpreterNames
7 | {
8 | public const string NumericalExpression = nameof(NumericalExpression);
9 |
10 | public const string PrimitiveExpression = nameof(PrimitiveExpression);
11 |
12 | public const string ConditionalExpression = nameof(ConditionalExpression);
13 |
14 | public const string FunctionExpression = nameof(FunctionExpression);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Api/AbstractSyntaxTree/VariableReferenceExpression.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Api
2 | {
3 | public sealed class VariableReferenceExpression : ReferenceExpression
4 | {
5 | public string VariableName { get; }
6 |
7 | public LinkedToken VariableToken { get; }
8 |
9 | public VariableReferenceExpression(LinkedToken token)
10 | : base(token, token)
11 | {
12 | Guard.IsNotNull(token);
13 | VariableToken = token;
14 | VariableName = token.Token.GetText();
15 | }
16 |
17 | public override string ToString()
18 | {
19 | return $"$({VariableName})";
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/app/tools/NotepadBasedCalculator.Benchmark/NotepadBasedCalculator.Benchmark.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 |
6 |
7 | $(MSBuildThisFileDirectory)\bin\
8 | Exe
9 | enable
10 | disable
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/app/dev/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | enable
7 | enable
8 | false
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/app/dev/NotepadBasedCalculator.Api/Core/Threading/CancellationTokenExtension.cs:
--------------------------------------------------------------------------------
1 | namespace NotepadBasedCalculator.Api
2 | {
3 | public static class CancellationTokenExtension
4 | {
5 | ///
6 | /// Converts the to a
7 | /// that canceled when the is being canceled.
8 | ///
9 | public static Task AsTask(this CancellationToken cancellationToken)
10 | {
11 | var tcs = new TaskCompletionSource