├── .gitattributes ├── .gitignore ├── EnlistmentRoot.marker ├── NETCORE ├── .github │ ├── ISSUE_TEMPLATE.md │ └── PULL_REQUEST_TEMPLATE.md ├── .vsts │ └── linux-build.yml ├── ApplicationInsights.AspNetCore.sln ├── CHANGELOG.md ├── CleanPackages.ps1 ├── CleanPackagesCore.ps1 ├── Common.targets ├── Directory.Build.props ├── GenerateReleaseMetadata.ps1 ├── LICENSE ├── Microsoft-Security-Recommended.ruleset ├── NuGet.config ├── NugetAudit.ps1 ├── Nupkg.props ├── Product.props ├── RunTests.cmd ├── RunTestsCore.ps1 ├── Schema │ ├── PublicSchema │ │ ├── AvailabilityData.bond │ │ ├── Base.bond │ │ ├── ContextTagKeys.bond │ │ ├── Data.bond │ │ ├── DataPoint.bond │ │ ├── DataPointType.bond │ │ ├── Domain.bond │ │ ├── Envelope.bond │ │ ├── EventData.bond │ │ ├── ExceptionData.bond │ │ ├── ExceptionDetails.bond │ │ ├── MessageData.bond │ │ ├── MetricData.bond │ │ ├── PageViewData.bond │ │ ├── PageViewPerfData.bond │ │ ├── RemoteDependencyData.bond │ │ ├── RequestData.bond │ │ ├── SeverityLevel.bond │ │ └── StackFrame.bond │ └── generateSchema.ps1 ├── SetEnv.targets ├── Signing.props ├── SourceRoot.marker ├── ThirdPartyNotices.txt ├── build.ps1 ├── buildDebug.cmd ├── buildRelease.cmd ├── clean.cmd ├── dirs.proj ├── disablestrongnamevalidation.ps1 ├── enablestrongnamevalidation.ps1 ├── findMsBuild.cmd ├── keys │ ├── 35MSSharedLib1024.snk │ └── InternalKey.snk ├── src │ ├── Microsoft.ApplicationInsights.AspNetCore │ │ ├── DiagnosticListeners │ │ │ └── Implementation │ │ │ │ ├── ExceptionUtilities.cs │ │ │ │ ├── HeadersUtilities.cs │ │ │ │ ├── HostingDiagnosticListener.cs │ │ │ │ ├── HttpHeadersUtilities.cs │ │ │ │ ├── IApplicationInsightDiagnosticListener.cs │ │ │ │ ├── MvcDiagnosticsListener.cs │ │ │ │ ├── PropertyFetcher.cs │ │ │ │ └── RequestResponseHeaders.cs │ │ ├── ExceptionTrackingMiddleware.cs │ │ ├── Extensibility │ │ │ └── Implementation │ │ │ │ └── Tracing │ │ │ │ └── AspNetCoreEventSource.cs │ │ ├── Extensions │ │ │ ├── ApplicationInsightsExtensions.cs │ │ │ ├── ApplicationInsightsWebHostBuilderExtensions.cs │ │ │ ├── DefaultApplicationInsightsServiceConfigureOptions.cs │ │ │ ├── HttpRequestExtensions.cs │ │ │ └── RequestCollectionOptions.cs │ │ ├── IJavaScriptSnippet.cs │ │ ├── Implementation │ │ │ ├── ApplicationInsightsStartupFilter.cs │ │ │ ├── AspNetCoreMajorVersion.cs │ │ │ ├── ProviderAliasAttribute.cs │ │ │ └── TelemetryConfigurationOptions.cs │ │ ├── JavaScriptSnippet.cs │ │ ├── Logging │ │ │ └── Implementation │ │ │ │ ├── ApplicationInsightsLogger.cs │ │ │ │ ├── ApplicationInsightsLoggerEvents.cs │ │ │ │ ├── ApplicationInsightsLoggerFactoryExtensions.cs │ │ │ │ ├── ApplicationInsightsLoggerOptions.cs │ │ │ │ └── ApplicationInsightsLoggerProvider.cs │ │ ├── Microsoft.ApplicationInsights.AspNetCore.csproj │ │ ├── Properties │ │ │ ├── AssemblyInfo.cs │ │ │ └── launchSettings.json │ │ ├── RequestTrackingTelemetryModule.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── SdkVersionUtils.cs │ │ └── TelemetryInitializers │ │ │ ├── AspNetCoreEnvironmentTelemetryInitializer.cs │ │ │ ├── AzureAppServiceRoleNameFromHostNameHeaderInitializer.cs │ │ │ ├── ClientIpHeaderTelemetryInitializer.cs │ │ │ ├── OperationNameTelemetryInitializer.cs │ │ │ ├── SyntheticTelemetryInitializer.cs │ │ │ ├── TelemetryInitializerBase.cs │ │ │ ├── WebSessionTelemetryInitializer.cs │ │ │ └── WebUserTelemetryInitializer.cs │ ├── Microsoft.ApplicationInsights.WorkerService │ │ ├── ApplicationInsightsExtensions.cs │ │ ├── DefaultApplicationInsightsServiceConfigureOptions.cs │ │ ├── Implementation │ │ │ ├── TelemetryConfigurationOptions.cs │ │ │ └── Tracing │ │ │ │ └── WorkerServiceEventSource.cs │ │ ├── Microsoft.ApplicationInsights.WorkerService.csproj │ │ └── Properties │ │ │ └── AssemblyInfo.cs │ └── Shared │ │ ├── Extensions │ │ ├── ApplicationInsightsExtensions.cs │ │ ├── ApplicationInsightsServiceOptions.cs │ │ └── DependencyCollectionOptions.cs │ │ ├── Implementation │ │ ├── ITelemetryModuleConfigurator.cs │ │ ├── ITelemetryProcessorFactory.cs │ │ ├── NoOpTelemetryModule.cs │ │ ├── TelemetryConfigurationOptionsSetup.cs │ │ ├── TelemetryModuleConfigurator.cs │ │ └── TelemetryProcessorFactory.cs │ │ ├── Internals │ │ └── ApplicationNameProvider.cs │ │ ├── Shared.projitems │ │ ├── Shared.shproj │ │ └── TelemetryInitializers │ │ ├── ComponentVersionTelemetryInitializer.cs │ │ └── DomainNameRoleInstanceTelemetryInitializer.cs └── test │ ├── ApplicationInsightsTypes │ ├── ApplicationInsightsTypes.csproj │ ├── Generated │ │ ├── AvailabilityData_types.cs │ │ ├── Base_types.cs │ │ ├── ContextTagKeys_types.cs │ │ ├── DataPointType_types.cs │ │ ├── DataPoint_types.cs │ │ ├── Data_types.cs │ │ ├── Domain_types.cs │ │ ├── Envelope_types.cs │ │ ├── EventData_types.cs │ │ ├── ExceptionData_types.cs │ │ ├── ExceptionDetails_types.cs │ │ ├── MessageData_types.cs │ │ ├── MetricData_types.cs │ │ ├── PageViewData_types.cs │ │ ├── PageViewPerfData_types.cs │ │ ├── RemoteDependencyData_types.cs │ │ ├── RequestData_types.cs │ │ ├── SeverityLevel_types.cs │ │ ├── StackFrame_types.cs │ │ └── bonddefaultcodegen.in │ ├── ItemType.cs │ ├── TelemetryItem.cs │ └── TelemetryItemType.cs │ ├── EmptyApp.FunctionalTests │ ├── App.config │ ├── EmptyApp.FunctionalTests10.csproj │ ├── FunctionalTest │ │ ├── ExceptionTelemetryEmptyAppTests.cs │ │ ├── RequestTelemetryEmptyAppTests.cs │ │ └── TelemetryModuleWorkingEmptyAppTests.cs │ ├── Properties │ │ └── launchSettings.json │ └── Startup.cs │ ├── EmptyApp20.FunctionalTests │ ├── App.config │ ├── EmptyApp20.FunctionalTests20.csproj │ ├── FunctionalTest │ │ ├── ExceptionTelemetryEmptyAppTests.cs │ │ ├── RequestTelemetryEmptyAppTests.cs │ │ └── TelemetryModuleWorkingEmptyAppTests.cs │ ├── Properties │ │ └── launchSettings.json │ └── Startup.cs │ ├── FunctionalTestUtils │ ├── BackTelemetryChannel.cs │ ├── FunctionalTestUtils.csproj │ ├── InProcessServer.cs │ ├── Properties │ │ └── launchSettings.json │ └── TelemetryTestsBase.cs │ ├── FunctionalTestUtils20 │ ├── FunctionalTestUtils20.csproj │ ├── HttpListenerObservableBase.cs │ ├── InProcessServer.cs │ ├── Properties │ │ └── launchSettings.json │ ├── TelemetryExtensions.cs │ ├── TelemetryHttpListenerObservable.cs │ ├── TelemetryItemFactory.cs │ └── TelemetryTestsBase.cs │ ├── MVCFramework.FunctionalTests │ ├── .bowerrc │ ├── App.config │ ├── Controllers │ │ ├── AccountController.cs │ │ ├── HomeController.cs │ │ └── ManageController.cs │ ├── Data │ │ ├── ApplicationDbContext.cs │ │ └── Migrations │ │ │ └── ApplicationDbContextModelSnapshot.cs │ ├── FunctionalTest │ │ ├── CorrelationMvcTests.cs │ │ ├── DependencyTelemetryMvcTests.cs │ │ ├── ExceptionTelemetryMvcTests.cs │ │ ├── RequestTelemetryMvcTests.cs │ │ └── TelemetryModuleWorkingMvcTests.cs │ ├── MVCFramework.FunctionalTests10.csproj │ ├── Models │ │ ├── AccountViewModels │ │ │ ├── ExternalLoginConfirmationViewModel.cs │ │ │ ├── ForgotPasswordViewModel.cs │ │ │ ├── LoginViewModel.cs │ │ │ ├── RegisterViewModel.cs │ │ │ ├── ResetPasswordViewModel.cs │ │ │ ├── SendCodeViewModel.cs │ │ │ └── VerifyCodeViewModel.cs │ │ ├── ApplicationUser.cs │ │ └── ManageViewModels │ │ │ ├── AddPhoneNumberViewModel.cs │ │ │ ├── ChangePasswordViewModel.cs │ │ │ ├── ConfigureTwoFactorViewModel.cs │ │ │ ├── FactorViewModel.cs │ │ │ ├── IndexViewModel.cs │ │ │ ├── ManageLoginsViewModel.cs │ │ │ ├── RemoveLoginViewModel.cs │ │ │ ├── SetPasswordViewModel.cs │ │ │ └── VerifyPhoneNumberViewModel.cs │ ├── Project_Readme.html │ ├── Properties │ │ └── launchSettings.json │ ├── Services │ │ ├── IEmailSender.cs │ │ ├── ISmsSender.cs │ │ └── MessageServices.cs │ ├── Startup.cs │ ├── Views │ │ ├── Account │ │ │ ├── ConfirmEmail.cshtml │ │ │ ├── ExternalLoginConfirmation.cshtml │ │ │ ├── ExternalLoginFailure.cshtml │ │ │ ├── ForgotPassword.cshtml │ │ │ ├── ForgotPasswordConfirmation.cshtml │ │ │ ├── Lockout.cshtml │ │ │ ├── Login.cshtml │ │ │ ├── Register.cshtml │ │ │ ├── ResetPassword.cshtml │ │ │ ├── ResetPasswordConfirmation.cshtml │ │ │ ├── SendCode.cshtml │ │ │ └── VerifyCode.cshtml │ │ ├── Home │ │ │ ├── About.cshtml │ │ │ ├── Contact.cshtml │ │ │ ├── Dependency.cshtml │ │ │ └── Index.cshtml │ │ ├── Manage │ │ │ ├── AddPhoneNumber.cshtml │ │ │ ├── ChangePassword.cshtml │ │ │ ├── Index.cshtml │ │ │ ├── ManageLogins.cshtml │ │ │ ├── SetPassword.cshtml │ │ │ └── VerifyPhoneNumber.cshtml │ │ ├── Shared │ │ │ ├── Error.cshtml │ │ │ ├── _Layout.cshtml │ │ │ ├── _LoginPartial.cshtml │ │ │ └── _ValidationScriptsPartial.cshtml │ │ ├── _ViewImports.cshtml │ │ └── _ViewStart.cshtml │ ├── appsettings.json │ ├── bower.json │ ├── gulpfile.js │ ├── package.json │ ├── web.Debug.config │ ├── web.Release.config │ ├── web.config │ ├── wwwroot │ │ ├── _references.js │ │ ├── css │ │ │ └── site.css │ │ ├── favicon.ico │ │ └── js │ │ │ └── site.js │ └── xunit.runner.json │ ├── MVCFramework20.FunctionalTests │ ├── .bowerrc │ ├── Controllers │ │ └── HomeController.cs │ ├── FunctionalTest │ │ ├── CorrelationMvcTests.cs │ │ ├── DependencyTelemetryMvcTests.cs │ │ ├── ExceptionTelemetryMvcTests.cs │ │ ├── RequestTelemetryMvcTests.cs │ │ └── TelemetryModuleWorkingMvcTests.cs │ ├── MVCFramework20.FunctionalTests20.csproj │ ├── Models │ │ └── ErrorViewModel.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Startup.cs │ ├── Views │ │ ├── Home │ │ │ ├── About.cshtml │ │ │ ├── Contact.cshtml │ │ │ └── Index.cshtml │ │ ├── Shared │ │ │ ├── Error.cshtml │ │ │ ├── _Layout.cshtml │ │ │ └── _ValidationScriptsPartial.cshtml │ │ ├── _ViewImports.cshtml │ │ └── _ViewStart.cshtml │ ├── appsettings.Development.json │ ├── appsettings.json │ ├── bower.json │ ├── bundleconfig.json │ ├── wwwroot │ │ ├── css │ │ │ ├── site.css │ │ │ └── site.min.css │ │ ├── favicon.ico │ │ ├── images │ │ │ ├── banner1.svg │ │ │ ├── banner2.svg │ │ │ ├── banner3.svg │ │ │ └── banner4.svg │ │ └── js │ │ │ ├── site.js │ │ │ └── site.min.js │ └── xunit.runner.json │ ├── Microsoft.ApplicationInsights.AspNetCore.Tests │ ├── App.config │ ├── AspNetCoreMajorVersion.cs │ ├── ExceptionTrackingMiddlewareTest.cs │ ├── Extensibility │ │ └── Implementation │ │ │ └── Tracing │ │ │ ├── AspNetEventSourceTests.cs │ │ │ ├── EventSourceTests.cs │ │ │ └── TestEventListener.cs │ ├── Extensions │ │ ├── ApplicationInsightsExtensionsTests.cs │ │ └── HttpRequestExtensionsTest.cs │ ├── FakeTelemetryChannel.cs │ ├── FakeTelemetryInitializer.cs │ ├── FakeTelemetryProcessor.cs │ ├── FakeTelemetryProcessorWithImportingConstructor.cs │ ├── HeadersUtilitiesTest.cs │ ├── Helpers │ │ ├── CommonMocks.cs │ │ ├── HttpContextAccessorHelper.cs │ │ ├── HttpContextStub.cs │ │ ├── HttpRequestStub.cs │ │ └── MockApplicationIdProvider.cs │ ├── HostingDiagnosticListenerTest.cs │ ├── HttpHeadersUtilitiesTest.cs │ ├── JavaScript │ │ └── ApplicationInsightsJavaScriptTest.cs │ ├── Logging │ │ └── ApplicationInsightsLoggerTests.cs │ ├── Microsoft.ApplicationInsights.AspNetCore.Tests.csproj │ ├── Properties │ │ └── launchSettings.json │ ├── RequestTrackingTelemetryModuleTest.cs │ ├── SdkVersionTestUtils.cs │ ├── TelemetryInitializers │ │ ├── AspNetCoreEnvironmentTelemetryInitializerTests.cs │ │ ├── AzureAppServiceRoleNameFromHostNameHeaderInitializerTests.cs │ │ ├── ClientIpHeaderTelemetryInitializerTests.cs │ │ ├── ComponentVersionTelemetryInitializerTests.cs │ │ ├── DomainNameRoleInstanceTelemetryInitializerTests.cs │ │ ├── OperationNameTelemetryInitializerTests.cs │ │ ├── SyntheticTelemetryInitializerTests.cs │ │ ├── WebSessionTelemetryInitializerTests.cs │ │ └── WebUserTelemetryInitializerTests.cs │ ├── TestTelemetryModule.cs │ ├── appsettings.json │ └── content │ │ ├── config-connection-string-and-instrumentation-key.json │ │ ├── config-connection-string.json │ │ ├── config-developer-mode.json │ │ ├── config-endpoint-address.json │ │ ├── config-instrumentation-key-new.json │ │ └── config-instrumentation-key.json │ ├── Microsoft.ApplicationInsights.WorkerService.Tests │ ├── ExtensionsTest.cs │ ├── FunctionalTests.cs │ ├── Microsoft.ApplicationInsights.WorkerService.Tests.csproj │ ├── Worker.cs │ └── content │ │ ├── config-connection-string.json │ │ ├── config-instrumentation-key-new.json │ │ └── sample-appsettings.json │ ├── StartupPerf │ └── startupPerf.ps1 │ ├── TestApp30.Tests │ ├── BasicTestWithCorrelation.cs │ ├── CustomWebApplicationFactory.cs │ ├── Properties │ │ └── launchSettings.json │ ├── StubChannel.cs │ └── TestApp30.Tests30.csproj │ ├── TestApp30 │ ├── Controllers │ │ └── HomeController.cs │ ├── Models │ │ └── ErrorViewModel.cs │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Startup.cs │ ├── TestApp30.csproj │ ├── Views │ │ ├── Home │ │ │ ├── Index.cshtml │ │ │ └── Privacy.cshtml │ │ ├── Shared │ │ │ ├── Error.cshtml │ │ │ ├── _Layout.cshtml │ │ │ └── _ValidationScriptsPartial.cshtml │ │ ├── _ViewImports.cshtml │ │ └── _ViewStart.cshtml │ ├── appsettings.Development.json │ ├── appsettings.json │ └── wwwroot │ │ ├── css │ │ └── site.css │ │ ├── favicon.ico │ │ └── js │ │ └── site.js │ ├── WebApi.FunctionalTests │ ├── App.config │ ├── Controllers │ │ ├── ExceptionController.cs │ │ └── ValuesController.cs │ ├── FunctionalTest │ │ ├── ExceptionTelemetryWebApiTests.cs │ │ ├── RequestTelemetryWebApiTests.cs │ │ └── TelemetryModuleWorkingWebApiTests.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Startup.cs │ ├── WebApi.FunctionalTests10.csproj │ ├── config.json │ ├── wwwroot │ │ └── web.config │ └── xunit.runner.json │ └── WebApi20.FunctionalTests │ ├── Controllers │ ├── DependencyController.cs │ ├── ExceptionController.cs │ └── ValuesController.cs │ ├── FunctionalTest │ ├── LoggerTests.cs │ ├── MultipleWebHostsTests.cs │ ├── RequestCollectionTests.cs │ ├── RequestCorrelationTests.cs │ └── RequestDependencyCorrelationTests.cs │ ├── Properties │ └── launchSettings.json │ ├── Startup.cs │ ├── WebApi20.FunctionalTests20.csproj │ ├── appsettings.Development.json │ ├── appsettings.json │ └── xunit.runner.json └── Readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | [Oo]bj/ 2 | [Bb]in/ 3 | TestResults/ 4 | .nuget/ 5 | _ReSharper.*/ 6 | packages/ 7 | artifacts/ 8 | PublishProfiles/ 9 | *.user 10 | *.suo 11 | *.cache 12 | *.docstates 13 | _ReSharper.* 14 | nuget.exe 15 | *net45.csproj 16 | *k10.csproj 17 | *.psess 18 | *.vsp 19 | *.pidb 20 | *.userprefs 21 | *DS_Store 22 | *.ncrunchsolution 23 | *.*sdf 24 | *.ipch 25 | *.done 26 | .vs/ 27 | project.lock.json 28 | 29 | bower_components/ 30 | node_modules/ 31 | **/wwwroot/lib 32 | /Msbuild.* -------------------------------------------------------------------------------- /EnlistmentRoot.marker: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/ApplicationInsights-aspnetcore/bfccb57e4f632fa2ee627dacedeaa55644c739f5/EnlistmentRoot.marker -------------------------------------------------------------------------------- /NETCORE/.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | If you are reporting bug/issue, please provide detailed Repro instructions. 2 | 3 | ## Repro Steps 4 | 1. 5 | 2. 6 | 7 | ## Actual Behavior 8 | 9 | 10 | ## Expected Behavior 11 | 12 | 13 | ## Version Info 14 | SDK Version (version of https://www.nuget.org/packages/Microsoft.ApplicationInsights.AspNetCore) : 15 | .NET Core Version (TargetFramework in your .csproj file) : 16 | How Application was onboarded with SDK(Installed Nugets/VisualStudio/Azure WebAppExtension) : 17 | OS : 18 | Hosting Info (IIS/Azure Web Apps/Running From Visual Studio etc) : -------------------------------------------------------------------------------- /NETCORE/.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Fix Issue # . 2 | 3 | 4 | - [ ] I ran Unit Tests locally. 5 | - [ ] CHANGELOG.md updated with one line description of the fix, and a link to the original issue if available. 6 | 7 | For significant contributions please make sure you have completed the following items: 8 | 9 | - [ ] Changes in public surface reviewed 10 | - [ ] Design discussion issue # 11 | - [ ] The PR will trigger build, unit tests, and functional tests automatically. If your PR was submitted from fork - mention one of committers to initiate the build for you. 12 | If you want to to re-run the build/tests, the easiest way is to simply Close and Re-Open this same PR. (Just click 'close pull request' followed by 'open pull request' buttons at the bottom of the PR) 13 | 14 | - Please follow [these] (https://github.com/Microsoft/ApplicationInsights-aspnetcore/blob/develop/Readme.md) instructions to build and test locally. 15 | -------------------------------------------------------------------------------- /NETCORE/CleanPackages.ps1: -------------------------------------------------------------------------------- 1 | #enable verbose mode 2 | $VerbosePreference = "Continue"; 3 | 4 | [String]$dnxRoot = [System.Environment]::ExpandEnvironmentVariables('%USERPROFILE%\.dnx'); 5 | 6 | rm -r $dnxRoot\packages -Force 7 | -------------------------------------------------------------------------------- /NETCORE/CleanPackagesCore.ps1: -------------------------------------------------------------------------------- 1 | #enable verbose mode 2 | $VerbosePreference = "Continue"; 3 | 4 | [String]$dnxRoot = [System.Environment]::ExpandEnvironmentVariables('%USERPROFILE%\.nuget'); 5 | 6 | rm -r $dnxRoot\packages -Force 7 | 8 | -------------------------------------------------------------------------------- /NETCORE/Common.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 5 | 6 | $(RuntimeToolingDirectory)\bin\dnu.cmd 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /NETCORE/Directory.Build.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'EnlistmentRoot.marker')) 11 | 12 | $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'SourceRoot.marker')) 13 | 14 | $(EnlistmentRoot)\..\bin 15 | $([System.IO.Path]::GetFullPath( $(BinRoot) )) 16 | 17 | $(EnlistmentRoot)\..\obj 18 | $([System.IO.Path]::GetFullPath( $(ObjRoot) )) 19 | 20 | $(MSBuildProjectDirectory.Substring($(SourceRoot.Length))) 21 | 22 | Debug 23 | 24 | $(BinRoot)\$(Configuration)\$(RelativeOutputPathBase) 25 | $([System.IO.Path]::GetFullPath( $(OutputPath) ))\ 26 | 27 | 28 | $(BinRoot)\$(Configuration)\NuGet 29 | $(PackageOutputDir) 30 | 31 | $(OutputPath) 32 | 33 | $(ObjRoot)\$(Configuration)\$(RelativeOutputPathBase) 34 | $([System.IO.Path]::GetFullPath( $(IntermediateOutputPath) ))\ 35 | 36 | 37 | -------------------------------------------------------------------------------- /NETCORE/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Microsoft 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /NETCORE/NuGet.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /NETCORE/Product.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 2.12.0-beta1 12 | 13 | 14 | -------------------------------------------------------------------------------- /NETCORE/RunTests.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | IF NOT DEFINED MSBUILD CALL findMsBuild.cmd 4 | 5 | SET ToolsVersion=15.0 6 | SET ProjectName=Msbuild.All 7 | SET Configuration=Debug 8 | SET Platform="Any CPU" 9 | 10 | "%MSBUILD%" dirs.proj /nologo /m:1 /fl /toolsversion:%ToolsVersion% /flp:logfile=%ProjectName%.%Platform%.log;v=d /flp1:logfile=%ProjectName%.%Platform%.wrn;warningsonly /flp2:logfile=%ProjectName%.%Platform%.err;errorsonly /p:Configuration=%Configuration% /p:Platform=%Platform% /p:RunCodeAnalysis="False" /flp3:logfile=%ProjectName%.%Platform%.prf;performancesummary /flp4:logfile=%ProjectName%.%Platform%.exec.log;showcommandline /p:BuildSingleFilePackage=true /p:IsOfficialBuild=%IsOfficialBuild% /p:RunTests=True 11 | 12 | pause -------------------------------------------------------------------------------- /NETCORE/RunTestsCore.ps1: -------------------------------------------------------------------------------- 1 | #enable verbose mode 2 | $VerbosePreference = "Continue"; 3 | 4 | $TestProjects = @( 5 | '.\test\Microsoft.ApplicationInsights.AspNetCore.Tests', 6 | '.\test\MVCFramework45.FunctionalTests', 7 | '.\test\WebApiShimFw46.FunctionalTests' 8 | ) 9 | 10 | Function Execute-DotnetProcess { 11 | Param ( 12 | [Parameter(Mandatory=$True)] 13 | [String]$RuntimePath, 14 | [Parameter(Mandatory=$True)] 15 | [String]$Arguments, 16 | [Parameter(Mandatory=$True)] 17 | [String]$WorkingDirectory 18 | ) 19 | 20 | $p = Start-Process $RuntimePath $Arguments -PassThru -NoNewWindow -Wait; 21 | 22 | Write-Host "Process executed, ExitCode:$($p.ExitCode)"; 23 | Write-Host "Output:"; 24 | Write-Host $p.StandardOutput; 25 | If ($p.ExitCode -ne 0) { 26 | $global:failed += $executeResult; 27 | } 28 | } 29 | 30 | Push-Location 31 | 32 | [PSObject[]]$global:failed = @(); 33 | $global:WorkingDirectory = (pwd).Path; 34 | 35 | $dotnetPath = "C:\Program Files\dotnet\dotnet.exe"; 36 | 37 | $TestProjects |% { 38 | [String]$arguments = "test"; 39 | [String]$currentWorkingDirectory = Join-Path $global:WorkingDirectory -ChildPath $_; 40 | Write-Host "========================================================="; 41 | Write-Host "== Executing tests"; 42 | Write-Host "== Working Folder: $currentWorkingDirectory"; 43 | Write-Host "== Runtime:$dotnetPath"; 44 | Write-Host "== Args:$arguments"; 45 | Write-Host "========================================================="; 46 | Set-Location -Path $currentWorkingDirectory; 47 | $executeResult = Execute-DotnetProcess ` 48 | -RuntimePath $dotnetPath ` 49 | -Arguments $arguments ` 50 | -WorkingDirectory $currentWorkingDirectory; 51 | } 52 | 53 | Pop-Location 54 | 55 | If ($global:failed.Count -gt 0) { 56 | Throw "Test execution failed"; 57 | } -------------------------------------------------------------------------------- /NETCORE/Schema/PublicSchema/AvailabilityData.bond: -------------------------------------------------------------------------------- 1 | import "Domain.bond" 2 | 3 | namespace AI 4 | 5 | [Description("Instances of AvailabilityData represent the result of executing an availability test.")] 6 | struct AvailabilityData 7 | : Domain 8 | { 9 | [Description("Schema version")] 10 | 10: required int32 ver = 2; 11 | 12 | [MaxStringLength("64")] 13 | [Description("Identifier of a test run. Use it to correlate steps of test run and telemetry generated by the service.")] 14 | [ActAsRequired("Renaming testRunId to id.")] 15 | 21: required string id; 16 | 17 | [MaxStringLength("1024")] 18 | [Description("Name of the test that these availability results represents.")] 19 | [ActAsRequired("Renaming testName to name.")] 20 | 41: required string name; 21 | 22 | [Description("Duration in TimeSpan 'G' (general long) format: d:hh:mm:ss.fffffff")] 23 | [CSType("TimeSpan")] 24 | 50: required string duration; 25 | 26 | [ActAsRequired("Renaming result to success.")] 27 | [Description("Success flag.")] 28 | 61: required bool success; 29 | 30 | [MaxStringLength("1024")] 31 | [Description("Name of the location where the test was run from.")] 32 | 70: string runLocation; 33 | 34 | [MaxStringLength("8192")] 35 | [Description("Diagnostic message for the result.")] 36 | 80: string message; 37 | 38 | [Description("Collection of custom properties.")] 39 | [MaxKeyLength("150")] 40 | [MaxValueLength("8192")] 41 | 100: map properties; 42 | 43 | [Description("Collection of custom measurements.")] 44 | [MaxKeyLength("150")] 45 | 200: map measurements; 46 | 47 | } 48 | -------------------------------------------------------------------------------- /NETCORE/Schema/PublicSchema/Base.bond: -------------------------------------------------------------------------------- 1 | 2 | namespace AI 3 | 4 | [Description("Data struct to contain only C section with custom fields.")] 5 | struct Base 6 | { 7 | [Name("ItemTypeName")] 8 | [Description("Name of item (B section) if any. If telemetry data is derived straight from this, this should be null.")] 9 | 10: string baseType; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /NETCORE/Schema/PublicSchema/Data.bond: -------------------------------------------------------------------------------- 1 | import "Base.bond" 2 | 3 | namespace AI 4 | 5 | [Description("Data struct to contain both B and C sections.")] 6 | struct Data 7 | : Base 8 | { 9 | [Name("Item")] 10 | [Description("Container for data item (B section).")] 11 | 20: required TDomain baseData; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /NETCORE/Schema/PublicSchema/DataPoint.bond: -------------------------------------------------------------------------------- 1 | import "DataPointType.bond" 2 | 3 | namespace AI 4 | 5 | [Description("Metric data single measurement.")] 6 | struct DataPoint 7 | { 8 | [Description("Name of the metric.")] 9 | [MaxStringLength("1024")] 10 | 10: required string name; 11 | 12 | [Description("Metric type.")] 13 | 20: AI.DataPointType kind = Measurement; 14 | 15 | [Description("Metric calculated value.")] 16 | 30: required double value; 17 | 18 | [Description("Metric weight of the aggregated metric. Should not be set for a measurement.")] 19 | 40: nullable count; 20 | 21 | [Description("Minimum value of the aggregated metric. Should not be set for a measurement.")] 22 | 50: nullable min; 23 | 24 | [Description("Maximum value of the aggregated metric. Should not be set for a measurement.")] 25 | 60: nullable max; 26 | 27 | [Description("Standard deviation of the aggregated metric. Should not be set for a measurement.")] 28 | 70: nullable stdDev; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /NETCORE/Schema/PublicSchema/DataPointType.bond: -------------------------------------------------------------------------------- 1 | namespace AI 2 | 3 | [Description("Type of the metric data measurement.")] 4 | enum DataPointType 5 | { 6 | Measurement, 7 | Aggregation, 8 | } 9 | -------------------------------------------------------------------------------- /NETCORE/Schema/PublicSchema/Domain.bond: -------------------------------------------------------------------------------- 1 | 2 | namespace AI 3 | 4 | [Description("The abstract common base of all domains.")] 5 | struct Domain 6 | { 7 | } 8 | -------------------------------------------------------------------------------- /NETCORE/Schema/PublicSchema/EventData.bond: -------------------------------------------------------------------------------- 1 | import "Domain.bond" 2 | 3 | namespace AI 4 | 5 | [Description("Instances of Event represent structured event records that can be grouped and searched by their properties. Event data item also creates a metric of event count by name.")] 6 | struct EventData 7 | : Domain 8 | { 9 | [Description("Schema version")] 10 | 10: required int32 ver = 2; 11 | 12 | [MaxStringLength("512")] 13 | [Description("Event name. Keep it low cardinality to allow proper grouping and useful metrics.")] 14 | [Question("Why Custom Event name is shorter than Request name or dependency name?")] 15 | 20: required string name; 16 | 17 | [Description("Collection of custom properties.")] 18 | [MaxKeyLength("150")] 19 | [MaxValueLength("8192")] 20 | 100: map properties; 21 | 22 | [Description("Collection of custom measurements.")] 23 | [MaxKeyLength("150")] 24 | 200: map measurements; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /NETCORE/Schema/PublicSchema/ExceptionData.bond: -------------------------------------------------------------------------------- 1 | import "Domain.bond" 2 | import "ExceptionDetails.bond" 3 | import "SeverityLevel.bond" 4 | 5 | namespace AI 6 | 7 | [Description("An instance of Exception represents a handled or unhandled exception that occurred during execution of the monitored application.")] 8 | struct ExceptionData 9 | : Domain 10 | { 11 | [Description("Schema version")] 12 | 10: required int32 ver = 2; 13 | 14 | [Description("Exception chain - list of inner exceptions.")] 15 | 50: required vector exceptions; 16 | 17 | [Description("Severity level. Mostly used to indicate exception severity level when it is reported by logging library.")] 18 | 60: nullable severityLevel; 19 | 20 | [Description("Identifier of where the exception was thrown in code. Used for exceptions grouping. Typically a combination of exception type and a function from the call stack.")] 21 | [MaxStringLength("1024")] 22 | 80: string problemId; 23 | 24 | [Description("Collection of custom properties.")] 25 | [MaxKeyLength("150")] 26 | [MaxValueLength("8192")] 27 | 100: map properties; 28 | 29 | [Description("Collection of custom measurements.")] 30 | [MaxKeyLength("150")] 31 | 200: map measurements; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /NETCORE/Schema/PublicSchema/ExceptionDetails.bond: -------------------------------------------------------------------------------- 1 | import "StackFrame.bond" 2 | 3 | namespace AI 4 | 5 | [Description("Exception details of the exception in a chain.")] 6 | struct ExceptionDetails 7 | { 8 | [Description("In case exception is nested (outer exception contains inner one), the id and outerId properties are used to represent the nesting.")] 9 | 10: int32 id; 10 | 11 | [Description("The value of outerId is a reference to an element in ExceptionDetails that represents the outer exception")] 12 | 20: int32 outerId; 13 | 14 | [Description("Exception type name.")] 15 | [MaxStringLength("1024")] 16 | 30: required string typeName; 17 | 18 | [Description("Exception message.")] 19 | [MaxStringLength("1024")] 20 | 40: required string message; 21 | 22 | [Description("Indicates if full exception stack is provided in the exception. The stack may be trimmed, such as in the case of a StackOverflow exception.")] 23 | 50: bool hasFullStack = true; 24 | 25 | [Description("Text describing the stack. Either stack or parsedStack should have a value.")] 26 | [MaxStringLength("32768")] 27 | 60: string stack; 28 | 29 | [Description("List of stack frames. Either stack or parsedStack should have a value.")] 30 | 70: vector parsedStack; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /NETCORE/Schema/PublicSchema/MessageData.bond: -------------------------------------------------------------------------------- 1 | import "Domain.bond" 2 | import "SeverityLevel.bond" 3 | 4 | namespace AI 5 | 6 | [Description("Instances of Message represent printf-like trace statements that are text-searched. Log4Net, NLog and other text-based log file entries are translated into instances of this type. The message does not have measurements.")] 7 | struct MessageData 8 | : Domain 9 | { 10 | [Description("Schema version")] 11 | 10: required int32 ver = 2; 12 | 13 | [MaxStringLength("32768")] 14 | [Description("Trace message")] 15 | 20: required string message; 16 | 17 | [Description("Trace severity level.")] 18 | 30: nullable severityLevel; 19 | 20 | [Description("Collection of custom properties.")] 21 | [MaxKeyLength("150")] 22 | [MaxValueLength("8192")] 23 | 100: map properties; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /NETCORE/Schema/PublicSchema/MetricData.bond: -------------------------------------------------------------------------------- 1 | import "Domain.bond" 2 | import "DataPoint.bond" 3 | 4 | namespace AI 5 | 6 | [Description("An instance of the Metric item is a list of measurements (single data points) and/or aggregations.")] 7 | struct MetricData 8 | : Domain 9 | { 10 | [Description("Schema version")] 11 | 10: required int32 ver = 2; 12 | 13 | [Description("List of metrics.")] 14 | 20: required vector metrics; 15 | 16 | [Description("Collection of custom properties.")] 17 | [MaxKeyLength("150")] 18 | [MaxValueLength("8192")] 19 | 100: map properties; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /NETCORE/Schema/PublicSchema/PageViewData.bond: -------------------------------------------------------------------------------- 1 | import "EventData.bond" 2 | 3 | namespace AI 4 | 5 | [Description("An instance of PageView represents a generic action on a page like a button click. It is also the base type for PageView.")] 6 | [Alias("PageviewData;PageEventData")] 7 | struct PageViewData 8 | : EventData 9 | { 10 | [MaxStringLength("2048")] 11 | [Description("Request URL with all query string parameters")] 12 | 10: string url; 13 | 14 | [CSType("TimeSpan")] 15 | [Description("Request duration in TimeSpan 'G' (general long) format: d:hh:mm:ss.fffffff. For a page view (PageViewData), this is the duration. For a page view with performance information (PageViewPerfData), this is the page load time.")] 16 | 20: string duration; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /NETCORE/Schema/PublicSchema/PageViewPerfData.bond: -------------------------------------------------------------------------------- 1 | import "PageViewData.bond" 2 | 3 | namespace AI 4 | 5 | [Description("An instance of PageViewPerf represents: a page view with no performance data, a page view with performance data, or just the performance data of an earlier page request.")] 6 | [Alias("PageViewPerformanceData;PageviewPerformanceData")] 7 | struct PageViewPerfData 8 | : PageViewData 9 | { 10 | [Description("Performance total in TimeSpan 'G' (general long) format: d:hh:mm:ss.fffffff")] 11 | [CSType("TimeSpan")] 12 | 10: string perfTotal; 13 | 14 | [Description("Network connection time in TimeSpan 'G' (general long) format: d:hh:mm:ss.fffffff")] 15 | [CSType("TimeSpan")] 16 | 20: string networkConnect; 17 | 18 | [Description("Sent request time in TimeSpan 'G' (general long) format: d:hh:mm:ss.fffffff")] 19 | [CSType("TimeSpan")] 20 | 30: string sentRequest; 21 | 22 | [Description("Received response time in TimeSpan 'G' (general long) format: d:hh:mm:ss.fffffff")] 23 | [CSType("TimeSpan")] 24 | 40: string receivedResponse; 25 | 26 | [Description("DOM processing time in TimeSpan 'G' (general long) format: d:hh:mm:ss.fffffff")] 27 | [CSType("TimeSpan")] 28 | 50: string domProcessing; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /NETCORE/Schema/PublicSchema/RequestData.bond: -------------------------------------------------------------------------------- 1 | import "Domain.bond" 2 | 3 | namespace AI 4 | 5 | [Description("An instance of Request represents completion of an external request to the application to do work and contains a summary of that request execution and the results.")] 6 | struct RequestData 7 | : Domain 8 | { 9 | [Description("Schema version")] 10 | 10: required int32 ver = 2; 11 | 12 | [MaxStringLength("128")] 13 | [Description("Identifier of a request call instance. Used for correlation between request and other telemetry items.")] 14 | 20: required string id; 15 | 16 | [CSType("TimeSpan")] 17 | [Description("Request duration in TimeSpan 'G' (general long) format: d:hh:mm:ss.fffffff.")] 18 | 50: required string duration; 19 | 20 | [MaxStringLength("1024")] 21 | [Description("Result of a request execution. HTTP status code for HTTP requests.")] 22 | 60: required string responseCode; 23 | 24 | [Description("Indication of successful or unsuccessful call.")] 25 | 70: required bool success; 26 | 27 | [MaxStringLength("1024")] 28 | [Description("Name of the request. Represents code path taken to process request. Low cardinality value to allow better grouping of requests. For HTTP requests it represents the HTTP method and URL path template like 'GET /values/{id}'.")] 29 | 30: string name; 30 | 31 | [MaxStringLength("2048")] 32 | [Description("Request URL with all query string parameters.")] 33 | 90: string url; 34 | 35 | [Description("Collection of custom properties.")] 36 | [MaxKeyLength("150")] 37 | [MaxValueLength("8192")] 38 | 100: map properties; 39 | 40 | [Description("Collection of custom measurements.")] 41 | [MaxKeyLength("150")] 42 | 200: map measurements; 43 | 44 | } 45 | -------------------------------------------------------------------------------- /NETCORE/Schema/PublicSchema/SeverityLevel.bond: -------------------------------------------------------------------------------- 1 | namespace AI 2 | 3 | [Description("Defines the level of severity for the event.")] 4 | enum SeverityLevel 5 | { 6 | Verbose, 7 | Information, 8 | Warning, 9 | Error, 10 | Critical, 11 | } 12 | -------------------------------------------------------------------------------- /NETCORE/Schema/PublicSchema/StackFrame.bond: -------------------------------------------------------------------------------- 1 | 2 | namespace AI 3 | 4 | [Description("Stack frame information.")] 5 | struct StackFrame 6 | { 7 | [Description("Level in the call stack. For the long stacks SDK may not report every function in a call stack.")] 8 | 10: required int32 level; 9 | 10 | [Description("Method name.")] 11 | [MaxStringLength("1024")] 12 | 20: required string method; 13 | 14 | [Description("Name of the assembly (dll, jar, etc.) containing this function.")] 15 | [MaxStringLength("1024")] 16 | 30: string assembly; 17 | 18 | [Description("File name or URL of the method implementation.")] 19 | [MaxStringLength("1024")] 20 | 50: string fileName; 21 | 22 | [Description("Line number of the code implementation.")] 23 | 60: int32 line; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /NETCORE/SetEnv.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 8 | 2016-9-28 9 | 13 | $([MSBuild]::Divide($([System.DateTime]::Now.Subtract($([System.DateTime]::Parse($(SemanticVersionDate)))).TotalMinutes), 5).ToString('F0')) 14 | 15 | 16 | 17 | 21 | 22 | 23 | 24 | 25 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /NETCORE/Signing.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | true 10 | $(SourceRoot)\Keys\InternalKey.snk 11 | 12 | 13 | 14 | $(DefineConstants);PUBLIC_RELEASE 15 | true 16 | $(SourceRoot)\Keys\35MSSharedLib1024.snk 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | Microsoft400 25 | MsSharedLib72 26 | 27 | 28 | Microsoft400 29 | 10006 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /NETCORE/SourceRoot.marker: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/ApplicationInsights-aspnetcore/bfccb57e4f632fa2ee627dacedeaa55644c739f5/NETCORE/SourceRoot.marker -------------------------------------------------------------------------------- /NETCORE/buildDebug.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | IF NOT DEFINED MSBUILD CALL findMsBuild.cmd 4 | 5 | SET ToolsVersion=15.0 6 | SET ProjectName=Msbuild.All 7 | SET Configuration=Debug 8 | SET Platform="Any CPU" 9 | 10 | "%MSBUILD%" dirs.proj /nologo /m:1 /fl /toolsversion:%ToolsVersion% /flp:logfile=%ProjectName%.%Platform%.log;v=d /flp1:logfile=%ProjectName%.%Platform%.wrn;warningsonly /flp2:logfile=%ProjectName%.%Platform%.err;errorsonly /p:Configuration=%Configuration% /p:Platform=%Platform% /p:RunCodeAnalysis="False" /flp3:logfile=%ProjectName%.%Platform%.prf;performancesummary /flp4:logfile=%ProjectName%.%Platform%.exec.log;showcommandline /p:BuildSingleFilePackage=true /p:IsOfficialBuild=%IsOfficialBuild% /p:RunTests=False 11 | 12 | pause -------------------------------------------------------------------------------- /NETCORE/buildRelease.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | IF NOT DEFINED MSBUILD CALL findMsBuild.cmd 4 | 5 | SET ToolsVersion=15.0 6 | SET ProjectName=Msbuild.All 7 | SET Configuration=Release 8 | SET Platform="Any CPU" 9 | 10 | "%MSBUILD%" dirs.proj /nologo /m:1 /fl /toolsversion:%ToolsVersion% /flp:logfile=%ProjectName%.%Platform%.log;v=d /flp1:logfile=%ProjectName%.%Platform%.wrn;warningsonly /flp2:logfile=%ProjectName%.%Platform%.err;errorsonly /p:Configuration=%Configuration% /p:Platform=%Platform% /p:RunCodeAnalysis="False" /flp3:logfile=%ProjectName%.%Platform%.prf;performancesummary /flp4:logfile=%ProjectName%.%Platform%.exec.log;showcommandline /p:BuildSingleFilePackage=true /p:IsOfficialBuild=%IsOfficialBuild% /p:RunTests=False 11 | 12 | pause -------------------------------------------------------------------------------- /NETCORE/clean.cmd: -------------------------------------------------------------------------------- 1 | del /q %TEMP%\VisualStudioTestExplorerExtensions\* 2 | for /d %%x in (%TEMP%\VisualStudioTestExplorerExtensions\*) do @rd /s /q "%%x" -------------------------------------------------------------------------------- /NETCORE/disablestrongnamevalidation.ps1: -------------------------------------------------------------------------------- 1 | & "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools\x64\sn.exe" -Vr *,31bf3856ad364e35 2 | & "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools\sn.exe" -Vr *,31bf3856ad364e35 3 | # running both the above as a hack which is known to work. Its not clear why both are needed. 4 | -------------------------------------------------------------------------------- /NETCORE/enablestrongnamevalidation.ps1: -------------------------------------------------------------------------------- 1 | & "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools\x64\sn.exe" -Vu *,31bf3856ad364e35 2 | & "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools\sn.exe" -Vu *,31bf3856ad364e35 3 | # running both the above as a hack which is known to work. Its not clear why both are needed. -------------------------------------------------------------------------------- /NETCORE/findMsBuild.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | IF NOT DEFINED VSVERSION SET VSVERSION=15.0 4 | 5 | IF DEFINED MSBUILD ( 6 | IF EXIST "%MSBUILD%" GOTO :eof 7 | ) 8 | 9 | SET VSWHERE=..\packages\vswhere\tools\vswhere.exe 10 | IF NOT EXIST "%VSWHERE%" nuget.exe install vswhere -NonInteractive -ExcludeVersion -Source https://www.nuget.org/api/v2 -OutputDirectory ..\packages> nul 11 | 12 | FOR /f "usebackq tokens=*" %%i in (`"%VSWHERE%" -version %VSVERSION% -products * -requires Microsoft.Component.MSBuild -property installationPath`) DO ( 13 | SET MSBUILD=%%i\MSBuild\%VSVERSION%\Bin\MSBuild.exe 14 | ) 15 | 16 | IF NOT DEFINED MSBUILD ( 17 | ECHO Could not find MSBuild %VSVERSION%. Please SET MSBUILD=^ and try again. 18 | GOTO :eof 19 | ) 20 | 21 | IF NOT EXIST "%MSBUILD%" ( 22 | ECHO vswhere.exe claims that MSBuild is at !MSBUILD! but it does not exist. 23 | ECHO Please SET MSBUILD=^ and try again. 24 | GOTO :eof 25 | ) 26 | 27 | ECHO Using MSBuild from %MSBUILD% 28 | -------------------------------------------------------------------------------- /NETCORE/keys/35MSSharedLib1024.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/ApplicationInsights-aspnetcore/bfccb57e4f632fa2ee627dacedeaa55644c739f5/NETCORE/keys/35MSSharedLib1024.snk -------------------------------------------------------------------------------- /NETCORE/keys/InternalKey.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/ApplicationInsights-aspnetcore/bfccb57e4f632fa2ee627dacedeaa55644c739f5/NETCORE/keys/InternalKey.snk -------------------------------------------------------------------------------- /NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/DiagnosticListeners/Implementation/ExceptionUtilities.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.ApplicationInsights.AspNetCore.DiagnosticListeners 2 | { 3 | using System; 4 | using Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing; 5 | 6 | /// 7 | /// Utility functions for dealing with exceptions. 8 | /// 9 | internal class ExceptionUtilities 10 | { 11 | /// 12 | /// Get the string representation of this Exception with special handling for AggregateExceptions. 13 | /// 14 | /// The exception to convert to a string. 15 | /// Returns a string representing the Exception message, and call stack. 16 | internal static string GetExceptionDetailString(Exception ex) 17 | { 18 | if (ex is AggregateException ae) 19 | { 20 | return ae.Flatten().InnerException.ToInvariantString(); 21 | } 22 | 23 | return ex.ToInvariantString(); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/DiagnosticListeners/Implementation/IApplicationInsightDiagnosticListener.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.ApplicationInsights.AspNetCore.DiagnosticListeners 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | /// 7 | /// Base diagnostic listener type for Application Insight. 8 | /// 9 | internal interface IApplicationInsightDiagnosticListener : IDisposable, IObserver> 10 | { 11 | /// 12 | /// Gets a value indicating which listener this instance should be subscribed to. 13 | /// 14 | string ListenerName { get; } 15 | 16 | /// 17 | /// Notifies listener that it is subscribed to DiagnosticSource. 18 | /// 19 | void OnSubscribe(); 20 | } 21 | } -------------------------------------------------------------------------------- /NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/DiagnosticListeners/Implementation/RequestResponseHeaders.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.ApplicationInsights.AspNetCore.DiagnosticListeners 2 | { 3 | /// 4 | /// Header names for requests / responses. 5 | /// 6 | internal static class RequestResponseHeaders 7 | { 8 | /// 9 | /// Request-Context header. 10 | /// 11 | public const string RequestContextHeader = "Request-Context"; 12 | 13 | /// 14 | /// Source key in the request context header that is added by an application while making http requests and retrieved by the other application when processing incoming requests. 15 | /// 16 | public const string RequestContextSourceKey = "appId"; 17 | 18 | /// 19 | /// Target key in the request context header that is added to the response and retrieved by the calling application when processing incoming responses. 20 | /// 21 | public const string RequestContextTargetKey = "appId"; // Although the name of Source and Target key is the same - appId. Conceptually they are different and hence, we intentionally have two constants here. Makes for better reading of the code. 22 | 23 | /// 24 | /// Request-Id header. 25 | /// 26 | public const string RequestIdHeader = "Request-Id"; 27 | 28 | /// 29 | /// Correlation-Context header. 30 | /// 31 | public const string CorrelationContextHeader = "Correlation-Context"; 32 | 33 | /// 34 | /// W3C traceparent header name. 35 | /// 36 | public const string TraceParentHeader = "traceparent"; 37 | 38 | /// 39 | /// W3C tracestate header name. 40 | /// 41 | public const string TraceStateHeader = "tracestate"; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/HttpRequestExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.ApplicationInsights.AspNetCore.Extensions 2 | { 3 | using System; 4 | using Microsoft.AspNetCore.Http; 5 | 6 | /// 7 | /// Set of extension methods for Microsoft.AspNetCore.Http.HttpRequest. 8 | /// 9 | public static class HttpRequestExtensions 10 | { 11 | private const string UnknownHostName = "UNKNOWN-HOST"; 12 | private const string MultipleHostName = "MULTIPLE-HOST"; 13 | private const string Comma = ","; 14 | 15 | /// 16 | /// Gets http request Uri from request object. 17 | /// 18 | /// The . 19 | /// A New Uri object representing request Uri. 20 | public static Uri GetUri(this HttpRequest request) 21 | { 22 | if (request == null) 23 | { 24 | throw new ArgumentNullException(nameof(request)); 25 | } 26 | 27 | if (string.IsNullOrWhiteSpace(request.Scheme) == true) 28 | { 29 | throw new ArgumentException("Http request Scheme is not specified"); 30 | } 31 | 32 | return new Uri(string.Concat( 33 | request.Scheme, 34 | "://", 35 | request.Host.HasValue ? (request.Host.Value.IndexOf(Comma, StringComparison.Ordinal) > 0 ? MultipleHostName : request.Host.Value) : UnknownHostName, 36 | request.Path.HasValue ? request.Path.Value : string.Empty, 37 | request.QueryString.HasValue ? request.QueryString.Value : string.Empty)); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/IJavaScriptSnippet.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.ApplicationInsights.AspNetCore 2 | { 3 | /// 4 | /// Represents factory used to generate Application Insights JavaScript snippet with dependency injection support. 5 | /// 6 | public interface IJavaScriptSnippet 7 | { 8 | /// 9 | /// Gets a JavaScript code snippet including the 'script' tag. 10 | /// 11 | /// JavaScript code snippet. 12 | string FullScript { get; } 13 | } 14 | } -------------------------------------------------------------------------------- /NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Implementation/AspNetCoreMajorVersion.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.ApplicationInsights.AspNetCore.Implementation 2 | { 3 | /// 4 | /// Represents the runtime version of AspNetCore. 5 | /// 6 | internal enum AspNetCoreMajorVersion 7 | { 8 | /// 9 | /// .NET Core Version 1.0 10 | /// 11 | One, 12 | 13 | /// 14 | /// .NET Core Version 2.0 15 | /// 16 | Two, 17 | 18 | /// 19 | /// .NET Core Version 3.0 20 | /// 21 | Three, 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Implementation/ProviderAliasAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.Extensions.Logging 2 | { 3 | using System; 4 | 5 | /// 6 | /// Controls logger provider alias used for configuration. 7 | /// 8 | [AttributeUsage(AttributeTargets.Class)] 9 | internal class ProviderAliasAttribute : Attribute 10 | { 11 | /// 12 | /// Initializes a new instance of the class. 13 | /// 14 | /// Sets an alias that can be used instead of full type name. 15 | public ProviderAliasAttribute(string alias) => this.Alias = alias; 16 | 17 | /// 18 | /// Gets an alias that can be used instead of full type name during configuration. 19 | /// 20 | public string Alias { get; } 21 | } 22 | } -------------------------------------------------------------------------------- /NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Logging/Implementation/ApplicationInsightsLoggerEvents.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.ApplicationInsights.AspNetCore.Logging 2 | { 3 | using System; 4 | 5 | /// 6 | /// Class to provide ApplicationInsights logger events. 7 | /// 8 | internal class ApplicationInsightsLoggerEvents 9 | { 10 | /// 11 | /// Event that is fired when new ApplicationInsights logger is added. 12 | /// 13 | public event Action LoggerAdded; 14 | 15 | /// 16 | /// Invokes LoggerAdded event. 17 | /// 18 | public void OnLoggerAdded() 19 | { 20 | this.LoggerAdded?.Invoke(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Logging/Implementation/ApplicationInsightsLoggerOptions.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.ApplicationInsights.AspNetCore.Logging 2 | { 3 | using System; 4 | using Microsoft.ApplicationInsights.DataContracts; 5 | using Microsoft.Extensions.Logging; 6 | 7 | /// 8 | /// defines the custom behavior of the tracing information sent to Application Insights. 9 | /// 10 | [Obsolete("Use Microsoft.Extensions.Logging.ApplicationInsights.AddApplicationInsights.ApplicationInsightsLoggerOptions from Microsoft.Extensions.Logging.ApplicationInsights package")] 11 | public class ApplicationInsightsLoggerOptions 12 | { 13 | /// 14 | /// Initializes a new instance of the class. 15 | /// Application Insights logger options can configure how behaves when sending telemetry. 16 | /// 17 | public ApplicationInsightsLoggerOptions() 18 | { 19 | this.TrackExceptionsAsExceptionTelemetry = true; 20 | } 21 | 22 | /// 23 | /// Gets or sets a value indicating whether to track exceptions as . 24 | /// 25 | public bool TrackExceptionsAsExceptionTelemetry { get; set; } 26 | 27 | /// 28 | /// Gets or sets a value indicating whether EventId and EventName properties should be included in telemetry. 29 | /// 30 | public bool IncludeEventId { get; set; } 31 | } 32 | } -------------------------------------------------------------------------------- /NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Logging/Implementation/ApplicationInsightsLoggerProvider.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.ApplicationInsights.AspNetCore.Logging 2 | { 3 | using System; 4 | using Microsoft.Extensions.Logging; 5 | using Microsoft.Extensions.Options; 6 | 7 | /// 8 | /// implementation that creates returns instances of . 9 | /// 10 | #if !NETSTANDARD2_0 11 | // For NETSTANDARD2.0 We take dependency on Microsoft.Extensions.Logging.ApplicationInsights which has ApplicationInsightsProvider having the same ProviderAlias and don't want to clash with this ProviderAlias. 12 | [ProviderAlias("ApplicationInsights")] 13 | #endif 14 | internal class ApplicationInsightsLoggerProvider : ILoggerProvider 15 | { 16 | private readonly TelemetryClient telemetryClient; 17 | private readonly Func filter; 18 | private readonly ApplicationInsightsLoggerOptions options; 19 | 20 | /// 21 | /// Initializes a new instance of the class. 22 | /// 23 | public ApplicationInsightsLoggerProvider(TelemetryClient telemetryClient, Func filter, IOptions options) 24 | { 25 | this.telemetryClient = telemetryClient; 26 | this.filter = filter; 27 | this.options = options.Value; 28 | } 29 | 30 | /// 31 | public ILogger CreateLogger(string categoryName) 32 | { 33 | return new ApplicationInsightsLogger(categoryName, this.telemetryClient, this.filter, this.options); 34 | } 35 | 36 | /// 37 | public void Dispose() 38 | { 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: InternalsVisibleTo("Microsoft.ApplicationInsights.AspNetCore.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] 5 | [assembly: ComVisible(false)] 6 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "SDK intentionally catch ALL exceptions and never re-throws.")] 7 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1633:File must have header", Justification = "Unnecessary.")] 8 | -------------------------------------------------------------------------------- /NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:4367/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNET_ENVIRONMENT": "Development" 16 | } 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/SdkVersionUtils.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.ApplicationInsights.AspNetCore 2 | { 3 | using System.Linq; 4 | using System.Reflection; 5 | 6 | /// 7 | /// Utility class for the version information of the current assembly. 8 | /// 9 | internal class SdkVersionUtils 10 | { 11 | #if NET451 || NET46 12 | /// 13 | /// SDK Version Prefix. 14 | /// 15 | public const string VersionPrefix = "aspnet5f:"; 16 | #else 17 | /// 18 | /// SDK Version Prefix. 19 | /// 20 | public const string VersionPrefix = "aspnet5c:"; 21 | #endif 22 | 23 | /// 24 | /// Get the Assembly Version with SDK prefix. 25 | /// 26 | /// Assembly version combined with this assembly's version prefix. 27 | internal static string GetVersion() 28 | { 29 | return VersionPrefix + GetAssemblyVersion(); 30 | } 31 | 32 | /// 33 | /// Get the Assembly Version with given SDK prefix. 34 | /// 35 | /// Prefix string to be included with the version. 36 | /// Returns a string representing the current assembly version. 37 | internal static string GetVersion(string versionPrefix) 38 | { 39 | return versionPrefix + GetAssemblyVersion(); 40 | } 41 | 42 | private static string GetAssemblyVersion() 43 | { 44 | return typeof(SdkVersionUtils).GetTypeInfo().Assembly.GetCustomAttributes() 45 | .First() 46 | .InformationalVersion; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/TelemetryInitializers/AspNetCoreEnvironmentTelemetryInitializer.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.ApplicationInsights.AspNetCore.TelemetryInitializers 2 | { 3 | using Microsoft.ApplicationInsights.Channel; 4 | using Microsoft.ApplicationInsights.DataContracts; 5 | using Microsoft.ApplicationInsights.Extensibility; 6 | using Microsoft.AspNetCore.Hosting; 7 | 8 | /// 9 | /// implementation that stamps ASP.NET Core environment name 10 | /// on telemetries. 11 | /// 12 | public class AspNetCoreEnvironmentTelemetryInitializer : ITelemetryInitializer 13 | { 14 | private const string AspNetCoreEnvironmentPropertyName = "AspNetCoreEnvironment"; 15 | private readonly IHostingEnvironment environment; 16 | 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// HostingEnvironment to provide EnvironmentName to be added to telemetry properties. 21 | public AspNetCoreEnvironmentTelemetryInitializer(IHostingEnvironment environment) 22 | { 23 | this.environment = environment; 24 | } 25 | 26 | /// 27 | public void Initialize(ITelemetry telemetry) 28 | { 29 | if (this.environment != null) 30 | { 31 | if (telemetry is ISupportProperties telProperties && !telProperties.Properties.ContainsKey(AspNetCoreEnvironmentPropertyName)) 32 | { 33 | telProperties.Properties.Add( 34 | AspNetCoreEnvironmentPropertyName, 35 | this.environment.EnvironmentName); 36 | } 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/TelemetryInitializers/OperationNameTelemetryInitializer.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.ApplicationInsights.AspNetCore.TelemetryInitializers 2 | { 3 | using Microsoft.ApplicationInsights.Channel; 4 | using Microsoft.ApplicationInsights.DataContracts; 5 | using Microsoft.AspNetCore.Http; 6 | 7 | /// 8 | /// This telemetry initializer sets the Operation Name on telemetry items. 9 | /// 10 | public class OperationNameTelemetryInitializer : TelemetryInitializerBase 11 | { 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | /// Accessor to provide HttpContext corresponding to telemetry items. 16 | public OperationNameTelemetryInitializer(IHttpContextAccessor httpContextAccessor) 17 | : base(httpContextAccessor) 18 | { 19 | } 20 | 21 | /// 22 | protected override void OnInitializeTelemetry(HttpContext platformContext, RequestTelemetry requestTelemetry, ITelemetry telemetry) 23 | { 24 | if (string.IsNullOrEmpty(telemetry.Context.Operation.Name)) 25 | { 26 | if (!string.IsNullOrEmpty(requestTelemetry.Name)) 27 | { 28 | telemetry.Context.Operation.Name = requestTelemetry.Name; 29 | } 30 | else 31 | { 32 | // We didn't get BeforeAction notification 33 | string name = platformContext.Request.Method + " " + platformContext.Request.Path.Value; 34 | telemetry.Context.Operation.Name = name; 35 | } 36 | } 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /NETCORE/src/Microsoft.ApplicationInsights.WorkerService/DefaultApplicationInsightsServiceConfigureOptions.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.ApplicationInsights.WorkerService 2 | { 3 | using System.Diagnostics; 4 | using System.Diagnostics.CodeAnalysis; 5 | using Microsoft.Extensions.Configuration; 6 | using Microsoft.Extensions.DependencyInjection; 7 | using Microsoft.Extensions.Options; 8 | 9 | /// 10 | /// implementation that reads options from provided IConfiguration. 11 | /// 12 | [SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "This class is instantiated by Dependency Injection.")] 13 | internal class DefaultApplicationInsightsServiceConfigureOptions : IConfigureOptions 14 | { 15 | private readonly IConfiguration configuration; 16 | 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// from which configuration for ApplicationInsights can be retrieved. 21 | public DefaultApplicationInsightsServiceConfigureOptions(IConfiguration configuration = null) 22 | { 23 | this.configuration = configuration; 24 | } 25 | 26 | /// 27 | public void Configure(ApplicationInsightsServiceOptions options) 28 | { 29 | if (this.configuration != null) 30 | { 31 | ApplicationInsightsExtensions.AddTelemetryConfiguration(this.configuration, options); 32 | } 33 | 34 | if (Debugger.IsAttached) 35 | { 36 | options.DeveloperMode = true; 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /NETCORE/src/Microsoft.ApplicationInsights.WorkerService/Implementation/TelemetryConfigurationOptions.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.Extensions.DependencyInjection 2 | { 3 | using System.Collections.Generic; 4 | using System.Diagnostics.CodeAnalysis; 5 | using System.Linq; 6 | using Microsoft.ApplicationInsights.Extensibility; 7 | using Microsoft.Extensions.Options; 8 | 9 | /// 10 | /// The implementation that create new every time when called". 11 | /// 12 | [SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "This class is instantiated by Dependency Injection.")] 13 | internal class TelemetryConfigurationOptions : IOptions 14 | { 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | /// Collection of options to be configured. 19 | public TelemetryConfigurationOptions(IEnumerable> configureOptions) 20 | { 21 | this.Value = TelemetryConfiguration.CreateDefault(); 22 | 23 | var configureOptionsArray = configureOptions.ToArray(); 24 | foreach (var c in configureOptionsArray) 25 | { 26 | c.Configure(this.Value); 27 | } 28 | } 29 | 30 | /// 31 | public TelemetryConfiguration Value { get; } 32 | } 33 | } -------------------------------------------------------------------------------- /NETCORE/src/Microsoft.ApplicationInsights.WorkerService/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1633:File must have header", Justification = "Unnecessary.")] -------------------------------------------------------------------------------- /NETCORE/src/Shared/Extensions/DependencyCollectionOptions.cs: -------------------------------------------------------------------------------- 1 | #if AI_ASPNETCORE_WEB 2 | namespace Microsoft.ApplicationInsights.AspNetCore.Extensions 3 | #else 4 | namespace Microsoft.ApplicationInsights.WorkerService 5 | #endif 6 | { 7 | /// 8 | /// Default collection options define the custom behavior or non-default features of dependency collection. 9 | /// 10 | public class DependencyCollectionOptions 11 | { 12 | /// 13 | /// Initializes a new instance of the class and fills default values. 14 | /// 15 | public DependencyCollectionOptions() 16 | { 17 | this.EnableLegacyCorrelationHeadersInjection = false; 18 | } 19 | 20 | /// 21 | /// Gets or sets a value indicating whether to enable legacy (x-ms*) correlation headers injection. 22 | /// 23 | public bool EnableLegacyCorrelationHeadersInjection { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /NETCORE/src/Shared/Implementation/ITelemetryModuleConfigurator.cs: -------------------------------------------------------------------------------- 1 | #if AI_ASPNETCORE_WEB 2 | namespace Microsoft.ApplicationInsights.AspNetCore 3 | #else 4 | namespace Microsoft.ApplicationInsights.WorkerService 5 | #endif 6 | { 7 | using System; 8 | using System.Diagnostics.CodeAnalysis; 9 | 10 | #if AI_ASPNETCORE_WEB 11 | using Microsoft.ApplicationInsights.AspNetCore.Extensions; 12 | #else 13 | using Microsoft.ApplicationInsights.WorkerService; 14 | #endif 15 | using Microsoft.ApplicationInsights.Extensibility; 16 | 17 | /// 18 | /// Represents method used to configure with dependency injection support. 19 | /// 20 | public interface ITelemetryModuleConfigurator 21 | { 22 | /// 23 | /// Gets the type of to be configured. 24 | /// 25 | Type TelemetryModuleType { get; } 26 | 27 | /// 28 | /// Configures the given . 29 | /// 30 | [Obsolete("Use Configure(ITelemetryModule telemetryModule, ApplicationInsightsServiceOptions options) instead.")] 31 | [SuppressMessage("Documentation Rules", "SA1600:ElementsMustBeDocumented", Justification = "This method is obsolete.")] 32 | void Configure(ITelemetryModule telemetryModule); 33 | 34 | /// 35 | /// Configures the given . 36 | /// 37 | /// Module to be configured. 38 | /// Configuration options. 39 | void Configure(ITelemetryModule telemetryModule, ApplicationInsightsServiceOptions options); 40 | } 41 | } -------------------------------------------------------------------------------- /NETCORE/src/Shared/Implementation/ITelemetryProcessorFactory.cs: -------------------------------------------------------------------------------- 1 | #if AI_ASPNETCORE_WEB 2 | namespace Microsoft.ApplicationInsights.AspNetCore 3 | #else 4 | namespace Microsoft.ApplicationInsights.WorkerService 5 | #endif 6 | { 7 | using Microsoft.ApplicationInsights.Channel; 8 | using Microsoft.ApplicationInsights.Extensibility; 9 | 10 | /// 11 | /// Represents factory used to create with dependency injection support. 12 | /// 13 | public interface ITelemetryProcessorFactory 14 | { 15 | /// 16 | /// Creates an instance of the telemetry processor, passing the 17 | /// next in the call chain to 18 | /// its constructor. 19 | /// 20 | /// The next processor in the chain. 21 | /// Returns a new TelemetryProcessor with it's Next property set to the provided processor. 22 | ITelemetryProcessor Create(ITelemetryProcessor nextProcessor); 23 | } 24 | } -------------------------------------------------------------------------------- /NETCORE/src/Shared/Implementation/NoOpTelemetryModule.cs: -------------------------------------------------------------------------------- 1 | namespace Shared.Implementation 2 | { 3 | using Microsoft.ApplicationInsights.Extensibility; 4 | 5 | /// 6 | /// No-op telemetry module that is added instead of actual one, when the actual module is disabled. 7 | /// 8 | internal class NoOpTelemetryModule : ITelemetryModule 9 | { 10 | /// 11 | /// This is a no-op and will do nothing. 12 | /// 13 | /// This does nothing. 14 | public void Initialize(TelemetryConfiguration configuration) 15 | { 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /NETCORE/src/Shared/Implementation/TelemetryProcessorFactory.cs: -------------------------------------------------------------------------------- 1 | #if AI_ASPNETCORE_WEB 2 | namespace Microsoft.ApplicationInsights.AspNetCore 3 | #else 4 | namespace Microsoft.ApplicationInsights.WorkerService 5 | #endif 6 | { 7 | using System; 8 | using Microsoft.ApplicationInsights.Extensibility; 9 | using Microsoft.Extensions.DependencyInjection; 10 | 11 | /// 12 | /// A generic factory for telemetry processors of a given type. 13 | /// 14 | internal class TelemetryProcessorFactory : ITelemetryProcessorFactory 15 | { 16 | private readonly IServiceProvider serviceProvider; 17 | private readonly Type telemetryProcessorType; 18 | 19 | /// 20 | /// Initializes a new instance of the class. 21 | /// 22 | /// The service provider. 23 | /// The type of telemetry processor to create. 24 | public TelemetryProcessorFactory(IServiceProvider serviceProvider, Type telemetryProcessorType) 25 | { 26 | this.serviceProvider = serviceProvider; 27 | this.telemetryProcessorType = telemetryProcessorType; 28 | } 29 | 30 | /// 31 | public ITelemetryProcessor Create(ITelemetryProcessor next) 32 | { 33 | return (ITelemetryProcessor)ActivatorUtilities.CreateInstance(this.serviceProvider, this.telemetryProcessorType, next); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /NETCORE/src/Shared/Internals/ApplicationNameProvider.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.ApplicationInsights.Shared.Internals 2 | { 3 | using System; 4 | using System.Reflection; 5 | 6 | /// 7 | /// This class provides the assembly name for the EventSource implementations. 8 | /// 9 | internal sealed class ApplicationNameProvider 10 | { 11 | /// 12 | /// Initializes a new instance of the class. 13 | /// 14 | public ApplicationNameProvider() 15 | { 16 | this.Name = GetApplicationName(); 17 | } 18 | 19 | /// 20 | /// Gets name of the current assembly. 21 | /// 22 | public string Name { get; private set; } 23 | 24 | private static string GetApplicationName() 25 | { 26 | try 27 | { 28 | return Assembly.GetEntryAssembly().GetName().Name; 29 | } 30 | catch (Exception exp) 31 | { 32 | return "Undefined " + exp.Message; 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /NETCORE/src/Shared/Shared.projitems: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | true 6 | d56f2979-d6bc-4ef2-bb9b-4077b3290599 7 | 8 | 9 | Microsoft.ApplicationInsights.Shared 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /NETCORE/src/Shared/Shared.shproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | d56f2979-d6bc-4ef2-bb9b-4077b3290599 5 | 14.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /NETCORE/src/Shared/TelemetryInitializers/ComponentVersionTelemetryInitializer.cs: -------------------------------------------------------------------------------- 1 | #if AI_ASPNETCORE_WEB 2 | namespace Microsoft.ApplicationInsights.AspNetCore.TelemetryInitializers 3 | #else 4 | namespace Microsoft.ApplicationInsights.WorkerService.TelemetryInitializers 5 | #endif 6 | { 7 | using Microsoft.ApplicationInsights.Channel; 8 | using Microsoft.ApplicationInsights.Extensibility; 9 | #if AI_ASPNETCORE_WEB 10 | using Microsoft.ApplicationInsights.AspNetCore.Extensions; 11 | #else 12 | using Microsoft.ApplicationInsights.WorkerService; 13 | #endif 14 | using Microsoft.Extensions.Options; 15 | 16 | /// 17 | /// A telemetry initializer that populates telemetry.Context.Component.Version to the value read from configuration. 18 | /// 19 | public class ComponentVersionTelemetryInitializer : ITelemetryInitializer 20 | { 21 | private readonly string version; 22 | 23 | /// 24 | /// Initializes a new instance of the class. 25 | /// 26 | /// Provides the Application Version to be added to the telemetry. 27 | public ComponentVersionTelemetryInitializer(IOptions options) 28 | { 29 | this.version = options.Value.ApplicationVersion; 30 | } 31 | 32 | /// 33 | public void Initialize(ITelemetry telemetry) 34 | { 35 | if (string.IsNullOrEmpty(telemetry.Context.Component.Version)) 36 | { 37 | if (!string.IsNullOrEmpty(this.version)) 38 | { 39 | telemetry.Context.Component.Version = this.version; 40 | } 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /NETCORE/src/Shared/TelemetryInitializers/DomainNameRoleInstanceTelemetryInitializer.cs: -------------------------------------------------------------------------------- 1 | #if AI_ASPNETCORE_WEB 2 | namespace Microsoft.ApplicationInsights.AspNetCore.TelemetryInitializers 3 | #else 4 | namespace Microsoft.ApplicationInsights.WorkerService.TelemetryInitializers 5 | #endif 6 | { 7 | using System; 8 | using System.Globalization; 9 | using System.Net; 10 | using System.Net.NetworkInformation; 11 | using System.Threading; 12 | 13 | using Microsoft.ApplicationInsights.Channel; 14 | using Microsoft.ApplicationInsights.Extensibility; 15 | 16 | /// 17 | /// A telemetry initializer that populates cloud context role instance. 18 | /// 19 | public class DomainNameRoleInstanceTelemetryInitializer : ITelemetryInitializer 20 | { 21 | private string roleInstanceName; 22 | 23 | /// 24 | /// Initializes role instance name and node name with the host name. 25 | /// 26 | /// Telemetry item. 27 | public void Initialize(ITelemetry telemetry) 28 | { 29 | if (string.IsNullOrEmpty(telemetry.Context.Cloud.RoleInstance)) 30 | { 31 | var name = LazyInitializer.EnsureInitialized(ref this.roleInstanceName, this.GetMachineName); 32 | telemetry.Context.Cloud.RoleInstance = name; 33 | } 34 | } 35 | 36 | private string GetMachineName() 37 | { 38 | string hostName = Dns.GetHostName(); 39 | 40 | // Issue #61: For dnxcore machine name does not have domain name like in full framework 41 | #if NET451 || NET46 42 | string domainName = IPGlobalProperties.GetIPGlobalProperties().DomainName; 43 | if (!hostName.EndsWith(domainName, StringComparison.OrdinalIgnoreCase)) 44 | { 45 | hostName = string.Format(CultureInfo.InvariantCulture, "{0}.{1}", hostName, domainName); 46 | } 47 | #endif 48 | return hostName; 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /NETCORE/test/ApplicationInsightsTypes/Generated/Base_types.cs: -------------------------------------------------------------------------------- 1 | 2 | //------------------------------------------------------------------------------ 3 | // This code was generated by a tool. 4 | // 5 | // Tool : Bond Compiler 0.10.1.0 6 | // File : Base_types.cs 7 | // 8 | // Changes to this file may cause incorrect behavior and will be lost when 9 | // the code is regenerated. 10 | // 11 | //------------------------------------------------------------------------------ 12 | 13 | 14 | // suppress "Missing XML comment for publicly visible type or member" 15 | #pragma warning disable 1591 16 | 17 | 18 | #region ReSharper warnings 19 | // ReSharper disable PartialTypeWithSinglePart 20 | // ReSharper disable RedundantNameQualifier 21 | // ReSharper disable InconsistentNaming 22 | // ReSharper disable CheckNamespace 23 | // ReSharper disable UnusedParameter.Local 24 | // ReSharper disable RedundantUsingDirective 25 | #endregion 26 | 27 | namespace AI 28 | { 29 | using System.Collections.Generic; 30 | 31 | [global::Bond.Attribute("Description", "Data struct to contain only C section with custom fields.")] 32 | [global::Bond.Schema] 33 | [System.CodeDom.Compiler.GeneratedCode("gbc", "0.10.1.0")] 34 | public partial class Base 35 | { 36 | [global::Bond.Attribute("Name", "ItemTypeName")] 37 | [global::Bond.Attribute("Description", "Name of item (B section) if any. If telemetry data is derived straight from this, this should be null.")] 38 | [global::Bond.Id(10)] 39 | public string baseType { get; set; } 40 | 41 | public Base() 42 | : this("AI.Base", "Base") 43 | {} 44 | 45 | protected Base(string fullName, string name) 46 | { 47 | baseType = ""; 48 | } 49 | } 50 | } // AI 51 | -------------------------------------------------------------------------------- /NETCORE/test/ApplicationInsightsTypes/Generated/DataPointType_types.cs: -------------------------------------------------------------------------------- 1 | 2 | //------------------------------------------------------------------------------ 3 | // This code was generated by a tool. 4 | // 5 | // Tool : Bond Compiler 0.10.1.0 6 | // File : DataPointType_types.cs 7 | // 8 | // Changes to this file may cause incorrect behavior and will be lost when 9 | // the code is regenerated. 10 | // 11 | //------------------------------------------------------------------------------ 12 | 13 | 14 | // suppress "Missing XML comment for publicly visible type or member" 15 | #pragma warning disable 1591 16 | 17 | 18 | #region ReSharper warnings 19 | // ReSharper disable PartialTypeWithSinglePart 20 | // ReSharper disable RedundantNameQualifier 21 | // ReSharper disable InconsistentNaming 22 | // ReSharper disable CheckNamespace 23 | // ReSharper disable UnusedParameter.Local 24 | // ReSharper disable RedundantUsingDirective 25 | #endregion 26 | 27 | namespace AI 28 | { 29 | using System.Collections.Generic; 30 | 31 | [global::Bond.Attribute("Description", "Type of the metric data measurement.")] 32 | [System.CodeDom.Compiler.GeneratedCode("gbc", "0.10.1.0")] 33 | public enum DataPointType 34 | { 35 | Measurement, 36 | Aggregation, 37 | } 38 | } // AI 39 | -------------------------------------------------------------------------------- /NETCORE/test/ApplicationInsightsTypes/Generated/Data_types.cs: -------------------------------------------------------------------------------- 1 | 2 | //------------------------------------------------------------------------------ 3 | // This code was generated by a tool. 4 | // 5 | // Tool : Bond Compiler 0.10.1.0 6 | // File : Data_types.cs 7 | // 8 | // Changes to this file may cause incorrect behavior and will be lost when 9 | // the code is regenerated. 10 | // 11 | //------------------------------------------------------------------------------ 12 | 13 | 14 | // suppress "Missing XML comment for publicly visible type or member" 15 | #pragma warning disable 1591 16 | 17 | 18 | #region ReSharper warnings 19 | // ReSharper disable PartialTypeWithSinglePart 20 | // ReSharper disable RedundantNameQualifier 21 | // ReSharper disable InconsistentNaming 22 | // ReSharper disable CheckNamespace 23 | // ReSharper disable UnusedParameter.Local 24 | // ReSharper disable RedundantUsingDirective 25 | #endregion 26 | 27 | namespace AI 28 | { 29 | using System.Collections.Generic; 30 | 31 | [global::Bond.Attribute("Description", "Data struct to contain both B and C sections.")] 32 | [global::Bond.Schema] 33 | [System.CodeDom.Compiler.GeneratedCode("gbc", "0.10.1.0")] 34 | public partial class Data 35 | : Base 36 | { 37 | [global::Bond.Attribute("Name", "Item")] 38 | [global::Bond.Attribute("Description", "Container for data item (B section).")] 39 | [global::Bond.Id(20), global::Bond.Type(typeof(global::Bond.Tag.classT)), global::Bond.Required] 40 | public TDomain baseData { get; set; } 41 | 42 | public Data() 43 | : this("AI.Data", "Data") 44 | {} 45 | 46 | protected Data(string fullName, string name) 47 | { 48 | baseData = global::Bond.GenericFactory.Create(); 49 | } 50 | } 51 | } // AI 52 | -------------------------------------------------------------------------------- /NETCORE/test/ApplicationInsightsTypes/Generated/Domain_types.cs: -------------------------------------------------------------------------------- 1 | 2 | //------------------------------------------------------------------------------ 3 | // This code was generated by a tool. 4 | // 5 | // Tool : Bond Compiler 0.10.1.0 6 | // File : Domain_types.cs 7 | // 8 | // Changes to this file may cause incorrect behavior and will be lost when 9 | // the code is regenerated. 10 | // 11 | //------------------------------------------------------------------------------ 12 | 13 | 14 | // suppress "Missing XML comment for publicly visible type or member" 15 | #pragma warning disable 1591 16 | 17 | 18 | #region ReSharper warnings 19 | // ReSharper disable PartialTypeWithSinglePart 20 | // ReSharper disable RedundantNameQualifier 21 | // ReSharper disable InconsistentNaming 22 | // ReSharper disable CheckNamespace 23 | // ReSharper disable UnusedParameter.Local 24 | // ReSharper disable RedundantUsingDirective 25 | #endregion 26 | 27 | namespace AI 28 | { 29 | using System.Collections.Generic; 30 | 31 | [global::Bond.Attribute("Description", "The abstract common base of all domains.")] 32 | [global::Bond.Schema] 33 | [System.CodeDom.Compiler.GeneratedCode("gbc", "0.10.1.0")] 34 | public partial class Domain 35 | { 36 | 37 | } 38 | } // AI 39 | -------------------------------------------------------------------------------- /NETCORE/test/ApplicationInsightsTypes/Generated/SeverityLevel_types.cs: -------------------------------------------------------------------------------- 1 | 2 | //------------------------------------------------------------------------------ 3 | // This code was generated by a tool. 4 | // 5 | // Tool : Bond Compiler 0.10.1.0 6 | // File : SeverityLevel_types.cs 7 | // 8 | // Changes to this file may cause incorrect behavior and will be lost when 9 | // the code is regenerated. 10 | // 11 | //------------------------------------------------------------------------------ 12 | 13 | 14 | // suppress "Missing XML comment for publicly visible type or member" 15 | #pragma warning disable 1591 16 | 17 | 18 | #region ReSharper warnings 19 | // ReSharper disable PartialTypeWithSinglePart 20 | // ReSharper disable RedundantNameQualifier 21 | // ReSharper disable InconsistentNaming 22 | // ReSharper disable CheckNamespace 23 | // ReSharper disable UnusedParameter.Local 24 | // ReSharper disable RedundantUsingDirective 25 | #endregion 26 | 27 | namespace AI 28 | { 29 | using System.Collections.Generic; 30 | 31 | [global::Bond.Attribute("Description", "Defines the level of severity for the event.")] 32 | [System.CodeDom.Compiler.GeneratedCode("gbc", "0.10.1.0")] 33 | public enum SeverityLevel 34 | { 35 | Verbose, 36 | Information, 37 | Warning, 38 | Error, 39 | Critical, 40 | } 41 | } // AI 42 | -------------------------------------------------------------------------------- /NETCORE/test/ApplicationInsightsTypes/Generated/bonddefaultcodegen.in: -------------------------------------------------------------------------------- 1 | ..\..\Schema\PublicSchema\AvailabilityData.bond 2 | ..\..\Schema\PublicSchema\Base.bond 3 | ..\..\Schema\PublicSchema\ContextTagKeys.bond 4 | ..\..\Schema\PublicSchema\Data.bond 5 | ..\..\Schema\PublicSchema\DataPoint.bond 6 | ..\..\Schema\PublicSchema\DataPointType.bond 7 | ..\..\Schema\PublicSchema\Domain.bond 8 | ..\..\Schema\PublicSchema\Envelope.bond 9 | ..\..\Schema\PublicSchema\EventData.bond 10 | ..\..\Schema\PublicSchema\ExceptionData.bond 11 | ..\..\Schema\PublicSchema\ExceptionDetails.bond 12 | ..\..\Schema\PublicSchema\MessageData.bond 13 | ..\..\Schema\PublicSchema\MetricData.bond 14 | ..\..\Schema\PublicSchema\PageViewData.bond 15 | ..\..\Schema\PublicSchema\PageViewPerfData.bond 16 | ..\..\Schema\PublicSchema\RemoteDependencyData.bond 17 | ..\..\Schema\PublicSchema\RequestData.bond 18 | ..\..\Schema\PublicSchema\SeverityLevel.bond 19 | ..\..\Schema\PublicSchema\StackFrame.bond 20 | -------------------------------------------------------------------------------- /NETCORE/test/ApplicationInsightsTypes/ItemType.cs: -------------------------------------------------------------------------------- 1 | namespace AI 2 | { 3 | public class ItemType 4 | { 5 | public const string Metric = "Microsoft.ApplicationInsights.Metric"; 6 | 7 | public const string Request = "Microsoft.ApplicationInsights.Request"; 8 | 9 | public const string Exception = "Microsoft.ApplicationInsights.Exception"; 10 | 11 | public const string Message = "Microsoft.ApplicationInsights.Message"; 12 | 13 | public const string Event = "Microsoft.ApplicationInsights.Event"; 14 | 15 | public const string PageView = "Microsoft.ApplicationInsights.PageView"; 16 | 17 | public const string PageViewPerformance = "Microsoft.ApplicationInsights.PageViewPerformance"; 18 | 19 | public const string RemoteDependency = "Microsoft.ApplicationInsights.RemoteDependency"; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /NETCORE/test/ApplicationInsightsTypes/TelemetryItem.cs: -------------------------------------------------------------------------------- 1 | namespace AI 2 | { 3 | /// 4 | /// Provides access to a complete telemetry item. 5 | /// 6 | /// The part B telemetry item type. 7 | public class TelemetryItem : Envelope 8 | { 9 | /// 10 | /// Gets the telemetry data. 11 | /// 12 | public new Data data { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /NETCORE/test/ApplicationInsightsTypes/TelemetryItemType.cs: -------------------------------------------------------------------------------- 1 | namespace AI 2 | { 3 | public enum TelemetryItemType 4 | { 5 | Event, 6 | Exception, 7 | Message, 8 | Metric, 9 | PageView, 10 | PageViewPerformance, 11 | RemoteDependency, 12 | Request, 13 | Availability 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /NETCORE/test/EmptyApp.FunctionalTests/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /NETCORE/test/EmptyApp.FunctionalTests/EmptyApp.FunctionalTests10.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 2.0.0 5 | net46;netcoreapp1.0 6 | netcoreapp1.0 7 | win7-x86 8 | true 9 | true 10 | EmptyApp.FunctionalTests 11 | EmptyApp.FunctionalTests 12 | true 13 | 14 | pdbonly 15 | true 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | Always 38 | SettingsSingleFileGenerator 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /NETCORE/test/EmptyApp.FunctionalTests/FunctionalTest/ExceptionTelemetryEmptyAppTests.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using Xunit; 3 | using Xunit.Abstractions; 4 | 5 | [assembly: CollectionBehavior(DisableTestParallelization = true)] 6 | namespace EmptyApp.FunctionalTests.FunctionalTest 7 | { 8 | using System; 9 | using FunctionalTestUtils; 10 | using Microsoft.ApplicationInsights.DataContracts; 11 | 12 | public class ExceptionTelemetryEmptyAppTests : TelemetryTestsBase 13 | { 14 | private const string assemblyName = "EmptyApp.FunctionalTests"; 15 | public ExceptionTelemetryEmptyAppTests(ITestOutputHelper output) : base(output) 16 | { 17 | } 18 | 19 | [Fact] 20 | public void TestBasicRequestPropertiesAfterRequestingRequestThatThrows() 21 | { 22 | using (var server = new InProcessServer(assemblyName)) 23 | { 24 | const string RequestPath = "/Exception"; 25 | 26 | var expectedRequestTelemetry = new RequestTelemetry(); 27 | 28 | expectedRequestTelemetry.Name = "GET /Exception"; 29 | expectedRequestTelemetry.ResponseCode = "500"; 30 | expectedRequestTelemetry.Success = false; 31 | expectedRequestTelemetry.Url = new System.Uri(server.BaseHost + RequestPath); 32 | this.ValidateBasicRequest(server, "/Exception", expectedRequestTelemetry); 33 | } 34 | } 35 | 36 | [Fact] 37 | public void TestBasicExceptionPropertiesAfterRequestingRequestThatThrows() 38 | { 39 | using (var server = new InProcessServer(assemblyName)) 40 | { 41 | var expectedExceptionTelemetry = new ExceptionTelemetry(); 42 | expectedExceptionTelemetry.Exception = new InvalidOperationException(); 43 | 44 | this.ValidateBasicException(server, "/Exception", expectedExceptionTelemetry); 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /NETCORE/test/EmptyApp.FunctionalTests/FunctionalTest/TelemetryModuleWorkingEmptyAppTests.cs: -------------------------------------------------------------------------------- 1 | namespace EmptyApp.FunctionalTests.FunctionalTest 2 | { 3 | using FunctionalTestUtils; 4 | using Xunit; 5 | using Xunit.Abstractions; 6 | 7 | public class TelemetryModuleWorkingEmptyAppTests : TelemetryTestsBase 8 | { 9 | private const string assemblyName = "EmptyApp.FunctionalTests"; 10 | public TelemetryModuleWorkingEmptyAppTests(ITestOutputHelper output) : base(output) 11 | { 12 | } 13 | // The NET451 conditional check is wrapped inside the test to make the tests visible in the test explorer. We can move them to the class level once if the issue is resolved. 14 | 15 | public void TestBasicDependencyPropertiesAfterRequestingBasicPage() 16 | { 17 | this.ValidateBasicDependency(assemblyName, "/"); 18 | } 19 | 20 | [Fact] 21 | public void TestIfPerformanceCountersAreCollected() 22 | { 23 | #if NET451 || NET46 24 | ValidatePerformanceCountersAreCollected(assemblyName); 25 | #endif 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /NETCORE/test/EmptyApp.FunctionalTests/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:4828/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNET_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "web": { 19 | "commandName": "web", 20 | "environmentVariables": { 21 | "ASPNET_ENVIRONMENT": "Development" 22 | } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /NETCORE/test/EmptyApp20.FunctionalTests/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /NETCORE/test/EmptyApp20.FunctionalTests/FunctionalTest/TelemetryModuleWorkingEmptyAppTests.cs: -------------------------------------------------------------------------------- 1 | namespace EmptyApp20.FunctionalTests.FunctionalTest 2 | { 3 | using FunctionalTestUtils; 4 | using Microsoft.ApplicationInsights.DataContracts; 5 | using Xunit; 6 | using Xunit.Abstractions; 7 | 8 | public class TelemetryModuleWorkingEmptyAppTests : TelemetryTestsBase 9 | { 10 | private const string assemblyName = "EmptyApp20.FunctionalTests20"; 11 | public TelemetryModuleWorkingEmptyAppTests(ITestOutputHelper output) : base (output) 12 | { 13 | } 14 | 15 | // The NET451 conditional check is wrapped inside the test to make the tests visible in the test explorer. We can move them to the class level once if the issue is resolved. 16 | 17 | public void TestBasicDependencyPropertiesAfterRequestingBasicPage() 18 | { 19 | const string RequestPath = "/"; 20 | 21 | using (var server = new InProcessServer(assemblyName, this.output)) 22 | { 23 | DependencyTelemetry expected = new DependencyTelemetry(); 24 | expected.ResultCode = "200"; 25 | expected.Success = true; 26 | expected.Name = "GET /"; 27 | expected.Data = server.BaseHost + RequestPath; 28 | 29 | this.ValidateBasicDependency(server, RequestPath, expected); 30 | } 31 | } 32 | 33 | [Fact] 34 | public void TestIfPerformanceCountersAreCollected() 35 | { 36 | ValidatePerformanceCountersAreCollected(assemblyName); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /NETCORE/test/EmptyApp20.FunctionalTests/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:4828/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNET_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "web": { 19 | "commandName": "web", 20 | "environmentVariables": { 21 | "ASPNET_ENVIRONMENT": "Development" 22 | } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /NETCORE/test/FunctionalTestUtils/BackTelemetryChannel.cs: -------------------------------------------------------------------------------- 1 | namespace FunctionalTestUtils 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using Microsoft.ApplicationInsights.Channel; 6 | 7 | public class BackTelemetryChannel : ITelemetryChannel 8 | { 9 | private IList buffer; 10 | 11 | public BackTelemetryChannel() 12 | { 13 | this.buffer = new List(); 14 | } 15 | 16 | public IList Buffer 17 | { 18 | get 19 | { 20 | return this.buffer; 21 | } 22 | } 23 | 24 | public bool? DeveloperMode 25 | { 26 | get 27 | { 28 | return true; 29 | } 30 | set 31 | { 32 | } 33 | } 34 | 35 | public string EndpointAddress 36 | { 37 | get 38 | { 39 | return "https://dc.services.visualstudio.com/v2/track"; 40 | } 41 | 42 | set 43 | { 44 | } 45 | } 46 | 47 | public void Dispose() 48 | { 49 | } 50 | 51 | public void Flush() 52 | { 53 | } 54 | 55 | public void Send(ITelemetry item) 56 | { 57 | this.buffer.Add(item); 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /NETCORE/test/FunctionalTestUtils/FunctionalTestUtils.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 1.0.2 5 | net46;netstandard1.6 6 | netstandard1.6 7 | true 8 | FunctionalTestUtils 9 | FunctionalTestUtils 10 | 1.6.1 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /NETCORE/test/FunctionalTestUtils/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:4824/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNET_ENVIRONMENT": "Development" 16 | } 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /NETCORE/test/FunctionalTestUtils20/FunctionalTestUtils20.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 1.0.2 5 | net461;netcoreapp2.0 6 | netcoreapp2.0 7 | true 8 | FunctionalTestUtils20 9 | FunctionalTestUtils 10 | 2.0.0 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /NETCORE/test/FunctionalTestUtils20/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:4824/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNET_ENVIRONMENT": "Development" 16 | } 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "wwwroot/lib" 3 | } 4 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using Microsoft.AspNetCore.Mvc; 4 | using Microsoft.ApplicationInsights.DataContracts; 5 | using Microsoft.ApplicationInsights; 6 | 7 | namespace MVCFramework45.FunctionalTests.Controllers 8 | { 9 | public class HomeController : Controller 10 | { 11 | private TelemetryClient telemetryClient; 12 | 13 | public HomeController(TelemetryClient telemetryClient) 14 | { 15 | this.telemetryClient = telemetryClient; 16 | } 17 | 18 | public IActionResult Index() 19 | { 20 | return View(); 21 | } 22 | 23 | public IActionResult Exception() 24 | { 25 | throw new InvalidOperationException("Do not call the method called Exception"); 26 | } 27 | 28 | public IActionResult About(int index) 29 | { 30 | ViewBag.Message = "Your application description page # " + index; 31 | 32 | return View(); 33 | } 34 | 35 | public IActionResult Contact() 36 | { 37 | this.telemetryClient.TrackEvent("GetContact"); 38 | this.telemetryClient.TrackMetric("ContactFile", 1); 39 | this.telemetryClient.TrackTrace("Fetched contact details.", SeverityLevel.Information); 40 | return View(); 41 | } 42 | 43 | public IActionResult Dependency() 44 | { 45 | this.telemetryClient.TrackDependency("MyDependency", "MyCommand", DateTimeOffset.Now, TimeSpan.FromMilliseconds(1), success: true); 46 | return View(); 47 | } 48 | 49 | public IActionResult Error() 50 | { 51 | return View("~/Views/Shared/Error.cshtml"); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Data/ApplicationDbContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Identity.EntityFrameworkCore; 6 | using Microsoft.EntityFrameworkCore; 7 | using MVCFramework45.FunctionalTests.Models; 8 | 9 | namespace MVCFramework45.FunctionalTests.Data 10 | { 11 | public class ApplicationDbContext : IdentityDbContext 12 | { 13 | public ApplicationDbContext(DbContextOptions options) 14 | : base(options) 15 | { 16 | } 17 | 18 | protected override void OnModelCreating(ModelBuilder builder) 19 | { 20 | base.OnModelCreating(builder); 21 | // Customize the ASP.NET Identity model and override the defaults if needed. 22 | // For example, you can rename the ASP.NET Identity table names and more. 23 | // Add your customizations after calling base.OnModelCreating(builder); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Data/Migrations/ApplicationDbContextModelSnapshot.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.EntityFrameworkCore; 6 | using Microsoft.EntityFrameworkCore.Infrastructure; 7 | using Microsoft.EntityFrameworkCore.Metadata; 8 | 9 | namespace MVCFramework45.FunctionalTests.Data.Migrations 10 | { 11 | [DbContext(typeof(ApplicationDbContext))] 12 | partial class ApplicationDbContextModelSnapshot : ModelSnapshot 13 | { 14 | protected override void BuildModel(ModelBuilder modelBuilder) 15 | { 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/FunctionalTest/CorrelationMvcTests.cs: -------------------------------------------------------------------------------- 1 | namespace MVCFramework.FunctionalTests.FunctionalTest 2 | { 3 | using FunctionalTestUtils; 4 | using Microsoft.ApplicationInsights.DataContracts; 5 | using System; 6 | using System.Linq; 7 | using System.Net.Http; 8 | using Xunit; 9 | using Xunit.Abstractions; 10 | 11 | public class CorrelationMvcTests : TelemetryTestsBase 12 | { 13 | private const string assemblyName = "MVCFramework.FunctionalTests"; 14 | public CorrelationMvcTests(ITestOutputHelper output) : base(output) 15 | { 16 | } 17 | [Fact] 18 | public void CorrelationInfoIsPropagatedToDependendedService() 19 | { 20 | #if netcoreapp1_0 // Correlation works on .Net core. 21 | InProcessServer server; 22 | 23 | using (server = new InProcessServer(assemblyName, InProcessServer.UseApplicationInsights)) 24 | { 25 | using (var httpClient = new HttpClient()) 26 | { 27 | var task = httpClient.GetAsync(server.BaseHost + "/"); 28 | task.Wait(TestTimeoutMs); 29 | } 30 | } 31 | 32 | var telemetries = server.BackChannel.Buffer; 33 | 34 | Assert.True(telemetries.Count >= 2); 35 | var requestTelemetry = telemetries.OfType().Single(); 36 | var dependencyTelemetry = telemetries.OfType().Single(); 37 | Assert.Equal(requestTelemetry.Context.Operation.Id, dependencyTelemetry.Context.Operation.Id); 38 | Assert.Equal(requestTelemetry.Context.Operation.ParentId, dependencyTelemetry.Id); 39 | #endif 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/FunctionalTest/TelemetryModuleWorkingMvcTests.cs: -------------------------------------------------------------------------------- 1 | namespace MVCFramework.FunctionalTests.FunctionalTest 2 | { 3 | using FunctionalTestUtils; 4 | using Xunit; 5 | using Xunit.Abstractions; 6 | 7 | public class TelemetryModuleWorkingMvcTests : TelemetryTestsBase 8 | { 9 | private const string assemblyName = "MVCFramework.FunctionalTests"; 10 | 11 | public TelemetryModuleWorkingMvcTests(ITestOutputHelper output) : base(output) 12 | { 13 | } 14 | 15 | // The NET451 conditional check is wrapped inside the test to make the tests visible in the test explorer. We can move them to the class level once if the issue is resolved. 16 | 17 | public void TestBasicDependencyPropertiesAfterRequestingBasicPage() 18 | { 19 | this.ValidateBasicDependency(assemblyName, "/Home/About/5", InProcessServer.UseApplicationInsights); 20 | } 21 | 22 | [Fact] 23 | public void TestIfPerformanceCountersAreCollected() 24 | { 25 | #if NET451 || NET46 26 | ValidatePerformanceCountersAreCollected(assemblyName, InProcessServer.UseApplicationInsights); 27 | #endif 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Models/AccountViewModels/ExternalLoginConfirmationViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace MVCFramework45.FunctionalTests.Models.AccountViewModels 8 | { 9 | public class ExternalLoginConfirmationViewModel 10 | { 11 | [Required] 12 | [EmailAddress] 13 | public string Email { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Models/AccountViewModels/ForgotPasswordViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace MVCFramework45.FunctionalTests.Models.AccountViewModels 8 | { 9 | public class ForgotPasswordViewModel 10 | { 11 | [Required] 12 | [EmailAddress] 13 | public string Email { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Models/AccountViewModels/LoginViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace MVCFramework45.FunctionalTests.Models.AccountViewModels 8 | { 9 | public class LoginViewModel 10 | { 11 | [Required] 12 | [EmailAddress] 13 | public string Email { get; set; } 14 | 15 | [Required] 16 | [DataType(DataType.Password)] 17 | public string Password { get; set; } 18 | 19 | [Display(Name = "Remember me?")] 20 | public bool RememberMe { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Models/AccountViewModels/RegisterViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace MVCFramework45.FunctionalTests.Models.AccountViewModels 8 | { 9 | public class RegisterViewModel 10 | { 11 | [Required] 12 | [EmailAddress] 13 | [Display(Name = "Email")] 14 | public string Email { get; set; } 15 | 16 | [Required] 17 | [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)] 18 | [DataType(DataType.Password)] 19 | [Display(Name = "Password")] 20 | public string Password { get; set; } 21 | 22 | [DataType(DataType.Password)] 23 | [Display(Name = "Confirm password")] 24 | [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")] 25 | public string ConfirmPassword { get; set; } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Models/AccountViewModels/ResetPasswordViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace MVCFramework45.FunctionalTests.Models.AccountViewModels 8 | { 9 | public class ResetPasswordViewModel 10 | { 11 | [Required] 12 | [EmailAddress] 13 | public string Email { get; set; } 14 | 15 | [Required] 16 | [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)] 17 | [DataType(DataType.Password)] 18 | public string Password { get; set; } 19 | 20 | [DataType(DataType.Password)] 21 | [Display(Name = "Confirm password")] 22 | [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")] 23 | public string ConfirmPassword { get; set; } 24 | 25 | public string Code { get; set; } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Models/AccountViewModels/SendCodeViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc.Rendering; 6 | 7 | namespace MVCFramework45.FunctionalTests.Models.AccountViewModels 8 | { 9 | public class SendCodeViewModel 10 | { 11 | public string SelectedProvider { get; set; } 12 | 13 | public ICollection Providers { get; set; } 14 | 15 | public string ReturnUrl { get; set; } 16 | 17 | public bool RememberMe { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Models/AccountViewModels/VerifyCodeViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace MVCFramework45.FunctionalTests.Models.AccountViewModels 8 | { 9 | public class VerifyCodeViewModel 10 | { 11 | [Required] 12 | public string Provider { get; set; } 13 | 14 | [Required] 15 | public string Code { get; set; } 16 | 17 | public string ReturnUrl { get; set; } 18 | 19 | [Display(Name = "Remember this browser?")] 20 | public bool RememberBrowser { get; set; } 21 | 22 | [Display(Name = "Remember me?")] 23 | public bool RememberMe { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Models/ApplicationUser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Identity.EntityFrameworkCore; 6 | 7 | namespace MVCFramework45.FunctionalTests.Models 8 | { 9 | // Add profile data for application users by adding properties to the ApplicationUser class 10 | public class ApplicationUser : IdentityUser 11 | { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Models/ManageViewModels/AddPhoneNumberViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace MVCFramework45.FunctionalTests.Models.ManageViewModels 8 | { 9 | public class AddPhoneNumberViewModel 10 | { 11 | [Required] 12 | [Phone] 13 | [Display(Name = "Phone number")] 14 | public string PhoneNumber { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Models/ManageViewModels/ChangePasswordViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace MVCFramework45.FunctionalTests.Models.ManageViewModels 8 | { 9 | public class ChangePasswordViewModel 10 | { 11 | [Required] 12 | [DataType(DataType.Password)] 13 | [Display(Name = "Current password")] 14 | public string OldPassword { get; set; } 15 | 16 | [Required] 17 | [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)] 18 | [DataType(DataType.Password)] 19 | [Display(Name = "New password")] 20 | public string NewPassword { get; set; } 21 | 22 | [DataType(DataType.Password)] 23 | [Display(Name = "Confirm new password")] 24 | [Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")] 25 | public string ConfirmPassword { get; set; } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Models/ManageViewModels/ConfigureTwoFactorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc.Rendering; 6 | 7 | namespace MVCFramework45.FunctionalTests.Models.ManageViewModels 8 | { 9 | public class ConfigureTwoFactorViewModel 10 | { 11 | public string SelectedProvider { get; set; } 12 | 13 | public ICollection Providers { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Models/ManageViewModels/FactorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace MVCFramework45.FunctionalTests.Models.ManageViewModels 7 | { 8 | public class FactorViewModel 9 | { 10 | public string Purpose { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Models/ManageViewModels/IndexViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Identity; 6 | 7 | namespace MVCFramework45.FunctionalTests.Models.ManageViewModels 8 | { 9 | public class IndexViewModel 10 | { 11 | public bool HasPassword { get; set; } 12 | 13 | public IList Logins { get; set; } 14 | 15 | public string PhoneNumber { get; set; } 16 | 17 | public bool TwoFactor { get; set; } 18 | 19 | public bool BrowserRemembered { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Models/ManageViewModels/ManageLoginsViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Http.Authentication; 6 | using Microsoft.AspNetCore.Identity; 7 | 8 | namespace MVCFramework45.FunctionalTests.Models.ManageViewModels 9 | { 10 | public class ManageLoginsViewModel 11 | { 12 | public IList CurrentLogins { get; set; } 13 | 14 | public IList OtherLogins { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Models/ManageViewModels/RemoveLoginViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace MVCFramework45.FunctionalTests.Models.ManageViewModels 8 | { 9 | public class RemoveLoginViewModel 10 | { 11 | public string LoginProvider { get; set; } 12 | public string ProviderKey { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Models/ManageViewModels/SetPasswordViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace MVCFramework45.FunctionalTests.Models.ManageViewModels 8 | { 9 | public class SetPasswordViewModel 10 | { 11 | [Required] 12 | [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)] 13 | [DataType(DataType.Password)] 14 | [Display(Name = "New password")] 15 | public string NewPassword { get; set; } 16 | 17 | [DataType(DataType.Password)] 18 | [Display(Name = "Confirm new password")] 19 | [Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")] 20 | public string ConfirmPassword { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Models/ManageViewModels/VerifyPhoneNumberViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace MVCFramework45.FunctionalTests.Models.ManageViewModels 8 | { 9 | public class VerifyPhoneNumberViewModel 10 | { 11 | [Required] 12 | public string Code { get; set; } 13 | 14 | [Required] 15 | [Phone] 16 | [Display(Name = "Phone number")] 17 | public string PhoneNumber { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:29543/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "environmentVariables": { 14 | "ASPNETCORE_ENVIRONMENT": "Development" 15 | } 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Services/IEmailSender.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace MVCFramework45.FunctionalTests.Services 7 | { 8 | public interface IEmailSender 9 | { 10 | Task SendEmailAsync(string email, string subject, string message); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Services/ISmsSender.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace MVCFramework45.FunctionalTests.Services 7 | { 8 | public interface ISmsSender 9 | { 10 | Task SendSmsAsync(string number, string message); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Services/MessageServices.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace MVCFramework45.FunctionalTests.Services 7 | { 8 | // This class is used by the application to send Email and SMS 9 | // when you turn on two-factor authentication in ASP.NET Identity. 10 | // For more details see this link http://go.microsoft.com/fwlink/?LinkID=532713 11 | public class AuthMessageSender : IEmailSender, ISmsSender 12 | { 13 | public Task SendEmailAsync(string email, string subject, string message) 14 | { 15 | // Plug in your email service here to send an email. 16 | return Task.FromResult(0); 17 | } 18 | 19 | public Task SendSmsAsync(string number, string message) 20 | { 21 | // Plug in your SMS service here to send a text message. 22 | return Task.FromResult(0); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Views/Account/ConfirmEmail.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Confirm Email"; 3 | } 4 | 5 |

