analysis: lock DTO fields passed as X.class to databind calls
Gson/Jackson/fastjson2/Moshi bind fields by reflection from a Class literal, with no field-name string for the string-based detection: renaming such a field silently breaks deserialization. Absorb_databind finds the nearest Const::Class before fromJson/readValue/parseObject/ adapter calls (10-insn window, control-flow boundaries stop the search) and keeps every field of that class; the class itself still renames. Tests: noxis-analysis/tests/dto.rs (red first), keep unit tests moved to tests/keep.rs (file budget). Code comments migrated to English.
This commit is contained in:
parent
139aea9a8f
commit
c3acc0baf4
3 changed files with 215 additions and 61 deletions
33
crates/noxis-analysis/tests/keep.rs
Normal file
33
crates/noxis-analysis/tests/keep.rs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
//! Keep-rule unit tests: globs and exact names.
|
||||
|
||||
#![allow(clippy::expect_used, clippy::unwrap_used)]
|
||||
|
||||
use noxis_analysis::KeepRules;
|
||||
use noxis_core::Config;
|
||||
|
||||
fn rules_with_patterns() -> KeepRules {
|
||||
KeepRules::from_config(&Config {
|
||||
keep: vec!["com/example/*".to_string(), "**/internal/**".to_string()],
|
||||
keep_resources: vec!["META-INF/services/*".to_string()],
|
||||
..Config::default()
|
||||
})
|
||||
.expect("patterns")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn glob_semantics() {
|
||||
let rules = rules_with_patterns();
|
||||
assert!(rules.keeps_class("com/example/Main"));
|
||||
assert!(!rules.keeps_class("com/example/sub/Main"));
|
||||
assert!(rules.keeps_class("x/internal/y/Z"));
|
||||
assert!(rules.keeps_resource("META-INF/services/a.b.C"));
|
||||
assert!(!rules.keeps_resource("assets/mc/mod.json"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn exact_names_win() {
|
||||
let mut rules = KeepRules::default();
|
||||
rules.keep_exact("app/Main");
|
||||
assert!(rules.keeps_class("app/Main"));
|
||||
assert!(!rules.keeps_class("app/Other"));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue