-
Notifications
You must be signed in to change notification settings - Fork 0
Add suppressWarnings option for per-package csc.rsp generation #4
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,38 @@ | ||||||||||||||||||||
| package unity | ||||||||||||||||||||
|
|
||||||||||||||||||||
| import ( | ||||||||||||||||||||
| "os" | ||||||||||||||||||||
| "path/filepath" | ||||||||||||||||||||
| "strings" | ||||||||||||||||||||
| ) | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // WriteCscRsp writes a csc.rsp file with -nowarn directives for the given warning codes. | ||||||||||||||||||||
| // The file is placed at the given path (typically next to an .asmdef file). | ||||||||||||||||||||
| func WriteCscRsp(dir string, warnings []string) error { | ||||||||||||||||||||
| if len(warnings) == 0 { | ||||||||||||||||||||
| return nil | ||||||||||||||||||||
| } | ||||||||||||||||||||
| content := "-nowarn:" + strings.Join(warnings, ",") + "\n" | ||||||||||||||||||||
| return os.WriteFile(filepath.Join(dir, "csc.rsp"), []byte(content), 0644) | ||||||||||||||||||||
|
||||||||||||||||||||
| return os.WriteFile(filepath.Join(dir, "csc.rsp"), []byte(content), 0644) | |
| path := filepath.Join(dir, "csc.rsp") | |
| f, err := os.OpenFile(path, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0644) | |
| if err != nil { | |
| return err | |
| } | |
| defer f.Close() | |
| _, err = f.WriteString(content) | |
| return err |
Copilot
AI
Mar 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WriteCscRspForAsmdefs currently swallows any filepath.Walk error by returning nil when err != nil. That can silently skip parts of the tree and report success even though csc.rsp files weren't written. Return err when it is non-nil so callers can fail fast and surface filesystem issues.
| if err != nil || info.IsDir() { | |
| if err != nil { | |
| return err | |
| } | |
| if info.IsDir() { |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,100 @@ | ||||||||||||||||||
| package unity | ||||||||||||||||||
|
|
||||||||||||||||||
| import ( | ||||||||||||||||||
| "os" | ||||||||||||||||||
| "path/filepath" | ||||||||||||||||||
| "testing" | ||||||||||||||||||
| ) | ||||||||||||||||||
|
|
||||||||||||||||||
| func TestWriteCscRsp(t *testing.T) { | ||||||||||||||||||
| dir := t.TempDir() | ||||||||||||||||||
|
|
||||||||||||||||||
| if err := WriteCscRsp(dir, []string{"0618", "0649"}); err != nil { | ||||||||||||||||||
| t.Fatalf("WriteCscRsp: %v", err) | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| data, err := os.ReadFile(filepath.Join(dir, "csc.rsp")) | ||||||||||||||||||
| if err != nil { | ||||||||||||||||||
| t.Fatalf("reading csc.rsp: %v", err) | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| expected := "-nowarn:0618,0649\n" | ||||||||||||||||||
| if string(data) != expected { | ||||||||||||||||||
| t.Errorf("csc.rsp content: got %q, want %q", string(data), expected) | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| func TestWriteCscRsp_SingleWarning(t *testing.T) { | ||||||||||||||||||
| dir := t.TempDir() | ||||||||||||||||||
|
|
||||||||||||||||||
| if err := WriteCscRsp(dir, []string{"0618"}); err != nil { | ||||||||||||||||||
| t.Fatalf("WriteCscRsp: %v", err) | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| data, _ := os.ReadFile(filepath.Join(dir, "csc.rsp")) | ||||||||||||||||||
|
||||||||||||||||||
| data, _ := os.ReadFile(filepath.Join(dir, "csc.rsp")) | |
| data, err := os.ReadFile(filepath.Join(dir, "csc.rsp")) | |
| if err != nil { | |
| t.Fatalf("reading csc.rsp: %v", err) | |
| } |
Copilot
AI
Mar 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test setup ignores errors from os.MkdirAll. If directory creation fails, later assertions will fail in a harder-to-debug way. Please handle these errors (e.g., if err := os.MkdirAll(...); err != nil { t.Fatal(...) }).
| os.MkdirAll(runtimeDir, 0755) | |
| os.MkdirAll(editorDir, 0755) | |
| if err := os.MkdirAll(runtimeDir, 0755); err != nil { | |
| t.Fatalf("failed to create runtimeDir: %v", err) | |
| } | |
| if err := os.MkdirAll(editorDir, 0755); err != nil { | |
| t.Fatalf("failed to create editorDir: %v", err) | |
| } |
Copilot
AI
Mar 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test setup ignores errors from os.WriteFile when creating the .asmdef fixtures. Please check the returned errors so failures are reported clearly and the test doesn't proceed with missing/partial inputs.
Copilot
AI
Mar 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test setup ignores the error from os.WriteFile here. Please check it and fail the test if writing the .asmdef fixture fails, to avoid false/unclear failures later in the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This struct formatting looks like it missed
gofmt(theExcludefield is misaligned vs the rest of the struct). Please rungofmton this file so the formatting is consistent and minimizes diffs/churn going forward.