@ViewData["Title"].

6 |
7 |

8 | Thank you for confirming your email. Please Click here to Log in. 9 |

10 |
11 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Views/Account/ExternalLoginConfirmation.cshtml: -------------------------------------------------------------------------------- 1 | @model ExternalLoginConfirmationViewModel 2 | @{ 3 | ViewData["Title"] = "Register"; 4 | } 5 | 6 |

@ViewData["Title"].

7 |

Associate your @ViewData["LoginProvider"] account.

8 | 9 |
10 |

Association Form

11 |
12 |
13 | 14 |

15 | You've successfully authenticated with @ViewData["LoginProvider"]. 16 | Please enter an email address for this site below and click the Register button to finish 17 | logging in. 18 |

19 |
20 | 21 |
22 | 23 | 24 |
25 |
26 |
27 |
28 | 29 |
30 |
31 |
32 | 33 | @section Scripts { 34 | @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); } 35 | } 36 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Views/Account/ExternalLoginFailure.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Login Failure"; 3 | } 4 | 5 |
6 |

@ViewData["Title"].

7 |

Unsuccessful login with service.

8 |
9 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Views/Account/ForgotPassword.cshtml: -------------------------------------------------------------------------------- 1 | @model ForgotPasswordViewModel 2 | @{ 3 | ViewData["Title"] = "Forgot your password?"; 4 | } 5 | 6 |

