Skip to content

Commit fd9c005

Browse files
committed
- update
1 parent c54f3a2 commit fd9c005

7 files changed

Lines changed: 92 additions & 48 deletions

File tree

.github/workflows/Master-CodeQL.yml

Lines changed: 60 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,70 +7,102 @@
77
# ******** NOTE ********
88
# We have attempted to detect the languages in your repository. Please check
99
# the `language` matrix defined below to confirm you have the correct set of
10-
# supported CodeQL languages.
10+
# supported CodeQL languages.
1111
#
1212
name: "master-codeql"
1313

1414
on:
1515
push:
16+
branches: [ "master" ]
17+
paths-ignore:
18+
- "**/*.md"
19+
- "**/*.gitignore"
20+
- "**/*.gitattributes"
1621
pull_request:
17-
types: [opened, reopened, edited, synchronize]
22+
branches: [ "master" ]
1823
paths-ignore:
1924
- "**/*.md"
2025
- "**/*.gitignore"
2126
- "**/*.gitattributes"
2227
schedule:
23-
- cron: '35 15 * * 2'
28+
- cron: '42 7 * * 5'
2429

2530
jobs:
2631
analyze:
27-
name: Analyze
28-
runs-on: ubuntu-latest
32+
name: Analyze (${{ matrix.language }})
33+
# Runner size impacts CodeQL analysis time. To learn more, please see:
34+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
35+
# - https://gh.io/supported-runners-and-hardware-resources
36+
# - https://gh.io/using-larger-runners (GitHub.com only)
37+
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
38+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
2939
permissions:
40+
# required for all workflows
41+
security-events: write
42+
43+
# required to fetch internal or private CodeQL packs
44+
packages: read
45+
46+
# only required for workflows in private repositories
3047
actions: read
3148
contents: read
32-
security-events: write
3349

3450
strategy:
3551
fail-fast: false
3652
matrix:
37-
language: [ 'csharp' ]
38-
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
39-
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
40-
53+
include:
54+
- language: actions
55+
build-mode: none
56+
- language: csharp
57+
build-mode: none
58+
# CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
59+
# Use `c-cpp` to analyze code written in C, C++ or both
60+
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
61+
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
62+
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
63+
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
64+
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
65+
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
4166
steps:
4267
- name: Checkout repository
43-
uses: actions/checkout@v3
68+
uses: actions/checkout@v4
69+
70+
# Add any setup steps before running the `github/codeql-action/init` action.
71+
# This includes steps like installing compilers or runtimes (`actions/setup-node`
72+
# or others). This is typically only required for manual builds.
73+
# - name: Setup runtime (example)
74+
# uses: actions/setup-example@v1
4475

4576
# Initializes the CodeQL tools for scanning.
4677
- name: Initialize CodeQL
47-
uses: github/codeql-action/init@v2
78+
uses: github/codeql-action/init@v3
4879
with:
4980
languages: ${{ matrix.language }}
81+
build-mode: ${{ matrix.build-mode }}
5082
# If you wish to specify custom queries, you can do so here or in a config file.
5183
# By default, queries listed here will override any specified in a config file.
5284
# Prefix the list here with "+" to use these queries and those in the config file.
5385

54-
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
86+
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
5587
# queries: security-extended,security-and-quality
5688

57-
58-
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
59-
# If this step fails, then you should remove it and run the build manually (see below)
60-
- name: Autobuild
61-
uses: github/codeql-action/autobuild@v2
62-
89+
# If the analyze step fails for one of the languages you are analyzing with
90+
# "We were unable to automatically build your code", modify the matrix above
91+
# to set the build mode to "manual" for that language. Then modify this step
92+
# to build your code.
6393
# ℹ️ Command-line programs to run using the OS shell.
6494
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
65-
66-
# If the Autobuild fails above, remove it and uncomment the following three lines.
67-
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
68-
69-
# - run: |
70-
# echo "Run, Build Application using script"
71-
# ./location_of_script_within_repo/buildscript.sh
95+
- if: matrix.build-mode == 'manual'
96+
shell: bash
97+
run: |
98+
echo 'If you are using a "manual" build mode for one or more of the' \
99+
'languages you are analyzing, replace this with the commands to build' \
100+
'your code, for example:'
101+
echo ' make bootstrap'
102+
echo ' make release'
103+
exit 1
72104
73105
- name: Perform CodeQL Analysis
74-
uses: github/codeql-action/analyze@v2
106+
uses: github/codeql-action/analyze@v3
75107
with:
76-
category: "/language:${{matrix.language}}"
108+
category: "/language:${{matrix.language}}"

src/Parsley/IocExtensions.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using Microsoft.Extensions.DependencyInjection;
2+
3+
namespace parsley
4+
{
5+
public static class IocExtensions
6+
{
7+
public static IServiceCollection UseParsley(this IServiceCollection services, char delimeter = ',')
8+
{
9+
services.AddTransient(typeof(IParser), c => new Parser(delimeter));
10+
return services;
11+
}
12+
}
13+
}

