-
Notifications
You must be signed in to change notification settings - Fork 1.9k
C#: Tool status page support #12217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
C#: Tool status page support #12217
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
fb6c27b
Refactor env var code in Autobuilder class
mbg fce9cb0
Read `..._DIAGNOSTIC_DIR` variable
mbg 4e7c39a
Add initial code for diagnostic messages
mbg f4c4871
Add basic reporting of a general autobuild failure
mbg 5963501
BuildCommandAutoRule: expose more information
mbg 7b5e19d
Add diagnostics for `BuildCommandAutoRule`
mbg 219b232
Add no projects/solutions diagnostic
mbg c5a2cfc
Fixup: We => CodeQL
mbg 9992491
Support asynchronous stdout/stderr processing
mbg 9865c50
Change logic for autobuild failures
mbg 61ff4c7
Set `DiagnosticMessage` defaults
mbg f68c529
Report projects incompatible with .NET Core
mbg eda33fc
Track which projects/solutions fail to build
mbg c55281a
Report .NET Core & MSBuild failures
mbg 7e48084
Fixup: better error message for `no-projects-or-solutions`
mbg 5537d79
Detect missing Xamarin SDKs
mbg aa6efce
Use `TryGetValue`
mbg 8e83fd0
Update C/C++ autobuilder
mbg 0f32099
Make improvements based on PR feedback
mbg 08b51c3
Link to docs for autobuild failures
mbg c3e25d2
Add docs link for missing Xamarin SDKs
mbg 93b7a2b
Fix: drop please
mbg b034b2f
Refactor autobuild logic into an `IBuildRule`
mbg 3bf6b6f
Add helper for markdown lists of projects
mbg 1e2329d
Add diagnostic for missing project files
mbg bdbcaab
Use relative paths
mbg 7de2655
Add tests for build script diagnostics
mbg b203533
Fix C++ test missing env var
mbg 430af66
Show .NET core error only if files exist
mbg 354f716
Add test for dotnet incompatible projects
mbg 3ef3441
Add test for missing project files
mbg 3167343
Add test for missing Xamarin SDKs
mbg e2af8f1
Simplify Xamarin query to be platform-independent
mbg e60676f
Fix `IDisposable` contract violation
mbg e3762c7
Move `Language` class to `Semmle.Util`
mbg fea29d5
Refactor to avoid public setters
mbg f22c864
Fix expected test output for Windows tests
mbg 4903924
Apply ql-for-ql suggestion
mbg 93a45fc
Simplify DiagnosticClassifier in CSharpAutobuilder
mbg 2525ac3
C#: Use dependency injection in the auto builder for Diagnostic class…
michaelnebel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
csharp/autobuilder/Semmle.Autobuild.CSharp/AutoBuildRule.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| using Semmle.Autobuild.Shared; | ||
| using Semmle.Extraction.CSharp; | ||
|
|
||
| namespace Semmle.Autobuild.CSharp | ||
| { | ||
| internal class AutoBuildRule : IBuildRule<CSharpAutobuildOptions> | ||
| { | ||
| private readonly CSharpAutobuilder autobuilder; | ||
|
|
||
| public DotNetRule DotNetRule { get; } | ||
|
|
||
| public MsBuildRule MsBuildRule { get; } | ||
|
|
||
| public BuildCommandAutoRule BuildCommandAutoRule { get; } | ||
|
|
||
| public AutoBuildRule(CSharpAutobuilder autobuilder) | ||
| { | ||
| this.autobuilder = autobuilder; | ||
| this.DotNetRule = new DotNetRule(); | ||
| this.MsBuildRule = new MsBuildRule(); | ||
| this.BuildCommandAutoRule = new BuildCommandAutoRule(DotNetRule.WithDotNet); | ||
| } | ||
|
|
||
| public BuildScript Analyse(IAutobuilder<CSharpAutobuildOptions> builder, bool auto) | ||
| { | ||
| var cleanTrapFolder = | ||
| BuildScript.DeleteDirectory(this.autobuilder.TrapDir); | ||
| var cleanSourceArchive = | ||
| BuildScript.DeleteDirectory(this.autobuilder.SourceArchiveDir); | ||
| var tryCleanExtractorArgsLogs = | ||
| BuildScript.Create(actions => | ||
| { | ||
| foreach (var file in Extractor.GetCSharpArgsLogs()) | ||
| { | ||
| try | ||
| { | ||
| actions.FileDelete(file); | ||
| } | ||
| catch // lgtm[cs/catch-of-all-exceptions] lgtm[cs/empty-catch-block] | ||
| { } | ||
|
Comment on lines
+39
to
+40
Check noticeCode scanning / CodeQL Poor error handling: empty catch block
Poor error handling: empty catch block.
|
||
| } | ||
|
|
||
| return 0; | ||
| }); | ||
| var attemptExtractorCleanup = | ||
| BuildScript.Try(cleanTrapFolder) & | ||
| BuildScript.Try(cleanSourceArchive) & | ||
| tryCleanExtractorArgsLogs & | ||
| BuildScript.DeleteFile(Extractor.GetCSharpLogPath()); | ||
|
|
||
| /// <summary> | ||
| /// Execute script `s` and check that the C# extractor has been executed. | ||
| /// If either fails, attempt to cleanup any artifacts produced by the extractor, | ||
| /// and exit with code 1, in order to proceed to the next attempt. | ||
| /// </summary> | ||
| BuildScript IntermediateAttempt(BuildScript s) => | ||
| (s & this.autobuilder.CheckExtractorRun(false)) | | ||
| (attemptExtractorCleanup & BuildScript.Failure); | ||
|
|
||
| return | ||
| // First try .NET Core | ||
| IntermediateAttempt(this.DotNetRule.Analyse(this.autobuilder, true)) | | ||
| // Then MSBuild | ||
| (() => IntermediateAttempt(this.MsBuildRule.Analyse(this.autobuilder, true))) | | ||
| // And finally look for a script that might be a build script | ||
| (() => this.BuildCommandAutoRule.Analyse(this.autobuilder, true) & this.autobuilder.CheckExtractorRun(true)); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check notice
Code scanning / CodeQL
Generic catch clause