@ViewData["Title"]

7 |

8 | For more information on how to enable reset password please see this article. 9 |

10 | 11 | @*
12 |

Enter your email.

13 |
14 |
15 |
16 | 17 |
18 | 19 | 20 |
21 |
22 |
23 |
24 | 25 |
26 |
27 |
*@ 28 | 29 | @section Scripts { 30 | @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); } 31 | } 32 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Views/Account/ForgotPasswordConfirmation.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Forgot Password Confirmation"; 3 | } 4 | 5 |

@ViewData["Title"].

6 |

7 | Please check your email to reset your password. 8 |

9 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Views/Account/Lockout.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Locked out"; 3 | } 4 | 5 |
6 |

Locked out.

7 |

This account has been locked out, please try again later.

8 |
9 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Views/Account/Register.cshtml: -------------------------------------------------------------------------------- 1 | @model RegisterViewModel 2 | @{ 3 | ViewData["Title"] = "Register"; 4 | } 5 | 6 |

@ViewData["Title"].

7 | 8 |
9 |

Create a new account.

10 |
11 |
12 |
13 | 14 |
15 | 16 | 17 |
18 |
19 |
20 | 21 |
22 | 23 | 24 |
25 |
26 |
27 | 28 |
29 | 30 | 31 |
32 |
33 |
34 |
35 | 36 |
37 |
38 |
39 | 40 | @section Scripts { 41 | @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); } 42 | } 43 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Views/Account/ResetPassword.cshtml: -------------------------------------------------------------------------------- 1 | @model ResetPasswordViewModel 2 | @{ 3 | ViewData["Title"] = "Reset password"; 4 | } 5 | 6 |