src/parsley/Extensions.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@ namespace parsley
22
{
33
internal static class Extensions
44
{
5-
public static bool In(this string input, params string[] values)
6-
{
7-
return values != null && values.Contains(input);
8-
}
9-
10-
public static void SetError(this IFileLine obj, string error)
5+
internal static void SetError(this IFileLine obj, string error)
116
{
127
if (obj.Errors == null)
138
obj.Errors = new List<string>();

src/parsley/IFileLine.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ namespace parsley
22
{
33
public interface IFileLine
44
{
5-
int Index { get; set; }
6-
IList<string> Errors { get; set; }
5+
public int Index { get; set; }
6+
public IList<string> Errors { get; set; }
77
}
88
}

src/parsley/Parsley.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@
66
<Nullable>enable</Nullable>
77
</PropertyGroup>
88

9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.4" />
11+
</ItemGroup>
12+
913
</Project>

tests/Parsley.Tests/FileLine.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public FileLine()
1818
public int Code { get; set; }
1919

2020
[Column(1)]
21-
public Name Name { get; set; }
21+
public NameType Name { get; set; }
2222

2323
[Column(2)]
2424
public bool IsActive { get; set; }
@@ -28,31 +28,31 @@ public FileLine()
2828
}
2929

3030
[TypeConverter(typeof(NameConverter))]
31-
public class Name
31+
public class NameType
3232
{
3333
public string FirstName { get; set; }
3434
public string Surname { get; set; }
3535

36-
public static Name Parse(string input)
36+
public static NameType Parse(string input)
3737
{
3838
var values = input.Split(' ');
3939

4040
if (values.Length == 1)
41-
return new Name { FirstName = values[0] };
41+
return new NameType { FirstName = values[0] };
4242

4343
if (values.Length == 2)
44-
return new Name { FirstName = values[0], Surname = values[1] };
44+
return new NameType { FirstName = values[0], Surname = values[1] };
4545

4646
if (values.Length > 2)
4747
{
4848
var forenames = string.Empty;
4949
for (var i = 0; i < values.Length - 1; i++)
5050
forenames += string.Concat(values[i]) + " ";
5151

52-
return new Name { FirstName = forenames.Trim(), Surname = values[values.Length - 1] };
52+
return new NameType { FirstName = forenames.Trim(), Surname = values[values.Length - 1] };
5353
}
5454

55-
return new Name { FirstName = input };
55+
return new NameType { FirstName = input };
5656
}
5757
}
5858

@@ -73,7 +73,7 @@ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo c
7373

7474
if (!string.IsNullOrEmpty(stringValue))
7575
{
76-
result = Name.Parse(stringValue);
76+
result = NameType.Parse(stringValue);
7777
}
7878

7979
return result ?? base.ConvertFrom(context, culture, value);

tests/Parsley.Tests/ParserFixture.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ public void TestParseWithFileInputShouldReturnCorrectlyParsedArray()
3434
Assert.That(parsed.Length, Is.EqualTo(2));
3535

3636
Assert.That(parsed[0].Code, Is.EqualTo(1));
37-
//Assert.That(parsed[0].Name, Is.EqualTo("Bob Marley"));
37+
//Assert.That(parsed[0].NameType, Is.EqualTo("Bob Marley"));
3838
Assert.That(parsed[0].Name.FirstName, Is.EqualTo("Bob"));
3939
Assert.That(parsed[0].Name.Surname, Is.EqualTo("Marley"));
4040
Assert.That(parsed[0].IsActive, Is.EqualTo(true));
4141
Assert.That(parsed[0].Subcription, Is.EqualTo(Subcription.Free));
4242
Assert.That(parsed[0].Errors, Is.Empty);
4343

4444
Assert.That(parsed[1].Code, Is.EqualTo(2));
45-
//Assert.That(parsed[1].Name, Is.EqualTo("John Walsh"));
45+
//Assert.That(parsed[1].NameType, Is.EqualTo("John Walsh"));
4646
Assert.That(parsed[1].Name.FirstName, Is.EqualTo("John Walsh"));
4747
Assert.That(parsed[1].Name.Surname, Is.EqualTo("McKinsey"));
4848
Assert.That(parsed[1].IsActive, Is.EqualTo(false));
@@ -66,15 +66,15 @@ public void TestParseWithStringArrayInputShouldReturnCorrectlyParsedArray()
6666
Assert.That(parsed.Length, Is.EqualTo(2));
6767

6868
Assert.That(parsed[0].Code, Is.EqualTo(1));
69-
//Assert.That(parsed[0].Name, Is.EqualTo("Bob Marley"));
69+
//Assert.That(parsed[0].NameType, Is.EqualTo("Bob Marley"));
7070
Assert.That(parsed[0].Name.FirstName, Is.EqualTo("Bob"));
7171
Assert.That(parsed[0].Name.Surname, Is.EqualTo("Marley"));
7272
Assert.That(parsed[0].IsActive, Is.EqualTo(true));
7373
Assert.That(parsed[0].Subcription, Is.EqualTo(Subcription.Free));
7474
Assert.That(parsed[0].Errors, Is.Empty);
7575

7676
Assert.That(parsed[1].Code, Is.EqualTo(2));
77-
//Assert.That(parsed[1].Name, Is.EqualTo("John Walsh"));
77+
//Assert.That(parsed[1].NameType, Is.EqualTo("John Walsh"));
7878
Assert.That(parsed[1].Name.FirstName, Is.EqualTo("John Walsh"));
7979
Assert.That(parsed[1].Name.Surname, Is.EqualTo("McKinsey"));
8080
Assert.That(parsed[1].IsActive, Is.EqualTo(false));

0 commit comments

Comments
 (0)