Skip to content

Commit

Permalink
Expand .net/nuget support for .targets files and FrameworkReferences (O…
Browse files Browse the repository at this point in the history
…ctoLinker#785)

* Add PackageReference support for .targets files

* Add .net FrameworkReference support

* Add Update support for PackageReference

* Add e2e tests for .net/nuget

* Remove trailing whitespace
  • Loading branch information
xt0rted authored and stefanbuck committed Jan 24, 2020
1 parent 8feff6f commit ec9b536
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 9 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<a href="https://chrome.google.com/webstore/detail/octo-linker/jlmafbaeoofdegohdhinkhilhclaklkp"><img src="https://cloud.githubusercontent.com/assets/1393946/15162649/647ca490-1704-11e6-8ed8-ef0674e40fc3.png" width="375"/></a
</p>

## What is OctoLinker?
## What is OctoLinker?

OctoLinker is a browser extension for GitHub, that turns language-specific statements like `include` `require` or `import` into links.
OctoLinker is a browser extension for GitHub, that turns language-specific statements like `include` `require` or `import` into links.

<img src="./demo.png" width="890" />

Expand All @@ -23,7 +23,7 @@ Trusted by over 25,000 developers! Install OctoLinker from [Chrome Web Store](ht
- [▲ ZEIT](https://zeit.co/) for sponsoring OctoLinker with hosting!
- [Redis Green](https://redisgreen.net) for sponsoring OctoLinker with four dedicated Redis server!
- [Art Noir](https://www.art-noir.net/) for this amazing logo!
- Everyone who supported, [contributed](https://github.com/OctoLinker/OctoLinker/graphs/contributors), promoted the project.
- Everyone who supported, [contributed](https://github.com/OctoLinker/OctoLinker/graphs/contributors), promoted the project.

## Become a backer

Expand Down Expand Up @@ -74,6 +74,6 @@ Our [Privacy Policy](https://octolinker.now.sh/privacy/) describes our practices
- [Notifier for GitHub](https://github.com/sindresorhus/notifier-for-github-chrome) - Shows your notification unread count
- [OctoPermalinker](https://github.com/josephfrazier/octopermalinker) - Fix outdated/broken GitHub links to branches

## Disclaimer
## Disclaimer

OctoLinker is not affiliated with, sponsored by, or endorsed by GitHub Inc.
4 changes: 2 additions & 2 deletions e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ E2E stand for End to End testing and the following lines from [Protractor](https
### How we do E2E tests

We're using [Puppeteer](https://github.com/GoogleChrome/puppeteer) which allows us to spin up a Chrome instance which then loads the OctoLinker extension. Once Chrome has started we can navigate to any website which is github.com in our case. In this directory we also have a folder called [fixtures](https://github.com/OctoLinker/OctoLinker/tree/master/e2e/fixtures) which contains all our dummy files which we use for testing.
We're using [Puppeteer](https://github.com/GoogleChrome/puppeteer) which allows us to spin up a Chrome instance which then loads the OctoLinker extension. Once Chrome has started we can navigate to any website which is github.com in our case. In this directory we also have a folder called [fixtures](https://github.com/OctoLinker/OctoLinker/tree/master/e2e/fixtures) which contains all our dummy files which we use for testing.

If you open one of those files, you will see a special annotation which we use to specify that the next line should resolve to the given target:

Expand Down Expand Up @@ -47,7 +47,7 @@ require('fs')
// @OctoLinkerResolveAbove(https://nodejs.org/api/fs.html)
```

Before we invoke [jest](https://github.com/facebook/jest), we scan the fixtures folder for the annotations described above and write a file named `fixtures.json` to the disk. This JSON file then gets loaded by our actual test file (https://github.com/OctoLinker/OctoLinker/blob/master/e2e/automated.test.js) to scaffold those tests on-the-fly.
Before we invoke [jest](https://github.com/facebook/jest), we scan the fixtures folder for the annotations described above and write a file named `fixtures.json` to the disk. This JSON file then gets loaded by our actual test file (https://github.com/OctoLinker/OctoLinker/blob/master/e2e/automated.test.js) to scaffold those tests on-the-fly.


```js
Expand Down
14 changes: 14 additions & 0 deletions e2e/fixtures/dotnet/ClassicProject.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<ItemGroup>
<!-- @OctoLinkerResolve(https://www.nuget.org/packages/Microsoft.Extensions.Configuration.Abstractions) -->
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions">
<Version>3.1.1</Version>
</PackageReference>

<!-- @OctoLinkerResolve(https://www.nuget.org/packages/Microsoft.Extensions.Hosting.Abstractions) -->
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.1" />
</ItemGroup>

</Project>
36 changes: 36 additions & 0 deletions e2e/fixtures/dotnet/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<Project>

<ItemGroup>
<!-- @OctoLinkerResolve(https://www.nuget.org/packages/dotnet-compile-fsc) -->
<DotNetCliToolReference Include="dotnet-compile-fsc">
<Version>1.0.0-preview2-020000</Version>
</DotNetCliToolReference>

<!-- @OctoLinkerResolve(https://www.nuget.org/packages/Microsoft.VisualStudio.Web.CodeGeneration.Tools) -->
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" />

<!-- @OctoLinkerResolve(https://www.nuget.org/packages/Microsoft.DotNet.Watcher.Tools) -->
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="2.0.0" />
</ItemGroup>

<ItemGroup>
<!-- @OctoLinkerResolve(https://www.nuget.org/packages/Microsoft.AspNetCore.App) -->
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
<!-- @OctoLinkerResolve(https://www.nuget.org/packages/Microsoft.Extensions.Configuration.Abstractions) -->
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions">
<Version>3.1.1</Version>
</PackageReference>

<!-- @OctoLinkerResolve(https://www.nuget.org/packages/Microsoft.Extensions.Hosting.Abstractions) -->
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.1" />
</ItemGroup>

<ItemGroup>
<!-- @OctoLinkerResolve(https://www.nuget.org/packages/Microsoft.AspNetCore.Hosting.Abstractions) -->
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" />
</ItemGroup>

</Project>
28 changes: 28 additions & 0 deletions e2e/fixtures/dotnet/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project>

<ItemGroup>
<!-- @OctoLinkerResolve(https://www.nuget.org/packages/dotnet-compile-fsc) -->
<DotNetCliToolReference Update="dotnet-compile-fsc">
<Version>1.0.0-preview2-020000</Version>
</DotNetCliToolReference>

<!-- @OctoLinkerResolve(https://www.nuget.org/packages/Microsoft.VisualStudio.Web.CodeGeneration.Tools) -->
<DotNetCliToolReference Update="Microsoft.VisualStudio.Web.CodeGeneration.Tools" />
</ItemGroup>

<ItemGroup>
<!-- @OctoLinkerResolve(https://www.nuget.org/packages/Microsoft.AspNetCore.App) -->
<FrameworkReference Update="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
<!-- @OctoLinkerResolve(https://www.nuget.org/packages/Microsoft.Extensions.Hosting.Abstractions) -->
<PackageReference Update="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.1" />
</ItemGroup>

<ItemGroup>
<!-- @OctoLinkerResolve(https://www.nuget.org/packages/Microsoft.AspNetCore.Hosting.Abstractions) -->
<PackageReference Update="Microsoft.AspNetCore.Hosting.Abstractions" />
</ItemGroup>

</Project>
26 changes: 26 additions & 0 deletions e2e/fixtures/dotnet/SdkProject.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<!-- @OctoLinkerResolve(https://www.nuget.org/packages/Microsoft.VisualStudio.Web.CodeGeneration.Tools) -->
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" />

<!-- @OctoLinkerResolve(https://www.nuget.org/packages/Microsoft.DotNet.Watcher.Tools) -->
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="2.0.0" />
</ItemGroup>

<ItemGroup>
<!-- @OctoLinkerResolve(https://www.nuget.org/packages/Microsoft.AspNetCore.App) -->
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
<!-- @OctoLinkerResolve(https://www.nuget.org/packages/Microsoft.Extensions.Hosting.Abstractions) -->
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.1" />
</ItemGroup>

<ItemGroup>
<!-- @OctoLinkerResolve(https://www.nuget.org/packages/Microsoft.AspNetCore.Hosting.Abstractions) -->
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions packages/helper-grammar-regex-collection/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ export const JAVA_IMPORT = regex`
`;

export const NET_PROJ_PACKAGE = regex`
<(PackageReference|DotNetCliToolReference)
<(PackageReference|DotNetCliToolReference|FrameworkReference)
\s+
.*
Include=${captureQuotedWord}
(Include|Update)=${captureQuotedWord}
.*/?>
`;
3 changes: 3 additions & 0 deletions packages/helper-grammar-regex-collection/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,9 @@ const fixtures = {
'<DotNetCliToolReference Include="foo">\n<Version>2.0.0</Version>\n</DotNetCliToolReference>',
['foo'],
],
['<PackageReference Update="foo" Version="6.2.0" />', ['foo']],
['<FrameworkReference Include="foo" />', ['foo']],
['<FrameworkReference Update="foo" />', ['foo']],
],
invalid: [
'<PackageReferences Include="EntityFramework" Version="6.2.0" />',
Expand Down
7 changes: 6 additions & 1 deletion packages/plugin-dot-net/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ export default {

getPattern() {
return {
pathRegexes: [/packages\.config$/, /\.(cs|fs|vb)proj$/, /\.props$/],
pathRegexes: [
/packages\.config$/,
/\.(cs|fs|vb)proj$/,
/\.props$/,
/\.targets$/,
],
githubClasses: [],
};
},
Expand Down

0 comments on commit ec9b536

Please sign in to comment.