@ViewData["Title"].

7 | 8 |
9 |

Reset your password.

10 |
11 |
12 | 13 |
14 | 15 |
16 | 17 | 18 |
19 |
20 |
21 | 22 |
23 | 24 | 25 |
26 |
27 |
28 | 29 |
30 | 31 | 32 |
33 |
34 |
35 |
36 | 37 |
38 |
39 |
40 | 41 | @section Scripts { 42 | @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); } 43 | } 44 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Views/Account/ResetPasswordConfirmation.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Reset password confirmation"; 3 | } 4 | 5 |

@ViewData["Title"].

6 |

7 | Your password has been reset. Please Click here to log in. 8 |

9 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Views/Account/SendCode.cshtml: -------------------------------------------------------------------------------- 1 | @model SendCodeViewModel 2 | @{ 3 | ViewData["Title"] = "Send Verification Code"; 4 | } 5 | 6 |

@ViewData["Title"].

7 | 8 |
9 | 10 |
11 |
12 | Select Two-Factor Authentication Provider: 13 | 14 | 15 |
16 |
17 |
18 | 19 | @section Scripts { 20 | @{await Html.RenderPartialAsync("_ValidationScriptsPartial"); } 21 | } 22 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Views/Account/VerifyCode.cshtml: -------------------------------------------------------------------------------- 1 | @model VerifyCodeViewModel 2 | @{ 3 | ViewData["Title"] = "Verify"; 4 | } 5 | 6 |

