Skip to content

Commit

Permalink
Fix co-variant array conversion from string[] to object?[]? can cause…
Browse files Browse the repository at this point in the history
… run-time exception on write operation, Close #211
  • Loading branch information
VahidN committed Oct 17, 2023
1 parent 6734ada commit a2a0417
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 188 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ jobs:
runs-on: windows-2019

steps:
- uses: actions/checkout@v2.3.4
- uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.100-preview.3.23178.7
dotnet-version: 8.0.x
- name: Build EFCoreSecondLevelCacheInterceptor lib
run: dotnet build ./src/EFCoreSecondLevelCacheInterceptor/EFCoreSecondLevelCacheInterceptor.csproj --configuration Release

Expand Down
86 changes: 86 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ "master" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "master" ]

jobs:
analyze:
name: Analyze
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners
# Consider using larger runners for possible analysis time improvements.
runs-on: windows-2019
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'csharp' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
config-file: ./.github/workflows/codeql/codeql-config.yml
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# 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
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
# - name: Autobuild
# uses: github/codeql-action/autobuild@v2
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Build
run: dotnet build --configuration Release

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
10 changes: 10 additions & 0 deletions .github/workflows/codeql/codeql-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: "Security and Quality"

queries:
- uses: security-and-quality

query-filters:
- exclude:
id: cs/useless-if-statement
- exclude:
id: cs/empty-block
91 changes: 0 additions & 91 deletions .vscode/launch.json

This file was deleted.

92 changes: 0 additions & 92 deletions .vscode/tasks.json

This file was deleted.

2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.100-preview.3.23178.7",
"version": "8.0.100-rc.2.23502.2",
"rollForward": "latestMajor",
"allowPrerelease": false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ public override T GetFieldValue<T>(int ordinal)

if (actualValueType.IsArray && expectedValueType.GetInterface(nameof(IEnumerable)) != null)
{
var enumerable = Activator.CreateInstance(typeof(T), value);
var enumerable = Activator.CreateInstance(typeof(T), new object[] { value });

Check failure on line 544 in src/EFCoreSecondLevelCacheInterceptor/EFTableRowsDataReader.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Remove this array creation and simply pass the elements. (https://rules.sonarsource.com/csharp/RSPEC-3878)

Check failure on line 544 in src/EFCoreSecondLevelCacheInterceptor/EFTableRowsDataReader.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Remove this array creation and simply pass the elements. (https://rules.sonarsource.com/csharp/RSPEC-3878)

Check failure on line 544 in src/EFCoreSecondLevelCacheInterceptor/EFTableRowsDataReader.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Remove this array creation and simply pass the elements. (https://rules.sonarsource.com/csharp/RSPEC-3878)

Check failure on line 544 in src/EFCoreSecondLevelCacheInterceptor/EFTableRowsDataReader.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Remove this array creation and simply pass the elements. (https://rules.sonarsource.com/csharp/RSPEC-3878)

Check failure on line 544 in src/EFCoreSecondLevelCacheInterceptor/EFTableRowsDataReader.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Remove this array creation and simply pass the elements. (https://rules.sonarsource.com/csharp/RSPEC-3878)

Check failure on line 544 in src/EFCoreSecondLevelCacheInterceptor/EFTableRowsDataReader.cs

View workflow job for this annotation

GitHub Actions / build

Remove this array creation and simply pass the elements. (https://rules.sonarsource.com/csharp/RSPEC-3878)

Check failure on line 544 in src/EFCoreSecondLevelCacheInterceptor/EFTableRowsDataReader.cs

View workflow job for this annotation

GitHub Actions / build

Remove this array creation and simply pass the elements. (https://rules.sonarsource.com/csharp/RSPEC-3878)

Check failure on line 544 in src/EFCoreSecondLevelCacheInterceptor/EFTableRowsDataReader.cs

View workflow job for this annotation

GitHub Actions / build

Remove this array creation and simply pass the elements. (https://rules.sonarsource.com/csharp/RSPEC-3878)

Check failure on line 544 in src/EFCoreSecondLevelCacheInterceptor/EFTableRowsDataReader.cs

View workflow job for this annotation

GitHub Actions / build

Remove this array creation and simply pass the elements. (https://rules.sonarsource.com/csharp/RSPEC-3878)

Check failure on line 544 in src/EFCoreSecondLevelCacheInterceptor/EFTableRowsDataReader.cs

View workflow job for this annotation

GitHub Actions / build

Remove this array creation and simply pass the elements. (https://rules.sonarsource.com/csharp/RSPEC-3878)
if (enumerable is not null)
{
return (T)enumerable;
Expand Down

0 comments on commit a2a0417

Please sign in to comment.