Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Mpdreamz committed Oct 16, 2020
0 parents commit 6009660
Show file tree
Hide file tree
Showing 165 changed files with 16,856 additions and 0 deletions.
139 changes: 139 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
root=true

[*.cs]
trim_trailing_whitespace=true
insert_final_newline=true
end_of_line = lf

[*]
indent_style = tab
indent_size = 4

[*.cshtml]
indent_style = tab
indent_size = 4
end_of_line = lf

[*.{fs,fsx,yml}]
indent_style = space
indent_size = 4
end_of_line = lf

[*.{md,markdown,json,js,csproj,fsproj,targets,targets,props}]
indent_style = space
indent_size = 2
end_of_line = lf

# Dotnet code style settings:
[*.{cs,vb}]

# ---
# naming conventions https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-naming-conventions
# currently not supported in Rider/Resharper so not using these for now
# ---

# ---
# langugage conventions https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#language-conventions

# Sort using and Import directives with System.* appearing first
dotnet_sort_system_directives_first = true

# Prefer this.X except for _fields
# TODO can we force _ for private fields?
# TODO elevate severity after code cleanup to warning minimum
# TODO use language latest
dotnet_style_qualification_for_field = false:error
dotnet_style_qualification_for_property = false:error
dotnet_style_qualification_for_method = false:error
dotnet_style_qualification_for_event = false:error

# Use language keywords instead of framework type names for type references
dotnet_style_predefined_type_for_locals_parameters_members = true:error
dotnet_style_predefined_type_for_member_access = true:error

# Suggest more modern language features when available
dotnet_style_object_initializer = true:error
dotnet_style_collection_initializer = true:error
dotnet_style_explicit_tuple_names = true:error
dotnet_style_prefer_inferred_anonymous_type_member_names = true:error
dotnet_style_prefer_inferred_tuple_names = true:error
dotnet_style_coalesce_expression = true:error
dotnet_style_null_propagation = true:error

dotnet_style_require_accessibility_modifiers = for_non_interface_members:error
dotnet_style_readonly_field = true:error

# CSharp code style settings:
[*.cs]
# Prefer "var" everywhere
csharp_style_var_for_built_in_types = true:error
csharp_style_var_when_type_is_apparent = true:error
csharp_style_var_elsewhere = true:error

csharp_style_expression_bodied_methods = true:error
csharp_style_expression_bodied_constructors = true:error
csharp_style_expression_bodied_operators = true:error
csharp_style_expression_bodied_properties = true:error
csharp_style_expression_bodied_indexers = true:error
csharp_style_expression_bodied_accessors = true:error

# Suggest more modern language features when available
csharp_style_pattern_matching_over_is_with_cast_check = true:error
csharp_style_pattern_matching_over_as_with_null_check = true:error
csharp_style_inlined_variable_declaration = true:error
csharp_style_deconstructed_variable_declaration = true:error
csharp_style_pattern_local_over_anonymous_function = true:error
csharp_style_throw_expression = true:error
csharp_style_conditional_delegate_call = true:error

csharp_prefer_braces = false:warning
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:error

# ---
# formatting conventions https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#formatting-conventions

# Newline settings (Allman yo!)
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true:error
csharp_new_line_before_catch = true:error
csharp_new_line_before_finally = true:error
csharp_new_line_before_members_in_object_initializers = true
# just a suggestion do to our JSON tests that use anonymous types to
# represent json quite a bit (makes copy paste easier).
csharp_new_line_before_members_in_anonymous_types = true:suggestion
csharp_new_line_between_query_expression_clauses = true:error

# Indent
csharp_indent_case_contents = true:error
csharp_indent_switch_labels = true:error
csharp_space_after_cast = false:error
csharp_space_after_keywords_in_control_flow_statements = true:error
csharp_space_between_method_declaration_parameter_list_parentheses = false:error
csharp_space_between_method_call_parameter_list_parentheses = false:error

#Wrap
csharp_preserve_single_line_statements = false:error
csharp_preserve_single_line_blocks = true:error

# Resharper
resharper_csharp_braces_for_lock=required_for_multiline
resharper_csharp_braces_for_using=required_for_multiline
resharper_csharp_braces_for_while=required_for_multiline
resharper_csharp_braces_for_foreach=required_for_multiline
resharper_csharp_braces_for_for=required_for_multiline
resharper_csharp_braces_for_fixed=required_for_multiline
resharper_csharp_braces_for_ifelse=required_for_multiline

resharper_csharp_accessor_owner_body=expression_body

[Jenkinsfile]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{sh,bat,ps1}]
trim_trailing_whitespace=true
insert_final_newline=true
15 changes: 15 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Auto detect text files and perform LF normalization
* text=auto eol=lf

# Set default behavior for command prompt diff.
# This gives output on command line taking C# language constructs into consideration (e.g showing class name)
*.cs text diff=csharp

# Set windows specific files explicitly to crlf line ending
*.cmd eol=crlf
*.bat eol=crlf
*.ps1 eol=crlf

# Mark files specifically as binary to avoid line ending conversion
*.snk binary
*.png binary
80 changes: 80 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
*.userprefs
*.local.xml
*.sln.docstates
*.obj
*.swp
*.exe
*.pdb
*.user
*.aps
*.pch
*.tss
*.vspscc
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.cache
*.ilk
*.log
*.nupkg
*.ncrunchsolution
[Bb]in
[Dd]ebug/
test-results
test-results/*
*.lib
*.sbr
*.DotSettings.user
obj/
[Rr]elease*/
_ReSharper*/
_NCrunch*/
[Tt]est[Rr]esult*

