-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcsharp-version-check-fallback.yml
More file actions
79 lines (66 loc) · 2.5 KB
/
Copy pathcsharp-version-check-fallback.yml
File metadata and controls
79 lines (66 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: C# 7.3 Check (Fallback)
on:
pull_request:
paths:
- "**.cs"
push:
branches:
- main
paths:
- "**.cs"
jobs:
# This job acts as a fallback when self-hosted runner is offline
# It will only run if the primary workflow fails to start within the timeout
csharp-version-check-fallback:
name: Verify C# 7.3 Compatibility (GitHub Runner)
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Scan for C# 8.0+ Features
shell: bash
run: |
echo "🔍 Running C# 7.3 compatibility check on GitHub-hosted runner..."
echo "ℹ️ This is a fallback in case self-hosted runner is unavailable"
echo ""
violations=0
# Null-coalescing assignment (??=)
if grep -rnF '??=' --include='*.cs' .; then
echo "❌ Found null-coalescing assignment (??=) - C# 8.0+"
violations=$((violations + 1))
fi
# Switch expressions
if grep -rEn 'switch.*=>.*}' --include='*.cs' .; then
echo "❌ Found switch expressions - C# 8.0+"
violations=$((violations + 1))
fi
# Index from end operator
if grep -rn '\[\^' --include='*.cs' .; then
echo "❌ Found index from end operator ([^) - C# 8.0+"
violations=$((violations + 1))
fi
# Range operator
# Match [start..end] pattern roughly
if grep -rEn '\[.*[0-9a-zA-Z_]\.\.[0-9a-zA-Z_].*\]' --include='*.cs' .; then
echo "❌ Found range operator ([..]) - C# 8.0+"
violations=$((violations + 1))
fi
# Nullable pragmas
if grep -rn '#nullable' --include='*.cs' .; then
echo "❌ Found #nullable pragma - C# 8.0+"
violations=$((violations + 1))
fi
# Using declarations (using var)
if grep -rEn 'using[[:space:]]+var[[:space:]]+' --include='*.cs' .; then
echo "❌ Found using declarations (using var) - C# 8.0+"
violations=$((violations + 1))
fi
if [ $violations -gt 0 ]; then
echo ""
echo "::error::Found $violations C# 8.0+ feature(s). Please use C# 7.3 compatible syntax."
echo "See CONTRIBUTING.md for C# 7.3 constraints and alternatives."
exit 1
fi
echo "✅ No C# 8.0+ features detected - code is C# 7.3 compatible"