@ViewData["Title"].

7 | 8 |
9 |
10 | 11 | 12 |

@ViewData["Status"]

13 |
14 |
15 | 16 |
17 | 18 | 19 |
20 |
21 |
22 |
23 |
24 | 25 | 26 |
27 |
28 |
29 |
30 |
31 | 32 |
33 |
34 |
35 | 36 | @section Scripts { 37 | @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); } 38 | } 39 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Views/Home/About.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "About"; 3 | } 4 |

@ViewData["Title"].

5 |

@ViewData["Message"]

6 | 7 |

Use this area to provide additional information.

8 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Views/Home/Contact.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Contact"; 3 | } 4 |

@ViewData["Title"].

5 |

@ViewData["Message"]

6 | 7 |
8 | One Microsoft Way
9 | Redmond, WA 98052-6399
10 | P: 11 | 425.555.0100 12 |
13 | 14 |
15 | Support: Support@example.com
16 | Marketing: Marketing@example.com 17 |
18 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Views/Home/Dependency.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | } 3 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Views/Manage/AddPhoneNumber.cshtml: -------------------------------------------------------------------------------- 1 | @model AddPhoneNumberViewModel 2 | @{ 3 | ViewData["Title"] = "Add Phone Number"; 4 | } 5 | 6 |

@ViewData["Title"].

