-
Notifications
You must be signed in to change notification settings - Fork 112
refactor: replace Nett with Tomlyn
#230
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
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0545fe4
WIP
JamieMagee d48a0b7
Updated some Nett reference -> Toml
Omotola 07dc91b
More changes for Nett to Tomlyn
Omotola 12eec8b
Changing ref back to Nett since project_assets_2_2 is only used in tests
Omotola cbd6065
Merge branch 'main' into users/oakeredolu/nett-tomlyn
JamieMagee 26bcd0f
Updated Data attributes and removed unnecessary comments
Omotola 2ce2eaa
Merge branch 'users/oakeredolu/nett-tomlyn' of https://github.com/mic…
Omotola 212ad1c
Updated Data attributes in PoetryLock file
Omotola df8cc91
Made property type more specific
Omotola bc53531
Merge branch 'main' of https://github.com/microsoft/component-detecti…
Omotola 60a852a
Formatting fixes
Omotola 06223fc
Made updates to add or ignore rproperties used in Toml Deserialization
Omotola ccf1070
Merge with Main branch
Omotola f442df9
Added documentation for running verification tests
Omotola 218cfa2
Small formatting and documentation fix
Omotola 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # Running Verification Tests On Your Local Machine | ||
| Verification tests are used to confirm that no detectors are lost when changes are made to the project. The tests are run on every PR build. They work by comparing the detection results from the main branch to detection results from the new changes on your PR. You can follow the steps below to run them locally. | ||
|
|
||
| ## Step 1 : Run Detection on the main branch | ||
|
|
||
| - Checkout the main branch in your local repo | ||
| - Create a folder to store detection results (e.g C:\old-output-folder) | ||
| - Use command line to run detection on the main branch with the code below: | ||
|
|
||
| ```dotnet run scan --Verbosity Verbose --SourceDirectory {path to your local repo} --Output {path to the output folder you created}``` | ||
|
|
||
| For Example: | ||
|
|
||
| ```dotnet run scan --Verbosity Verbose --SourceDirectory C:\componentdetection --Output C:\old-output-folder``` | ||
|
|
||
|
|
||
| ## Step 2 : Run Detection on your new branch | ||
|
|
||
| - Checkout the branch with the new changes you are trying to merge | ||
| - Create a folder to store detection results. This folder should be seperate from the one you used in Step 1 (e.g C:\new-output-folder) | ||
| - Use command line to run detection on the main branch with the code below: | ||
|
|
||
| ```dotnet run scan --Verbosity Verbose --SourceDirectory {path to your local repo} --Output {path to the output folder you created}``` | ||
|
|
||
| For Example: | ||
|
|
||
| ```dotnet run scan --Verbosity Verbose --SourceDirectory C:\componentdetection --Output C:\new-output-folder``` | ||
|
|
||
| ## Step 3 : Update variables in the test | ||
|
|
||
| - Open the Microsoft.ComponentDetection.VerificationTests project in VS Studio | ||
| - Navigate to `GatherResources()` in `ComponentDetectionIntegrationTests.cs` | ||
| - Update the following variables: | ||
| - `oldGithubArtifactsDir` : This should be the output folder you created in Step 1 | ||
| - `newGithubArtifactsDir` : This should be the output folder you created in Step 2 | ||
| - `allowedTimeDriftRatioString`: This should be ".75" | ||
|
|
||
|
|
||
| ## Step 4: Run The tests | ||
| You can run the tests in two ways: | ||
| - Run or Debug the tests in test explorer. | ||
| - Use the command line to navigate to the Microsoft.ComponentDetection.VerificationTests folder, and run `dotnet test`. |
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
12 changes: 9 additions & 3 deletions
12
src/Microsoft.ComponentDetection.Detectors/poetry/Contracts/PoetryLock.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 |
|---|---|---|
| @@ -1,11 +1,17 @@ | ||
| using System.Diagnostics.CodeAnalysis; | ||
| using System.Collections.Generic; | ||
| using System.Diagnostics.CodeAnalysis; | ||
| using System.Runtime.Serialization; | ||
|
|
||
| namespace Microsoft.ComponentDetection.Detectors.Poetry.Contracts | ||
| { | ||
| // Represents Poetry.Lock file structure. | ||
| [DataContract] | ||
| public class PoetryLock | ||
| { | ||
| [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Deserialization contract. Casing cannot be overwritten.")] | ||
| public PoetryPackage[] package { get; set; } | ||
| [DataMember(Name = "Package")] | ||
| public List<PoetryPackage> Package { get; set; } | ||
|
|
||
| [DataMember(Name = "metadata")] | ||
| public Dictionary<string, object> Metadata { get; set; } | ||
| } | ||
| } |
26 changes: 17 additions & 9 deletions
26
src/Microsoft.ComponentDetection.Detectors/poetry/Contracts/PoetryPackage.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 |
|---|---|---|
| @@ -1,19 +1,27 @@ | ||
| using System.Diagnostics.CodeAnalysis; | ||
| using System.Collections.Generic; | ||
| using System.Runtime.Serialization; | ||
|
|
||
| namespace Microsoft.ComponentDetection.Detectors.Poetry.Contracts | ||
| { | ||
| [DataContract] | ||
| public class PoetryPackage | ||
| { | ||
| [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Deserialization contract. Casing cannot be overwritten.")] | ||
| public string category { get; set; } | ||
| [DataMember(Name = "category")] | ||
| public string Category { get; set; } | ||
|
|
||
| [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Deserialization contract. Casing cannot be overwritten.")] | ||
| public string name { get; set; } | ||
| [DataMember(Name = "name")] | ||
| public string Name { get; set; } | ||
|
|
||
| [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Deserialization contract. Casing cannot be overwritten.")] | ||
| public string version { get; set; } | ||
| [DataMember(Name = "version")] | ||
| public string Version { get; set; } | ||
|
|
||
| [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Deserialization contract. Casing cannot be overwritten.")] | ||
| public PoetrySource source { get; set; } | ||
| [DataMember(Name = "source")] | ||
| public PoetrySource Source { get; set; } | ||
|
|
||
| [DataMember(Name = "dependencies")] | ||
| public Dictionary<string, object> Dependencies { get; set; } | ||
|
|
||
| [DataMember(Name = "extras")] | ||
| public Dictionary<string, object> Extras { get; set; } | ||
| } | ||
| } |
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
16 changes: 10 additions & 6 deletions
16
src/Microsoft.ComponentDetection.Detectors/rust/Contracts/CargoLock.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 |
|---|---|---|
| @@ -1,15 +1,19 @@ | ||
| using System.Diagnostics.CodeAnalysis; | ||
| using Nett; | ||
| using System.Diagnostics.CodeAnalysis; | ||
|
|
||
| namespace Microsoft.ComponentDetection.Detectors.Rust.Contracts | ||
| { | ||
| using System.Collections.Generic; | ||
| using System.Runtime.Serialization; | ||
| using Tomlyn.Model; | ||
|
|
||
| // Represents Cargo.Lock file structure. | ||
| [DataContract] | ||
| public class CargoLock | ||
| { | ||
| [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Deserialization contract. Casing cannot be overwritten.")] | ||
| public CargoPackage[] package { get; set; } | ||
| [DataMember(Name = "package")] | ||
| public List<CargoPackage> Package { get; set; } | ||
|
|
||
| [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Deserialization contract. Casing cannot be overwritten.")] | ||
| public TomlTable metadata { get; set; } | ||
| [DataMember(Name = "metadata")] | ||
| public Dictionary<string, object> Metadata { get; set; } | ||
| } | ||
| } | ||
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.
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.
pout these statements outside of namespace at class level.
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.
I would apply "Convert to file-scoped namespace" at the same time, too. Also, remove unneccessary directives.