.fake/*
.fake
packages/*
paket.exe
paket-files/*.cached

build/*
!build/tools
!build/keys
build/tools/*
!build/tools/sn
!build/tools/sn/*
!build/tools/ilmerge
!build/*.fsx
!build/*.fsx
!build/*.ps1
!build/*.nuspec
!build/*.png
!build/*.targets
!build/scripts

!docs/build
docs/node_modules
doc/Help

*.ncrunchproject
Cache
YamlCache
tests.yaml

*.DS_Store
*.sln.ide

launchSettings.json
project.lock.json
.vs
.vs/*

.idea/
*.sln.iml
/src/.vs/restore.dg
src/packages/
BenchmarkDotNet.Artifacts
18 changes: 18 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MinVerDefaultPreReleasePhase>canary</MinVerDefaultPreReleasePhase>
<MinVerMinimumMajorMinor>0.1</MinVerMinimumMajorMinor>

<LangVersion>latest</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<IsPackable>False</IsPackable>

<DefineConstants Condition="'$(TargetFramework)'=='net461'">$(DefineConstants);FULLFRAMEWORK</DefineConstants>
<DefineConstants Condition="$(DefineConstants.Contains(FULLFRAMEWORK)) == False">$(DefineConstants);DOTNETCORE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MinVer" Version="2.2.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net461" Version="1.0.0" PrivateAssets="all"/>
</ItemGroup>
</Project>
3 changes: 3 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
set -euo pipefail
dotnet run --project build/scripts -- "$@"
Binary file added build/keys/keypair.snk
Binary file not shown.
Binary file added build/keys/public.snk
Binary file not shown.
47 changes: 47 additions & 0 deletions build/scripts/CommandLine.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
module CommandLine

open Argu
open Microsoft.FSharp.Reflection

type Arguments =
| [<CliPrefix(CliPrefix.None);SubCommand>] Clean
| [<CliPrefix(CliPrefix.None);SubCommand>] Build
| [<CliPrefix(CliPrefix.None);SubCommand>] Test

| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] PristineCheck
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] GeneratePackages
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] ValidatePackages
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] GenerateReleaseNotes
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] GenerateApiChanges
| [<CliPrefix(CliPrefix.None);SubCommand>] Release

| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] CreateReleaseOnGithub
| [<CliPrefix(CliPrefix.None);SubCommand>] Publish

| [<Inherit;AltCommandLine("-s")>] SingleTarget of bool
| [<Inherit>] Token of string
| [<Inherit;AltCommandLine("-c")>] CleanCheckout of bool
with
interface IArgParserTemplate with
member this.Usage =
match this with
| Clean _ -> "clean known output locations"
| Build _ -> "Run build"
| Test _ -> "Runs build then tests"
| Release _ -> "runs build, tests, and create and validates the packages shy of publishing them"
| Publish _ -> "Runs the full release"

| SingleTarget _ -> "Runs the provided sub command without running their dependencies"
| Token _ -> "Token to be used to authenticate with github"
| CleanCheckout _ -> "Skip the clean checkout check that guards the release/publish targets"

| PristineCheck
| GeneratePackages
| ValidatePackages
| GenerateReleaseNotes
| GenerateApiChanges
| CreateReleaseOnGithub
-> "Undocumented, dependent target"
member this.Name =
match FSharpValue.GetUnionFields(this, typeof<Arguments>) with
| case, _ -> case.Name.ToLowerInvariant()
25 changes: 25 additions & 0 deletions build/scripts/Paths.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module Paths

open System
open System.IO

let ToolName = "ecs-dotnet"
let Repository = sprintf "elastic/%s" ToolName
let MainTFM = "netstandard2.0"
let SignKey = "069ca2728db333c1"

let ValidateAssemblyName = false
let IncludeGitHashInInformational = true
let GenerateApiChanges = false

let Root =
let mutable dir = DirectoryInfo(".")
while dir.GetFiles("*.sln").Length = 0 do dir <- dir.Parent
Environment.CurrentDirectory <- dir.FullName
dir

let RootRelative path = Path.GetRelativePath(Root.FullName, path)

let Output = DirectoryInfo(Path.Combine(Root.FullName, "build", "output"))

let ToolProject = DirectoryInfo(Path.Combine(Root.FullName, "src", ToolName))
32 changes: 32 additions & 0 deletions build/scripts/Program.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module Program

open Argu
open Bullseye
open ProcNet
open CommandLine

[<EntryPoint>]
let main argv =
let parser = ArgumentParser.Create<Arguments>(programName = "./build.sh")
let parsed =
try
let parsed = parser.ParseCommandLine(inputs = argv, raiseOnUsage = true)
let arguments = parsed.GetSubCommand()
Some (parsed, arguments)
with e ->
printfn "%s" e.Message
None

match parsed with
| None -> 2
| Some (parsed, arguments) ->

let target = arguments.Name

Targets.Setup parsed arguments
let swallowTypes = [typeof<ProcExecException>; typeof<ExceptionExiter>]

Targets.RunTargetsAndExit
([target], (fun e -> swallowTypes |> List.contains (e.GetType()) ), ":")
0

Loading

0 comments on commit 6009660

Please sign in to comment.