7 |
8 |

Add a phone number.

9 |
10 |
11 |
12 | 13 |
14 | 15 | 16 |
17 |
18 |
19 |
20 | 21 |
22 |
23 |
24 | 25 | @section Scripts { 26 | @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); } 27 | } 28 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Views/Manage/ChangePassword.cshtml: -------------------------------------------------------------------------------- 1 | @model ChangePasswordViewModel 2 | @{ 3 | ViewData["Title"] = "Change Password"; 4 | } 5 | 6 |

@ViewData["Title"].

7 | 8 |
9 |

Change Password Form

10 |
11 |
12 |
13 | 14 |
15 | 16 | 17 |
18 |
19 |
20 | 21 |
22 | 23 | 24 |
25 |
26 |
27 | 28 |
29 | 30 | 31 |
32 |
33 |
34 |
35 | 36 |
37 |
38 |
39 | 40 | @section Scripts { 41 | @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); } 42 | } 43 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Views/Manage/SetPassword.cshtml: -------------------------------------------------------------------------------- 1 | @model SetPasswordViewModel 2 | @{ 3 | ViewData["Title"] = "Set Password"; 4 | } 5 | 6 |

7 | You do not have a local username/password for this site. Add a local 8 | account so you can log in without an external login. 9 |

10 | 11 |
12 |

Set your password

13 |
14 |
15 |
16 | 17 |
18 | 19 | 20 |
21 |
22 |
23 | 24 |
25 | 26 | 27 |
28 |
29 |
30 |
31 | 32 |
33 |
34 |
35 | 36 | @section Scripts { 37 | @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); } 38 | } 39 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Views/Manage/VerifyPhoneNumber.cshtml: -------------------------------------------------------------------------------- 1 | @model VerifyPhoneNumberViewModel 2 | @{ 3 | ViewData["Title"] = "Verify Phone Number"; 4 | } 5 | 6 |

@ViewData["Title"].

7 | 8 |
9 | 10 |

Add a phone number.

11 |
@ViewData["Status"]
12 |
13 |
14 |
15 | 16 |
17 | 18 | 19 |
20 |
21 |
22 |
23 | 24 |
25 |
26 |
27 | 28 | @section Scripts { 29 | @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); } 30 | } 31 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Error"; 3 | } 4 | 5 |

Error.

6 |

An error occurred while processing your request.

7 | 8 |

Development Mode

9 |

10 | Swapping to Development environment will display more detailed information about the error that occurred. 11 |

12 |

13 | Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application. 14 |

