我在本地克隆了ASP.NET Core SignalR Repo,并尝试在以下环境中打开解决方案.
IDE
Microsoft Visual Studio Enterprise 2015
Version 14.0.25431.01 Update 3
Microsoft .NET Framework
Version 4.6.01055
Run Code Online (Sandbox Code Playgroud)
DOT NET CLI
? dotnet --info
.NET Command Line Tools (1.0.0-preview2-1-003177)
Product Information:
Version: 1.0.0-preview2-1-003177
Commit SHA-1 hash: a2df9c2576
Runtime Environment:
OS Name: Windows
OS Version: 6.1.7601
OS Platform: Windows
RID: win7-x64
Run Code Online (Sandbox Code Playgroud)
我最终看到了很多这类错误消息:
..\Repos\SignalR\src\Microsoft.AspNetCore.SignalR\Microsoft.AspNetCore.SignalR.csproj
:error:项目的默认XML名称空间必须是MSBuild XML名称空间.如果项目是以MSBuild 2003格式创作的,请添加xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
到元素中.如果项目是以旧的1.0或1.2格式编写的,请将其转换为MSBuild 2003格式...\Repos\SignalR\src\Microsoft.AspNetCore.SignalR\Microsoft.AspNetCore.SignalR.csproj
我想知道如何以正确的方式解决这个问题.
msbuild asp.net-mvc visual-studio-2015 .net-core asp.net-core
在"旧学校"MSBuild项目中 - 例如仍然在VS2017中的Windows窗体中使用 - 文件可以通过DependentUpon
csproj文件中的项目"嵌套" .
我用它来在Noda Time中将单元测试组合在一起,例如
<Compile Include="LocalDateTest.PeriodArithmetic.cs">
<DependentUpon>LocalDateTest.cs</DependentUpon>
</Compile>
Run Code Online (Sandbox Code Playgroud)
这导致了易于导航的测试:
转向project.json
.NET Core时,我故意"丢失"此功能,但希望在转换为MSBuild时会返回.但是,看起来基于.NET Core SDK(根元素<Project Sdk="Microsoft.NET.Sdk">
)的MSBuild项目在Visual Studio 2017中得不到相同的处理,即使ItemGroup
手动添加与"旧学校"项目相同的元素.
ASP.NET Core项目为缩小的CSS和Javascript接收自动嵌套,但目前尚不清楚如何将其应用于.NET Core库项目中的C#.
我正在开发一个Angular2应用程序,我需要显示 - 但是disable
一个<a>
HTML元素.这样做的正确方法是什么?
更新
请注意*ngFor
,这将阻止使用*ngIf
和完全渲染的选项<a>
.
<a *ngFor="let link of links"
href="#"
[class.disabled]="isDisabled(link)"
(click)="onClick(link)">
{{ link.name }}
</a>
Run Code Online (Sandbox Code Playgroud)
该打字稿组件具有类似如下的方法:
onClick(link: LinkObj) {
// Do something relevant with the object...
return false;
}
Run Code Online (Sandbox Code Playgroud)
我需要实际上阻止元素被点击,而不仅仅是出现在CSS中.我假设我首先需要绑定到[disabled]
属性,但这是不正确的,因为锚元素没有disabled
属性.
我看着并考虑使用pointer-events: none
但这阻止了我的cursor: not-allowed
工作风格- 这是要求的一部分.
我安装了Visual Studio 2015 Enterprise,版本14.0.24720.00 Update 1以及ReSharper 10 Ultimate 10.0.2版.我有一个打字稿文件使用AtScript语法来引用Angular2指令模块作为其注释.但是,ReSharper声明了以下错误:
符号'指令'无法正确解析,可能位于无法访问的模块中.
以下是完整错误工具提示.
应用程序按预期编译和运行,应用程序的角度部分也可以根据需要运行.看起来好像这是一个ReSharper假阴性.是否有人熟悉其他只是禁用ReSharper或忽略警告的解决方法?
我试图改变我从这里借来的任务转轮脚本; 在Visual Studio 2015的Task Runner Explorer中成功执行任务运行程序后,实际上并未复制文件.
这是改变的脚本:
/// <binding BeforeBuild='copy-assets' />
"use strict";
var _ = require('lodash'),
gulp = require('gulp');
gulp.task('copy-assets', function() {
var assets = {
js: [
'./node_modules/bootstrap/dist/js/bootstrap.js',
'./node_modules/systemjs/dist/system.src.js',
'./node_modules/angular2/bundles/angular2.dev.js',
'./node_modules/angular2/bundles/router.dev.js',
'./node_modules/angular2/bundles/angular2-polyfills.js',
'./node_modules/angular2/bundles/http.dev.js',
'./node_modules/rxjs/bundles/Rx.js',
'./node_modules/typescript/lib/typescript.js'
],
css: ['./node_modules/bootstrap/dist/css/bootstrap.css']
};
_(assets).forEach(function(assets, type) {
gulp.src(assets).pipe(gulp.dest('./webroot/' + type));
});
});
Run Code Online (Sandbox Code Playgroud)
任务运行器似乎在Visual Studio 2015 Enterprise中没有错误地运行,但之后我的wwwroot/js或wwwroot/css中没有文件?
这是文件结构:
我做错了什么,如何解决这个问题?任何和所有的帮助非常感谢!
我试图在XUnit项目中执行以下操作,以获取我的测试应该使用的数据库的连接字符串:
public class TestFixture : IDisposable
{
public IConfigurationRoot Configuration { get; set; }
public MyFixture()
{
var builder = new ConfigurationBuilder()
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
Configuration = builder.Build();
}
public void Dispose()
{
}
}
Run Code Online (Sandbox Code Playgroud)
这很奇怪,因为它在Startup.cs中使用时在WebAPI和MVC模板中完美运行.此外,此代码以前在RC1中使用dnx工作,但现在我将所有内容更新到RC2和Core CLI,它不再能够找到appsettings.json
xunit类库的根目录中的文件.
这是我的测试类的样子,所以你可以看到我如何调用配置:
public class MyTests : IClassFixture<MyFixture>
{
private readonly MyFixture _fixture;
public MyTests(MyFixture fixture)
{
this._fixture = fixture;
}
[Fact]
public void TestCase1()
{
ICarRepository carRepository = new CarRepository(_fixture.Configuration);
}
}
Run Code Online (Sandbox Code Playgroud) 在RxJS主题的订阅回调中,我想要await
一个async
函数.下面是打字稿发布者抱怨说的代码示例:
错误:(131,21)TS2304:找不到名称'await'.
async ngOnInit() {
this.subscriber = dateSubscription.subscribe((date: Date) => {
let dbKey = await this._someService.saveToDatabase(someObject);
// wait for db write to finish before evaluating the next code
// ... some other code here
});
}
Run Code Online (Sandbox Code Playgroud)
通常我在尝试在非async
函数内调用await时会看到这个.我是否需要进行订阅回调async
或者我是否会犯这个错误?该函数saveToDatabase
是async
并返回一个解析为写入的数据库主键的promise.
考虑到Node.js包管理器,即npm - 如果发布命令在发布之前执行pack命令或者它是否完全不同,我很好奇?所以,如果我要执行:
npm publish <folder>
Run Code Online (Sandbox Code Playgroud)
它首先执行以下操作:
npm pack <folder>
Run Code Online (Sandbox Code Playgroud)
npm publish
没有明确npm pack
之前,但不包出现有预期的内容.即; 的内容.tgz
,当我执行本地不同npm pack
到的内容npm publish
. 在C#中,我们知道a bool
是原子的 - 那么为什么将它标记为有效volatile
呢?有什么不同,什么是一个好的(甚至是实际的)用例?
bool _isPending;
Run Code Online (Sandbox Code Playgroud)
与
volatile bool _isPending; // Is this realistic, or insanity?
Run Code Online (Sandbox Code Playgroud)
我在这里和这里做了一些阅读,我正在努力确保我完全理解两者的内部运作.我想知道什么时候使用一个与另一个相比,或者只是bool
足够.
我正在编写一个通用代码,它应该处理从多个源加载数据的情况.我有一个带有以下签名的方法:
public static TResult LoadFromAnySource<TContract, TSection, TResult>
(this TSection section,
string serviceBaseUri,
string nodeName)
where TSection : ConfigurationSection
where TResult : IDatabaseConfigurable<TContract, TSection>, new()
where TContract : new()
Run Code Online (Sandbox Code Playgroud)
但它是一个矫枉过正:当我通过TResult
,我已经知道什么TContract
和TSection
确切的.在我的例子中:
public interface ISourceObserverConfiguration
: IDatabaseConfigurable<SourceObserverContract, SourceObserverSection>
Run Code Online (Sandbox Code Playgroud)
但我必须写下面的内容:
sourceObserverSection.LoadFromAnySource<SourceObserverContract,
SourceObserverSection,
SourceObserverConfiguration>
(_registrationServiceConfiguration.ServiceBaseUri, nodeName);
Run Code Online (Sandbox Code Playgroud)
您可以看到我必须指定<SourceObserverContract, SourceObserverSection>
两次对,这违反了DRY原则.所以我想写一些类似的东西:
sourceObserverSection.LoadFromAnySource<SourceObserverConfiguration>
(_registrationServiceConfiguration.ServiceBaseUri, nodeName);
Run Code Online (Sandbox Code Playgroud)
从界面制作SourceObserverContract
和SourceObserverSection
推断.
是否有可能在C#或我应该手动指定它?
IDatabaseConfigurable
好像:
public interface IDatabaseConfigurable<in TContract, in TSection>
where TContract : ConfigContract
where TSection : ConfigurationSection …
Run Code Online (Sandbox Code Playgroud) angular ×3
asp.net-core ×3
typescript ×3
.net-core ×2
c# ×2
msbuild ×2
npm ×2
.net ×1
asp.net ×1
asp.net-mvc ×1
async-await ×1
atomic ×1
atscript ×1
boolean ×1
csproj ×1
dom ×1
generics ×1
gulp ×1
html ×1
node.js ×1
npm-publish ×1
resharper ×1
rxjs ×1
volatile ×1
xunit ×1
xunit.net ×1
xunit2 ×1