15 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Views/Shared/_LoginPartial.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Identity 2 | @using MVCFramework45.FunctionalTests.Models 3 | 4 | @inject SignInManager SignInManager 5 | @inject UserManager UserManager 6 | 7 | @if (SignInManager.IsSignedIn(User)) 8 | { 9 | 19 | } 20 | else 21 | { 22 | 26 | } 27 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 10 | 14 | 15 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using MVCFramework45.FunctionalTests 2 | @using MVCFramework45.FunctionalTests.Models 3 | @using MVCFramework45.FunctionalTests.Models.AccountViewModels 4 | @using MVCFramework45.FunctionalTests.Models.ManageViewModels 5 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 6 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ApplicationInsights": { 3 | "InstrumentationKey": "11111111-2222-3333-4444-555555555555" 4 | }, 5 | "ConnectionStrings": { 6 | "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-MVCFramework45.FunctionalTests-60cfc765-2dc9-454c-bb34-dc379ed92cd0;Trusted_Connection=True;MultipleActiveResultSets=true" 7 | }, 8 | "Logging": { 9 | "IncludeScopes": false, 10 | "LogLevel": { 11 | "Default": "Debug", 12 | "System": "Information", 13 | "Microsoft": "Information" 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ASP.NET", 3 | "private": true, 4 | "dependencies": { 5 | "bootstrap": "3.3.6", 6 | "jquery": "2.2.0", 7 | "jquery-validation": "1.14.0", 8 | "jquery-validation-unobtrusive": "3.2.6" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/gulpfile.js: -------------------------------------------------------------------------------- 1 | /// 2 | "use strict"; 3 | 4 | var gulp = require("gulp"), 5 | rimraf = require("rimraf"), 6 | concat = require("gulp-concat"), 7 | cssmin = require("gulp-cssmin"), 8 | uglify = require("gulp-uglify"); 9 | 10 | var webroot = "./wwwroot/"; 11 | 12 | var paths = { 13 | js: webroot + "js/**/*.js", 14 | minJs: webroot + "js/**/*.min.js", 15 | css: webroot + "css/**/*.css", 16 | minCss: webroot + "css/**/*.min.css", 17 | concatJsDest: webroot + "js/site.min.js", 18 | concatCssDest: webroot + "css/site.min.css" 19 | }; 20 | 21 | gulp.task("clean:js", function (cb) { 22 | rimraf(paths.concatJsDest, cb); 23 | }); 24 | 25 | gulp.task("clean:css", function (cb) { 26 | rimraf(paths.concatCssDest, cb); 27 | }); 28 | 29 | gulp.task("clean", ["clean:js", "clean:css"]); 30 | 31 | gulp.task("min:js", function () { 32 | return gulp.src([paths.js, "!" + paths.minJs], { base: "." }) 33 | .pipe(concat(paths.concatJsDest)) 34 | .pipe(uglify()) 35 | .pipe(gulp.dest(".")); 36 | }); 37 | 38 | gulp.task("min:css", function () { 39 | return gulp.src([paths.css, "!" + paths.minCss]) 40 | .pipe(concat(paths.concatCssDest)) 41 | .pipe(cssmin()) 42 | .pipe(gulp.dest(".")); 43 | }); 44 | 45 | gulp.task("min", ["min:js", "min:css"]); 46 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "asp.net", 3 | "version": "0.0.0", 4 | "private": true, 5 | "devDependencies": { 6 | "gulp": "3.8.11", 7 | "gulp-concat": "2.5.2", 8 | "gulp-cssmin": "0.1.7", 9 | "gulp-uglify": "1.2.0", 10 | "rimraf": "2.2.8" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/wwwroot/_references.js: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding-top: 50px; 3 | padding-bottom: 20px; 4 | } 5 | 6 | /* Wrapping element */ 7 | /* Set some basic padding to keep content from hitting the edges */ 8 | .body-content { 9 | padding-left: 15px; 10 | padding-right: 15px; 11 | } 12 | 13 | /* Set widths on the form inputs since otherwise they're 100% wide */ 14 | input, 15 | select, 16 | textarea { 17 | max-width: 280px; 18 | } 19 | 20 | /* Carousel */ 21 | .carousel-caption p { 22 | font-size: 20px; 23 | line-height: 1.4; 24 | } 25 | 26 | /* buttons and links extension to use brackets: [ click me ] */ 27 | .btn-bracketed::before { 28 | display:inline-block; 29 | content: "["; 30 | padding-right: 0.5em; 31 | } 32 | .btn-bracketed::after { 33 | display:inline-block; 34 | content: "]"; 35 | padding-left: 0.5em; 36 | } 37 | 38 | /* Hide/rearrange for smaller screens */ 39 | @media screen and (max-width: 767px) { 40 | /* Hide captions */ 41 | .carousel-caption { 42 | display: none 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/ApplicationInsights-aspnetcore/bfccb57e4f632fa2ee627dacedeaa55644c739f5/NETCORE/test/MVCFramework.FunctionalTests/wwwroot/favicon.ico -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Write your Javascript code. 2 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework.FunctionalTests/xunit.runner.json: -------------------------------------------------------------------------------- 1 | { 2 | "shadowCopy": false 3 | } -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework20.FunctionalTests/.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "wwwroot/lib" 3 | } 4 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework20.FunctionalTests/FunctionalTest/CorrelationMvcTests.cs: -------------------------------------------------------------------------------- 1 | namespace MVC20.FuncTests 2 | { 3 | using FunctionalTestUtils; 4 | using Microsoft.ApplicationInsights.DataContracts; 5 | using System; 6 | using System.Linq; 7 | using System.Net.Http; 8 | using AI; 9 | using Xunit; 10 | using Xunit.Abstractions; 11 | 12 | public class CorrelationMvcTests : TelemetryTestsBase 13 | { 14 | private const string assemblyName = "MVCFramework20.FunctionalTests20"; 15 | 16 | public CorrelationMvcTests(ITestOutputHelper output) : base(output) 17 | { 18 | } 19 | 20 | 21 | [Fact] 22 | public void CorrelationInfoIsPropagatedToDependendedService() 23 | { 24 | #if netcoreapp2_0 // Correlation works on .Net core. 25 | using (var server = new InProcessServer(assemblyName, this.output)) 26 | { 27 | using (var httpClient = new HttpClient()) 28 | { 29 | var task = httpClient.GetAsync(server.BaseHost + "/"); 30 | task.Wait(TestTimeoutMs); 31 | } 32 | 33 | var actual = server.Execute(() => server.Listener.ReceiveItems(2, TestListenerTimeoutInMs)); 34 | this.DebugTelemetryItems(actual); 35 | 36 | var dependencyTelemetry = actual.OfType>().FirstOrDefault(); 37 | Assert.NotNull(dependencyTelemetry); 38 | 39 | var requestTelemetry = actual.OfType>().FirstOrDefault(); 40 | Assert.NotNull(requestTelemetry); 41 | 42 | Assert.Equal(requestTelemetry.tags["ai.operation.id"], dependencyTelemetry.tags["ai.operation.id"]); 43 | Assert.Contains(dependencyTelemetry.tags["ai.operation.id"], requestTelemetry.tags["ai.operation.parentId"]); 44 | } 45 | #endif 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework20.FunctionalTests/FunctionalTest/TelemetryModuleWorkingMvcTests.cs: -------------------------------------------------------------------------------- 1 | namespace MVC20.FuncTests 2 | { 3 | using FunctionalTestUtils; 4 | using Microsoft.ApplicationInsights.DataContracts; 5 | using Xunit; 6 | using Xunit.Abstractions; 7 | 8 | public class TelemetryModuleWorkingMvcTests : TelemetryTestsBase 9 | { 10 | private const string assemblyName = "MVCFramework20.FunctionalTests20"; 11 | 12 | public TelemetryModuleWorkingMvcTests(ITestOutputHelper output) : base(output) 13 | { 14 | } 15 | 16 | // The NET451 conditional check is wrapped inside the test to make the tests visible in the test explorer. We can move them to the class level once if the issue is resolved. 17 | 18 | public void TestBasicDependencyPropertiesAfterRequestingBasicPage() 19 | { 20 | const string RequestPath = "/Home/About/5"; 21 | 22 | using (var server = new InProcessServer(assemblyName, this.output)) 23 | { 24 | DependencyTelemetry expected = new DependencyTelemetry(); 25 | expected.ResultCode = "200"; 26 | expected.Success = true; 27 | expected.Name = "GET " + RequestPath; 28 | expected.Data = server.BaseHost + RequestPath; 29 | 30 | this.ValidateBasicDependency(server, RequestPath, expected); 31 | } 32 | } 33 | 34 | [Fact] 35 | public void TestIfPerformanceCountersAreCollected() 36 | { 37 | ValidatePerformanceCountersAreCollected(assemblyName); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework20.FunctionalTests/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MVCFramework20.FunctionalTests.Models 4 | { 5 | public class ErrorViewModel 6 | { 7 | public string RequestId { get; set; } 8 | 9 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 10 | } 11 | } -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework20.FunctionalTests/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:34244/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "MVCFramework20.FunctionalTests": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "environmentVariables": { 22 | "ASPNETCORE_ENVIRONMENT": "Development" 23 | }, 24 | "applicationUrl": "http://localhost:34245/" 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework20.FunctionalTests/Views/Home/About.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "About"; 3 | } 4 |

@ViewData["Title"]

5 |

@ViewData["Message"]

6 | 7 |

Use this area to provide additional information.

8 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework20.FunctionalTests/Views/Home/Contact.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Contact"; 3 | } 4 |

@ViewData["Title"]

5 |

@ViewData["Message"]

6 | 7 |
8 | One Microsoft Way
9 | Redmond, WA 98052-6399
10 | P: 11 | 425.555.0100 12 |
13 | 14 |
15 | Support: Support@example.com
16 | Marketing: Marketing@example.com 17 |
18 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework20.FunctionalTests/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | @{ 3 | ViewData["Title"] = "Error"; 4 | } 5 | 6 |

Error.

7 |

An error occurred while processing your request.

8 | 9 | @if (Model.ShowRequestId) 10 | { 11 |

12 | Request ID: @Model.RequestId 13 |

14 | } 15 | 16 |

Development Mode

17 |

18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

20 |

21 | Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application. 22 |

23 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework20.FunctionalTests/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 12 | 18 | 19 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework20.FunctionalTests/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using MVCFramework20.FunctionalTests 2 | @using MVCFramework20.FunctionalTests.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework20.FunctionalTests/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework20.FunctionalTests/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "IncludeScopes": false, 4 | "LogLevel": { 5 | "Default": "Debug", 6 | "System": "Information", 7 | "Microsoft": "Information" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework20.FunctionalTests/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "IncludeScopes": false, 4 | "LogLevel": { 5 | "Default": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework20.FunctionalTests/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "asp.net", 3 | "private": true, 4 | "dependencies": { 5 | "bootstrap": "3.3.7", 6 | "jquery": "2.2.0", 7 | "jquery-validation": "1.14.0", 8 | "jquery-validation-unobtrusive": "3.2.6" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework20.FunctionalTests/bundleconfig.json: -------------------------------------------------------------------------------- 1 | // Configure bundling and minification for the project. 2 | // More info at https://go.microsoft.com/fwlink/?LinkId=808241 3 | [ 4 | { 5 | "outputFileName": "wwwroot/css/site.min.css", 6 | // An array of relative input file paths. Globbing patterns supported 7 | "inputFiles": [ 8 | "wwwroot/css/site.css" 9 | ] 10 | }, 11 | { 12 | "outputFileName": "wwwroot/js/site.min.js", 13 | "inputFiles": [ 14 | "wwwroot/js/site.js" 15 | ], 16 | // Optionally specify minification options 17 | "minify": { 18 | "enabled": true, 19 | "renameLocals": true 20 | }, 21 | // Optionally generate .map file 22 | "sourceMap": false 23 | } 24 | ] 25 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework20.FunctionalTests/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding-top: 50px; 3 | padding-bottom: 20px; 4 | } 5 | 6 | /* Wrapping element */ 7 | /* Set some basic padding to keep content from hitting the edges */ 8 | .body-content { 9 | padding-left: 15px; 10 | padding-right: 15px; 11 | } 12 | 13 | /* Carousel */ 14 | .carousel-caption p { 15 | font-size: 20px; 16 | line-height: 1.4; 17 | } 18 | 19 | /* Make .svg files in the carousel display properly in older browsers */ 20 | .carousel-inner .item img[src$=".svg"] { 21 | width: 100%; 22 | } 23 | 24 | /* QR code generator */ 25 | #qrCode { 26 | margin: 15px; 27 | } 28 | 29 | /* Hide/rearrange for smaller screens */ 30 | @media screen and (max-width: 767px) { 31 | /* Hide captions */ 32 | .carousel-caption { 33 | display: none; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework20.FunctionalTests/wwwroot/css/site.min.css: -------------------------------------------------------------------------------- 1 | body{padding-top:50px;padding-bottom:20px}.body-content{padding-left:15px;padding-right:15px}.carousel-caption p{font-size:20px;line-height:1.4}.carousel-inner .item img[src$=".svg"]{width:100%}#qrCode{margin:15px}@media screen and (max-width:767px){.carousel-caption{display:none}} -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework20.FunctionalTests/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/ApplicationInsights-aspnetcore/bfccb57e4f632fa2ee627dacedeaa55644c739f5/NETCORE/test/MVCFramework20.FunctionalTests/wwwroot/favicon.ico -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework20.FunctionalTests/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Write your JavaScript code. 2 | -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework20.FunctionalTests/wwwroot/js/site.min.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/ApplicationInsights-aspnetcore/bfccb57e4f632fa2ee627dacedeaa55644c739f5/NETCORE/test/MVCFramework20.FunctionalTests/wwwroot/js/site.min.js -------------------------------------------------------------------------------- /NETCORE/test/MVCFramework20.FunctionalTests/xunit.runner.json: -------------------------------------------------------------------------------- 1 | { 2 | "shadowCopy": false 3 | } -------------------------------------------------------------------------------- /NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/AspNetCoreMajorVersion.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Microsoft.ApplicationInsights.AspNetCore.Tests 6 | { 7 | public enum AspNetCoreMajorVersion { One, Two, Three}; 8 | } 9 | -------------------------------------------------------------------------------- /NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/Extensibility/Implementation/Tracing/AspNetEventSourceTests.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //----------------------------------------------------------------------- 6 | namespace Microsoft.ApplicationInsights.AspNetCore.Tests.Extensibility.Implementation.Tracing 7 | { 8 | using System; 9 | using System.Diagnostics.Tracing; 10 | using System.Reflection; 11 | using Xunit; 12 | 13 | /// 14 | /// Tests for the AspNetEventSource class. 15 | /// 16 | public class AspNetEventSourceTests 17 | { 18 | /// 19 | /// Tests the event source methods and their attributes. 20 | /// 21 | [Fact] 22 | public void TestThatEventSourceMethodsAreImplementedConsistentlyWithTheirAttributes() 23 | { 24 | Assembly asm = Assembly.Load(new AssemblyName("Microsoft.ApplicationInsights.AspNetCore")); 25 | Type eventSourceType = asm.GetType("Microsoft.ApplicationInsights.AspNetCore.Extensibility.Implementation.Tracing.AspNetCoreEventSource"); 26 | EventSource aspNetCoreEventSource = (EventSource)eventSourceType.GetField("Instance", BindingFlags.Public | BindingFlags.Static).GetValue(null); 27 | 28 | EventSourceTests.MethodsAreImplementedConsistentlyWithTheirAttributes(aspNetCoreEventSource); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/FakeTelemetryChannel.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.ApplicationInsights.AspNetCore.Tests 2 | { 3 | using System; 4 | using Microsoft.ApplicationInsights.Channel; 5 | 6 | // TODO: Remove FakeTelemetryChannel when we can use a dynamic test isolation framework, like NSubstitute or Moq 7 | internal class FakeTelemetryChannel : ITelemetryChannel 8 | { 9 | public Action OnSend = t => { }; 10 | 11 | public string EndpointAddress 12 | { 13 | get; 14 | set; 15 | } 16 | 17 | public bool? DeveloperMode { get; set; } 18 | 19 | public void Dispose() 20 | { 21 | throw new NotImplementedException(); 22 | } 23 | 24 | public void Flush() 25 | { 26 | throw new NotImplementedException(); 27 | } 28 | 29 | public void Send(ITelemetry item) 30 | { 31 | this.OnSend(item); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/FakeTelemetryInitializer.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.ApplicationInsights.AspNetCore.Tests 2 | { 3 | using System; 4 | using Microsoft.ApplicationInsights.Channel; 5 | using Microsoft.ApplicationInsights.Extensibility; 6 | 7 | // TODO: Remove FakeTelemetryInitializer when we can use a dynamic test isolation framework, like NSubstitute or Moq 8 | internal class FakeTelemetryInitializer : ITelemetryInitializer 9 | { 10 | public void Initialize(ITelemetry telemetry) 11 | { 12 | throw new NotImplementedException(); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/FakeTelemetryProcessor.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.ApplicationInsights.AspNetCore.Tests 2 | { 3 | using System; 4 | using Microsoft.ApplicationInsights.Channel; 5 | using Microsoft.ApplicationInsights.Extensibility; 6 | 7 | internal class FakeTelemetryProcessor : ITelemetryProcessor, ITelemetryModule 8 | { 9 | private readonly ITelemetryProcessor next; 10 | 11 | public FakeTelemetryProcessor(ITelemetryProcessor next) 12 | { 13 | if (next == null) 14 | { 15 | throw new ArgumentNullException(nameof(next)); 16 | } 17 | 18 | this.next = next; 19 | this.IsInitialized = false; 20 | } 21 | 22 | public bool IsInitialized { get; private set; } 23 | 24 | public void Initialize(TelemetryConfiguration configuration) 25 | { 26 | this.IsInitialized = true; 27 | } 28 | 29 | public void Process(ITelemetry item) 30 | { 31 | this.next.Process(item); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/FakeTelemetryProcessorWithImportingConstructor.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.ApplicationInsights.AspNetCore.Tests 2 | { 3 | using Microsoft.ApplicationInsights.Channel; 4 | using Microsoft.ApplicationInsights.Extensibility; 5 | using Microsoft.AspNetCore.Hosting; 6 | 7 | internal class FakeTelemetryProcessorWithImportingConstructor : ITelemetryProcessor 8 | { 9 | private readonly ITelemetryProcessor nextProcessor; 10 | 11 | public IHostingEnvironment HostingEnvironment { get; } 12 | 13 | /// 14 | /// Constructs an instance of the telemetry processor. 15 | /// This constructor is designed to be called from a DI framework. 16 | /// 17 | /// The next procesor in the chain. 18 | /// The hosting environment. This parameter will be injected by the DI framework. 19 | public FakeTelemetryProcessorWithImportingConstructor(ITelemetryProcessor next, IHostingEnvironment hostingEnvironment) 20 | { 21 | this.nextProcessor = next; 22 | this.HostingEnvironment = hostingEnvironment; 23 | } 24 | 25 | public void Process(ITelemetry item) 26 | { 27 | nextProcessor.Process(item); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/Helpers/CommonMocks.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.ApplicationInsights.AspNetCore.Tests.Helpers 2 | { 3 | using System; 4 | using System.Diagnostics; 5 | using Microsoft.ApplicationInsights.Channel; 6 | using Microsoft.ApplicationInsights.Extensibility; 7 | 8 | public static class CommonMocks 9 | { 10 | public const string InstrumentationKey = "REQUIRED"; 11 | public const string TestApplicationId = nameof(TestApplicationId); 12 | 13 | public static TelemetryClient MockTelemetryClient(Action onSendCallback, bool isW3C = true) 14 | { 15 | if(isW3C) 16 | { 17 | Activity.DefaultIdFormat = ActivityIdFormat.W3C; 18 | } 19 | else 20 | { 21 | Activity.DefaultIdFormat = ActivityIdFormat.Hierarchical; 22 | } 23 | Activity.ForceDefaultIdFormat = true; 24 | 25 | return new TelemetryClient(new TelemetryConfiguration() 26 | { 27 | InstrumentationKey = InstrumentationKey, 28 | TelemetryChannel = new FakeTelemetryChannel { OnSend = onSendCallback }, 29 | }); 30 | } 31 | 32 | public static TelemetryClient MockTelemetryClient(Action onSendCallback, TelemetryConfiguration configuration) 33 | { 34 | configuration.InstrumentationKey = InstrumentationKey; 35 | configuration.TelemetryChannel = new FakeTelemetryChannel {OnSend = onSendCallback}; 36 | return new TelemetryClient(configuration); 37 | } 38 | 39 | internal static IApplicationIdProvider GetMockApplicationIdProvider() 40 | { 41 | return new MockApplicationIdProvider(InstrumentationKey, TestApplicationId); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/Helpers/HttpContextStub.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.ApplicationInsights.AspNetCore.Tests.Helpers 2 | { 3 | using System; 4 | using Microsoft.AspNetCore.Http; 5 | 6 | /// 7 | /// Class that is used in unit tests and allows to override main HttpContext properties. 8 | /// 9 | public class HttpContextStub : DefaultHttpContext 10 | { 11 | public Func OnRequestGetter = () => null; 12 | 13 | public override HttpRequest Request => this.OnRequestGetter(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/Helpers/HttpRequestStub.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.ApplicationInsights.AspNetCore.Tests.Helpers 2 | { 3 | using System; 4 | using Microsoft.AspNetCore.Http; 5 | using Microsoft.AspNetCore.Http.Internal; 6 | 7 | public class HttpRequestStub : DefaultHttpRequest 8 | { 9 | public Func OnGetHeaders = () => null; 10 | 11 | public HttpRequestStub(HttpContext context) : base(context) 12 | { 13 | } 14 | 15 | public override IHeaderDictionary Headers => this.OnGetHeaders(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/Helpers/MockApplicationIdProvider.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.ApplicationInsights.Extensibility; 2 | 3 | namespace Microsoft.ApplicationInsights.AspNetCore.Tests.Helpers 4 | { 5 | internal class MockApplicationIdProvider : IApplicationIdProvider 6 | { 7 | private readonly string expectedInstrumentationKey; 8 | private readonly string applicationId; 9 | 10 | public MockApplicationIdProvider() 11 | { 12 | } 13 | 14 | public MockApplicationIdProvider(string expectedInstrumentationKey, string applicationId) 15 | { 16 | this.expectedInstrumentationKey = expectedInstrumentationKey; 17 | this.applicationId = applicationId; 18 | } 19 | 20 | public bool TryGetApplicationId(string instrumentationKey, out string applicationId) 21 | { 22 | if (this.expectedInstrumentationKey == instrumentationKey) 23 | { 24 | applicationId = this.applicationId; 25 | return true; 26 | } 27 | 28 | applicationId = null; 29 | return false; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:4822/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNET_ENVIRONMENT": "Development" 16 | } 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/RequestTrackingTelemetryModuleTest.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.ApplicationInsights.AspNetCore.Tests 2 | { 3 | using Microsoft.ApplicationInsights.Extensibility; 4 | using Xunit; 5 | 6 | public class RequestTrackingTelemetryModuleTest 7 | { 8 | [Fact] 9 | public void RequestTrackingTelemetryModuleDoesNoThrowWhenAppIdProviderisNull() 10 | { 11 | RequestTrackingTelemetryModule requestTrackingTelemetryModule = new RequestTrackingTelemetryModule(null); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/SdkVersionTestUtils.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.ApplicationInsights.AspNetCore.Tests 2 | { 3 | public class SdkVersionTestUtils 4 | { 5 | #if NET451 || NET46 6 | public const string VersionPrefix = "aspnet5f:"; 7 | #else 8 | public const string VersionPrefix = "aspnet5c:"; 9 | #endif 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/TelemetryInitializers/AspNetCoreEnvironmentTelemetryInitializerTests.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.ApplicationInsights.AspNetCore.Tests.TelemetryInitializers 2 | { 3 | using Microsoft.ApplicationInsights.AspNetCore.TelemetryInitializers; 4 | using Microsoft.ApplicationInsights.DataContracts; 5 | using Microsoft.AspNetCore.Hosting.Internal; 6 | using Xunit; 7 | 8 | public class AspNetCoreEnvironmentTelemetryInitializerTests 9 | { 10 | [Fact] 11 | public void InitializeDoesNotThrowIfHostingEnvironmentIsNull() 12 | { 13 | var initializer = new AspNetCoreEnvironmentTelemetryInitializer(null); 14 | initializer.Initialize(new RequestTelemetry()); 15 | } 16 | 17 | [Fact] 18 | public void InitializeDoesNotOverrideExistingProperty() 19 | { 20 | var initializer = new AspNetCoreEnvironmentTelemetryInitializer(new HostingEnvironment() { EnvironmentName = "Production"}); 21 | var telemetry = new RequestTelemetry(); 22 | telemetry.Context.Properties.Add("AspNetCoreEnvironment", "Development"); 23 | initializer.Initialize(telemetry); 24 | 25 | Assert.Equal("Development", telemetry.Context.Properties["AspNetCoreEnvironment"]); 26 | } 27 | 28 | [Fact] 29 | public void InitializeSetsCurrentEnvironmentNameToProperty() 30 | { 31 | var initializer = new AspNetCoreEnvironmentTelemetryInitializer(new HostingEnvironment() { EnvironmentName = "Production"}); 32 | var telemetry = new RequestTelemetry(); 33 | initializer.Initialize(telemetry); 34 | 35 | Assert.Equal("Production", telemetry.Context.Properties["AspNetCoreEnvironment"]); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/TestTelemetryModule.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.ApplicationInsights.AspNetCore.Tests 2 | { 3 | using System; 4 | using Microsoft.ApplicationInsights.Extensibility; 5 | 6 | internal class TestTelemetryModule : ITelemetryModule 7 | { 8 | public TestTelemetryModule() 9 | { 10 | this.IsInitialized = false; 11 | } 12 | 13 | public bool IsInitialized { get; private set; } 14 | 15 | public string CustomProperty { get; set; } 16 | 17 | public void Initialize(TelemetryConfiguration configuration) 18 | { 19 | this.IsInitialized = true; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ApplicationInsights": { 3 | "InstrumentationKey": "ikeyhere", 4 | "TelemetryChannel": { 5 | "EndpointAddress": "http://hosthere/v2/track/" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/content/config-connection-string-and-instrumentation-key.json: -------------------------------------------------------------------------------- 1 | { 2 | "ApplicationInsights": { 3 | "ConnectionString": "InstrumentationKey=11111111-2222-3333-4444-555555555555;IngestionEndpoint=http://127.0.0.1", 4 | "InstrumentationKey": "33333333-4444-5555-6666-777777777777" 5 | } 6 | } -------------------------------------------------------------------------------- /NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/content/config-connection-string.json: -------------------------------------------------------------------------------- 1 | { 2 | "ApplicationInsights": { 3 | "ConnectionString" : "InstrumentationKey=11111111-2222-3333-4444-555555555555;IngestionEndpoint=http://127.0.0.1" 4 | } 5 | } -------------------------------------------------------------------------------- /NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/content/config-developer-mode.json: -------------------------------------------------------------------------------- 1 | { 2 | "ApplicationInsights": { 3 | "TelemetryChannel": { 4 | "DeveloperMode": true 5 | } 6 | } 7 | } -------------------------------------------------------------------------------- /NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/content/config-endpoint-address.json: -------------------------------------------------------------------------------- 1 | { 2 | "ApplicationInsights": { 3 | "TelemetryChannel": { 4 | "EndpointAddress": "http://localhost:1234/v2/track/" 5 | } 6 | } 7 | } -------------------------------------------------------------------------------- /NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/content/config-instrumentation-key-new.json: -------------------------------------------------------------------------------- 1 | { 2 | "ApplicationInsights": { 3 | "InstrumentationKey": "33333333-4444-5555-6666-777777777777" 4 | } 5 | } -------------------------------------------------------------------------------- /NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/content/config-instrumentation-key.json: -------------------------------------------------------------------------------- 1 | { 2 | "ApplicationInsights": { 3 | "InstrumentationKey": "11111111-2222-3333-4444-555555555555" 4 | } 5 | } -------------------------------------------------------------------------------- /NETCORE/test/Microsoft.ApplicationInsights.WorkerService.Tests/Microsoft.ApplicationInsights.WorkerService.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp2.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | all 15 | runtime; build; native; contentfiles; analyzers; buildtransitive 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | Always 30 | 31 | 32 | Always 33 | 34 | 35 | Always 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /NETCORE/test/Microsoft.ApplicationInsights.WorkerService.Tests/content/config-connection-string.json: -------------------------------------------------------------------------------- 1 | { 2 | "ApplicationInsights": { 3 | "ConnectionString" : "InstrumentationKey=11111111-2222-3333-4444-555555555555;IngestionEndpoint=http://127.0.0.1" 4 | } 5 | } -------------------------------------------------------------------------------- /NETCORE/test/Microsoft.ApplicationInsights.WorkerService.Tests/content/config-instrumentation-key-new.json: -------------------------------------------------------------------------------- 1 | { 2 | "ApplicationInsights": { 3 | "InstrumentationKey": "33333333-4444-5555-6666-777777777777" 4 | } 5 | } -------------------------------------------------------------------------------- /NETCORE/test/Microsoft.ApplicationInsights.WorkerService.Tests/content/sample-appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ApplicationInsights": { 3 | "InstrumentationKey": "11111111-2222-3333-4444-555555555555", 4 | "TelemetryChannel": { 5 | "EndpointAddress": "http://testendpoint/v2/track", 6 | "DeveloperMode": true 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /NETCORE/test/StartupPerf/startupPerf.ps1: -------------------------------------------------------------------------------- 1 | # execute this first: Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process -Confirm 2 | 3 | function GetUrlStatusCode($url) 4 | { 5 | $req = [system.Net.WebRequest]::Create($url) 6 | try { 7 | $res = $req.GetResponse() 8 | } catch [System.Net.WebException] { 9 | $res = $_.Exception.Response 10 | } 11 | return [int]$res.StatusCode 12 | } 13 | 14 | $totalTime = 0 15 | $attempts = 10 16 | 17 | function StartUnderDebugger() 18 | { 19 | $script:sw = [system.diagnostics.stopwatch]::StartNew() 20 | 21 | $dte.ExecuteCommand("Debug.Start"); 22 | #$dte.ExecuteCommand("Debug.StartWithoutDebugging"); 23 | 24 | $status = GetUrlStatusCode("http://localhost:54056/") 25 | while ($status -ne 200) 26 | { 27 | $status = GetUrlStatusCode("http://localhost:54056/") 28 | } 29 | 30 | $script:sw.Stop() 31 | $elapsed = $script:sw.Elapsed.TotalMilliseconds 32 | Write-Host $elapsed 33 | 34 | $global:totalTime = $global:totalTime + $elapsed 35 | 36 | $dte.ExecuteCommand("Debug.StopDebugging"); 37 | } 38 | 39 | $i = 0 40 | while ($i -lt $attempts) 41 | { 42 | StartUnderDebugger 43 | $i = $i + 1 44 | } 45 | 46 | Write-Host "Total $attempts attempts" 47 | 48 | -------------------------------------------------------------------------------- /NETCORE/test/TestApp30.Tests/CustomWebApplicationFactory.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.ApplicationInsights; 2 | using Microsoft.ApplicationInsights.AspNetCore.Extensions; 3 | using Microsoft.ApplicationInsights.Channel; 4 | using Microsoft.AspNetCore.Hosting; 5 | using Microsoft.AspNetCore.Mvc.Testing; 6 | using Microsoft.Extensions.DependencyInjection; 7 | using System; 8 | using System.Collections.Concurrent; 9 | using System.Collections.Generic; 10 | using System.Linq; 11 | using System.Threading.Tasks; 12 | 13 | namespace TestApp30.Tests 14 | { 15 | public class CustomWebApplicationFactory 16 | : WebApplicationFactory where TStartup : class 17 | { 18 | internal ConcurrentBag sentItems = new ConcurrentBag(); 19 | 20 | 21 | protected override void ConfigureWebHost(IWebHostBuilder builder) 22 | { 23 | builder.ConfigureServices(services => 24 | { 25 | services.AddSingleton(new StubChannel() 26 | { 27 | OnSend = (item) => this.sentItems.Add(item) 28 | }); 29 | var aiOptions = new ApplicationInsightsServiceOptions(); 30 | aiOptions.AddAutoCollectedMetricExtractor = false; 31 | aiOptions.EnableAdaptiveSampling = false; 32 | aiOptions.InstrumentationKey = "ikey"; 33 | services.AddApplicationInsightsTelemetry(aiOptions); 34 | 35 | // Build the service provider. 36 | var sp = services.BuildServiceProvider(); 37 | var tc = sp.GetRequiredService(); 38 | }); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /NETCORE/test/TestApp30.Tests/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:1809", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "TestApp30.Tests": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "applicationUrl": "http://localhost:5000", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /NETCORE/test/TestApp30.Tests/StubChannel.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.ApplicationInsights.Channel; 2 | using System; 3 | 4 | namespace TestApp30.Tests 5 | { 6 | internal class StubChannel : ITelemetryChannel 7 | { 8 | public Action OnSend = t => { }; 9 | 10 | public string EndpointAddress 11 | { 12 | get; 13 | set; 14 | } 15 | 16 | public bool? DeveloperMode { get; set; } 17 | 18 | public void Dispose() 19 | { 20 | throw new NotImplementedException(); 21 | } 22 | 23 | public void Flush() 24 | { 25 | throw new NotImplementedException(); 26 | } 27 | 28 | public void Send(ITelemetry item) 29 | { 30 | this.OnSend(item); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /NETCORE/test/TestApp30.Tests/TestApp30.Tests30.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp3.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | all 12 | runtime; build; native; contentfiles; analyzers; buildtransitive 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /NETCORE/test/TestApp30/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Mvc; 7 | using Microsoft.Extensions.Logging; 8 | using TestApp30.Models; 9 | 10 | namespace TestApp30.Controllers 11 | { 12 | public class HomeController : Controller 13 | { 14 | private readonly ILogger _logger; 15 | 16 | public HomeController(ILogger logger) 17 | { 18 | _logger = logger; 19 | } 20 | 21 | public IActionResult Index() 22 | { 23 | _logger.LogWarning("sample warning"); 24 | return View(); 25 | } 26 | 27 | public IActionResult Privacy() 28 | { 29 | return View(); 30 | } 31 | 32 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 33 | public IActionResult Error() 34 | { 35 | throw new Exception("sample exception"); 36 | // return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /NETCORE/test/TestApp30/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TestApp30.Models 4 | { 5 | public class ErrorViewModel 6 | { 7 | public string RequestId { get; set; } 8 | 9 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /NETCORE/test/TestApp30/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace TestApp30 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /NETCORE/test/TestApp30/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:1792", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "TestApp30": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "applicationUrl": "http://localhost:5000", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /NETCORE/test/TestApp30/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.AspNetCore.Hosting; 7 | using Microsoft.Extensions.Configuration; 8 | using Microsoft.Extensions.DependencyInjection; 9 | using Microsoft.Extensions.Hosting; 10 | 11 | namespace TestApp30 12 | { 13 | public class Startup 14 | { 15 | public Startup(IConfiguration configuration) 16 | { 17 | Configuration = configuration; 18 | } 19 | 20 | public IConfiguration Configuration { get; } 21 | 22 | // This method gets called by the runtime. Use this method to add services to the container. 23 | public void ConfigureServices(IServiceCollection services) 24 | { 25 | services.AddControllersWithViews(); 26 | } 27 | 28 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 29 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 30 | { 31 | if (env.IsDevelopment()) 32 | { 33 | app.UseDeveloperExceptionPage(); 34 | } 35 | else 36 | { 37 | app.UseExceptionHandler("/Home/Error"); 38 | } 39 | app.UseStaticFiles(); 40 | 41 | app.UseRouting(); 42 | 43 | app.UseAuthorization(); 44 | 45 | app.UseEndpoints(endpoints => 46 | { 47 | endpoints.MapControllerRoute( 48 | name: "default", 49 | pattern: "{controller=Home}/{action=Index}/{id?}"); 50 | }); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /NETCORE/test/TestApp30/TestApp30.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp3.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /NETCORE/test/TestApp30/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Home Page"; 3 | } 4 | 5 |
6 |

Welcome

7 |

Learn about building Web apps with ASP.NET Core.

8 |
9 | -------------------------------------------------------------------------------- /NETCORE/test/TestApp30/Views/Home/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Privacy Policy"; 3 | } 4 |

@ViewData["Title"]

5 | 6 |

Use this page to detail your site's privacy policy.

7 | -------------------------------------------------------------------------------- /NETCORE/test/TestApp30/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | @{ 3 | ViewData["Title"] = "Error"; 4 | } 5 | 6 |

Error.

7 |

An error occurred while processing your request.

8 | 9 | @if (Model.ShowRequestId) 10 | { 11 |

12 | Request ID: @Model.RequestId 13 |

14 | } 15 | 16 |

Development Mode

17 |

18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

20 |

21 | The Development environment shouldn't be enabled for deployed applications. 22 | It can result in displaying sensitive information from exceptions to end users. 23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 24 | and restarting the app. 25 |

26 | -------------------------------------------------------------------------------- /NETCORE/test/TestApp30/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 |  2 | -------------------------------------------------------------------------------- /NETCORE/test/TestApp30/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using TestApp30 2 | @using TestApp30.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /NETCORE/test/TestApp30/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /NETCORE/test/TestApp30/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /NETCORE/test/TestApp30/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "ApplicationInsights": { 4 | "LogLevel": { 5 | "Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager": "None" 6 | } 7 | }, 8 | "LogLevel": { 9 | "Default": "Error", 10 | "Microsoft": "Error", 11 | "Microsoft.Hosting.Lifetime": "Information" 12 | } 13 | }, 14 | "AllowedHosts": "*" 15 | } 16 | -------------------------------------------------------------------------------- /NETCORE/test/TestApp30/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | /* Provide sufficient contrast against white background */ 11 | a { 12 | color: #0366d6; 13 | } 14 | 15 | .btn-primary { 16 | color: #fff; 17 | background-color: #1b6ec2; 18 | border-color: #1861ac; 19 | } 20 | 21 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link { 22 | color: #fff; 23 | background-color: #1b6ec2; 24 | border-color: #1861ac; 25 | } 26 | 27 | /* Sticky footer styles 28 | -------------------------------------------------- */ 29 | html { 30 | font-size: 14px; 31 | } 32 | @media (min-width: 768px) { 33 | html { 34 | font-size: 16px; 35 | } 36 | } 37 | 38 | .border-top { 39 | border-top: 1px solid #e5e5e5; 40 | } 41 | .border-bottom { 42 | border-bottom: 1px solid #e5e5e5; 43 | } 44 | 45 | .box-shadow { 46 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 47 | } 48 | 49 | button.accept-policy { 50 | font-size: 1rem; 51 | line-height: inherit; 52 | } 53 | 54 | /* Sticky footer styles 55 | -------------------------------------------------- */ 56 | html { 57 | position: relative; 58 | min-height: 100%; 59 | } 60 | 61 | body { 62 | /* Margin bottom by footer height */ 63 | margin-bottom: 60px; 64 | } 65 | .footer { 66 | position: absolute; 67 | bottom: 0; 68 | width: 100%; 69 | white-space: nowrap; 70 | line-height: 60px; /* Vertically center the text there */ 71 | } 72 | -------------------------------------------------------------------------------- /NETCORE/test/TestApp30/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/ApplicationInsights-aspnetcore/bfccb57e4f632fa2ee627dacedeaa55644c739f5/NETCORE/test/TestApp30/wwwroot/favicon.ico -------------------------------------------------------------------------------- /NETCORE/test/TestApp30/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /NETCORE/test/WebApi.FunctionalTests/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /NETCORE/test/WebApi.FunctionalTests/Controllers/ExceptionController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Microsoft.AspNetCore.Mvc; 4 | 5 | namespace SampleWebAPIIntegration.Controllers 6 | { 7 | [Route("api/[controller]")] 8 | public class ExceptionController : Controller 9 | { 10 | // GET: api/exception 11 | [HttpGet] 12 | public IEnumerable Get() 13 | { 14 | throw new InvalidOperationException(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /NETCORE/test/WebApi.FunctionalTests/Controllers/ValuesController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | namespace SampleWebAPIIntegration.Controllers 8 | { 9 | [Route("api/[controller]")] 10 | public class ValuesController : Controller 11 | { 12 | // GET: api/values 13 | [HttpGet] 14 | public IEnumerable Get() 15 | { 16 | return new string[] { "value1", "value2" }; 17 | } 18 | 19 | // GET api/values/5 20 | [HttpGet("{id}")] 21 | public string Get(int id) 22 | { 23 | return "value"; 24 | } 25 | 26 | // POST api/values 27 | [HttpPost] 28 | public void Post([FromBody]string value) 29 | { 30 | } 31 | 32 | // PUT api/values/5 33 | [HttpPut("{id}")] 34 | public void Put(int id, [FromBody]string value) 35 | { 36 | } 37 | 38 | // DELETE api/values/5 39 | [HttpDelete("{id}")] 40 | public void Delete(int id) 41 | { 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /NETCORE/test/WebApi.FunctionalTests/FunctionalTest/TelemetryModuleWorkingWebApiTests.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | 3 | [assembly: CollectionBehavior(DisableTestParallelization = true)] 4 | namespace WebApi.FunctionalTests.FunctionalTest 5 | { 6 | using FunctionalTestUtils; 7 | using Xunit.Abstractions; 8 | 9 | public class TelemetryModuleWorkingWebApiTests : TelemetryTestsBase 10 | { 11 | private const string assemblyName = "WebApi.FunctionalTests"; 12 | 13 | public TelemetryModuleWorkingWebApiTests(ITestOutputHelper output) : base (output) 14 | { 15 | } 16 | // The NET451 conditional check is wrapped inside the test to make the tests visible in the test explorer. We can move them to the class level once if the issue is resolved. 17 | 18 | 19 | public void TestBasicDependencyPropertiesAfterRequestingBasicPage() 20 | { 21 | this.ValidateBasicDependency(assemblyName, "/api/values"); 22 | } 23 | 24 | [Fact] 25 | public void TestIfPerformanceCountersAreCollected() 26 | { 27 | #if NET451 || NET46 28 | ValidatePerformanceCountersAreCollected(assemblyName); 29 | #endif 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /NETCORE/test/WebApi.FunctionalTests/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:41846/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "launchUrl": "api/values", 15 | "environmentVariables": { 16 | "ASPNET_ENV": "Development" 17 | } 18 | }, 19 | "web": { 20 | "commandName": "web", 21 | "environmentVariables": { 22 | "Hosting:Environment": "Development" 23 | } 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /NETCORE/test/WebApi.FunctionalTests/Startup.cs: -------------------------------------------------------------------------------- 1 | namespace SampleWebAPIIntegration 2 | { 3 | using FunctionalTestUtils; 4 | using Microsoft.ApplicationInsights.Channel; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.AspNetCore.Hosting; 7 | using Microsoft.Extensions.Configuration; 8 | using Microsoft.Extensions.DependencyInjection; 9 | 10 | public class Startup 11 | { 12 | public Startup(IHostingEnvironment env) 13 | { 14 | // Setup configuration sources. 15 | Configuration = new ConfigurationBuilder() 16 | .AddJsonFile("config.json") 17 | .Build(); 18 | } 19 | 20 | public IConfiguration Configuration { get; set; } 21 | 22 | // This method gets called by a runtime. 23 | // Use this method to add services to the container 24 | public void ConfigureServices(IServiceCollection services) 25 | { 26 | services.AddSingleton(new BackTelemetryChannel()); 27 | services.AddApplicationInsightsTelemetry(Configuration); 28 | 29 | // Uncomment the following line to add Web API services which makes it easier to port Web API 2 controllers. 30 | // You will also need to add the Microsoft.AspNet.Mvc.WebApiCompatShim package to the 'dependencies' section of project.json. 31 | services.AddMvc().AddWebApiConventions(); 32 | } 33 | 34 | // Configure is called after ConfigureServices is called. 35 | public void Configure(IApplicationBuilder app, IHostingEnvironment env) 36 | { 37 | // Configure the HTTP request pipeline. 38 | app.UseStaticFiles(); 39 | 40 | // Add MVC to the request pipeline. 41 | app.UseMvc(routes => 42 | { 43 | // Add the following route for porting Web API 2 controllers. 44 | routes.MapWebApiRoute("DefaultApi", "api/{controller}/{id?}"); 45 | }); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /NETCORE/test/WebApi.FunctionalTests/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "ApplicationInsights": { 3 | "InstrumentationKey": "11111111-2222-3333-4444-555555555555" 4 | } 5 | } -------------------------------------------------------------------------------- /NETCORE/test/WebApi.FunctionalTests/wwwroot/web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /NETCORE/test/WebApi.FunctionalTests/xunit.runner.json: -------------------------------------------------------------------------------- 1 | { 2 | "parallelizeAssembly": false, 3 | "parallelizeTestCollections": false 4 | } 5 | -------------------------------------------------------------------------------- /NETCORE/test/WebApi20.FunctionalTests/Controllers/DependencyController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net.Http; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Mvc; 7 | 8 | namespace WebApi20.FunctionalTests.Controllers 9 | { 10 | [Route("api/[controller]")] 11 | public class DependencyController : Controller 12 | { 13 | // GET api/values 14 | [HttpGet] 15 | public async Task Get() 16 | { 17 | using (var hc = new HttpClient()) 18 | { 19 | await hc.GetAsync("https://www.microsoft.com").ContinueWith(t => { }); // ignore all errors 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /NETCORE/test/WebApi20.FunctionalTests/Controllers/ExceptionController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Microsoft.AspNetCore.Mvc; 4 | 5 | namespace WebApi20.FunctionalTests.Controllers 6 | { 7 | [Route("api/[controller]")] 8 | public class ExceptionController : Controller 9 | { 10 | // GET: api/exception 11 | [HttpGet] 12 | public IEnumerable Get() 13 | { 14 | throw new InvalidOperationException(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /NETCORE/test/WebApi20.FunctionalTests/Controllers/ValuesController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.Extensions.Logging; 7 | 8 | namespace WebApi20.FunctionalTests.Controllers 9 | { 10 | [Route("api/[controller]")] 11 | public class ValuesController : Controller 12 | { 13 | ILogger logger; 14 | 15 | public ValuesController(ILogger logger) 16 | { 17 | this.logger = logger; 18 | } 19 | 20 | // GET api/values 21 | [HttpGet] 22 | public IEnumerable Get() 23 | { 24 | return new string[] { "value1", "value2" }; 25 | } 26 | 27 | // GET api/values/5 28 | [HttpGet("{id}")] 29 | public string Get(int id) 30 | { 31 | logger.LogError("error logged"); 32 | logger.LogWarning("warning logged"); 33 | logger.LogInformation("information logged"); 34 | logger.LogTrace("trace logged"); 35 | return "value"; 36 | } 37 | 38 | // POST api/values 39 | [HttpPost] 40 | public void Post([FromBody]string value) 41 | { 42 | } 43 | 44 | // PUT api/values/5 45 | [HttpPut("{id}")] 46 | public void Put(int id, [FromBody]string value) 47 | { 48 | } 49 | 50 | // DELETE api/values/5 51 | [HttpDelete("{id}")] 52 | public void Delete(int id) 53 | { 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /NETCORE/test/WebApi20.FunctionalTests/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:11955/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "launchUrl": "api/values", 15 | "environmentVariables": { 16 | "ASPNETCORE_ENVIRONMENT": "Development" 17 | } 18 | }, 19 | "WebApi20.FunctionalTests": { 20 | "commandName": "Project", 21 | "launchBrowser": true, 22 | "launchUrl": "api/values", 23 | "environmentVariables": { 24 | "ASPNETCORE_ENVIRONMENT": "Development" 25 | }, 26 | "applicationUrl": "http://localhost:11956/" 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /NETCORE/test/WebApi20.FunctionalTests/Startup.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.Extensions.Configuration; 4 | using Microsoft.Extensions.DependencyInjection; 5 | using FunctionalTestUtils; 6 | using Microsoft.ApplicationInsights.Channel; 7 | 8 | namespace WebApi20.FunctionalTests 9 | { 10 | public class Startup 11 | { 12 | public Startup(IConfiguration configuration) 13 | { 14 | Configuration = configuration; 15 | } 16 | 17 | public IConfiguration Configuration { get; } 18 | 19 | // This method gets called by the runtime. Use this method to add services to the container. 20 | public void ConfigureServices(IServiceCollection services) 21 | { 22 | var endpointAddress = new EndpointAddress(); 23 | services.AddSingleton(endpointAddress); 24 | 25 | var builder = new ConfigurationBuilder(); 26 | builder.AddApplicationInsightsSettings(instrumentationKey: InProcessServer.IKey, endpointAddress: endpointAddress.ConnectionString, developerMode: true); 27 | services.AddSingleton(typeof(ITelemetryChannel), new InMemoryChannel()); 28 | services.AddApplicationInsightsTelemetry(builder.Build()); 29 | 30 | services.AddMvc(); 31 | } 32 | 33 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 34 | public void Configure(IApplicationBuilder app, IHostingEnvironment env) 35 | { 36 | if (env.IsDevelopment()) 37 | { 38 | app.UseDeveloperExceptionPage(); 39 | } 40 | 41 | app.UseMvc(routes => 42 | { 43 | // Add the following route for porting Web API 2 controllers. 44 | routes.MapWebApiRoute("DefaultApi", "api/{controller}/{id?}"); 45 | }); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /NETCORE/test/WebApi20.FunctionalTests/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "IncludeScopes": false, 4 | "LogLevel": { 5 | "Default": "Debug", 6 | "System": "Information", 7 | "Microsoft": "Information" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /NETCORE/test/WebApi20.FunctionalTests/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "IncludeScopes": false, 4 | "Debug": { 5 | "LogLevel": { 6 | "Default": "Warning" 7 | } 8 | }, 9 | "Console": { 10 | "LogLevel": { 11 | "Default": "Warning" 12 | } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /NETCORE/test/WebApi20.FunctionalTests/xunit.runner.json: -------------------------------------------------------------------------------- 1 | { 2 | "parallelizeAssembly": false, 3 | "parallelizeTestCollections": false, 4 | "shadowCopy": false 5 | } 6 | --------------------------------------------------------------------------------